From 29a7ef644c2166a1d0bb6b6b59df96a5fba2fba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Choi=C5=84ski?= Date: Wed, 9 Dec 2020 11:15:13 +0100 Subject: [PATCH] Fix null voucher name handle (#891) * Fix null voucher name handle * Fix behavior for optional name * Fix voucher list * Fix loading voucher * Update storybook --- .../components/VoucherList/VoucherList.tsx | 34 ++++++++++++------- .../__snapshots__/Stories.test.ts.snap | 24 +++---------- .../views/TranslationsEntities.tsx | 2 +- 3 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/discounts/components/VoucherList/VoucherList.tsx b/src/discounts/components/VoucherList/VoucherList.tsx index bc400e25a..a16532850 100644 --- a/src/discounts/components/VoucherList/VoucherList.tsx +++ b/src/discounts/components/VoucherList/VoucherList.tsx @@ -243,8 +243,12 @@ const VoucherList: React.FC = props => { {maybe(() => voucher.code, )} - {hasChannelsLoaded ? ( - + {voucher?.code ? ( + hasChannelsLoaded ? ( + + ) : ( + "-" + ) ) : ( )} @@ -269,19 +273,23 @@ const VoucherList: React.FC = props => { className={classes.colValue} onClick={voucher ? onRowClick(voucher.id) : undefined} > - {hasChannelsLoaded ? ( - voucher.discountValueType === - DiscountValueTypeEnum.FIXED ? ( - + /> + ) : ( + + ) ) : ( - + "-" ) ) : ( diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index 34bc36aca..4fd004819 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -87873,11 +87873,7 @@ exports[`Storyshots Views / Discounts / Voucher list no channels 1`] = ` - - ‌ - + - - - ‌ - + - - - ‌ - + - - - ‌ - + - = ({ max: 1 }, id: node.voucher?.id, - name: node.voucher?.name + name: node.voucher?.name || "-" } )} onRowClick={id =>