Skip to content

Commit

Permalink
fix: stock problem
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-liu-smile committed Jan 3, 2023
1 parent beabab3 commit 88f8d6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export const ReAddToCart = (props: ShoppingProductsProps) => {
}

const handleClearNoStock = () => {
const newProduct = products.filter((item: ProductsProps) => item.stock !== 0)
const newProduct = products.filter((item: ProductsProps) => item.isStock === '0' || item.stock !== 0)
setValidateFailureProducts(newProduct)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,32 @@ const ShoppingDetailFooter = (props: ShoppingDetailFooterProps) => {
const verifyInventory = (inventoryInfos: ProductsProps[]) => {
const validateFailureArr: ProductsProps[] = []
const validateSuccessArr: ProductsProps[] = []

checkedArr.forEach((item: ProductsProps) => {
const {
node,
} = item

inventoryInfos.forEach((option: CustomFieldItems) => {
if (node.variantSku === option.variantSku) {
const isPassVerify = +node.quantity <= option.stock && +node.quantity >= option.minQuantity && +node.quantity <= option.maxQuantity
let isPassVerify = true
if (option.isStock === '1' && +node.quantity > option.stock) isPassVerify = false

if (option.minQuantity !== 0 && +node.quantity < option.minQuantity) isPassVerify = false

if (option.maxQuantity !== 0 && +node.quantity > option.maxQuantity) isPassVerify = false

if (isPassVerify) {
validateSuccessArr.push({
node,
})
} else {
validateFailureArr.push({
node,
node: {
...node,
},
stock: option.stock,
isStock: option.isStock,
maxQuantity: option.maxQuantity,
minQuantity: option.minQuantity,
})
Expand Down

0 comments on commit 88f8d6e

Please sign in to comment.