mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
fix
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
import type { FleetResourceConfig } from "./resources";
|
||||||
|
import { VEHICLE_TYPE_OPTIONS } from "./vehicles";
|
||||||
|
|
||||||
|
const DRIVER_STATUS_OPTIONS = [
|
||||||
|
{ label: "Active", value: "ACTIVE" },
|
||||||
|
{ label: "Inactive", value: "INACTIVE" },
|
||||||
|
{ label: "Suspended", value: "SUSPENDED" },
|
||||||
|
{ label: "On leave", value: "ON_LEAVE" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const driversConfig: FleetResourceConfig = {
|
||||||
|
slug: "drivers",
|
||||||
|
label: "Drivers",
|
||||||
|
subtitle: "Manage driver records and licenses",
|
||||||
|
basePath: "/dashboard/drivers",
|
||||||
|
addLabel: "Add Driver",
|
||||||
|
entityLabel: "Driver",
|
||||||
|
searchPlaceholder: "Search drivers…",
|
||||||
|
supportsSearch: true,
|
||||||
|
removeAction: "delete",
|
||||||
|
cardTitleKey: "firstName",
|
||||||
|
cardCodeKey: "licenseNumber",
|
||||||
|
cardSubtitleKey: "status",
|
||||||
|
listFilters: [
|
||||||
|
{
|
||||||
|
key: "status",
|
||||||
|
label: "Status",
|
||||||
|
allLabel: "All statuses",
|
||||||
|
options: DRIVER_STATUS_OPTIONS,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
searchKeys: ["firstName", "lastName", "email", "phoneNumber", "licenseNumber", "status"],
|
||||||
|
columns: [
|
||||||
|
{ id: "licenseNumber", header: "License Number", accessorKey: "licenseNumber", format: "code", size: 140 },
|
||||||
|
{ id: "firstName", header: "First Name", accessorKey: "firstName", size: 120 },
|
||||||
|
{ id: "lastName", header: "Last Name", accessorKey: "lastName", size: 120 },
|
||||||
|
{ id: "email", header: "Email", accessorKey: "email", size: 180 },
|
||||||
|
{ id: "phoneNumber", header: "Phone", accessorKey: "phoneNumber", size: 120 },
|
||||||
|
{ id: "licenseExpiryDate", header: "License Expiry", accessorKey: "licenseExpiryDate", size: 130 },
|
||||||
|
{ id: "status", header: "Status", accessorKey: "status", format: "statusBadge", size: 100 },
|
||||||
|
],
|
||||||
|
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: "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 },
|
||||||
|
{ name: "address", label: "Address", type: "textarea" },
|
||||||
|
{ name: "emergencyContact", label: "Emergency Contact", type: "text" },
|
||||||
|
{ name: "notes", label: "Notes", type: "textarea" },
|
||||||
|
],
|
||||||
|
emptyValues: {
|
||||||
|
licenseNumber: "",
|
||||||
|
firstName: "",
|
||||||
|
lastName: "",
|
||||||
|
email: "",
|
||||||
|
phoneNumber: "",
|
||||||
|
dateOfBirth: "",
|
||||||
|
licenseExpiryDate: "",
|
||||||
|
status: "ACTIVE",
|
||||||
|
vehicleTypesAuthorized: [],
|
||||||
|
address: "",
|
||||||
|
emergencyContact: "",
|
||||||
|
notes: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export { DRIVER_STATUS_OPTIONS };
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
import { Freight } from "@edr/types";
|
import { Freight } from "@edr/types";
|
||||||
import type { ColumnFormat, FormFieldDef } from "@/pages/ruleEngine/config/resources";
|
import type { ColumnFormat, FormFieldDef } from "@/pages/ruleEngine/config/resources";
|
||||||
|
import { vehiclesConfig, VEHICLE_TYPE_OPTIONS, FUEL_TYPE_OPTIONS, VEHICLE_STATUS_OPTIONS } from "./vehicles";
|
||||||
|
import { driversConfig, DRIVER_STATUS_OPTIONS } from "./drivers";
|
||||||
|
|
||||||
|
// Re-export options for backward compatibility
|
||||||
|
export { VEHICLE_TYPE_OPTIONS, FUEL_TYPE_OPTIONS, VEHICLE_STATUS_OPTIONS, DRIVER_STATUS_OPTIONS };
|
||||||
|
|
||||||
export type FleetResourceSlug =
|
export type FleetResourceSlug =
|
||||||
| "locomotives"
|
| "locomotives"
|
||||||
@@ -99,36 +104,6 @@ const WAGON_STATUS_OPTIONS = [
|
|||||||
{ label: "Retired", value: Freight.WagonStatus.Retired },
|
{ label: "Retired", value: Freight.WagonStatus.Retired },
|
||||||
];
|
];
|
||||||
|
|
||||||
const VEHICLE_TYPE_OPTIONS = [
|
|
||||||
{ label: "Truck", value: "TRUCK" },
|
|
||||||
{ label: "Van", value: "VAN" },
|
|
||||||
{ label: "Car", value: "CAR" },
|
|
||||||
{ label: "Bus", value: "BUS" },
|
|
||||||
{ label: "Trailer", value: "TRAILER" },
|
|
||||||
{ label: "Tanker", value: "TANKER" },
|
|
||||||
{ label: "Flatbed", value: "FLATBED" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const FUEL_TYPE_OPTIONS = [
|
|
||||||
{ label: "Petrol", value: "PETROL" },
|
|
||||||
{ label: "Diesel", value: "DIESEL" },
|
|
||||||
{ label: "Electric", value: "ELECTRIC" },
|
|
||||||
{ label: "Hybrid", value: "HYBRID" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const VEHICLE_STATUS_OPTIONS = [
|
|
||||||
{ label: "Active", value: "ACTIVE" },
|
|
||||||
{ label: "Maintenance", value: "MAINTENANCE" },
|
|
||||||
{ label: "Retired", value: "RETIRED" },
|
|
||||||
{ label: "Out of service", value: "OUT_OF_SERVICE" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const DRIVER_STATUS_OPTIONS = [
|
|
||||||
{ label: "Active", value: "ACTIVE" },
|
|
||||||
{ label: "Inactive", value: "INACTIVE" },
|
|
||||||
{ label: "Suspended", value: "SUSPENDED" },
|
|
||||||
{ label: "On leave", value: "ON_LEAVE" },
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
export const FLEET_RESOURCES: FleetResourceConfig[] = [
|
export const FLEET_RESOURCES: FleetResourceConfig[] = [
|
||||||
@@ -378,122 +353,8 @@ export const FLEET_RESOURCES: FleetResourceConfig[] = [
|
|||||||
status: "PENDING",
|
status: "PENDING",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
vehiclesConfig,
|
||||||
slug: "vehicles",
|
driversConfig,
|
||||||
label: "Vehicles",
|
|
||||||
subtitle: "Manage vehicle master data for fleet operations",
|
|
||||||
basePath: "/dashboard/vehicles",
|
|
||||||
addLabel: "Add Vehicle",
|
|
||||||
entityLabel: "Vehicle",
|
|
||||||
searchPlaceholder: "Search vehicles…",
|
|
||||||
supportsSearch: true,
|
|
||||||
removeAction: "delete",
|
|
||||||
cardTitleKey: "plateNumber",
|
|
||||||
cardCodeKey: "plateNumber",
|
|
||||||
cardSubtitleKey: "status",
|
|
||||||
listFilters: [
|
|
||||||
{
|
|
||||||
key: "status",
|
|
||||||
label: "Status",
|
|
||||||
allLabel: "All statuses",
|
|
||||||
options: VEHICLE_STATUS_OPTIONS,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
searchKeys: ["plateNumber", "registrationNumber", "manufacturer", "model", "vehicleType", "status"],
|
|
||||||
columns: [
|
|
||||||
{ id: "plateNumber", header: "Plate Number", accessorKey: "plateNumber", format: "code", size: 130 },
|
|
||||||
{ id: "registrationNumber", header: "Registration", accessorKey: "registrationNumber", size: 140 },
|
|
||||||
{ id: "manufacturer", header: "Manufacturer", accessorKey: "manufacturer", size: 140 },
|
|
||||||
{ id: "model", header: "Model", accessorKey: "model", size: 120 },
|
|
||||||
{ id: "vehicleType", header: "Type", accessorKey: "vehicleType", size: 100 },
|
|
||||||
{ id: "year", header: "Year", accessorKey: "year", format: "number", size: 80 },
|
|
||||||
{ id: "fuelType", header: "Fuel Type", accessorKey: "fuelType", size: 110 },
|
|
||||||
{ id: "capacity", header: "Capacity (tons)", accessorKey: "capacity", format: "number", size: 130 },
|
|
||||||
{ id: "status", header: "Status", accessorKey: "status", format: "statusBadge", size: 100 },
|
|
||||||
],
|
|
||||||
formFields: [
|
|
||||||
{ name: "plateNumber", label: "Plate Number", type: "text", required: true },
|
|
||||||
{ name: "vehicleType", label: "Vehicle Type", type: "select", required: true, options: VEHICLE_TYPE_OPTIONS },
|
|
||||||
{ name: "manufacturer", label: "Manufacturer", type: "text", required: true },
|
|
||||||
{ name: "model", label: "Model", type: "text", required: true },
|
|
||||||
{ name: "year", label: "Year", type: "number", required: true },
|
|
||||||
{ name: "fuelType", label: "Fuel Type", type: "select", required: true, options: FUEL_TYPE_OPTIONS },
|
|
||||||
{ name: "capacity", label: "Capacity", type: "number", required: true },
|
|
||||||
{ name: "status", label: "Status", type: "select", required: true, options: VEHICLE_STATUS_OPTIONS },
|
|
||||||
{ name: "description", label: "Description", type: "textarea" },
|
|
||||||
],
|
|
||||||
emptyValues: {
|
|
||||||
plateNumber: "",
|
|
||||||
vehicleType: "TRUCK",
|
|
||||||
manufacturer: "",
|
|
||||||
model: "",
|
|
||||||
year: new Date().getFullYear(),
|
|
||||||
fuelType: "DIESEL",
|
|
||||||
capacity: 0,
|
|
||||||
status: "ACTIVE",
|
|
||||||
description: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
slug: "drivers",
|
|
||||||
label: "Drivers",
|
|
||||||
subtitle: "Manage driver records and licenses",
|
|
||||||
basePath: "/dashboard/drivers",
|
|
||||||
addLabel: "Add Driver",
|
|
||||||
entityLabel: "Driver",
|
|
||||||
searchPlaceholder: "Search drivers…",
|
|
||||||
supportsSearch: true,
|
|
||||||
removeAction: "delete",
|
|
||||||
cardTitleKey: "firstName",
|
|
||||||
cardCodeKey: "licenseNumber",
|
|
||||||
cardSubtitleKey: "status",
|
|
||||||
listFilters: [
|
|
||||||
{
|
|
||||||
key: "status",
|
|
||||||
label: "Status",
|
|
||||||
allLabel: "All statuses",
|
|
||||||
options: DRIVER_STATUS_OPTIONS,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
searchKeys: ["firstName", "lastName", "email", "phoneNumber", "licenseNumber", "status"],
|
|
||||||
columns: [
|
|
||||||
{ id: "licenseNumber", header: "License Number", accessorKey: "licenseNumber", format: "code", size: 140 },
|
|
||||||
{ id: "firstName", header: "First Name", accessorKey: "firstName", size: 120 },
|
|
||||||
{ id: "lastName", header: "Last Name", accessorKey: "lastName", size: 120 },
|
|
||||||
{ id: "email", header: "Email", accessorKey: "email", size: 180 },
|
|
||||||
{ id: "phoneNumber", header: "Phone", accessorKey: "phoneNumber", size: 120 },
|
|
||||||
{ id: "licenseExpiryDate", header: "License Expiry", accessorKey: "licenseExpiryDate", size: 130 },
|
|
||||||
{ id: "status", header: "Status", accessorKey: "status", format: "statusBadge", size: 100 },
|
|
||||||
],
|
|
||||||
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: "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 },
|
|
||||||
{ name: "address", label: "Address", type: "textarea" },
|
|
||||||
{ name: "emergencyContact", label: "Emergency Contact", type: "text" },
|
|
||||||
{ name: "notes", label: "Notes", type: "textarea" },
|
|
||||||
],
|
|
||||||
emptyValues: {
|
|
||||||
licenseNumber: "",
|
|
||||||
firstName: "",
|
|
||||||
lastName: "",
|
|
||||||
email: "",
|
|
||||||
phoneNumber: "",
|
|
||||||
dateOfBirth: "",
|
|
||||||
licenseExpiryDate: "",
|
|
||||||
status: "ACTIVE",
|
|
||||||
vehicleTypesAuthorized: [],
|
|
||||||
address: "",
|
|
||||||
emergencyContact: "",
|
|
||||||
notes: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const getFleetResource = (slug: string): FleetResourceConfig | undefined =>
|
export const getFleetResource = (slug: string): FleetResourceConfig | undefined =>
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import type { FleetResourceConfig } from "./resources";
|
||||||
|
|
||||||
|
const VEHICLE_TYPE_OPTIONS = [
|
||||||
|
{ label: "Truck", value: "TRUCK" },
|
||||||
|
{ label: "Van", value: "VAN" },
|
||||||
|
{ label: "Car", value: "CAR" },
|
||||||
|
{ label: "Bus", value: "BUS" },
|
||||||
|
{ label: "Trailer", value: "TRAILER" },
|
||||||
|
{ label: "Tanker", value: "TANKER" },
|
||||||
|
{ label: "Flatbed", value: "FLATBED" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const FUEL_TYPE_OPTIONS = [
|
||||||
|
{ label: "Petrol", value: "PETROL" },
|
||||||
|
{ label: "Diesel", value: "DIESEL" },
|
||||||
|
{ label: "Electric", value: "ELECTRIC" },
|
||||||
|
{ label: "Hybrid", value: "HYBRID" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const VEHICLE_STATUS_OPTIONS = [
|
||||||
|
{ label: "Active", value: "ACTIVE" },
|
||||||
|
{ label: "Maintenance", value: "MAINTENANCE" },
|
||||||
|
{ label: "Retired", value: "RETIRED" },
|
||||||
|
{ label: "Out of service", value: "OUT_OF_SERVICE" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const vehiclesConfig: FleetResourceConfig = {
|
||||||
|
slug: "vehicles",
|
||||||
|
label: "Vehicles",
|
||||||
|
subtitle: "Manage vehicle master data for fleet operations",
|
||||||
|
basePath: "/dashboard/vehicles",
|
||||||
|
addLabel: "Add Vehicle",
|
||||||
|
entityLabel: "Vehicle",
|
||||||
|
searchPlaceholder: "Search vehicles…",
|
||||||
|
supportsSearch: true,
|
||||||
|
removeAction: "delete",
|
||||||
|
cardTitleKey: "plateNumber",
|
||||||
|
cardCodeKey: "plateNumber",
|
||||||
|
cardSubtitleKey: "status",
|
||||||
|
listFilters: [
|
||||||
|
{
|
||||||
|
key: "status",
|
||||||
|
label: "Status",
|
||||||
|
allLabel: "All statuses",
|
||||||
|
options: VEHICLE_STATUS_OPTIONS,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
searchKeys: ["plateNumber", "registrationNumber", "manufacturer", "model", "vehicleType", "status"],
|
||||||
|
columns: [
|
||||||
|
{ id: "plateNumber", header: "Plate Number", accessorKey: "plateNumber", format: "code", size: 130 },
|
||||||
|
{ id: "registrationNumber", header: "Registration", accessorKey: "registrationNumber", size: 140 },
|
||||||
|
{ id: "manufacturer", header: "Manufacturer", accessorKey: "manufacturer", size: 140 },
|
||||||
|
{ id: "model", header: "Model", accessorKey: "model", size: 120 },
|
||||||
|
{ id: "vehicleType", header: "Type", accessorKey: "vehicleType", size: 100 },
|
||||||
|
{ id: "year", header: "Year", accessorKey: "year", format: "number", size: 80 },
|
||||||
|
{ id: "fuelType", header: "Fuel Type", accessorKey: "fuelType", size: 110 },
|
||||||
|
{ id: "capacity", header: "Capacity (tons)", accessorKey: "capacity", format: "number", size: 130 },
|
||||||
|
{ id: "status", header: "Status", accessorKey: "status", format: "statusBadge", size: 100 },
|
||||||
|
],
|
||||||
|
formFields: [
|
||||||
|
{ name: "plateNumber", label: "Plate Number", type: "text", required: true },
|
||||||
|
{ name: "vehicleType", label: "Vehicle Type", type: "select", required: true, options: VEHICLE_TYPE_OPTIONS },
|
||||||
|
{ name: "manufacturer", label: "Manufacturer", type: "text", required: true },
|
||||||
|
{ name: "model", label: "Model", type: "text", required: true },
|
||||||
|
{ name: "year", label: "Year", type: "number", required: true },
|
||||||
|
{ name: "fuelType", label: "Fuel Type", type: "select", required: true, options: FUEL_TYPE_OPTIONS },
|
||||||
|
{ name: "capacity", label: "Capacity", type: "number", required: true },
|
||||||
|
{ name: "status", label: "Status", type: "select", required: true, options: VEHICLE_STATUS_OPTIONS },
|
||||||
|
{ name: "description", label: "Description", type: "textarea" },
|
||||||
|
],
|
||||||
|
emptyValues: {
|
||||||
|
plateNumber: "",
|
||||||
|
vehicleType: "TRUCK",
|
||||||
|
manufacturer: "",
|
||||||
|
model: "",
|
||||||
|
year: new Date().getFullYear(),
|
||||||
|
fuelType: "DIESEL",
|
||||||
|
capacity: 0,
|
||||||
|
status: "ACTIVE",
|
||||||
|
description: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export { VEHICLE_TYPE_OPTIONS, FUEL_TYPE_OPTIONS, VEHICLE_STATUS_OPTIONS };
|
||||||
Reference in New Issue
Block a user