Skip to content

Commit

Permalink
Refactor: Add validation for item quantity in the editItemQuantity fu…
Browse files Browse the repository at this point in the history
…nc of ListItemCheckBox component
  • Loading branch information
RossaMania committed Sep 28, 2024
1 parent f5f9ee6 commit eb19b32
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export function ListItemCheckBox({ item, listPath }: Props) {
const editItemQuantity = async (quantity: number) => {
console.log("Item quantity edited:", quantity);

if (quantity < 1) {
toast.error("Oops! Quantity must be at least 1!");
return;
}

try {
await toast.promise(updateItemQuantity(listPath, item, quantity), {
loading: `Updating ${item.name} quantity!`,
Expand Down

0 comments on commit eb19b32

Please sign in to comment.