Updated ciam prod client-id
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { mapStringToSsn } from '@msfa-utils/map-string-to-ssn.util';
|
||||
import { Address, mapResponseToAddress } from './address.model';
|
||||
import { ContactInformationResponse } from './api/contact-information.response.model';
|
||||
import { mapResponseToPhoneNumber, PhoneNumber } from './phonenumber.model';
|
||||
@@ -12,23 +13,15 @@ export interface ContactInformation {
|
||||
addresses: Address[];
|
||||
}
|
||||
|
||||
export function mapResponseToContactInformation(contactInformation: ContactInformationResponse): ContactInformation {
|
||||
export function mapResponseToContactInformation(data: ContactInformationResponse): ContactInformation {
|
||||
const { fornamn, efternamn, personnummer, epost, telekomadresser, adresser } = data;
|
||||
return {
|
||||
firstName: contactInformation.fornamn,
|
||||
lastName: contactInformation.efternamn,
|
||||
fullName: `${contactInformation.fornamn} ${contactInformation.efternamn}`,
|
||||
ssn: `${contactInformation.personnummer.substring(
|
||||
0,
|
||||
contactInformation.personnummer.length - 4
|
||||
)}-${contactInformation.personnummer.substring(contactInformation.personnummer.length - 4)}`,
|
||||
email: contactInformation.epost,
|
||||
phoneNumbers: contactInformation.telekomadresser
|
||||
? contactInformation.telekomadresser.map(phoneNumber => {
|
||||
return mapResponseToPhoneNumber(phoneNumber);
|
||||
})
|
||||
: [],
|
||||
addresses: contactInformation.adresser
|
||||
? contactInformation.adresser.map(address => mapResponseToAddress(address))
|
||||
: null,
|
||||
firstName: fornamn || '',
|
||||
lastName: efternamn || '',
|
||||
fullName: fornamn && efternamn ? `${fornamn} ${efternamn}` : '',
|
||||
ssn: personnummer ? mapStringToSsn(personnummer) : '',
|
||||
email: epost || '',
|
||||
phoneNumbers: telekomadresser ? telekomadresser.map(phoneNumber => mapResponseToPhoneNumber(phoneNumber)) : [],
|
||||
addresses: adresser ? adresser.map(address => mapResponseToAddress(address)) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { RoleEnum } from '@msfa-enums/role.enum';
|
||||
import { mapStringToSsn } from '@msfa-utils/map-string-to-ssn.util';
|
||||
import { EmployeeCompactResponse, EmployeeResponse } from './api/employee.response.model';
|
||||
import { EmployeeTjanst, mapResponseToEmployeeTjanst } from './employee-tjanst.model';
|
||||
import {
|
||||
@@ -7,8 +8,6 @@ import {
|
||||
} from './employee-utforande-verksamhet.model';
|
||||
import { PaginationMeta } from './pagination-meta.model';
|
||||
|
||||
const CURRENT_YEAR = new Date().getFullYear().toString().slice(2, 4);
|
||||
|
||||
export interface EmployeeCompact {
|
||||
id: string;
|
||||
fullName: string;
|
||||
@@ -16,7 +15,6 @@ export interface EmployeeCompact {
|
||||
allaUtforandeVerksamheter: boolean;
|
||||
utforandeVerksamheter: string[];
|
||||
}
|
||||
|
||||
export interface Employee {
|
||||
id: string;
|
||||
firstName: string;
|
||||
@@ -35,18 +33,6 @@ export interface EmployeesData {
|
||||
meta: PaginationMeta;
|
||||
}
|
||||
|
||||
function mapResponseToSsn(ssn: string): string {
|
||||
ssn = ssn.replaceAll('-', '');
|
||||
if (ssn.length === 10) {
|
||||
const century = +CURRENT_YEAR - +ssn.slice(0, 2) > 0 ? '20' : '19';
|
||||
ssn = ssn.padStart(12, century);
|
||||
}
|
||||
if (ssn.length === 12) {
|
||||
ssn = `${ssn.slice(0, 8)}-${ssn.slice(8, 12)}`;
|
||||
}
|
||||
return ssn;
|
||||
}
|
||||
|
||||
export function mapResponseToEmployeeCompact(data: EmployeeCompactResponse): EmployeeCompact {
|
||||
const { ciamUserId, name, tjanst, allaUtforandeVerksamheter, utforandeVerksamhet } = data;
|
||||
return {
|
||||
@@ -76,7 +62,7 @@ export function mapResponseToEmployee(data: EmployeeResponse): Employee {
|
||||
lastName,
|
||||
fullName: `${firstName} ${lastName}`,
|
||||
email,
|
||||
ssn: ssn ? mapResponseToSsn(ssn) : null,
|
||||
ssn: ssn ? mapStringToSsn(ssn) : null,
|
||||
roles: roles || [],
|
||||
tjanster: tjanster?.map(tjanst => mapResponseToEmployeeTjanst(tjanst)),
|
||||
allaUtforandeVerksamheter,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
const CURRENT_YEAR = new Date().getFullYear().toString().slice(2, 4);
|
||||
|
||||
export function mapStringToSsn(ssn: string): string {
|
||||
ssn = ssn.replaceAll('-', '');
|
||||
if (ssn.length === 10) {
|
||||
const century = +CURRENT_YEAR - +ssn.slice(0, 2) > 0 ? '20' : '19';
|
||||
ssn = ssn.padStart(12, century);
|
||||
}
|
||||
if (ssn.length === 12) {
|
||||
ssn = `${ssn.slice(0, 8)}-${ssn.slice(8, 12)}`;
|
||||
}
|
||||
return ssn;
|
||||
}
|
||||
Reference in New Issue
Block a user