Update ProductVariantName components "name" form field into "variantName" (#2903)

This commit is contained in:
İlkay Kısayol 2023-01-05 16:33:17 +03:00 committed by GitHub
parent fe709db82b
commit 3f94803c79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 11 deletions

View file

@ -131,6 +131,16 @@ const ProductStocks: React.FC<ProductStocksProps> = ({
} }
}; };
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
onFormDataChange(e);
onFormDataChange({
target: {
name: "variantName",
value: e.target.value,
},
});
};
return ( return (
<Card> <Card>
<CardTitle title={intl.formatMessage(messages.title)} /> <CardTitle title={intl.formatMessage(messages.title)} />
@ -143,7 +153,7 @@ const ProductStocks: React.FC<ProductStocksProps> = ({
helperText={getProductErrorMessage(formErrors.sku, intl)} helperText={getProductErrorMessage(formErrors.sku, intl)}
label={intl.formatMessage(messages.sku)} label={intl.formatMessage(messages.sku)}
name="sku" name="sku"
onChange={onFormDataChange} onChange={handleChange}
value={data.sku} value={data.sku}
/> />
</div> </div>

View file

@ -198,7 +198,7 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
</div> </div>
<div> <div>
<ProductVariantName <ProductVariantName
value={data.name} value={data.variantName}
onChange={change} onChange={change}
errors={errors} errors={errors}
/> />

View file

@ -68,7 +68,7 @@ export interface ProductVariantCreateFormData extends MetadataFormData {
hasPreorderEndDate: boolean; hasPreorderEndDate: boolean;
quantityLimitPerCustomer: number | null; quantityLimitPerCustomer: number | null;
preorderEndDateTime?: string; preorderEndDateTime?: string;
name: string; variantName: string;
} }
export interface ProductVariantCreateData extends ProductVariantCreateFormData { export interface ProductVariantCreateData extends ProductVariantCreateFormData {
attributes: AttributeInput[]; attributes: AttributeInput[];
@ -141,7 +141,7 @@ const initial: ProductVariantCreateFormData = {
hasPreorderEndDate: false, hasPreorderEndDate: false,
preorderEndDateTime: "", preorderEndDateTime: "",
quantityLimitPerCustomer: null, quantityLimitPerCustomer: null,
name: "", variantName: "",
}; };
function useProductVariantCreateForm( function useProductVariantCreateForm(

View file

@ -33,7 +33,7 @@ const ProductVariantName: React.FC<ProductVariantNameProps> = ({
/> />
<CardContent> <CardContent>
<TextField <TextField
name="name" name="variantName"
value={value} value={value}
label={intl.formatMessage(commonMessages.name)} label={intl.formatMessage(commonMessages.name)}
onChange={onChange} onChange={onChange}

View file

@ -260,7 +260,7 @@ const ProductVariantPage: React.FC<ProductVariantPageProps> = ({
</div> </div>
<div> <div>
<ProductVariantName <ProductVariantName
value={data.name} value={data.variantName}
onChange={change} onChange={change}
disabled={loading} disabled={loading}
errors={errors} errors={errors}

View file

@ -78,7 +78,7 @@ export interface ProductVariantUpdateFormData extends MetadataFormData {
quantityLimitPerCustomer: number | null; quantityLimitPerCustomer: number | null;
hasPreorderEndDate: boolean; hasPreorderEndDate: boolean;
preorderEndDateTime?: string; preorderEndDateTime?: string;
name: string; variantName: string;
media: string[]; media: string[];
} }
export interface ProductVariantUpdateData extends ProductVariantUpdateFormData { export interface ProductVariantUpdateData extends ProductVariantUpdateFormData {
@ -193,7 +193,7 @@ function useProductVariantUpdateForm(
preorderEndDateTime: variant?.preorder?.endDate, preorderEndDateTime: variant?.preorder?.endDate,
weight: variant?.weight?.value.toString() || "", weight: variant?.weight?.value.toString() || "",
quantityLimitPerCustomer: variant?.quantityLimitPerCustomer || null, quantityLimitPerCustomer: variant?.quantityLimitPerCustomer || null,
name: variant?.name ?? "", variantName: variant?.name ?? "",
media: variant?.media?.map(({ id }) => id) || [], media: variant?.media?.map(({ id }) => id) || [],
}; };

View file

@ -40,4 +40,4 @@ export const validateProductCreateData = (data: ProductCreateData) => {
export const validateVariantData = ( export const validateVariantData = (
data: ProductVariantCreateData | ProductVariantUpdateSubmitData, data: ProductVariantCreateData | ProductVariantUpdateSubmitData,
): ProductErrorWithAttributesFragment[] => ): ProductErrorWithAttributesFragment[] =>
!data.name ? [createEmptyRequiredError("name")] : []; !data.variantName ? [createEmptyRequiredError("variantName")] : [];

View file

@ -230,7 +230,7 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
: null, : null,
weight: weight(data.weight), weight: weight(data.weight),
firstValues: 10, firstValues: 10,
name: data.name, name: data.variantName,
}, },
}); });

View file

@ -124,7 +124,7 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
}), }),
product: productId, product: productId,
sku: formData.sku, sku: formData.sku,
name: formData.name, name: formData.variantName,
stocks: formData.stocks.map(stock => ({ stocks: formData.stocks.map(stock => ({
quantity: parseInt(stock.value, 10) || 0, quantity: parseInt(stock.value, 10) || 0,
warehouse: stock.id, warehouse: stock.id,