From b53c907cefdf180c734cc978f59cf88642d86f8a Mon Sep 17 00:00:00 2001 From: Victor Almeida Date: Mon, 4 Sep 2023 14:32:27 -0300 Subject: [PATCH 1/4] Add timeout to batch modal update response --- .../components/DetailsPage/BatchModal.tsx | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/vtex-my-subscriptions-3/react/components/DetailsPage/BatchModal.tsx b/apps/vtex-my-subscriptions-3/react/components/DetailsPage/BatchModal.tsx index ec47c180..729a5d27 100644 --- a/apps/vtex-my-subscriptions-3/react/components/DetailsPage/BatchModal.tsx +++ b/apps/vtex-my-subscriptions-3/react/components/DetailsPage/BatchModal.tsx @@ -175,24 +175,30 @@ class BatchModal extends Component { } promises?.then(() => { - const displayError = this.state.completed.length !== selectedIds.length - - if (!displayError) { - showToast({ message: intl.formatMessage(messages.success) }) - onClose() - } else { - this.setState((finalState) => { - finalState.completed.map((id) => delete finalState.selectionItems[id]) - - return { - selectionItems: finalState.selectionItems, - loading: false, - // If some subscription isn't on the finalState - // it means that some error has ocurred - displayError, - } - }) - } + // timeout added due to state not update instantaneously + setTimeout(() => { + // filter only unique completed ids + const uniqueCompletedIds = this.state.completed.filter((completed, index) => this.state.completed.indexOf(completed) === index); + + const displayError = uniqueCompletedIds.length !== selectedIds.length + + if (!displayError) { + showToast({ message: intl.formatMessage(messages.success) }) + onClose() + } else { + this.setState((finalState) => { + finalState.completed.map((id) => delete finalState.selectionItems[id]) + + return { + selectionItems: finalState.selectionItems, + loading: false, + // If some subscription isn't on the finalState + // it means that some error has ocurred + displayError, + } + }) + } + }, 100) }) } From 075e966e8d29955f555136ffb0ccc37f4689c9ac Mon Sep 17 00:00:00 2001 From: Victor Almeida Date: Thu, 14 Sep 2023 18:50:03 -0300 Subject: [PATCH 2/4] Add productName to not display only sku name --- .../react/components/AddItemModal/Modal.tsx | 3 ++- .../react/components/AddItemModal/search.d.ts | 1 + .../react/components/AddItemModal/search.gql | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx b/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx index aa5d49ae..88d74170 100644 --- a/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx +++ b/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx @@ -72,6 +72,7 @@ const AddItemModal: FunctionComponent = ({ targetPlan, }) => { let state: State + console.log(`products`, products) if (loading) { state = 'loading' } else if (products && products?.length > 0) { @@ -119,7 +120,7 @@ const AddItemModal: FunctionComponent = ({
Date: Tue, 19 Sep 2023 16:54:20 -0700 Subject: [PATCH 3/4] add break line in product name + sku name --- apps/vtex-my-subscriptions-3/manifest.json | 4 +++- .../react/components/AddItemModal/Modal.tsx | 2 +- .../react/components/DetailsPage/Products/Listing.tsx | 2 +- .../vtex-my-subscriptions-3/react/components/SkuThumbnail.tsx | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/vtex-my-subscriptions-3/manifest.json b/apps/vtex-my-subscriptions-3/manifest.json index 0c614c0c..e30c731f 100644 --- a/apps/vtex-my-subscriptions-3/manifest.json +++ b/apps/vtex-my-subscriptions-3/manifest.json @@ -11,7 +11,9 @@ "store": "0.x" }, "mustUpdateAt": "2019-04-02", - "registries": ["smartcheckout"], + "registries": [ + "smartcheckout" + ], "scripts": { "postreleasy": "vtex publish --verbose" }, diff --git a/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx b/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx index 88d74170..cd358e76 100644 --- a/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx +++ b/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx @@ -120,7 +120,7 @@ const AddItemModal: FunctionComponent = ({
= ({ > = ({
{brandName}
-
{name}
+
{name.split('\n').map( (it, i) =>
{it}
)}
{`${unitMultiplier} ${measurementUnit}`}
From 8e5b3f23f778f43f5c65c9866b825170f21ac49d Mon Sep 17 00:00:00 2001 From: Vitor Hansen <64436563+v-hansen@users.noreply.github.com> Date: Tue, 19 Sep 2023 20:54:51 -0300 Subject: [PATCH 4/4] Update apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx Co-authored-by: Wagner Lemos Duarte --- .../react/components/AddItemModal/Modal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx b/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx index cd358e76..3d6dff2b 100644 --- a/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx +++ b/apps/vtex-my-subscriptions-3/react/components/AddItemModal/Modal.tsx @@ -72,7 +72,6 @@ const AddItemModal: FunctionComponent = ({ targetPlan, }) => { let state: State - console.log(`products`, products) if (loading) { state = 'loading' } else if (products && products?.length > 0) {