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", format: "code", size: 140 },
    { id: "manufacturer", header: "Manufacturer", accessorKey: "manufacturer", format: "code", size: 140 },
    { id: "model", header: "Model", accessorKey: "model", format: "code", size: 120 },
    { id: "vehicleType", header: "Type", accessorKey: "vehicleType", format: "code", size: 100 },
    { id: "year", header: "Year", accessorKey: "year", format: "number", size: 80 },
    { id: "fuelType", header: "Fuel Type", accessorKey: "fuelType", format: "code", size: 110 },
    { id: "capacity", header: "Capacity (tons)", accessorKey: "capacity", format: "number", size: 130 },
    { id: "assignedDriverName", header: "Assigned Driver", accessorKey: "assignedDriverName", format: "code", size: 140 },
    { 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 };
