change create product

This commit is contained in:
hamid zarghami
2025-10-25 16:22:24 +03:30
parent f9122d2661
commit 40fb5a6c15
+8 -8
View File
@@ -9,8 +9,8 @@ import { CloseCircle } from 'iconsax-react';
interface AttributeSelectorProps {
attribute: CategoryAttributeType;
selectedValues: number[];
onChange: (attributeId: number, values: number[]) => void;
selectedValues: string[];
onChange: (attributeId: number, values: string[]) => void;
}
interface TextNumberInputProps {
@@ -20,7 +20,7 @@ interface TextNumberInputProps {
}
const AttributeSelector: FC<AttributeSelectorProps> = ({ attribute, selectedValues, onChange }) => {
const handleValueChange = (valueId: number, checked: boolean) => {
const handleValueChange = (valueId: string, checked: boolean) => {
if (attribute.multiple) {
// چند انتخابی - checkbox
const newValues = checked
@@ -46,7 +46,7 @@ const AttributeSelector: FC<AttributeSelectorProps> = ({ attribute, selectedValu
<div className="space-y-2">
{attribute.values.map((value) => {
const isChecked = selectedValues.includes(value._id);
const isChecked = selectedValues.includes(value.text);
return (
<label key={value._id} className="flex items-center space-x-2 cursor-pointer">
@@ -54,7 +54,7 @@ const AttributeSelector: FC<AttributeSelectorProps> = ({ attribute, selectedValu
type={attribute.multiple ? "checkbox" : "radio"}
name={`attribute-${attribute._id}`}
checked={isChecked}
onChange={(e) => handleValueChange(value._id, e.target.checked)}
onChange={(e) => handleValueChange(value.text, e.target.checked)}
className={`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2 ${attribute.multiple ? 'rounded' : 'rounded-full'
}`}
/>
@@ -126,7 +126,7 @@ interface Step2FormProps {
interface AttributeWithValue {
id: number;
values: number[] | string[];
values: string[];
}
// کامپوننت مدیریت تگ‌ها
@@ -270,7 +270,7 @@ const Step2Form: FC<Step2FormProps> = ({ onSubmit, loading, onPrevious, category
const { data: categoryAttributesData } = useGetCategoryAttributes(categoryId || '');
const handleAttributeChange = (attributeId: number, values: number[]) => {
const handleAttributeChange = (attributeId: number, values: string[]) => {
setFormData(prev => ({
...prev,
attributes: prev.attributes.filter(attr => attr.id !== attributeId).concat({
@@ -323,7 +323,7 @@ const Step2Form: FC<Step2FormProps> = ({ onSubmit, loading, onPrevious, category
<AttributeSelector
key={attribute._id}
attribute={attribute}
selectedValues={selectedValues as number[]}
selectedValues={selectedValues as string[]}
onChange={handleAttributeChange}
/>
);