This commit is contained in:
yaschalew
2026-06-18 12:38:15 +03:00
parent 4b46c44147
commit 96ad7bd152

View File

@@ -12,6 +12,7 @@ import {
Textarea, Textarea,
TextInput, TextInput,
} from "@mantine/core"; } from "@mantine/core";
import { DateInput } from "@mantine/dates";
import { FLEET_SELECT_NONE, type FleetFormFieldDef } from "@/pages/fleet/config/resources"; import { FLEET_SELECT_NONE, type FleetFormFieldDef } from "@/pages/fleet/config/resources";
import type { FleetRecord } from "@/services/fleet/fleet.service"; import type { FleetRecord } from "@/services/fleet/fleet.service";
@@ -131,6 +132,7 @@ const FleetFormDialog = ({
<NumberInput <NumberInput
key={field.name} key={field.name}
label={field.label} label={field.label}
placeholder={field.placeholder}
value={value === "" || value == null ? "" : Number(value)} value={value === "" || value == null ? "" : Number(value)}
onChange={(next) => onChange={(next) =>
setValues((current) => ({ setValues((current) => ({
@@ -139,6 +141,7 @@ const FleetFormDialog = ({
})) }))
} }
error={error} error={error}
disabled={field.disabled}
/> />
); );
} }
@@ -148,15 +151,35 @@ const FleetFormDialog = ({
<Textarea <Textarea
key={field.name} key={field.name}
label={field.label} label={field.label}
placeholder={field.placeholder}
value={String(value ?? "")} value={String(value ?? "")}
onChange={(e) => onChange={(e) =>
setValues((current) => ({ setValues((current) => ({ ...current, [field.name]: e.currentTarget?.value }))
...current,
[field.name]: e.target?.value ?? "",
}))
} }
error={error} error={error}
minRows={3} minRows={3}
disabled={field.disabled}
/>
);
}
if (field.type === "date") {
return (
<DateInput
key={field.name}
label={field.label}
placeholder={field.placeholder}
value={value ? new Date(value as string) : null}
onChange={(date) =>
setValues((current) => ({
...current,
[field.name]: date ? (date instanceof Date ? date.toISOString().split('T')[0] : date) : "",
}))
}
error={error}
disabled={field.disabled}
clearable
valueFormat="DD/MM/YYYY"
/> />
); );
} }
@@ -165,14 +188,14 @@ const FleetFormDialog = ({
<TextInput <TextInput
key={field.name} key={field.name}
label={field.label} label={field.label}
placeholder={field.placeholder}
description={field.description}
value={String(value ?? "")} value={String(value ?? "")}
onChange={(e) => onChange={(e) =>
setValues((current) => ({ setValues((current) => ({ ...current, [field.name]: e.currentTarget?.value }))
...current,
[field.name]: e.target?.value ?? "",
}))
} }
error={error} error={error}
disabled={field.disabled}
/> />
); );
}; };
@@ -204,4 +227,4 @@ const FleetFormDialog = ({
); );
}; };
export default FleetFormDialog; export default FleetFormDialog;