Files
mina-sidor-fa-web/apps/dafa-web/src/app/data/models/employee.model.ts
Erik Tiekstra c4440a2bbe Merge pull request #14 in TEA/dafa-web-monorepo from feature/more-mock-api-fixes to develop
Squashed commit of the following:

commit 9473ca4e23eb6c5967d9df3403cc071d48e0ab73
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Tue Jun 1 08:18:39 2021 +0200

    Adding footer

commit 8f13809ad3928fd09fd67d713a61c2ca4ef27bc4
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Tue Jun 1 06:57:34 2021 +0200

    Added footer

commit ee8a5be048786843e3c5672368a0663ead424852
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Mon May 31 16:07:14 2021 +0200

    Added size to edit icon

commit b8e99713bc0190075cfe201f8cd515dca78e184e
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Mon May 24 15:54:15 2021 +0200

    Renamed create account to employee form and fixed some validation

commit 935509bc5dd6bc7f6533b580197da2f8c15affc3
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Mon May 24 08:28:40 2021 +0200

    More changes to mock-api and views

commit d0bb8e1c0130c996ee89413f5ddda015fcf49ec5
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Fri May 21 11:22:40 2021 +0200

    Modified mock-api and implemented a part inside employee-list
2021-06-01 11:19:22 +02:00

115 lines
2.8 KiB
TypeScript

import { Participant } from './participant.model';
import { Service } from './service.model';
import { User, UserApiResponse } from './user.model';
export interface Employee extends User {
languages: string[];
participants: Participant[];
services: Service[];
}
export interface EmployeeApiResponse extends UserApiResponse {
services: Service[];
languages: string[];
participants: Participant[];
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface EmployeeApiRequestData extends Employee {}
export interface PegaEmployeesApiResponse {
pxMore: string;
pxObjClass: string;
pxPageCount: string;
pxQueryTimeStamp: string;
pxResultCount: string;
pxTotalResultCount: string;
pyMaxRecords: string;
pyObjClass: string;
pxResults: PegaEmployeeApiResponse[];
pzPerformanceSettings: string[];
}
export interface PegaEmployeeApiResponse {
pxInsHandle: string;
pxObjClass: string;
pyAccessGroup: string;
pyFirstName: string;
pyLastName: string;
pyOrganization: string;
pyOrgDivision: string;
pyOrgUnit: string;
pyUserIdentifier: string;
pyUserName: string;
}
export interface PegaEmployeeApiRequestData {
pyFirstName: string;
pyLastName: string;
}
export interface PegaEmployeeApiPostResponse {
pxObjClass: string;
pyErrorMessage: string;
pyFirstName: string;
pyHasError: 'true' | 'false';
pyLastName: string;
pyUserIdentifier: string;
}
export function mapEmployeeToEmployeeApiRequestData(data: Employee): EmployeeApiRequestData {
return data;
}
export function mapEmployeeToPegaEmployeeApiRequestData(data: Employee): PegaEmployeeApiRequestData {
return {
pyFirstName: data.firstName,
pyLastName: data.lastName,
};
}
export function mapPegaEmployeeReponseToEmployee(data: PegaEmployeeApiResponse): Employee {
return {
id: data.pyUserIdentifier,
lastName: data.pyLastName,
firstName: data.pyFirstName,
fullName: `${data.pyFirstName} ${data.pyLastName}`,
organizations: [
{
id: '',
name: data.pyOrganization,
kaNumber: null,
address: {
street: null,
houseNumber: null,
postalCode: null,
city: null,
kommun: null,
},
},
],
authorizations: null,
// authorizations: mapPegaAuthorizationToAuthorization(data.pyAccessGroup as PegaAuthorization),
services: [],
languages: [],
ssn: '',
participants: [],
};
}
export function mapEmployeeReponseToEmployee(data: EmployeeApiResponse): Employee {
const { id, firstName, lastName, ssn, services, languages, organizations, authorizations, participants } = data;
return {
id,
firstName,
lastName,
fullName: `${firstName} ${lastName}`,
organizations,
authorizations,
services,
languages,
ssn,
participants,
};
}