Fix display stock for simple products (#937)
This commit is contained in:
parent
c7081da8d0
commit
a9b3c6c53c
1 changed files with 5 additions and 3 deletions
|
@ -39,7 +39,7 @@ import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTr
|
||||||
import useRichText from "@saleor/utils/richText/useRichText";
|
import useRichText from "@saleor/utils/richText/useRichText";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { ProductStockInput } from "../ProductStocks";
|
import { ProductStockFormsetData, ProductStockInput } from "../ProductStocks";
|
||||||
|
|
||||||
export interface ProductCreateFormData extends MetadataFormData {
|
export interface ProductCreateFormData extends MetadataFormData {
|
||||||
category: string;
|
category: string;
|
||||||
|
@ -172,7 +172,7 @@ function useProductCreateForm(
|
||||||
: []
|
: []
|
||||||
);
|
);
|
||||||
const attributesWithNewFileValue = useFormset<null, File>([]);
|
const attributesWithNewFileValue = useFormset<null, File>([]);
|
||||||
const stocks = useFormset<null, string>([]);
|
const stocks = useFormset<ProductStockFormsetData>([]);
|
||||||
const [productType, setProductType] = useStateFromProps<ProductType>(
|
const [productType, setProductType] = useStateFromProps<ProductType>(
|
||||||
initialProductType || null
|
initialProductType || null
|
||||||
);
|
);
|
||||||
|
@ -229,7 +229,9 @@ function useProductCreateForm(
|
||||||
const handleStockAdd = (id: string) => {
|
const handleStockAdd = (id: string) => {
|
||||||
triggerChange();
|
triggerChange();
|
||||||
stocks.add({
|
stocks.add({
|
||||||
data: null,
|
data: {
|
||||||
|
quantityAllocated: 0
|
||||||
|
},
|
||||||
id,
|
id,
|
||||||
label: opts.warehouses.find(warehouse => warehouse.id === id).name,
|
label: opts.warehouses.find(warehouse => warehouse.id === id).name,
|
||||||
value: "0"
|
value: "0"
|
||||||
|
|
Loading…
Reference in a new issue