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", format: "code", size: 120 },
    { id: "lastName", header: "Last Name", accessorKey: "lastName", format: "code", size: 120 },
    { id: "email", header: "Email", accessorKey: "email", format: "code", size: 180 },
    { id: "phoneNumber", header: "Phone", accessorKey: "phoneNumber", format: "code", size: 120 },
    { id: "licenseExpiryDate", header: "License Expiry", accessorKey: "licenseExpiryDate", format: "code", 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 };
