fix edit form on fetch data
This commit is contained in:
@ -111,7 +111,7 @@ const EditDialog = () => {
|
||||
name: response?.data.name,
|
||||
description: response?.data.description,
|
||||
status: response?.data.status,
|
||||
currency_id: response?.data.currency_id,
|
||||
currency_id: response?.data.id_currency,
|
||||
group: Array.isArray(response?.data.group)
|
||||
? response?.data.group.map((target: GroupProps) => target.id)
|
||||
: []
|
||||
@ -156,6 +156,8 @@ const EditDialog = () => {
|
||||
.map((g) => g.name)
|
||||
.join(', ');
|
||||
|
||||
const selectedCurrency = currencies.find((currency) => currency.ID === formField.currency_id);
|
||||
|
||||
useEffect(() => {
|
||||
getCurrencyLists([{ id: 'name', desc: false }]);
|
||||
getGroupLists([{ id: 'name', desc: false }]);
|
||||
@ -247,28 +249,14 @@ const EditDialog = () => {
|
||||
<div className="w-full">
|
||||
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label className="form-label flex items-center gap-1 max-w-56">Currency</label>
|
||||
<Select
|
||||
value={formField.currency_id}
|
||||
onValueChange={(value) => setFormField({ ...formField, currency_id: value })}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select Currency Type" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{currencies.map((currency) => (
|
||||
<SelectItem key={currency.ID} value={currency.ID}>
|
||||
{currency.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input type="text" placeholder='Empty' value={selectedCurrency?.name || ''} readOnly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="w-full">
|
||||
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label className="form-label flex items-center gap-1 max-w-56">Groups</label>
|
||||
<Input type="text" value={selectedGroupNames} readOnly />
|
||||
<Input type="text" placeholder='Empty' value={selectedGroupNames} readOnly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user