This commit is contained in:
natib21
2026-07-02 11:22:35 +00:00
parent bab329e8e5
commit ff7e20d2ee
4 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
/**
* Add location_id column to vehicles table to track vehicle base location.
*/
export class AddLocationToVehicles1870000000000 implements MigrationInterface {
name = "AddLocationToVehicles1870000000000";
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE freight.vehicles
ADD COLUMN IF NOT EXISTS location_id uuid;
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE freight.vehicles
DROP COLUMN IF EXISTS location_id;
`);
}
}

View File

@@ -68,4 +68,7 @@ export class Vehicle extends BaseEntity {
@Column({ name: 'actual_distance_km', type: 'numeric', nullable: true })
actualDistanceKm?: number;
@Column({ name: 'location_id', type: 'uuid', nullable: true })
locationId?: string;
}

View File

@@ -74,6 +74,7 @@ export const vehiclesConfig: FleetResourceConfig = {
{ 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: "locationId", label: "Location", type: "select", dataSource: "yards" },
{ name: "estimatedDistanceKm", label: "Estimated Distance (KM)", type: "number" },
{ name: "actualDistanceKm", label: "Actual Distance (KM)", type: "number" },
{ name: "status", label: "Status", type: "select", required: true, options: VEHICLE_STATUS_OPTIONS },
@@ -90,6 +91,7 @@ export const vehiclesConfig: FleetResourceConfig = {
year: new Date().getFullYear(),
fuelType: "DIESEL",
capacity: 0,
locationId: null,
estimatedDistanceKm: "",
actualDistanceKm: "",
status: "ACTIVE",

View File

@@ -29,6 +29,7 @@ export interface Vehicle {
code?: string | null;
powerPlateNo?: string | null;
trailerPlateNo?: string | null;
locationId?: string | null;
createdAt: string;
updatedAt: string;
}
@@ -55,7 +56,7 @@ export const vehiclesService = {
getById: (id: string) => apiClient.get<Vehicle>(URL_CONSTANTS.VEHICLES.BY_ID(id)),
create: (data: Partial<SaveVehiclePayload>) =>
apiClient.post(URL_CONSTANTS.VEHICLES.BASE, data),
update: (id: string, data: Partial<SaveVehiclePayload>) =>
update: (id: string, data: Partial<SaveVehiclePayload & { locationId?: string | null }>) =>
apiClient.patch(URL_CONSTANTS.VEHICLES.BY_ID(id), data),
delete: (id: string) => apiClient.delete(URL_CONSTANTS.VEHICLES.BY_ID(id)),
};