diff --git a/feature-libs/order/root/utils/order-card-utils.spec.ts b/feature-libs/order/root/utils/order-card-utils.spec.ts index 1d4f1150d93..feb8e391164 100644 --- a/feature-libs/order/root/utils/order-card-utils.spec.ts +++ b/feature-libs/order/root/utils/order-card-utils.spec.ts @@ -24,6 +24,24 @@ describe('Order Card utils', () => { postalCode: 'zip', country: mockCountry, }; + const mockAddress2: Address = { + line1: 'Toyosaki 2 create on cart', + line2: 'line2', + town: 'town', + region: { isocode: 'JP-27' }, + postalCode: 'zip', + country: mockCountry, + }; + const mockAddress3: Address = { + titleCode: 'mr', + firstName: 'John', + line1: 'Toyosaki 2 create on cart', + line2: 'line2', + town: 'town', + region: { isocode: 'JP-27' }, + postalCode: 'zip', + country: mockCountry, + }; it('should return delivery address card', () => { const card = deliveryAddressCard( @@ -42,6 +60,22 @@ describe('Order Card utils', () => { 'zip', undefined, ]); + const card2 = deliveryAddressCard( + 'title', + 'phone', + 'mobile', + mockAddress2, + 'Canada' + ); + expect(card2.textBold).toEqual(undefined); + const card3 = deliveryAddressCard( + 'title', + 'phone', + 'mobile', + mockAddress3, + 'Canada' + ); + expect(card3.textBold).toEqual('John'); }); }); diff --git a/feature-libs/order/root/utils/order-card-utils.ts b/feature-libs/order/root/utils/order-card-utils.ts index 4afce4ea8af..9c47fe73e0d 100644 --- a/feature-libs/order/root/utils/order-card-utils.ts +++ b/feature-libs/order/root/utils/order-card-utils.ts @@ -33,10 +33,18 @@ export function deliveryAddressCard( } const numbers = getAddressNumbers(deliveryAddress, textPhone, textMobile); + let fullName; + if (deliveryAddress.firstName && deliveryAddress.lastName) { + fullName = deliveryAddress.firstName + ' ' + deliveryAddress.lastName; + } else if (deliveryAddress.firstName) { + fullName = deliveryAddress.firstName; + } else if (deliveryAddress.lastName) { + fullName = deliveryAddress.lastName; + } return { title: textTitle, - textBold: deliveryAddress.firstName + ' ' + deliveryAddress.lastName, + textBold: fullName, text: [ deliveryAddress.line1, deliveryAddress.line2,