Fix null voucher name handle (#891)

* Fix null voucher name handle

* Fix behavior for optional name

* Fix voucher list

* Fix loading voucher

* Update storybook
This commit is contained in:
Marek Choiński 2020-12-09 11:15:13 +01:00 committed by GitHub
parent 82bbb93d94
commit 29a7ef644c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 34 deletions

View file

@ -243,8 +243,12 @@ const VoucherList: React.FC<VoucherListProps> = props => {
{maybe<React.ReactNode>(() => voucher.code, <Skeleton />)}
</TableCell>
<TableCell className={classes.colMinSpent}>
{hasChannelsLoaded ? (
<Money money={channel?.minSpent} />
{voucher?.code ? (
hasChannelsLoaded ? (
<Money money={channel?.minSpent} />
) : (
"-"
)
) : (
<Skeleton />
)}
@ -269,19 +273,23 @@ const VoucherList: React.FC<VoucherListProps> = props => {
className={classes.colValue}
onClick={voucher ? onRowClick(voucher.id) : undefined}
>
{hasChannelsLoaded ? (
voucher.discountValueType ===
DiscountValueTypeEnum.FIXED ? (
<Money
money={
channel?.discountValue && {
amount: channel?.discountValue,
currency: channel?.currency
{voucher?.code ? (
hasChannelsLoaded ? (
voucher.discountValueType ===
DiscountValueTypeEnum.FIXED ? (
<Money
money={
channel?.discountValue && {
amount: channel?.discountValue,
currency: channel?.currency
}
}
}
/>
/>
) : (
<Percent amount={channel?.discountValue} />
)
) : (
<Percent amount={channel?.discountValue} />
"-"
)
) : (
<Skeleton />

View file

@ -87873,11 +87873,7 @@ exports[`Storyshots Views / Discounts / Voucher list no channels 1`] = `
<td
class="MuiTableCell-root-id MuiTableCell-body-id VoucherList-colMinSpent-id"
>
<span
class="Skeleton-skeleton-id"
>
</span>
-
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id VoucherList-colStart-id"
@ -87898,11 +87894,7 @@ exports[`Storyshots Views / Discounts / Voucher list no channels 1`] = `
<td
class="MuiTableCell-root-id MuiTableCell-body-id VoucherList-colValue-id"
>
<span
class="Skeleton-skeleton-id"
>
</span>
-
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id VoucherList-colUses-id"
@ -87955,11 +87947,7 @@ exports[`Storyshots Views / Discounts / Voucher list no channels 1`] = `
<td
class="MuiTableCell-root-id MuiTableCell-body-id VoucherList-colMinSpent-id"
>
<span
class="Skeleton-skeleton-id"
>
</span>
-
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id VoucherList-colStart-id"
@ -87980,11 +87968,7 @@ exports[`Storyshots Views / Discounts / Voucher list no channels 1`] = `
<td
class="MuiTableCell-root-id MuiTableCell-body-id VoucherList-colValue-id"
>
<span
class="Skeleton-skeleton-id"
>
</span>
-
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id VoucherList-colUses-id"

View file

@ -346,7 +346,7 @@ const TranslationsEntities: React.FC<TranslationsEntitiesProps> = ({
max: 1
},
id: node.voucher?.id,
name: node.voucher?.name
name: node.voucher?.name || "-"
}
)}
onRowClick={id =>