Update ProductVariantName components "name" form field into "variantName" (#2903)
This commit is contained in:
parent
fe709db82b
commit
3f94803c79
9 changed files with 21 additions and 11 deletions
|
@ -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 (
|
||||
<Card>
|
||||
<CardTitle title={intl.formatMessage(messages.title)} />
|
||||
|
@ -143,7 +153,7 @@ const ProductStocks: React.FC<ProductStocksProps> = ({
|
|||
helperText={getProductErrorMessage(formErrors.sku, intl)}
|
||||
label={intl.formatMessage(messages.sku)}
|
||||
name="sku"
|
||||
onChange={onFormDataChange}
|
||||
onChange={handleChange}
|
||||
value={data.sku}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -198,7 +198,7 @@ const ProductVariantCreatePage: React.FC<ProductVariantCreatePageProps> = ({
|
|||
</div>
|
||||
<div>
|
||||
<ProductVariantName
|
||||
value={data.name}
|
||||
value={data.variantName}
|
||||
onChange={change}
|
||||
errors={errors}
|
||||
/>
|
||||
|
|
|
@ -68,7 +68,7 @@ export interface ProductVariantCreateFormData extends MetadataFormData {
|
|||
hasPreorderEndDate: boolean;
|
||||
quantityLimitPerCustomer: number | null;
|
||||
preorderEndDateTime?: string;
|
||||
name: string;
|
||||
variantName: string;
|
||||
}
|
||||
export interface ProductVariantCreateData extends ProductVariantCreateFormData {
|
||||
attributes: AttributeInput[];
|
||||
|
@ -141,7 +141,7 @@ const initial: ProductVariantCreateFormData = {
|
|||
hasPreorderEndDate: false,
|
||||
preorderEndDateTime: "",
|
||||
quantityLimitPerCustomer: null,
|
||||
name: "",
|
||||
variantName: "",
|
||||
};
|
||||
|
||||
function useProductVariantCreateForm(
|
||||
|
|
|
@ -33,7 +33,7 @@ const ProductVariantName: React.FC<ProductVariantNameProps> = ({
|
|||
/>
|
||||
<CardContent>
|
||||
<TextField
|
||||
name="name"
|
||||
name="variantName"
|
||||
value={value}
|
||||
label={intl.formatMessage(commonMessages.name)}
|
||||
onChange={onChange}
|
||||
|
|
|
@ -260,7 +260,7 @@ const ProductVariantPage: React.FC<ProductVariantPageProps> = ({
|
|||
</div>
|
||||
<div>
|
||||
<ProductVariantName
|
||||
value={data.name}
|
||||
value={data.variantName}
|
||||
onChange={change}
|
||||
disabled={loading}
|
||||
errors={errors}
|
||||
|
|
|
@ -78,7 +78,7 @@ export interface ProductVariantUpdateFormData extends MetadataFormData {
|
|||
quantityLimitPerCustomer: number | null;
|
||||
hasPreorderEndDate: boolean;
|
||||
preorderEndDateTime?: string;
|
||||
name: string;
|
||||
variantName: string;
|
||||
media: string[];
|
||||
}
|
||||
export interface ProductVariantUpdateData extends ProductVariantUpdateFormData {
|
||||
|
@ -193,7 +193,7 @@ function useProductVariantUpdateForm(
|
|||
preorderEndDateTime: variant?.preorder?.endDate,
|
||||
weight: variant?.weight?.value.toString() || "",
|
||||
quantityLimitPerCustomer: variant?.quantityLimitPerCustomer || null,
|
||||
name: variant?.name ?? "",
|
||||
variantName: variant?.name ?? "",
|
||||
media: variant?.media?.map(({ id }) => id) || [],
|
||||
};
|
||||
|
||||
|
|
|
@ -40,4 +40,4 @@ export const validateProductCreateData = (data: ProductCreateData) => {
|
|||
export const validateVariantData = (
|
||||
data: ProductVariantCreateData | ProductVariantUpdateSubmitData,
|
||||
): ProductErrorWithAttributesFragment[] =>
|
||||
!data.name ? [createEmptyRequiredError("name")] : [];
|
||||
!data.variantName ? [createEmptyRequiredError("variantName")] : [];
|
||||
|
|
|
@ -230,7 +230,7 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
|||
: null,
|
||||
weight: weight(data.weight),
|
||||
firstValues: 10,
|
||||
name: data.name,
|
||||
name: data.variantName,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ export const ProductVariant: React.FC<ProductVariantCreateProps> = ({
|
|||
}),
|
||||
product: productId,
|
||||
sku: formData.sku,
|
||||
name: formData.name,
|
||||
name: formData.variantName,
|
||||
stocks: formData.stocks.map(stock => ({
|
||||
quantity: parseInt(stock.value, 10) || 0,
|
||||
warehouse: stock.id,
|
||||
|
|
Loading…
Reference in a new issue