Skip to content

Commit

Permalink
fix: shopping list update number limit
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Feb 22, 2024
1 parent bf04759 commit 15495b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ function ShoppingListDetails({ setOpenPage }: ShoppingListDetailsProps) {
node.productsSearch = productInfo || {}
node.productName = productInfo?.name || node.productName
node.productUrl = productInfo?.productUrl || node.productUrl

node.disableCurrentCheckbox = false
if (node.quantity === 0) {
node.disableCurrentCheckbox = true
}
})

return listProducts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface ProductInfoProps {
variantSku: string
productsSearch: CustomFieldItems
productNote: string
disableCurrentCheckbox?: boolean
}

interface ListItemProps {
Expand Down Expand Up @@ -185,6 +186,7 @@ function ShoppingDetailTable(
const [addNoteOpen, setAddNoteOpen] = useState<boolean>(false)
const [addNoteItemId, setAddNoteItemId] = useState<number | string>('')
const [notes, setNotes] = useState<string>('')
const [disabledSelectAll, setDisabledSelectAll] = useState<boolean>(false)

const [priceHidden, setPriceHidden] = useState<boolean>(false)

Expand Down Expand Up @@ -215,6 +217,8 @@ function ShoppingDetailTable(
const { node } = item
if (node?.id === id) {
node.quantity = `${+value}`
node.disableCurrentCheckbox = +value === 0
setDisabledSelectAll(+value === 0)
}

return item
Expand Down Expand Up @@ -410,6 +414,18 @@ function ShoppingDetailTable(
}
}, [shoppingListInfo])

useEffect(() => {
if (shoppingListInfo) {
const {
products: { edges },
} = shoppingListInfo
const nonNumberProducts = edges.filter(
(item: ListItemProps) => item.node.quantity === 0
)
setDisabledSelectAll(nonNumberProducts.length > 0)
}
}, [shoppingListInfo])

const showPrice = (price: string, row: CustomFieldItems): string | number => {
const {
productsSearch: { isPriceHidden },
Expand Down Expand Up @@ -737,10 +753,12 @@ function ShoppingDetailTable(
isCustomRender={false}
showCheckbox
showSelectAllCheckbox
applyAllDisableCheckbox={false}
disableCheckbox={
+role === 2
disabledSelectAll ||
(+role === 2
? !(allowJuniorPlaceOrder || productQuoteEnabled)
: isReadForApprove || isJuniorApprove
: isReadForApprove || isJuniorApprove)
// allowJuniorPlaceOrder
// ? !allowJuniorPlaceOrder
// : isReadForApprove || isJuniorApprove
Expand Down

0 comments on commit 15495b9

Please sign in to comment.