diff --git a/src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts b/src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts index 8d9b071988..d9d308a3b4 100644 --- a/src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts +++ b/src/features/process/confirm/helpers/returnConfirmSummaryObject.test.ts @@ -57,18 +57,36 @@ describe('returnConfirmSummaryObject', () => { }); }); - it('should return sender as empty string when neither ssn or orgNumber is present', () => { + it('should return sender as name only when neither ssn nor orgNumber is present', () => { const result = returnConfirmSummaryObject({ langTools, instanceOwnerParty: { partyId: 50001, - name: 'Ola Bedrift', + name: 'Ola Selvidentifisert', } as IParty, }); expect(result).toEqual({ 'confirm.sender': { - value: '', + value: 'Ola Selvidentifisert', + }, + }); + }); + + it('should return sender as name only when ssn and orgNumber are null', () => { + const result = returnConfirmSummaryObject({ + langTools, + instanceOwnerParty: { + partyId: 50001, + name: 'Ola Selvidentifisert', + ssn: null, + orgNumber: null, + } as IParty, + }); + + expect(result).toEqual({ + 'confirm.sender': { + value: 'Ola Selvidentifisert', }, }); }); diff --git a/src/features/process/confirm/helpers/returnConfirmSummaryObject.ts b/src/features/process/confirm/helpers/returnConfirmSummaryObject.ts index f7854f28c1..8d05faad30 100644 --- a/src/features/process/confirm/helpers/returnConfirmSummaryObject.ts +++ b/src/features/process/confirm/helpers/returnConfirmSummaryObject.ts @@ -8,14 +8,11 @@ interface ISummaryData { } export function getInstanceSender(instanceOwnerParty?: IParty): string { - let sender = ''; - if (instanceOwnerParty?.ssn) { - sender = `${instanceOwnerParty.ssn}-${instanceOwnerParty.name}`; - } else if (instanceOwnerParty?.orgNumber) { - sender = `${instanceOwnerParty.orgNumber}-${instanceOwnerParty.name}`; + if (!instanceOwnerParty) { + return ''; } - - return sender; + const identifier = instanceOwnerParty.ssn ?? instanceOwnerParty.orgNumber; + return identifier ? `${identifier}-${instanceOwnerParty.name}` : instanceOwnerParty.name; } export const returnConfirmSummaryObject = ({ instanceOwnerParty, langTools }: ISummaryData): SummaryDataObject => { diff --git a/src/layout/InstanceInformation/InstanceInformationComponent.tsx b/src/layout/InstanceInformation/InstanceInformationComponent.tsx index b9fcc4dfab..01dccf0920 100644 --- a/src/layout/InstanceInformation/InstanceInformationComponent.tsx +++ b/src/layout/InstanceInformation/InstanceInformationComponent.tsx @@ -74,10 +74,11 @@ export function InstanceInformation({ elements }: Pick