fix(employee): Added capitalize util to capitalize names. (TV-674)
Squashed commit of the following: commit d23bba16bc5378857b3cfd38afee40c3e60971a9 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Fri Sep 24 15:51:45 2021 +0200 Added capitalize util and implemented inside employee mapping
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { RoleEnum } from '@msfa-enums/role.enum';
|
||||
import { capitalizeWords } from '@msfa-utils/capitalize-words.util';
|
||||
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';
|
||||
@@ -37,7 +38,7 @@ export function mapResponseToEmployeeCompact(data: EmployeeCompactResponse): Emp
|
||||
const { ciamUserId, name, tjanst, allaUtforandeVerksamheter, utforandeVerksamhet } = data;
|
||||
return {
|
||||
id: ciamUserId,
|
||||
fullName: name,
|
||||
fullName: capitalizeWords(name),
|
||||
tjanster: tjanst || [],
|
||||
allaUtforandeVerksamheter: allaUtforandeVerksamheter,
|
||||
utforandeVerksamheter: utforandeVerksamhet || [],
|
||||
@@ -45,17 +46,11 @@ export function mapResponseToEmployeeCompact(data: EmployeeCompactResponse): Emp
|
||||
}
|
||||
|
||||
export function mapResponseToEmployee(data: EmployeeResponse): Employee {
|
||||
const {
|
||||
ciamUserId,
|
||||
firstName,
|
||||
lastName,
|
||||
email,
|
||||
ssn,
|
||||
roles,
|
||||
tjanster,
|
||||
allaUtforandeVerksamheter,
|
||||
utforandeVerksamheter,
|
||||
} = data;
|
||||
const { ciamUserId, email, ssn, roles, tjanster, allaUtforandeVerksamheter, utforandeVerksamheter } = data;
|
||||
|
||||
const firstName = capitalizeWords(data.firstName);
|
||||
const lastName = capitalizeWords(data.lastName);
|
||||
|
||||
return {
|
||||
id: ciamUserId,
|
||||
firstName,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export function capitalizeWords(words: string): string {
|
||||
return words
|
||||
.split(' ')
|
||||
.map(word => `${word.charAt(0).toUpperCase()}${word.slice(1).toLowerCase()}`)
|
||||
.join(' ');
|
||||
}
|
||||
Reference in New Issue
Block a user