Fix gift card update view crashing when gift card created by app (#1462)

This commit is contained in:
Magdalena Markusik 2021-10-08 11:28:31 +02:00 committed by GitHub
parent d750d3684e
commit 7ac6572a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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),