fix values

This commit is contained in:
hamid zarghami
2025-10-22 13:18:48 +03:30
parent f2a92d87de
commit dcdb09b147
@@ -95,47 +95,46 @@ const AttributesModal: FC<AttributesModalProps> = ({
/>
</div>
{newAttribute.type === 'select' && (
<div className="space-y-3">
<label className="text-sm font-medium">مقادیر قابل انتخاب</label>
<div className="flex gap-2 items-center">
<Input
placeholder="مقدار جدید اضافه کنید"
value={newValue}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNewValue(e.target.value)}
onKeyPress={(e) => e.key === 'Enter' && handleAddValue()}
/>
<Button
onClick={handleAddValue}
variant="outline"
// size="sm"
disabled={!newValue.trim()}
className='w-fit mt-1'
>
<Add size={16} color='#000' />
</Button>
</div>
{newAttribute.values.length > 0 && (
<div className="space-y-2 flex gap-3 items-center flex-wrap max-h-32 overflow-y-auto">
{newAttribute.values.map((value, index) => (
<div key={index} className="flex min-w-[30%] flex-1 items-center justify-between bg-gray-50 p-2 rounded">
<div className="text-sm">{value.text}</div>
<Button
variant="ghost"
size="sm"
onClick={() => onRemoveValue(index)}
className="text-red-500 w-fit hover:text-red-700"
>
<Trash color='red' size={20} />
</Button>
</div>
))}
<div className='min-w-[30%] flex-1 px-2'></div>
<div className='min-w-[30%] flex-1 px-2'></div>
</div>
)}
<div className="space-y-3">
<label className="text-sm font-medium">
مقادیر قابل انتخاب {newAttribute.type === 'select' ? '(اجباری)' : '(اختیاری)'}
</label>
<div className="flex gap-2 items-center">
<Input
placeholder="مقدار جدید اضافه کنید"
value={newValue}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setNewValue(e.target.value)}
onKeyPress={(e) => e.key === 'Enter' && handleAddValue()}
/>
<Button
onClick={handleAddValue}
variant="outline"
disabled={!newValue.trim()}
className='w-fit mt-1'
>
<Add size={16} color='#000' />
</Button>
</div>
)}
{newAttribute.values.length > 0 && (
<div className="space-y-2 flex gap-3 items-center flex-wrap max-h-32 overflow-y-auto">
{newAttribute.values.map((value, index) => (
<div key={index} className="flex min-w-[30%] flex-1 items-center justify-between bg-gray-50 p-2 rounded">
<div className="text-sm">{value.text}</div>
<Button
variant="ghost"
size="sm"
onClick={() => onRemoveValue(index)}
className="text-red-500 w-fit hover:text-red-700"
>
<Trash color='red' size={20} />
</Button>
</div>
))}
<div className='min-w-[30%] flex-1 px-2'></div>
<div className='min-w-[30%] flex-1 px-2'></div>
</div>
)}
</div>
<div className="flex gap-3 pt-4 border-t border-border">
<Button