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, createdBy,
usedByEmail, usedByEmail,
usedBy, usedBy,
app,
product, product,
events events
} = giftCard; } = giftCard;
@ -48,12 +47,22 @@ const GiftCardUpdateInfoCardContent: React.FC = () => {
// createdBy can be either customer or staff hence // createdBy can be either customer or staff hence
// we check for issued event // we check for issued event
if (cardIssuedEvent) { if (cardIssuedEvent) {
const { app } = cardIssuedEvent;
if (app) {
return {
label: messages.issuedByAppLabel,
name: app?.name,
url: appUrl(app?.id)
};
}
const userName = getFullName(createdBy); const userName = getFullName(createdBy);
return { return {
label: messages.issuedByLabel, label: messages.issuedByLabel,
name: userName || createdByEmail, 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 { return {
label: messages.boughtByLabel, label: messages.boughtByLabel,
name: getFullName(createdBy), name: getFullName(createdBy),