From 7ac6572a1a147afe2286e22b9f16ef7c44c20785 Mon Sep 17 00:00:00 2001 From: Magdalena Markusik Date: Fri, 8 Oct 2021 11:28:31 +0200 Subject: [PATCH] Fix gift card update view crashing when gift card created by app (#1462) --- .../GiftCardUpdateInfoCardContent.tsx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/giftCards/GiftCardUpdate/GiftCardUpdateInfoCard/GiftCardUpdateInfoCardContent.tsx b/src/giftCards/GiftCardUpdate/GiftCardUpdateInfoCard/GiftCardUpdateInfoCardContent.tsx index 853ec7812..4b89f459b 100644 --- a/src/giftCards/GiftCardUpdate/GiftCardUpdateInfoCard/GiftCardUpdateInfoCardContent.tsx +++ b/src/giftCards/GiftCardUpdate/GiftCardUpdateInfoCard/GiftCardUpdateInfoCardContent.tsx @@ -32,7 +32,6 @@ const GiftCardUpdateInfoCardContent: React.FC = () => { createdBy, usedByEmail, usedBy, - app, product, events } = giftCard; @@ -48,12 +47,22 @@ const GiftCardUpdateInfoCardContent: React.FC = () => { // createdBy can be either customer or staff hence // we check for issued event if (cardIssuedEvent) { + const { app } = cardIssuedEvent; + + if (app) { + return { + label: messages.issuedByAppLabel, + name: app?.name, + url: appUrl(app?.id) + }; + } + const userName = getFullName(createdBy); return { label: messages.issuedByLabel, name: userName || createdByEmail, - url: staffMemberDetailsUrl(createdBy.id) + url: staffMemberDetailsUrl(createdBy?.id) }; } @@ -64,14 +73,6 @@ const GiftCardUpdateInfoCardContent: React.FC = () => { }; } - if (app) { - return { - label: messages.issuedByAppLabel, - name: app.name, - url: appUrl(app.id) - }; - } - return { label: messages.boughtByLabel, name: getFullName(createdBy),