mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 07:38:10 +00:00
fix
This commit is contained in:
@@ -258,6 +258,12 @@ const FleetFormDialog = ({
|
||||
}, [fields]);
|
||||
|
||||
const handleSubmit = () => {
|
||||
// Hard gate: a driver record cannot be saved until its identity is verified
|
||||
// with Fayda. Mirrored server-side in DriversService.
|
||||
if (verifyWithFayda && !faydaVerified) {
|
||||
setFaydaError("Verify the driver's identity with Fayda before saving.");
|
||||
return;
|
||||
}
|
||||
if (!validate()) return;
|
||||
const payload = Object.fromEntries(
|
||||
Object.entries(values)
|
||||
@@ -278,6 +284,9 @@ const FleetFormDialog = ({
|
||||
const renderField = (field: FleetFormFieldDef) => {
|
||||
const value = values[field.name];
|
||||
const error = errors[field.name];
|
||||
// Fayda-owned identity fields (name/email/phone/DOB/gender) are populated
|
||||
// only by verification and never hand-edited.
|
||||
const isDisabled = Boolean(field.disabled || field.faydaLocked);
|
||||
|
||||
if (field.type === "select") {
|
||||
return (
|
||||
@@ -297,7 +306,7 @@ const FleetFormDialog = ({
|
||||
}
|
||||
error={error}
|
||||
searchable
|
||||
disabled={selectOptionsLoading}
|
||||
disabled={selectOptionsLoading || isDisabled}
|
||||
rightSection={
|
||||
selectOptionsLoading ? (
|
||||
<Loader2 size={14} className="animate-spin" />
|
||||
@@ -327,7 +336,7 @@ const FleetFormDialog = ({
|
||||
error={error}
|
||||
searchable
|
||||
clearable
|
||||
disabled={selectOptionsLoading}
|
||||
disabled={selectOptionsLoading || isDisabled}
|
||||
rightSection={
|
||||
selectOptionsLoading ? (
|
||||
<Loader2 size={14} className="animate-spin" />
|
||||
@@ -351,7 +360,7 @@ const FleetFormDialog = ({
|
||||
}))
|
||||
}
|
||||
error={error}
|
||||
disabled={field.disabled}
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -371,7 +380,7 @@ const FleetFormDialog = ({
|
||||
}
|
||||
error={error}
|
||||
minRows={3}
|
||||
disabled={field.disabled}
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -391,7 +400,7 @@ const FleetFormDialog = ({
|
||||
}))
|
||||
}
|
||||
error={error}
|
||||
disabled={field.disabled}
|
||||
disabled={isDisabled}
|
||||
description={field.description || "Select a date"}
|
||||
rightSection={
|
||||
<ActionIcon size="sm" variant="subtle" color="green">
|
||||
@@ -429,7 +438,7 @@ const FleetFormDialog = ({
|
||||
}))
|
||||
}
|
||||
error={error}
|
||||
disabled={field.disabled}
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -457,7 +466,8 @@ const FleetFormDialog = ({
|
||||
</Badge>
|
||||
) : (
|
||||
<Text size="sm" c="dimmed">
|
||||
Verify the driver's identity with Fayda to prefill their details.
|
||||
Identity must be verified with Fayda before this driver can be
|
||||
saved.
|
||||
</Text>
|
||||
)}
|
||||
<Button
|
||||
@@ -489,6 +499,7 @@ const FleetFormDialog = ({
|
||||
color="edr-green"
|
||||
loading={isSubmitting}
|
||||
onClick={handleSubmit}
|
||||
disabled={verifyWithFayda && !faydaVerified}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
|
||||
@@ -50,12 +50,12 @@ export const driversConfig: FleetResourceConfig = {
|
||||
],
|
||||
formFields: [
|
||||
{ name: "licenseNumber", label: "License Number", type: "text", required: true },
|
||||
{ name: "firstName", label: "First Name", type: "text", required: true },
|
||||
{ name: "lastName", label: "Last Name", type: "text", required: true },
|
||||
{ name: "email", label: "Email", type: "email", required: true },
|
||||
{ name: "phoneNumber", label: "Phone Number", type: "text", required: true },
|
||||
{ name: "dateOfBirth", label: "Date of Birth", type: "date", required: true },
|
||||
{ name: "gender", label: "Gender", type: "select", options: DRIVER_GENDER_OPTIONS },
|
||||
{ name: "firstName", label: "First Name", type: "text", required: true, faydaLocked: true },
|
||||
{ name: "lastName", label: "Last Name", type: "text", required: true, faydaLocked: true },
|
||||
{ name: "email", label: "Email", type: "email", required: true, faydaLocked: true },
|
||||
{ name: "phoneNumber", label: "Phone Number", type: "text", required: true, faydaLocked: true },
|
||||
{ name: "dateOfBirth", label: "Date of Birth", type: "date", required: true, faydaLocked: true },
|
||||
{ name: "gender", label: "Gender", type: "select", options: DRIVER_GENDER_OPTIONS, faydaLocked: true },
|
||||
{ name: "licenseExpiryDate", label: "License Expiry Date", type: "date", required: true },
|
||||
{ name: "status", label: "Status", type: "select", required: true, options: DRIVER_STATUS_OPTIONS },
|
||||
{ name: "vehicleTypesAuthorized", label: "Authorized Vehicle Types", type: "multiselect", options: VEHICLE_TYPE_OPTIONS },
|
||||
|
||||
@@ -40,6 +40,11 @@ export interface FleetResourceColumn {
|
||||
export interface FleetFormFieldDef extends FormFieldDef {
|
||||
dynamicOptions?: FleetDynamicOptions;
|
||||
noneOption?: boolean;
|
||||
/**
|
||||
* Field is owned by the Fayda identity — populated only by verification and
|
||||
* never hand-edited. Rendered disabled in the form.
|
||||
*/
|
||||
faydaLocked?: boolean;
|
||||
}
|
||||
|
||||
export interface FleetListFilterDef {
|
||||
|
||||
Reference in New Issue
Block a user