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 />)} {maybe<React.ReactNode>(() => voucher.code, <Skeleton />)}
</TableCell> </TableCell>
<TableCell className={classes.colMinSpent}> <TableCell className={classes.colMinSpent}>
{hasChannelsLoaded ? ( {voucher?.code ? (
hasChannelsLoaded ? (
<Money money={channel?.minSpent} /> <Money money={channel?.minSpent} />
) : (
"-"
)
) : ( ) : (
<Skeleton /> <Skeleton />
)} )}
@ -269,7 +273,8 @@ const VoucherList: React.FC<VoucherListProps> = props => {
className={classes.colValue} className={classes.colValue}
onClick={voucher ? onRowClick(voucher.id) : undefined} onClick={voucher ? onRowClick(voucher.id) : undefined}
> >
{hasChannelsLoaded ? ( {voucher?.code ? (
hasChannelsLoaded ? (
voucher.discountValueType === voucher.discountValueType ===
DiscountValueTypeEnum.FIXED ? ( DiscountValueTypeEnum.FIXED ? (
<Money <Money
@ -283,6 +288,9 @@ const VoucherList: React.FC<VoucherListProps> = props => {
) : ( ) : (
<Percent amount={channel?.discountValue} /> <Percent amount={channel?.discountValue} />
) )
) : (
"-"
)
) : ( ) : (
<Skeleton /> <Skeleton />
)} )}

View file

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

View file

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