having one solution for different components of app
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export enum CookieType {
|
||||
TEAM_SHORTCUTS_ONBOARDING = "TEAM_SHORTCUTS_ONBOARDING",
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import moment from "moment";
|
||||
|
||||
export function generateGreetings(): string {
|
||||
const hour = moment().hour();
|
||||
|
||||
if (hour > 16) {
|
||||
return "Good evening";
|
||||
}
|
||||
|
||||
if (hour > 11) {
|
||||
return "Good afternoon";
|
||||
}
|
||||
|
||||
return "Good morning";
|
||||
}
|
||||
|
||||
export function getTime(date?: Date) {
|
||||
return date != null ? date.getTime() : 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export default function isValidHttpUrl(potentialUrl: string) {
|
||||
let url;
|
||||
|
||||
try {
|
||||
url = new URL(potentialUrl);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { User, UserStatus } from "../models/user";
|
||||
|
||||
function getStatusValue(status: UserStatus) {
|
||||
switch (status) {
|
||||
case UserStatus.online:
|
||||
return 10;
|
||||
case UserStatus.busy:
|
||||
return 5;
|
||||
case UserStatus.offline:
|
||||
return 0;
|
||||
default:
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
|
||||
export function compareStatus(usera: User, userb: User) {
|
||||
return getStatusValue(userb.userStatus) - getStatusValue(usera.userStatus);
|
||||
}
|
||||
Reference in New Issue
Block a user