From bae6574d8fe458169ece33d8da6ec555947e3c7d Mon Sep 17 00:00:00 2001 From: Josmar Soares Trigueiro Junior Date: Wed, 14 Aug 2024 10:19:36 -0300 Subject: [PATCH 1/6] fix: [quick order] adjust validation of skus and show better status --- react/components/ReviewBlock.tsx | 51 +++++++++++++++--------------- react/typings/vtex.styleguide.d.ts | 1 + 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/react/components/ReviewBlock.tsx b/react/components/ReviewBlock.tsx index 288cff6d..772d214c 100644 --- a/react/components/ReviewBlock.tsx +++ b/react/components/ReviewBlock.tsx @@ -7,10 +7,9 @@ import { Input, ButtonWithIcon, IconDelete, - IconInfo, - Tooltip, Dropdown, ToastContext, + Tag, } from 'vtex.styleguide' import type { WrappedComponentProps } from 'react-intl' import { injectIntl } from 'react-intl' @@ -32,8 +31,8 @@ const ReviewBlock: FunctionComponent = ({ hiddenColumns, reviewedItems, onRefidLoading, - backList, intl, + backList, }: any) => { const client = useApolloClient() const { showToast } = useContext(ToastContext) @@ -128,11 +127,11 @@ const ReviewBlock: FunctionComponent = ({ // drops sellers without stock from refidData refidData?.skuFromRefIds.items.forEach((item: any) => { - if (!item.sellers) return + if (!item?.sellers) return item.sellers = item.sellers.filter( (seller: any) => - seller.availability === 'available' || - seller.availability === 'partiallyAvailable' + seller?.availability === 'available' || + seller?.availability === 'partiallyAvailable' ) }) @@ -192,19 +191,20 @@ const ReviewBlock: FunctionComponent = ({ let selectedSellerHasPartialStock const foundHasStock = - found?.sellers?.length && - found.sellers.filter((seller: any) => { - if (seller.id === sellerWithStock) { - selectedSellerHasPartialStock = - seller.availability === 'partiallyAvailable' - } - - return ( - seller.availability && - (seller.availability === 'available' || - seller.availability === 'partiallyAvailable') - ) - }).length + (found?.sellers?.length && + found.sellers.filter((seller: any) => { + if (seller?.id === sellerWithStock) { + selectedSellerHasPartialStock = + seller?.availability === 'partiallyAvailable' + } + + return ( + seller?.availability && + (seller?.availability === 'available' || + seller?.availability === 'partiallyAvailable') + ) + })?.length) || + 0 const itemRestricted = sellerWithStock ? null @@ -281,6 +281,7 @@ const ReviewBlock: FunctionComponent = ({ }) onReviewItems(updated) + if (JSON.stringify(reviewItems) !== JSON.stringify(updated)) { setReviewState({ ...state, @@ -546,7 +547,7 @@ const ReviewBlock: FunctionComponent = ({ title: intl.formatMessage({ id: 'store/quickorder.review.label.status', }), - width: 75, + cellRenderer: ({ cellData, rowData }: any) => { if (rowData.error) { const errMsg = errorMessage[cellData || 'store/quickorder.valid'] @@ -560,12 +561,10 @@ const ReviewBlock: FunctionComponent = ({ : intl.formatMessage(errMsg) return ( - - - - - - + + + {text} + ) } diff --git a/react/typings/vtex.styleguide.d.ts b/react/typings/vtex.styleguide.d.ts index 65f734f6..f69b4ab9 100644 --- a/react/typings/vtex.styleguide.d.ts +++ b/react/typings/vtex.styleguide.d.ts @@ -23,4 +23,5 @@ declare module 'vtex.styleguide' { export const IconClear export const Tag export const Collapsible + export const Alert } From d7e7e0bcad707f527bbcb6b9e1c1521cd3de63ba Mon Sep 17 00:00:00 2001 From: Josmar Soares Trigueiro Junior Date: Wed, 14 Aug 2024 15:02:30 -0300 Subject: [PATCH 2/6] doc: update change log file --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0c2e1ba..05aa5619 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Fixes validation of SKU codes in the quickorder ReviewBlock component + ## [3.15.4] - 2024-06-13 ## [3.15.3] - 2024-06-10 From 1e27a7d74c56ed31ebd5dc160543e5027f645650 Mon Sep 17 00:00:00 2001 From: Josmar Soares Trigueiro Junior Date: Mon, 19 Aug 2024 11:18:44 -0300 Subject: [PATCH 3/6] doc: update change log file --- react/components/ReviewBlock.tsx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/react/components/ReviewBlock.tsx b/react/components/ReviewBlock.tsx index 772d214c..13134af0 100644 --- a/react/components/ReviewBlock.tsx +++ b/react/components/ReviewBlock.tsx @@ -476,7 +476,7 @@ const ReviewBlock: FunctionComponent = ({ tableSchema.properties.sku = { type: 'string', title: intl.formatMessage({ id: 'store/quickorder.review.label.sku' }), - width: 125, + width: 112, } } @@ -486,7 +486,7 @@ const ReviewBlock: FunctionComponent = ({ title: intl.formatMessage({ id: 'store/quickorder.review.label.quantity', }), - width: 75, + width: 72, } } @@ -501,12 +501,20 @@ const ReviewBlock: FunctionComponent = ({ } if (columnsToBeHidden.indexOf('totalQuantity') === -1) { + const totalQuantity = intl.formatMessage({ + id: 'store/quickorder.review.label.totalQuantity', + }) as string + + const [quantity, total] = totalQuantity.split(' ') + tableSchema.properties.totalQuantity = { type: 'float', - title: intl.formatMessage({ - id: 'store/quickorder.review.label.totalQuantity', - }), - width: 100, + title: ( + <> + {quantity} {total} + + ), + width: 82, } } @@ -547,7 +555,6 @@ const ReviewBlock: FunctionComponent = ({ title: intl.formatMessage({ id: 'store/quickorder.review.label.status', }), - cellRenderer: ({ cellData, rowData }: any) => { if (rowData.error) { const errMsg = errorMessage[cellData || 'store/quickorder.valid'] @@ -562,7 +569,7 @@ const ReviewBlock: FunctionComponent = ({ return ( - + {text} @@ -578,7 +585,7 @@ const ReviewBlock: FunctionComponent = ({ tableSchema.properties.delete = { type: 'object', title: ' ', - width: 75, + width: 58, // eslint-disable-next-line react/display-name cellRenderer: ({ rowData }: any) => { return ( From e094e2df2aede4210c6a375879effd914b8b465a Mon Sep 17 00:00:00 2001 From: Josmar Soares Trigueiro Junior Date: Mon, 19 Aug 2024 16:43:13 -0300 Subject: [PATCH 4/6] fix: remove alert component in vtex.styleguide.d.ts file --- CHANGELOG.md | 2 +- react/typings/vtex.styleguide.d.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05aa5619..f1cc9250 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Fixed -- Fixes validation of SKU codes in the quickorder ReviewBlock component +- Fixes validation of SKU codes in the quickorder and styles of the ReviewBlock component ## [3.15.4] - 2024-06-13 diff --git a/react/typings/vtex.styleguide.d.ts b/react/typings/vtex.styleguide.d.ts index f69b4ab9..65f734f6 100644 --- a/react/typings/vtex.styleguide.d.ts +++ b/react/typings/vtex.styleguide.d.ts @@ -23,5 +23,4 @@ declare module 'vtex.styleguide' { export const IconClear export const Tag export const Collapsible - export const Alert } From 69ec2bfeddb76d2f09e351b52697f18a2cd728e2 Mon Sep 17 00:00:00 2001 From: Josmar Soares Trigueiro Junior Date: Tue, 20 Aug 2024 11:26:30 -0300 Subject: [PATCH 5/6] fix: add break-spaces style --- react/components/ReviewBlock.tsx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/react/components/ReviewBlock.tsx b/react/components/ReviewBlock.tsx index 13134af0..49ae6886 100644 --- a/react/components/ReviewBlock.tsx +++ b/react/components/ReviewBlock.tsx @@ -501,18 +501,15 @@ const ReviewBlock: FunctionComponent = ({ } if (columnsToBeHidden.indexOf('totalQuantity') === -1) { - const totalQuantity = intl.formatMessage({ - id: 'store/quickorder.review.label.totalQuantity', - }) as string - - const [quantity, total] = totalQuantity.split(' ') - tableSchema.properties.totalQuantity = { type: 'float', title: ( - <> - {quantity} {total} - +
+ {intl.formatMessage({ + id: 'store/quickorder.review.label.totalQuantity', + })} + aa +
), width: 82, } From fe5d85b5d009d36cbfb5fe42a09234a704356b6c Mon Sep 17 00:00:00 2001 From: Josmar Soares Trigueiro Junior Date: Tue, 20 Aug 2024 11:27:20 -0300 Subject: [PATCH 6/6] fix: add break-spaces style --- react/components/ReviewBlock.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/react/components/ReviewBlock.tsx b/react/components/ReviewBlock.tsx index 49ae6886..81962bdb 100644 --- a/react/components/ReviewBlock.tsx +++ b/react/components/ReviewBlock.tsx @@ -508,7 +508,6 @@ const ReviewBlock: FunctionComponent = ({ {intl.formatMessage({ id: 'store/quickorder.review.label.totalQuantity', })} - aa ), width: 82,