Add no warehouses info in variant creator

This commit is contained in:
Dawid Tarasiuk 2020-09-16 13:55:49 +02:00
parent 7e24e4a14f
commit 9e8f453c99
2 changed files with 196 additions and 178 deletions

View file

@ -302,6 +302,10 @@
"context": "variant stock, header", "context": "variant stock, header",
"string": "Stock" "string": "Stock"
}, },
"productVariantCreatorWarehouseSectionDescription": {
"context": "no warehouses info",
"string": "There are no warehouses set up for your store. You can configure your variants without providing stock quantites."
},
"productVariantCreatorWarehouseSectionHeader": { "productVariantCreatorWarehouseSectionHeader": {
"context": "header", "context": "header",
"string": "Warehouses" "string": "Warehouses"

View file

@ -123,6 +123,16 @@ const ProductVariantCreatorStock: React.FC<ProductVariantCreatorStockProps> = pr
})} })}
/> />
<CardContent> <CardContent>
{!warehouses.length ? (
<Typography color="textSecondary">
<FormattedMessage
defaultMessage="There are no warehouses set up for your store. You can configure your variants without providing stock quantites."
description="no warehouses info"
id="productVariantCreatorWarehouseSectionDescription"
/>
</Typography>
) : (
<>
{warehouses.length > 1 && ( {warehouses.length > 1 && (
<> <>
<Typography className={classes.warehouseHeader} variant="h5"> <Typography className={classes.warehouseHeader} variant="h5">
@ -185,8 +195,9 @@ const ProductVariantCreatorStock: React.FC<ProductVariantCreatorStockProps> = pr
<div key={warehouseId}> <div key={warehouseId}>
<Typography className={classes.warehouseName}> <Typography className={classes.warehouseName}>
{ {
warehouses.find(warehouse => warehouse.id === warehouseId) warehouses.find(
.name warehouse => warehouse.id === warehouseId
).name
} }
</Typography> </Typography>
<TextField <TextField
@ -271,7 +282,8 @@ const ProductVariantCreatorStock: React.FC<ProductVariantCreatorStockProps> = pr
})} })}
value={ value={
data.stock.values.find( data.stock.values.find(
value => value.slug === attributeValue.slug value =>
value.slug === attributeValue.slug
).value[warehouseIndex] ).value[warehouseIndex]
} }
onChange={event => onChange={event =>
@ -309,6 +321,8 @@ const ProductVariantCreatorStock: React.FC<ProductVariantCreatorStockProps> = pr
onChange={() => onApplyToAllChange("skip")} onChange={() => onApplyToAllChange("skip")}
/> />
</RadioGroup> </RadioGroup>
</>
)}
</CardContent> </CardContent>
</Card> </Card>
); );