diff --git a/src/products/components/ProductStocks/ProductStocks.tsx b/src/products/components/ProductStocks/ProductStocks.tsx index b1564c0de..84a72acbd 100644 --- a/src/products/components/ProductStocks/ProductStocks.tsx +++ b/src/products/components/ProductStocks/ProductStocks.tsx @@ -268,7 +268,7 @@ const ProductStocks: React.FC = ({ {stock.label} - {stock.data.quantityAllocated} + {stock.data?.quantityAllocated || 0} { triggerChange(); stocks.add({ - data: null, + data: { + quantityAllocated: 0 + }, id, label: opts.warehouses.find(warehouse => warehouse.id === id).name, value: "0" @@ -317,7 +319,6 @@ function useProductUpdateForm( ...data, ...getStocksData(product, stocks.data), ...getMetadata(data, isMetadataModified, isPrivateMetadataModified), - addStocks: [], attributes: attributes.data, attributesWithNewFileValue: attributesWithNewFileValue.data, description: description.current diff --git a/src/products/components/ProductVariantCreatePage/form.tsx b/src/products/components/ProductVariantCreatePage/form.tsx index bad8c22a9..7e7b669ea 100644 --- a/src/products/components/ProductVariantCreatePage/form.tsx +++ b/src/products/components/ProductVariantCreatePage/form.tsx @@ -30,7 +30,7 @@ import { FetchMoreProps, ReorderEvent } from "@saleor/types"; import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger"; import React from "react"; -import { ProductStockInput } from "../ProductStocks"; +import { ProductStockFormsetData, ProductStockInput } from "../ProductStocks"; export interface ProductVariantCreateFormData extends MetadataFormData { sku: string; @@ -112,7 +112,7 @@ function useProductVariantCreateForm( const form = useForm(initial); const attributes = useFormset(attributeInput); const attributesWithNewFileValue = useFormset([]); - const stocks = useFormset([]); + const stocks = useFormset([]); const channels = useFormset(channelsInput); const { makeChangeHandler: makeMetadataChangeHandler @@ -163,7 +163,9 @@ function useProductVariantCreateForm( const handleStockAdd = (id: string) => { triggerChange(); stocks.add({ - data: null, + data: { + quantityAllocated: 0 + }, id, label: opts.warehouses.find(warehouse => warehouse.id === id).name, value: "0"