Filter out products with no variant

This commit is contained in:
dominik-zeglen 2020-10-27 09:55:06 +01:00
parent 1bfc13c8b5
commit a855a95246

View file

@ -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>