-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmember.ts
60 lines (54 loc) · 1.34 KB
/
member.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { NonFunctionPropertyNames } from '@/shared/sharedTypes';
import { Department } from './department';
export class Member {
static PUBLIC_FIELDS: NonFunctionPropertyNames<Member>[] = [
'id',
'avatar',
'firstName',
'lastName',
'department',
'joinedAt',
'phoneNumber',
'email',
'pr',
];
static PRIVATE_FIELDS: NonFunctionPropertyNames<Member>[] = ['age', 'salary'];
constructor(
public id: string,
public avatar: string,
public firstName: string,
public lastName: string,
public age: number,
public salary: number,
public department: Department,
public joinedAt: Date,
public phoneNumber: string,
public email: string,
public pr: string
) {}
createObjectWithAuthorizedFields(
this: any,
fields: Set<keyof Member>
): DisplayableMember {
const authorizedMember: DisplayableMember = {};
for (const field of Array.from(fields.values())) {
authorizedMember[field as keyof DisplayableMember] = this[field];
}
return authorizedMember;
}
}
export type DisplayableMember = {
id?: string;
avatar?: string;
firstName?: string;
lastName?: string;
age?: number;
salary?: number;
department?: Department;
joinedAt?: Date;
phoneNumber?: string;
email?: string;
pr?: string;
editable?: boolean;
isLoggedInUser?: boolean;
};