Filter out products with no variant
This commit is contained in:
parent
1bfc13c8b5
commit
a855a95246
1 changed files with 8 additions and 5 deletions
|
@ -186,13 +186,16 @@ const OrderProductAddDialog: React.FC<OrderProductAddDialogProps> = props => {
|
||||||
onClose: () => setVariants([])
|
onClose: () => setVariants([])
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedVariantsToProductsMap = products
|
const productChoices = products.filter(
|
||||||
? products.map(product =>
|
product => product.variants?.length > 0
|
||||||
|
);
|
||||||
|
const selectedVariantsToProductsMap = productChoices
|
||||||
|
? productChoices.map(product =>
|
||||||
product.variants.map(variant => isVariantSelected(variant, variants))
|
product.variants.map(variant => isVariantSelected(variant, variants))
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
const productsWithAllVariantsSelected = products
|
const productsWithAllVariantsSelected = productChoices
|
||||||
? products.map(product =>
|
? productChoices.map(product =>
|
||||||
hasAllVariantsSelected(product.variants, variants)
|
hasAllVariantsSelected(product.variants, variants)
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
|
@ -248,7 +251,7 @@ const OrderProductAddDialog: React.FC<OrderProductAddDialogProps> = props => {
|
||||||
<ResponsiveTable key="table">
|
<ResponsiveTable key="table">
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{renderCollection(
|
{renderCollection(
|
||||||
products,
|
productChoices,
|
||||||
(product, productIndex) => (
|
(product, productIndex) => (
|
||||||
<React.Fragment key={product ? product.id : "skeleton"}>
|
<React.Fragment key={product ? product.id : "skeleton"}>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
Loading…
Reference in a new issue