Skip to content

Commit

Permalink
fix: quick order page search to cart
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed May 18, 2023
1 parent c37dfaf commit df3e4f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
22 changes: 12 additions & 10 deletions apps/storefront/src/pages/quickorder/components/QuickOrderPad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ export default function QuickOrderPad(props: QuickOrderPadProps) {
const quickAddToList = async (products: CustomFieldItems[]) => {
const lineItems = products.map((product) => {
const { newSelectOptionList, quantity } = product
const optionList = newSelectOptionList.map((option: any) => {
const splitOptionId = handleSplitOptionId(option.optionId)
const optionSelections = newSelectOptionList.map(
(option: CustomFieldItems) => {
const splitOptionId = handleSplitOptionId(option.optionId)

return {
optionId: splitOptionId,
optionValue: option.optionValue,
return {
optionId: splitOptionId,
optionValue: option.optionValue,
}
}
})
)

return {
optionList,
productId: parseInt(product.productId, 10) || 0,
optionSelections,
productId: parseInt(product.productId || product.id, 10) || 0,
quantity,
variantId: parseInt(product.variantId, 10) || 0,
}
Expand Down Expand Up @@ -206,7 +208,7 @@ export default function QuickOrderPad(props: QuickOrderPadProps) {
productId: parseInt(productId, 10) || 0,
variantId: parseInt(variantId, 10) || 0,
quantity: +qty,
optionList: optionsList,
optionSelections: optionsList,
})
})

Expand Down Expand Up @@ -390,7 +392,7 @@ export default function QuickOrderPad(props: QuickOrderPadProps) {
const isPassVerify = handleVerifyProduct(currentProduct)
try {
if (isPassVerify) {
quickAddToList(productData)
await quickAddToList(productData)
}
} catch (error) {
console.error(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ export default function SearchProduct({
try {
setIsLoading(true)
await calculateProductListPrice(products)
handleAddToListClick(products)
await handleAddToListClick(products)
setChooseOptionsOpen(false)
setProductListOpen(true)
setIsLoading(false)
} catch (error) {
setIsLoading(false)
} finally {
setIsLoading(false)
}
}

Expand Down

0 comments on commit df3e4f9

Please sign in to comment.