diff --git a/apps/storefront/src/components/B3ProductList.tsx b/apps/storefront/src/components/B3ProductList.tsx index 7b38990e..64f7fa69 100644 --- a/apps/storefront/src/components/B3ProductList.tsx +++ b/apps/storefront/src/components/B3ProductList.tsx @@ -173,10 +173,14 @@ export default function B3ProductList(props: ProductProps) { } } - const handleNumberInputBlur = (product: any) => () => { + const handleNumberInputBlur = (product: CustomFieldItems) => () => { if (!product[quantityKey]) { onProductQuantityChange(product.id, 1) } + + if (+product[quantityKey] > 1000000) { + onProductQuantityChange(product.id, 1000000) + } } const handleSelectAllChange = () => { diff --git a/apps/storefront/src/pages/quickorder/components/QuickAdd.tsx b/apps/storefront/src/pages/quickorder/components/QuickAdd.tsx index 9facd4c0..93d4dc1e 100644 --- a/apps/storefront/src/pages/quickorder/components/QuickAdd.tsx +++ b/apps/storefront/src/pages/quickorder/components/QuickAdd.tsx @@ -381,7 +381,7 @@ export default function QuickAdd(props: AddToListContentProps) { return ( - + 1000000) { + setQuantity(1000000) + } } const { diff --git a/apps/storefront/src/pages/shoppingListDetails/components/QuickAdd.tsx b/apps/storefront/src/pages/shoppingListDetails/components/QuickAdd.tsx index b654bb7d..0716a1e4 100644 --- a/apps/storefront/src/pages/shoppingListDetails/components/QuickAdd.tsx +++ b/apps/storefront/src/pages/shoppingListDetails/components/QuickAdd.tsx @@ -140,6 +140,7 @@ export default function QuickAdd(props: AddToListContentProps) { const productItems: CustomFieldItems[] = [] const passSku: string[] = [] const notAddAble: string[] = [] + const numberLimit: string[] = [] skus.forEach((sku) => { const variantInfo: CustomFieldItems | null = (variantInfoList || []).find( @@ -177,6 +178,11 @@ export default function QuickAdd(props: AddToListContentProps) { return } + if (+quantity < 1 || +quantity > 1000000) { + numberLimit.push(sku) + return + } + const optionList = (options || []).reduce( (arr: ShoppingListAddProductOption[], optionStr: string) => { try { @@ -230,6 +236,7 @@ export default function QuickAdd(props: AddToListContentProps) { productItems, passSku, notAddAble, + numberLimit, } } @@ -301,6 +308,7 @@ export default function QuickAdd(props: AddToListContentProps) { productItems, notAddAble, passSku, + numberLimit, } = getProductItems(variantInfoList, skuValue, skus) if (notFoundSku.length > 0) { @@ -327,6 +335,19 @@ export default function QuickAdd(props: AddToListContentProps) { }) } + if (numberLimit.length > 0) { + numberLimit.forEach((sku) => { + showErrors(value, [sku], 'qty', '') + }) + + snackbar.error( + `SKU ${numberLimit} add quantity is limited from 1 to 1,000,000`, + { + isClose: true, + } + ) + } + if (productItems.length > 0) { await quickAddToList(productItems) clearInputValue(value, passSku) @@ -347,7 +368,7 @@ export default function QuickAdd(props: AddToListContentProps) { return ( - + [ fieldType: 'number', default: '', allowArrow: true, + min: 1, + max: 1000000, }, ]