Updated some models and changed to custom api

This commit is contained in:
Erik Tiekstra
2021-05-05 14:19:57 +02:00
parent cd60e9383a
commit f24ab48943
21 changed files with 125 additions and 89 deletions

View File

@@ -2,18 +2,22 @@ import { Agency } from '@dafa-models/agency.model';
import { EmployeeResponse } from './api/employee-response.model';
import { Participant } from './participant.model';
export interface User {
export interface Employee {
id: string;
employeeId: string;
firstName: string;
lastName: string;
fullName: string;
organization: string;
organizationDivision: string;
organizationUnit: string;
phone: string;
email: string;
accessGroup: string;
utforandeverksamhet: string;
active: boolean;
service: string;
fullName?: string;
}
export interface EmployeeDetail extends User {
export interface EmployeeDetail extends Employee {
languages: string[];
outOfOffice: {
start: Date;
@@ -27,17 +31,19 @@ export interface EmployeeDetail extends User {
participants: Participant[];
}
export function mapEmployeeReponseToEmployee(data: EmployeeResponse): User {
const names = data.pyUserName.split(' ');
export function mapEmployeeReponseToEmployee(data: EmployeeResponse): Employee {
return {
id: data.pyUserIdentifier,
employeeId: data.pyUserIdentifier,
lastName: names.pop() || 'Doe',
firstName: names.join(' ') || 'John',
lastName: data.pyLastName,
firstName: data.pyFirstName,
fullName: `${data.pyFirstName} ${data.pyLastName}`,
organization: data.pyOrganization,
organizationDivision: data.pyOrgDivision,
organizationUnit: data.pyOrgUnit,
phone: data.pyTelephone,
email: '',
accessGroup: data.pyAccessGroup,
utforandeverksamhet: '',
active: true,
service: '',
fullName: data.pyUserName,
};
}