Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 78x 78x 78x 78x 78x 78x 78x 78x 78x 1x 1x 1x | import { PhoneClass } from './phone.class';
import { LoginInterface } from '../interfaces/login.interface';
export class UserClass {
id!: string;
email!: string;
first_name!: string;
last_name!: string;
phones!: any;
roles!: string[];
fromJson(json: LoginInterface): void {
console.log(json.data?.id);
this.id = json.data?.id;
this.email = json.data?.attributes.email;
this.first_name = json.data?.attributes['first-name'];
this.last_name = json.data?.attributes['last-name'];
this.roles = json.data?.attributes.roles || [];
this.phones = (json.data?.attributes.phones || []).map((phone) => new PhoneClass(phone));
}
getId(): string {
return this.id;
}
getName(): string {
return [this.first_name, this.last_name].join(' ');
}
getEmail(): string {
return this.email;
}
isAdmin(): boolean {
if (
this.roles?.indexOf('admin') > -1 ||
this.roles?.indexOf('builder') > -1 ||
this.roles?.indexOf('travel_agent') > -1 ||
this.roles?.indexOf('travel_agent_admin') > -1
)
return true;
return false;
}
isVendor(): boolean {
if (this.roles?.indexOf('vendor') > -1) return true;
return false;
}
}
|