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