remove advantages + disadvantages
This commit is contained in:
@@ -116,7 +116,7 @@ const VariantModal: FC<VariantModalProps> = ({
|
|||||||
title_header={getModalTitle()}
|
title_header={getModalTitle()}
|
||||||
width={500}
|
width={500}
|
||||||
>
|
>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6 w-[400px]">
|
||||||
{renderFormContent()}
|
{renderFormContent()}
|
||||||
|
|
||||||
<div className="flex gap-3 pt-4 border-t border-border">
|
<div className="flex gap-3 pt-4 border-t border-border">
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ const CreateVariant: FC = () => {
|
|||||||
sellerSpecialCode: Yup.string(),
|
sellerSpecialCode: Yup.string(),
|
||||||
retail_price: Yup.number().required('قیمت فروش الزامی است').min(0, 'قیمت نمیتواند منفی باشد'),
|
retail_price: Yup.number().required('قیمت فروش الزامی است').min(0, 'قیمت نمیتواند منفی باشد'),
|
||||||
package_weight: Yup.number().required('وزن بسته الزامی است').min(0.1, 'وزن باید حداقل ۰.۱ کیلوگرم باشد'),
|
package_weight: Yup.number().required('وزن بسته الزامی است').min(0.1, 'وزن باید حداقل ۰.۱ کیلوگرم باشد'),
|
||||||
package_height: Yup.number().required('ارتفاع بسته الزامی است').min(1, 'ارتفاع باید حداقل ۱ سانتیمتر باشد'),
|
// package_height: Yup.number().required('ارتفاع بسته الزامی است').min(1, 'ارتفاع باید حداقل ۱ سانتیمتر باشد'),
|
||||||
package_length: Yup.number().required('طول بسته الزامی است').min(1, 'طول باید حداقل ۱ سانتیمتر باشد'),
|
// package_length: Yup.number().required('طول بسته الزامی است').min(1, 'طول باید حداقل ۱ سانتیمتر باشد'),
|
||||||
package_width: Yup.number().required('عرض بسته الزامی است').min(1, 'عرض باید حداقل ۱ سانتیمتر باشد'),
|
// package_width: Yup.number().required('عرض بسته الزامی است').min(1, 'عرض باید حداقل ۱ سانتیمتر باشد'),
|
||||||
postingTime: Yup.number().required('زمان ارسال الزامی است').min(1, 'زمان ارسال باید حداقل ۱ روز باشد'),
|
postingTime: Yup.number().required('زمان ارسال الزامی است').min(1, 'زمان ارسال باید حداقل ۱ روز باشد'),
|
||||||
stock: Yup.number().required('موجودی انبار الزامی است').min(0, 'موجودی نمیتواند منفی باشد'),
|
stock: Yup.number().required('موجودی انبار الزامی است').min(0, 'موجودی نمیتواند منفی باشد'),
|
||||||
specialSale_order_limit: Yup.number().min(0, 'محدودیت فروش ویژه نمیتواند منفی باشد'),
|
specialSale_order_limit: Yup.number().min(0, 'محدودیت فروش ویژه نمیتواند منفی باشد'),
|
||||||
@@ -65,9 +65,9 @@ const CreateVariant: FC = () => {
|
|||||||
sellerSpecialCode: '' as string | undefined,
|
sellerSpecialCode: '' as string | undefined,
|
||||||
retail_price: '',
|
retail_price: '',
|
||||||
package_weight: '',
|
package_weight: '',
|
||||||
package_height: '',
|
// package_height: '',
|
||||||
package_length: '',
|
// package_length: '',
|
||||||
package_width: '',
|
// package_width: '',
|
||||||
postingTime: '',
|
postingTime: '',
|
||||||
stock: '',
|
stock: '',
|
||||||
specialSale_order_limit: '',
|
specialSale_order_limit: '',
|
||||||
@@ -121,9 +121,9 @@ const CreateVariant: FC = () => {
|
|||||||
sellerSpecialCode: values.sellerSpecialCode,
|
sellerSpecialCode: values.sellerSpecialCode,
|
||||||
retail_price: parseFloat(values.retail_price),
|
retail_price: parseFloat(values.retail_price),
|
||||||
package_weight: parseFloat(values.package_weight),
|
package_weight: parseFloat(values.package_weight),
|
||||||
package_height: parseFloat(values.package_height),
|
package_height: 10, // مقدار پیشفرض
|
||||||
package_length: parseFloat(values.package_length),
|
package_length: 10, // مقدار پیشفرض
|
||||||
package_width: parseFloat(values.package_width),
|
package_width: 10, // مقدار پیشفرض
|
||||||
postingTime: parseInt(values.postingTime),
|
postingTime: parseInt(values.postingTime),
|
||||||
stock: parseInt(values.stock)
|
stock: parseInt(values.stock)
|
||||||
}
|
}
|
||||||
@@ -318,7 +318,7 @@ const CreateVariant: FC = () => {
|
|||||||
<ErrorMessage name="package_weight" component="div" className="text-red-500 text-sm mt-1" />
|
<ErrorMessage name="package_weight" component="div" className="text-red-500 text-sm mt-1" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
{/* <div>
|
||||||
<Field name="package_height">
|
<Field name="package_height">
|
||||||
{({ field }: FormikFieldProps) => (
|
{({ field }: FormikFieldProps) => (
|
||||||
<Input
|
<Input
|
||||||
@@ -364,7 +364,7 @@ const CreateVariant: FC = () => {
|
|||||||
)}
|
)}
|
||||||
</Field>
|
</Field>
|
||||||
<ErrorMessage name="package_width" component="div" className="text-red-500 text-sm mt-1" />
|
<ErrorMessage name="package_width" component="div" className="text-red-500 text-sm mt-1" />
|
||||||
</div>
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -189,76 +189,76 @@ const TagInput: FC<TagInputProps> = ({ tags, onChange, placeholder }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// کامپوننت مدیریت لیست مزایا/معایب
|
// کامپوننت مدیریت لیست مزایا/معایب
|
||||||
interface ListInputProps {
|
// interface ListInputProps {
|
||||||
items: string[];
|
// items: string[];
|
||||||
onChange: (items: string[]) => void;
|
// onChange: (items: string[]) => void;
|
||||||
placeholder?: string;
|
// placeholder?: string;
|
||||||
label: string;
|
// label: string;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const ListInput: FC<ListInputProps> = ({ items, onChange, placeholder, label }) => {
|
// const ListInput: FC<ListInputProps> = ({ items, onChange, placeholder, label }) => {
|
||||||
const [inputValue, setInputValue] = useState('');
|
// const [inputValue, setInputValue] = useState('');
|
||||||
|
|
||||||
const addItem = () => {
|
// const addItem = () => {
|
||||||
const newItem = inputValue.trim();
|
// const newItem = inputValue.trim();
|
||||||
if (newItem && !items.includes(newItem)) {
|
// if (newItem && !items.includes(newItem)) {
|
||||||
onChange([...items, newItem]);
|
// onChange([...items, newItem]);
|
||||||
setInputValue('');
|
// setInputValue('');
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
const removeItem = (itemToRemove: string) => {
|
// const removeItem = (itemToRemove: string) => {
|
||||||
onChange(items.filter(item => item !== itemToRemove));
|
// onChange(items.filter(item => item !== itemToRemove));
|
||||||
};
|
// };
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
// const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
if (e.key === 'Enter') {
|
// if (e.key === 'Enter') {
|
||||||
e.preventDefault();
|
// e.preventDefault();
|
||||||
addItem();
|
// addItem();
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
return (
|
// return (
|
||||||
<div className="space-y-3">
|
// <div className="space-y-3">
|
||||||
<label className="block text-sm font-medium text-gray-700">{label}</label>
|
// <label className="block text-sm font-medium text-gray-700">{label}</label>
|
||||||
<div className="flex gap-2">
|
// <div className="flex gap-2">
|
||||||
<Input
|
// <Input
|
||||||
value={inputValue}
|
// value={inputValue}
|
||||||
onChange={(e) => setInputValue(e.target.value)}
|
// onChange={(e) => setInputValue(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
// onKeyDown={handleKeyDown}
|
||||||
placeholder={placeholder}
|
// placeholder={placeholder}
|
||||||
className="flex-1"
|
// className="flex-1"
|
||||||
/>
|
// />
|
||||||
<Button
|
// <Button
|
||||||
type="button"
|
// type="button"
|
||||||
onClick={addItem}
|
// onClick={addItem}
|
||||||
disabled={!inputValue.trim()}
|
// disabled={!inputValue.trim()}
|
||||||
className="px-4 w-fit"
|
// className="px-4 w-fit"
|
||||||
>
|
// >
|
||||||
افزودن
|
// افزودن
|
||||||
</Button>
|
// </Button>
|
||||||
</div>
|
// </div>
|
||||||
{items.length > 0 && (
|
// {items.length > 0 && (
|
||||||
<div className="space-y-2 flex flex-wrap gap-3 max-h-40 overflow-y-auto">
|
// <div className="space-y-2 flex flex-wrap gap-3 max-h-40 overflow-y-auto">
|
||||||
{items.map((item, index) => (
|
// {items.map((item, index) => (
|
||||||
<div key={index} className="flex min-w-[30%] flex-1 h-10 items-center justify-between p-2 bg-gray-50 rounded-md">
|
// <div key={index} className="flex min-w-[30%] flex-1 h-10 items-center justify-between p-2 bg-gray-50 rounded-md">
|
||||||
<span className="text-sm text-gray-700">{item}</span>
|
// <span className="text-sm text-gray-700">{item}</span>
|
||||||
<button
|
// <button
|
||||||
type="button"
|
// type="button"
|
||||||
onClick={() => removeItem(item)}
|
// onClick={() => removeItem(item)}
|
||||||
className="text-red-500 hover:text-red-700 p-1"
|
// className="text-red-500 hover:text-red-700 p-1"
|
||||||
>
|
// >
|
||||||
<CloseCircle size={16} color='red' />
|
// <CloseCircle size={16} color='red' />
|
||||||
</button>
|
// </button>
|
||||||
</div>
|
// </div>
|
||||||
))}
|
// ))}
|
||||||
<div className='min-w-[30%] flex-1 px-2'></div>
|
// <div className='min-w-[30%] flex-1 px-2'></div>
|
||||||
<div className='min-w-[30%] flex-1 px-2'></div>
|
// <div className='min-w-[30%] flex-1 px-2'></div>
|
||||||
</div>
|
// </div>
|
||||||
)}
|
// )}
|
||||||
</div>
|
// </div>
|
||||||
);
|
// );
|
||||||
};
|
// };
|
||||||
|
|
||||||
const Step2Form: FC<Step2FormProps> = ({ onSubmit, loading, onPrevious, categoryId, initialData, specifications }) => {
|
const Step2Form: FC<Step2FormProps> = ({ onSubmit, loading, onPrevious, categoryId, initialData, specifications }) => {
|
||||||
const [formData, setFormData] = useState<Omit<CreateProductAttributeRequestType, 'productId'>>(() => ({
|
const [formData, setFormData] = useState<Omit<CreateProductAttributeRequestType, 'productId'>>(() => ({
|
||||||
@@ -266,8 +266,10 @@ const Step2Form: FC<Step2FormProps> = ({ onSubmit, loading, onPrevious, category
|
|||||||
description: initialData?.description || '',
|
description: initialData?.description || '',
|
||||||
metaDescription: initialData?.metaDescription || '',
|
metaDescription: initialData?.metaDescription || '',
|
||||||
tags: initialData?.tags || [],
|
tags: initialData?.tags || [],
|
||||||
advantages: initialData?.advantages || [],
|
// advantages: initialData?.advantages || [],
|
||||||
disAdvantages: initialData?.disAdvantages || []
|
// disAdvantages: initialData?.disAdvantages || []
|
||||||
|
advantages: [],
|
||||||
|
disAdvantages: []
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { data: categoryAttributesData } = useGetCategoryAttributes(categoryId || '');
|
const { data: categoryAttributesData } = useGetCategoryAttributes(categoryId || '');
|
||||||
@@ -403,7 +405,7 @@ const Step2Form: FC<Step2FormProps> = ({ onSubmit, loading, onPrevious, category
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ListInput
|
{/* <ListInput
|
||||||
label="مزایا"
|
label="مزایا"
|
||||||
items={formData.advantages}
|
items={formData.advantages}
|
||||||
onChange={(advantages) => setFormData(prev => ({ ...prev, advantages }))}
|
onChange={(advantages) => setFormData(prev => ({ ...prev, advantages }))}
|
||||||
@@ -415,7 +417,7 @@ const Step2Form: FC<Step2FormProps> = ({ onSubmit, loading, onPrevious, category
|
|||||||
items={formData.disAdvantages}
|
items={formData.disAdvantages}
|
||||||
onChange={(disAdvantages) => setFormData(prev => ({ ...prev, disAdvantages }))}
|
onChange={(disAdvantages) => setFormData(prev => ({ ...prev, disAdvantages }))}
|
||||||
placeholder="عیبی را وارد کنید..."
|
placeholder="عیبی را وارد کنید..."
|
||||||
/>
|
/> */}
|
||||||
|
|
||||||
<div className="flex gap-2 justify-between">
|
<div className="flex gap-2 justify-between">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -274,9 +274,9 @@ export type CreateProductVariantRequestType = {
|
|||||||
sellerSpecialCode?: string;
|
sellerSpecialCode?: string;
|
||||||
retail_price: number;
|
retail_price: number;
|
||||||
package_weight: number;
|
package_weight: number;
|
||||||
package_height: number;
|
package_height?: number;
|
||||||
package_length: number;
|
package_length?: number;
|
||||||
package_width: number;
|
package_width?: number;
|
||||||
postingTime: number;
|
postingTime: number;
|
||||||
stock: number;
|
stock: number;
|
||||||
specialSale_order_limit?: number;
|
specialSale_order_limit?: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user