diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreator.stories.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreator.stories.tsx index 71416b3ff..2c903f43d 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreator.stories.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreator.stories.tsx @@ -73,7 +73,7 @@ const data: ProductVariantCreateFormData = { warehouses: selectedWarehouses.map(warehouse => warehouse.id) }; const props: ProductVariantCreatorContentProps = { - attributes, + attributes: [0, 1, 4, 6].map(index => attributes[index]), currencySymbol: "USD", data: { ...data, diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx index 0f23cab7d..a59e42cec 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx @@ -76,15 +76,21 @@ const ProductVariantCreatorContent: React.FC : ProductVariantCreateReducerActionType.applyStockToAll }) } - onApplyToAllPriceOrStockChange={(value, type) => + onApplyToAllPriceChange={price => dispatchFormDataAction({ changeApplyPriceToAllValue: { - price: value + price }, - type: - type === "price" - ? ProductVariantCreateReducerActionType.applyPriceToAll - : ProductVariantCreateReducerActionType.applyStockToAll + type: ProductVariantCreateReducerActionType.applyPriceToAll + }) + } + onApplyToAllStockChange={(warehouseIndex, quantity) => + dispatchFormDataAction({ + changeApplyStockToAllValue: { + quantity: parseInt(quantity, 10), + warehouseIndex + }, + type: ProductVariantCreateReducerActionType.applyStockToAll }) } onAttributeSelect={(attributeId, type) => diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPriceAndSku.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPriceAndSku.tsx index 8e4e350ee..a70bf1332 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPriceAndSku.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPriceAndSku.tsx @@ -20,7 +20,8 @@ export interface ProductVariantCreatorPriceAndSkuProps { value: VariantCreatorPricesAndSkuMode, type: PriceOrStock ) => void; - onApplyToAllPriceOrStockChange: (value: string, type: PriceOrStock) => void; + onApplyToAllPriceChange: (value: string) => void; + onApplyToAllStockChange: (warehouseIndex: number, value: string) => void; onAttributeSelect: (id: string, type: PriceOrStock) => void; onAttributeValueChange: ( id: string, @@ -35,8 +36,9 @@ const ProductVariantCreatorPriceAndSku: React.FC onApplyToAllChange(value, "price")} - onApplyToAllPriceChange={value => - onApplyToAllPriceOrStockChange(value, "price") - } + onApplyToAllPriceChange={onApplyToAllPriceChange} onAttributeSelect={id => onAttributeSelect(id, "price")} onAttributeValueChange={(id, value) => onAttributeValueChange(id, value, "price") @@ -61,9 +61,7 @@ const ProductVariantCreatorPriceAndSku: React.FC onApplyToAllChange(value, "stock")} - onApplyToAllStockChange={value => - onApplyToAllPriceOrStockChange(value, "stock") - } + onApplyToAllStockChange={onApplyToAllStockChange} onAttributeSelect={id => onAttributeSelect(id, "stock")} onAttributeValueChange={(id, value) => onAttributeValueChange(id, value, "stock") diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorStock.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorStock.tsx index 8ce48200a..1c9768f39 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorStock.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorStock.tsx @@ -18,7 +18,7 @@ import CardTitle from "@saleor/components/CardTitle"; import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import CardSpacer from "@saleor/components/CardSpacer"; import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; -import { isSelected, toggle } from "@saleor/utils/lists"; +import { isSelected } from "@saleor/utils/lists"; import { ProductVariantCreateFormData, VariantCreatorPricesAndSkuMode @@ -73,7 +73,7 @@ export interface ProductVariantCreatorStockProps { data: ProductVariantCreateFormData; warehouses: WarehouseFragment[]; onApplyToAllChange: (mode: VariantCreatorPricesAndSkuMode) => void; - onApplyToAllStockChange: (value: string) => void; + onApplyToAllStockChange: (warehouseIndex: number, value: string) => void; onAttributeSelect: (id: string) => void; onAttributeValueChange: (id: string, value: string) => void; onWarehouseToggle: (id: string) => void; @@ -190,7 +190,10 @@ const ProductVariantCreatorStock: React.FC = pr })} value={data.stock.value[warehouseIndex]} onChange={event => - onApplyToAllStockChange(event.target.value) + onApplyToAllStockChange( + warehouseIndex, + event.target.value + ) } />