From 5d1f1450a93638f41bd694d642d8e835445b913c Mon Sep 17 00:00:00 2001 From: norda-gunni <161026627+norda-gunni@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:01:52 +0000 Subject: [PATCH] fix(accident-notification): improve representative handling (#16669) (#16670) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../accident-notification-v2.utils.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts b/libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts index b2bb6cffe094..a3368c59e30f 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/accident-notification/accident-notification-v2.utils.ts @@ -16,6 +16,7 @@ import { InjuredPersonInformationV2, RepresentativeInfoV2, StudiesAccidentTypeEnum, + utils, WhoIsTheNotificationForEnum, WorkAccidentTypeEnum, WorkMachineV2, @@ -334,7 +335,27 @@ const getEmployer = ( 'representative', ) as RepresentativeInfoV2 - if (accidentType !== AccidentTypeEnum.WORK) return + if ( + answers.juridicalPerson && + answers.applicant && + utils.isRepresentativeOfCompanyOrInstitute(answers) + ) { + return { + companyName: answers.juridicalPerson.companyNationalId, + companyNationalId: answers.juridicalPerson.companyName, + representativeName: answers.applicant.name ?? '', + representativeEmail: answers.applicant.email ?? '', + representativePhone: answers.applicant.phoneNumber ?? '', + } + } + + if ( + accidentType === AccidentTypeEnum.HOMEACTIVITIES || + !companyInfo || + !representative + ) { + return undefined + } return { companyName: companyInfo.name ?? '',