From 09d5d61058f86e78101352d317f60d4e4d83eff9 Mon Sep 17 00:00:00 2001 From: kris-liu-smile Date: Wed, 10 May 2023 21:27:44 +0800 Subject: [PATCH] fix: quickOrder fixed --- .../quickorder/components/QuickOrderFooter.tsx | 14 +++++++++++++- apps/storefront/src/pages/quote/QuoteDraft.tsx | 2 +- apps/storefront/src/utils/b3Product/b3Product.ts | 3 +-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx b/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx index d6b0cce9..b7723f2e 100644 --- a/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx +++ b/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx @@ -26,6 +26,7 @@ import { import { addProductToCart, createCart, getCartInfo } from '@/shared/service/bc' import { addQuoteDraftProduce, + calculateProductListPrice, currencyFormat, getProductPriceIncTax, snackbar, @@ -281,6 +282,8 @@ function QuickOrderFooter(props: QuickOrderFooterProps) { const newProductInfo: CustomFieldItems = conversionProductsList(productsSearch) let isSuccess = false + + const newProducts: CustomFieldItems[] = [] productsWithSku.forEach((product: ListItemProps) => { const { node: { @@ -321,10 +324,19 @@ function QuickOrderFooter(props: QuickOrderFooterProps) { }, } - addQuoteDraftProduce(quoteListitem, +quantity, optionsList || []) + newProducts.push(quoteListitem) + isSuccess = true }) + await calculateProductListPrice(newProducts, '2') + newProducts.forEach((product: CustomFieldItems) => { + addQuoteDraftProduce( + product, + product.node.quantity, + JSON.parse(product.node.optionList) || [] + ) + }) if (isSuccess) { snackbar.success('', { jsx: successTip({ diff --git a/apps/storefront/src/pages/quote/QuoteDraft.tsx b/apps/storefront/src/pages/quote/QuoteDraft.tsx index 6819f3b0..a9f1d897 100644 --- a/apps/storefront/src/pages/quote/QuoteDraft.tsx +++ b/apps/storefront/src/pages/quote/QuoteDraft.tsx @@ -450,7 +450,7 @@ function QuoteDraft({ setOpenPage }: QuoteDraftProps) { .map((item) => ({ optionId: item.optionId, optionValue: item.optionValue, - optionLabel: item.valueText, + optionLabel: `${item.valueText}`, optionName: item.valueLabel, })) .filter((list: CustomFieldItems) => !!list.optionName) || [] diff --git a/apps/storefront/src/utils/b3Product/b3Product.ts b/apps/storefront/src/utils/b3Product/b3Product.ts index 28de3a10..521d5884 100644 --- a/apps/storefront/src/utils/b3Product/b3Product.ts +++ b/apps/storefront/src/utils/b3Product/b3Product.ts @@ -683,7 +683,6 @@ const calculateProductListPrice = async ( let isError = false let i = 0 let itemsOptions: Partial[] | [] = [] - while (i < products.length && !isError) { let newSelectOptionList = [] let allOptions: Partial[] = [] @@ -717,7 +716,7 @@ const calculateProductListPrice = async ( i += 1 const variantItem = variants.find( - (item: Partial) => item.variant_id === variantId + (item: Partial) => item.variant_id === +variantId ) if (variantItem) {