This commit is contained in:
natib21
2026-07-02 14:14:13 +00:00
parent 34b87bbcee
commit c2c29f0735
13 changed files with 84 additions and 23 deletions

View File

@@ -43,7 +43,7 @@ export function ContainerAllocationTable({
const { data: vehicles = [], isLoading: vehiclesLoading } = useQuery({
queryKey: ["vehicles", "free"],
queryFn: () => vehiclesService.getAll({ status: "FREE" }),
queryFn: () => vehiclesService.getAll({ status: "ACTIVE", availability: "FREE" }),
});
const vehicleOptions = useMemo(

View File

@@ -43,7 +43,7 @@ export function FirstMileContainerAllocationTable({
const { data: vehicles = [], isLoading: vehiclesLoading } = useQuery({
queryKey: ["vehicles", "free"],
queryFn: () => vehiclesService.getAll({ status: "FREE" }),
queryFn: () => vehiclesService.getAll({ status: "ACTIVE", availability: "FREE" }),
});
const vehicleOptions = useMemo(

View File

@@ -43,7 +43,7 @@ export function LastMileContainerAllocationTable({
const { data: vehicles = [], isLoading: vehiclesLoading } = useQuery({
queryKey: ["vehicles", "free"],
queryFn: () => vehiclesService.getAll({ status: "FREE" }),
queryFn: () => vehiclesService.getAll({ status: "ACTIVE", availability: "FREE" }),
});
const vehicleOptions = useMemo(

View File

@@ -19,13 +19,16 @@ 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" },
];
const VEHICLE_AVAILABILITY_OPTIONS = [
{ label: "Free", value: "FREE" },
{ label: "Busy", value: "BUSY" },
];
export const vehiclesConfig: FleetResourceConfig = {
slug: "vehicles",
label: "Vehicles",
@@ -58,6 +61,7 @@ export const vehiclesConfig: FleetResourceConfig = {
{ id: "capacity", header: "Capacity (tons)", accessorKey: "capacity", format: "number", size: 100 },
{ id: "locationId", header: "Location", accessorKey: "locationId", size: 140 },
{ id: "status", header: "Status", accessorKey: "status", format: "statusBadge", size: 100 },
{ id: "availability", header: "Availability", accessorKey: "availability", format: "statusBadge", size: 100 },
],
formFields: [
{ name: "code", label: "Code", type: "text" },
@@ -95,4 +99,4 @@ export const vehiclesConfig: FleetResourceConfig = {
},
};
export { VEHICLE_TYPE_OPTIONS, FUEL_TYPE_OPTIONS, VEHICLE_STATUS_OPTIONS };
export { VEHICLE_TYPE_OPTIONS, FUEL_TYPE_OPTIONS, VEHICLE_STATUS_OPTIONS, VEHICLE_AVAILABILITY_OPTIONS };

View File

@@ -357,7 +357,7 @@ const FirstMilePage = () => {
const { data: vehiclesData } = useQuery({
queryKey: ["vehicles", "free"],
queryFn: async () => {
const res = await vehiclesService.getAll({ status: "FREE" });
const res = await vehiclesService.getAll({ status: "ACTIVE", availability: "FREE" });
return res.data;
},
});

View File

@@ -341,7 +341,7 @@ const LastMilePage = () => {
const { data: vehiclesData } = useQuery({
queryKey: ["vehicles", "free"],
queryFn: async () => {
const res = await vehiclesService.getAll({ status: "FREE" });
const res = await vehiclesService.getAll({ status: "ACTIVE", availability: "FREE" });
return res.data;
},
});

View File

@@ -3,10 +3,12 @@ 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' | 'FREE' | 'BUSY' | 'MAINTENANCE' | 'RETIRED' | 'OUT_OF_SERVICE';
export type VehicleStatus = 'ACTIVE' | 'MAINTENANCE' | 'RETIRED' | 'OUT_OF_SERVICE';
export type VehicleAvailability = 'FREE' | 'BUSY';
export interface VehicleListFilters {
status?: VehicleStatus;
availability?: VehicleAvailability;
search?: string;
page?: number;
limit?: number;
@@ -25,6 +27,7 @@ export interface Vehicle {
fuelType: FuelType;
capacity: number;
status: VehicleStatus;
availability: VehicleAvailability;
description?: string | null;
code?: string | null;
powerPlateNo?: string | null;
@@ -43,6 +46,7 @@ export const vehiclesService = {
getAll: (filters: VehicleListFilters = {}) => {
const params = new URLSearchParams();
if (filters.status) params.set('status', filters.status);
if (filters.availability) params.set('availability', filters.availability);
if (filters.search) params.set('search', filters.search);
if (filters.page) params.set('page', filters.page.toString());
if (filters.limit) params.set('limit', filters.limit.toString());