From ae1d1f478a4d1a033858b2197c82a31514731fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dro=C5=84?= Date: Wed, 1 Dec 2021 14:37:51 +0100 Subject: [PATCH] Fix long name vouchers (#1626) (#1640) * Fix long name vouchers * update snapshots * QA improvements - wrap page headers * QA improvements - same changes for sales --- .../SaleDetailsPage/SaleDetailsPage.tsx | 4 +- .../components/SaleList/SaleList.tsx | 9 ++- .../components/SaleSummary/SaleSummary.tsx | 5 +- .../components/SaleSummary/styles.ts | 10 +++ .../VoucherDetailsPage/VoucherDetailsPage.tsx | 7 +- .../components/VoucherList/VoucherList.tsx | 11 +++- .../VoucherSummary/VoucherSummary.tsx | 4 +- .../components/VoucherSummary/styles.ts | 10 +++ .../__snapshots__/Stories.test.ts.snap | 64 +++++++++---------- 9 files changed, 84 insertions(+), 40 deletions(-) create mode 100644 src/discounts/components/SaleSummary/styles.ts create mode 100644 src/discounts/components/VoucherSummary/styles.ts diff --git a/src/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx b/src/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx index 79e36cb1f..46d499ea1 100644 --- a/src/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx +++ b/src/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx @@ -33,6 +33,7 @@ import DiscountProducts from "../DiscountProducts"; import DiscountVariants from "../DiscountVariants"; import SaleInfo from "../SaleInfo"; import SaleSummary from "../SaleSummary"; +import { useStyles } from "../SaleSummary/styles"; import SaleType from "../SaleType"; import SaleValue from "../SaleValue"; @@ -150,6 +151,7 @@ const SaleDetailsPage: React.FC = ({ toggleAll }) => { const intl = useIntl(); + const classes = useStyles(); const { makeChangeHandler: makeMetadataChangeHandler } = useMetadataChangeTrigger(); @@ -185,7 +187,7 @@ const SaleDetailsPage: React.FC = ({ {intl.formatMessage(sectionNames.sales)} - sale.name)} /> +
= props => { onChange={() => toggle(sale.id)} /> - + {maybe(() => sale.name, )} diff --git a/src/discounts/components/SaleSummary/SaleSummary.tsx b/src/discounts/components/SaleSummary/SaleSummary.tsx index 44ab1b5b5..b470255e9 100644 --- a/src/discounts/components/SaleSummary/SaleSummary.tsx +++ b/src/discounts/components/SaleSummary/SaleSummary.tsx @@ -15,7 +15,7 @@ import { FormattedMessage, useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { SaleType } from "../../../types/globalTypes"; import { SaleDetails_sale } from "../../types/SaleDetails"; - +import { useStyles } from "./styles"; export interface SaleSummaryProps extends ChannelProps { sale: SaleDetails_sale; } @@ -25,6 +25,7 @@ const SaleSummary: React.FC = ({ sale }) => { const intl = useIntl(); + const classes = useStyles(); const channel = sale?.channelListings?.find( listing => listing.channel.id === selectedChannelId @@ -36,7 +37,7 @@ const SaleSummary: React.FC = ({ - + {maybe(() => sale.name, )} diff --git a/src/discounts/components/SaleSummary/styles.ts b/src/discounts/components/SaleSummary/styles.ts new file mode 100644 index 000000000..a8e97277a --- /dev/null +++ b/src/discounts/components/SaleSummary/styles.ts @@ -0,0 +1,10 @@ +import { makeStyles } from "@saleor/macaw-ui"; + +export const useStyles = makeStyles( + () => ({ + wrapAnywhere: { + overflowWrap: "anywhere" + } + }), + { name: "SaleSummary" } +); diff --git a/src/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx b/src/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx index 43617e9c1..b73cf5162 100644 --- a/src/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx +++ b/src/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx @@ -42,6 +42,7 @@ import VoucherInfo from "../VoucherInfo"; import VoucherLimits from "../VoucherLimits"; import VoucherRequirements from "../VoucherRequirements"; import VoucherSummary from "../VoucherSummary"; +import { useStyles } from "../VoucherSummary/styles"; import VoucherTypes from "../VoucherTypes"; import VoucherValue from "../VoucherValue"; @@ -154,6 +155,7 @@ const VoucherDetailsPage: React.FC = ({ productListToolbar }) => { const intl = useIntl(); + const classes = useStyles(); const { makeChangeHandler: makeMetadataChangeHandler } = useMetadataChangeTrigger(); @@ -226,7 +228,10 @@ const VoucherDetailsPage: React.FC = ({ {intl.formatMessage(sectionNames.vouchers)} - +
= props => { onChange={() => toggle(voucher.id)} /> - - {maybe(() => voucher.code, )} + + {voucher?.code ?? } {voucher?.code ? ( diff --git a/src/discounts/components/VoucherSummary/VoucherSummary.tsx b/src/discounts/components/VoucherSummary/VoucherSummary.tsx index ce8e0fc41..583c0f213 100644 --- a/src/discounts/components/VoucherSummary/VoucherSummary.tsx +++ b/src/discounts/components/VoucherSummary/VoucherSummary.tsx @@ -16,6 +16,7 @@ import { maybe } from "../../../misc"; import { DiscountValueTypeEnum } from "../../../types/globalTypes"; import { translateVoucherTypes } from "../../translations"; import { VoucherDetails_voucher } from "../../types/VoucherDetails"; +import { useStyles } from "./styles"; export interface VoucherSummaryProps extends ChannelProps { voucher: VoucherDetails_voucher; @@ -26,6 +27,7 @@ const VoucherSummary: React.FC = ({ voucher }) => { const intl = useIntl(); + const classes = useStyles(); const translatedVoucherTypes = translateVoucherTypes(intl); const channel = voucher?.channelListings?.find( @@ -39,7 +41,7 @@ const VoucherSummary: React.FC = ({ - + {maybe(() => voucher.code, )} diff --git a/src/discounts/components/VoucherSummary/styles.ts b/src/discounts/components/VoucherSummary/styles.ts new file mode 100644 index 000000000..d58c6c98c --- /dev/null +++ b/src/discounts/components/VoucherSummary/styles.ts @@ -0,0 +1,10 @@ +import { makeStyles } from "@saleor/macaw-ui"; + +export const useStyles = makeStyles( + () => ({ + wrapAnywhere: { + overflowWrap: "anywhere" + } + }), + { name: "VoucherSummary" } +); diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index cd31960e5..3f07b2ad1 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -88362,7 +88362,7 @@ exports[`Storyshots Views / Discounts / Sale details collections 1`] = ` class="Container-root-id" >
Happy minute day!
@@ -89791,7 +89791,7 @@ exports[`Storyshots Views / Discounts / Sale details default 1`] = ` class="Container-root-id" >
Happy minute day!
@@ -91220,7 +91220,7 @@ exports[`Storyshots Views / Discounts / Sale details form errors 1`] = ` class="Container-root-id" >
Happy minute day!
@@ -92664,7 +92664,7 @@ exports[`Storyshots Views / Discounts / Sale details loading 1`] = ` class="Container-root-id" >
Happy minute day!
@@ -96301,7 +96301,7 @@ exports[`Storyshots Views / Discounts / Sale list default 1`] = ` Happy front day! @@ -96359,7 +96359,7 @@ exports[`Storyshots Views / Discounts / Sale list default 1`] = ` Happy minute day! @@ -96433,7 +96433,7 @@ exports[`Storyshots Views / Discounts / Sale list default 1`] = ` Happy class day! @@ -96491,7 +96491,7 @@ exports[`Storyshots Views / Discounts / Sale list default 1`] = ` Happy human day! @@ -96549,7 +96549,7 @@ exports[`Storyshots Views / Discounts / Sale list default 1`] = ` Happy year day! @@ -96965,7 +96965,7 @@ exports[`Storyshots Views / Discounts / Sale list loading 1`] = ` Happy front day! @@ -97453,7 +97453,7 @@ exports[`Storyshots Views / Discounts / Sale list no channels 1`] = ` Happy minute day! @@ -97511,7 +97511,7 @@ exports[`Storyshots Views / Discounts / Sale list no channels 1`] = ` Happy class day! @@ -97569,7 +97569,7 @@ exports[`Storyshots Views / Discounts / Sale list no channels 1`] = ` Happy human day! @@ -97627,7 +97627,7 @@ exports[`Storyshots Views / Discounts / Sale list no channels 1`] = ` Happy year day! @@ -101129,7 +101129,7 @@ exports[`Storyshots Views / Discounts / Voucher details default 1`] = ` class="Container-root-id" >
DISCOUNT
@@ -103489,7 +103489,7 @@ exports[`Storyshots Views / Discounts / Voucher details form errors 1`] = ` class="Container-root-id" >
DISCOUNT
@@ -105874,7 +105874,7 @@ exports[`Storyshots Views / Discounts / Voucher details loading 1`] = ` class="Container-root-id" >
FREE2019 @@ -108246,7 +108246,7 @@ exports[`Storyshots Views / Discounts / Voucher list default 1`] = ` FREE2020 @@ -108732,7 +108732,7 @@ exports[`Storyshots Views / Discounts / Voucher list loading 1`] = ` FREE2019 @@ -109278,7 +109278,7 @@ exports[`Storyshots Views / Discounts / Voucher list no channels 1`] = ` FREE2020