Skip to content

Commit

Permalink
fix: quickOrder fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-liu-smile committed May 10, 2023
1 parent 35aa30d commit 09d5d61
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import { addProductToCart, createCart, getCartInfo } from '@/shared/service/bc'
import {
addQuoteDraftProduce,
calculateProductListPrice,
currencyFormat,
getProductPriceIncTax,
snackbar,
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/pages/quote/QuoteDraft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) || []
Expand Down
3 changes: 1 addition & 2 deletions apps/storefront/src/utils/b3Product/b3Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,6 @@ const calculateProductListPrice = async (
let isError = false
let i = 0
let itemsOptions: Partial<Calculateditems>[] | [] = []

while (i < products.length && !isError) {
let newSelectOptionList = []
let allOptions: Partial<AllOptionProps>[] = []
Expand Down Expand Up @@ -717,7 +716,7 @@ const calculateProductListPrice = async (
i += 1

const variantItem = variants.find(
(item: Partial<Variant>) => item.variant_id === variantId
(item: Partial<Variant>) => item.variant_id === +variantId
)

if (variantItem) {
Expand Down

0 comments on commit 09d5d61

Please sign in to comment.