mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 19:28:17 +00:00
fix null value
This commit is contained in:
@@ -263,6 +263,14 @@ const FleetFormDialog = ({
|
||||
return map;
|
||||
}, [fields]);
|
||||
|
||||
// Emptying one of these means "unset the column", so it submits an explicit
|
||||
// null instead of being dropped from the payload like other empty fields.
|
||||
const clearableByName = useMemo(() => {
|
||||
const map: Record<string, boolean> = {};
|
||||
fields.forEach((f) => (map[f.name] = Boolean(f.clearable)));
|
||||
return map;
|
||||
}, [fields]);
|
||||
|
||||
const handleSubmit = () => {
|
||||
// Hard gate: a driver record cannot be saved until its identity is verified
|
||||
// with Fayda. Mirrored server-side in DriversService.
|
||||
@@ -280,8 +288,8 @@ const FleetFormDialog = ({
|
||||
const payload = Object.fromEntries(
|
||||
Object.entries(submitted)
|
||||
.map(([key, value]) => {
|
||||
if (value === FLEET_SELECT_NONE || value === "")
|
||||
return [key, undefined];
|
||||
if (value === FLEET_SELECT_NONE || value === "" || value == null)
|
||||
return [key, clearableByName[key] ? null : undefined];
|
||||
if (fieldTypeByName[key] === "number") {
|
||||
const num = Number(value);
|
||||
return [key, Number.isNaN(num) ? undefined : num];
|
||||
@@ -357,6 +365,7 @@ const FleetFormDialog = ({
|
||||
}
|
||||
error={error}
|
||||
searchable
|
||||
clearable={field.clearable}
|
||||
disabled={selectOptionsLoading || isDisabled}
|
||||
rightSection={
|
||||
selectOptionsLoading ? (
|
||||
|
||||
Reference in New Issue
Block a user