mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 15:18:11 +00:00
add export/inport number
This commit is contained in:
@@ -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 === ""
|
||||
|
||||
Reference in New Issue
Block a user