-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuser.ts
31 lines (29 loc) · 829 Bytes
/
user.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { OffOnSetting, User } from "api/models";
export function newUser(name = "", username = "", password = ""): User {
return {
name,
username,
password,
id: "",
avatar: "",
hasAvatar: false,
email: "",
phone: "",
projectRoles: {},
workedProjects: {},
glossSuggestion: OffOnSetting.On,
token: "",
isAdmin: false,
answeredConsent: false,
};
}
/** Returns whether the given `text` is a (case-insensitive) substring of the
* name, username, or email of the given `user`. */
export function doesTextMatchUser(text: string, user: User): boolean {
const lower = text.toLocaleLowerCase();
return (
user.name.toLocaleLowerCase().includes(lower) ||
user.username.toLocaleLowerCase().includes(lower) ||
user.email.toLocaleLowerCase().includes(lower)
);
}