Fix issues with stocks (#954)
This commit is contained in:
parent
77ed12664d
commit
37bb52d087
3 changed files with 9 additions and 6 deletions
|
@ -268,7 +268,7 @@ const ProductStocks: React.FC<ProductStocksProps> = ({
|
||||||
{stock.label}
|
{stock.label}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.colQuantity}>
|
<TableCell className={classes.colQuantity}>
|
||||||
{stock.data.quantityAllocated}
|
{stock.data?.quantityAllocated || 0}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className={classes.colQuantity}>
|
<TableCell className={classes.colQuantity}>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
|
@ -274,7 +274,9 @@ function useProductUpdateForm(
|
||||||
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"
|
||||||
|
@ -317,7 +319,6 @@ function useProductUpdateForm(
|
||||||
...data,
|
...data,
|
||||||
...getStocksData(product, stocks.data),
|
...getStocksData(product, stocks.data),
|
||||||
...getMetadata(data, isMetadataModified, isPrivateMetadataModified),
|
...getMetadata(data, isMetadataModified, isPrivateMetadataModified),
|
||||||
addStocks: [],
|
|
||||||
attributes: attributes.data,
|
attributes: attributes.data,
|
||||||
attributesWithNewFileValue: attributesWithNewFileValue.data,
|
attributesWithNewFileValue: attributesWithNewFileValue.data,
|
||||||
description: description.current
|
description: description.current
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { FetchMoreProps, ReorderEvent } from "@saleor/types";
|
||||||
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { ProductStockInput } from "../ProductStocks";
|
import { ProductStockFormsetData, ProductStockInput } from "../ProductStocks";
|
||||||
|
|
||||||
export interface ProductVariantCreateFormData extends MetadataFormData {
|
export interface ProductVariantCreateFormData extends MetadataFormData {
|
||||||
sku: string;
|
sku: string;
|
||||||
|
@ -112,7 +112,7 @@ function useProductVariantCreateForm(
|
||||||
const form = useForm(initial);
|
const form = useForm(initial);
|
||||||
const attributes = useFormset(attributeInput);
|
const attributes = useFormset(attributeInput);
|
||||||
const attributesWithNewFileValue = useFormset<null, File>([]);
|
const attributesWithNewFileValue = useFormset<null, File>([]);
|
||||||
const stocks = useFormset<null, string>([]);
|
const stocks = useFormset<ProductStockFormsetData, string>([]);
|
||||||
const channels = useFormset(channelsInput);
|
const channels = useFormset(channelsInput);
|
||||||
const {
|
const {
|
||||||
makeChangeHandler: makeMetadataChangeHandler
|
makeChangeHandler: makeMetadataChangeHandler
|
||||||
|
@ -163,7 +163,9 @@ function useProductVariantCreateForm(
|
||||||
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