add export/inport number

This commit is contained in:
natib21
2026-07-17 09:15:21 +00:00
parent b4118e1bd4
commit 1abf71306e
2 changed files with 65 additions and 3 deletions

View File

@@ -271,8 +271,14 @@ const FleetFormDialog = ({
return;
}
if (!validate()) return;
// Derived fields are never edited, so form state for them can be stale (or
// seeded from the record) — recompute before building the payload.
const submitted: Record<string, unknown> = { ...values };
fields.forEach((field) => {
if (field.derivedValue) submitted[field.name] = field.derivedValue(values);
});
const payload = Object.fromEntries(
Object.entries(values)
Object.entries(submitted)
.map(([key, value]) => {
if (value === FLEET_SELECT_NONE || value === "")
return [key, undefined];
@@ -294,6 +300,23 @@ const FleetFormDialog = ({
// only by verification and never hand-edited.
const isDisabled = Boolean(field.disabled || field.faydaLocked);
// Computed from other fields (e.g. the import run implied by the export
// run) — read-only, and recomputed here rather than read from form state.
if (field.derivedValue) {
return (
<TextInput
key={field.name}
label={field.label}
description={field.description}
placeholder={field.placeholder}
value={field.derivedValue(values)}
readOnly
variant="filled"
error={error}
/>
);
}
if (field.type === "radio") {
return (
<Radio.Group
@@ -319,6 +342,8 @@ const FleetFormDialog = ({
<Select
key={field.name}
label={field.label}
description={field.description}
placeholder={field.placeholder}
data={field.options ?? []}
value={
value == null || value === ""