This commit is contained in:
natib21
2026-07-02 12:43:03 +00:00
parent 657f3bd2ab
commit 58b3805d0b
6 changed files with 36 additions and 7 deletions

View File

@@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
/**
* Add FREE and BUSY statuses to vehicle status enum.
*/
export class AddVehicleStatuses1880000000000 implements MigrationInterface {
name = "AddVehicleStatuses1880000000000";
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TYPE freight.vehicles_status_enum ADD VALUE IF NOT EXISTS 'FREE' BEFORE 'MAINTENANCE';
`);
await queryRunner.query(`
ALTER TYPE freight.vehicles_status_enum ADD VALUE IF NOT EXISTS 'BUSY' AFTER 'FREE';
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
// Note: Postgres cannot drop individual enum values, so the down migration is a no-op
// The enum values FREE and BUSY will remain but will be unused after downgrade
}
}

View File

@@ -20,6 +20,8 @@ export enum FuelType {
export enum VehicleStatus {
ACTIVE = 'ACTIVE',
FREE = 'FREE',
BUSY = 'BUSY',
MAINTENANCE = 'MAINTENANCE',
RETIRED = 'RETIRED',
OUT_OF_SERVICE = 'OUT_OF_SERVICE',

View File

@@ -25,6 +25,8 @@ export const formatFleetCell = (
const getStatusColor = (st: string): string => {
const s = st.toUpperCase();
if (s === "ACTIVE" || s === "AVAILABLE") return "green";
if (s === "FREE") return "teal";
if (s === "BUSY") return "blue";
if (s === "INACTIVE") return "gray";
if (s === "SUSPENDED" || s === "OUT_OF_SERVICE") return "red";
if (s === "MAINTENANCE" || s === "ON_LEAVE") return "orange";

View File

@@ -189,6 +189,7 @@ const FleetResourcePage = () => {
registerFleetOptionLabels("wagonId", dynamicOptions.wagons);
registerFleetOptionLabels("containerId", dynamicOptions.containers);
registerFleetOptionLabels("currentYardId", dynamicOptions.yards);
registerFleetOptionLabels("locationId", dynamicOptions.yards);
}, [dynamicOptions]);
const formFields = useMemo((): FleetFormFieldDef[] => {

View File

@@ -19,6 +19,8 @@ const FUEL_TYPE_OPTIONS = [
const VEHICLE_STATUS_OPTIONS = [
{ label: "Active", value: "ACTIVE" },
{ label: "Free", value: "FREE" },
{ label: "Busy", value: "BUSY" },
{ label: "Maintenance", value: "MAINTENANCE" },
{ label: "Retired", value: "RETIRED" },
{ label: "Out of service", value: "OUT_OF_SERVICE" },
@@ -47,13 +49,13 @@ export const vehiclesConfig: FleetResourceConfig = {
],
searchKeys: ["plateNumber", "registrationNumber", "manufacturer", "model", "vehicleType", "status"],
columns: [
{ id: "code", header: "Code", accessorKey: "code", format: "code", size: 110 },
{ id: "plateNumber", header: "Plate Number", accessorKey: "plateNumber", format: "code", size: 130 },
{ id: "manufacturer", header: "Manufacturer", accessorKey: "manufacturer", format: "code", size: 120 },
{ id: "model", header: "Model", accessorKey: "model", format: "code", size: 100 },
{ id: "vehicleType", header: "Type", accessorKey: "vehicleType", format: "code", size: 80 },
{ id: "code", header: "Code", accessorKey: "code", size: 90 },
{ id: "plateNumber", header: "Plate Number", accessorKey: "plateNumber", size: 120 },
{ id: "manufacturer", header: "Manufacturer", accessorKey: "manufacturer", size: 120 },
{ id: "model", header: "Model", accessorKey: "model", size: 100 },
{ id: "vehicleType", header: "Type", accessorKey: "vehicleType", size: 75 },
{ id: "capacity", header: "Capacity (tons)", accessorKey: "capacity", format: "number", size: 100 },
{ id: "locationId", header: "Location", accessorKey: "locationId", format: "code", size: 130 },
{ id: "locationId", header: "Location", accessorKey: "locationId", size: 140 },
{ id: "status", header: "Status", accessorKey: "status", format: "statusBadge", size: 100 },
],
formFields: [

View File

@@ -3,7 +3,7 @@ import { URL_CONSTANTS } from '@/constants/URLS';
export type VehicleType = 'TRUCK' | 'VAN' | 'CAR' | 'BUS' | 'TRAILER' | 'TANKER' | 'FLATBED';
export type FuelType = 'PETROL' | 'DIESEL' | 'ELECTRIC' | 'HYBRID';
export type VehicleStatus = 'ACTIVE' | 'MAINTENANCE' | 'RETIRED' | 'OUT_OF_SERVICE';
export type VehicleStatus = 'ACTIVE' | 'FREE' | 'BUSY' | 'MAINTENANCE' | 'RETIRED' | 'OUT_OF_SERVICE';
export interface VehicleListFilters {
status?: VehicleStatus;