mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 13:40:57 +00:00
export loading
This commit is contained in:
@@ -79,6 +79,42 @@ export interface ContainerItem {
|
||||
hasLastMile: boolean;
|
||||
}
|
||||
|
||||
/** A pre-dispatch EXPORT train that has inventory waiting to be loaded. */
|
||||
export interface LoadableTrain {
|
||||
scheduleId: string;
|
||||
trainNumber: string | null;
|
||||
origin: string | null;
|
||||
destination: string | null;
|
||||
status: string;
|
||||
departureTime: string | null;
|
||||
readyCount: number;
|
||||
loadedCount: number;
|
||||
}
|
||||
|
||||
/** A container/cargo inventory item assigned to a train, with its allocated wagon. */
|
||||
export interface TrainLoadableItem {
|
||||
id: string;
|
||||
bookingId: string | null;
|
||||
bookingReference: string | null;
|
||||
customerName: string | null;
|
||||
containerNumber: string | null;
|
||||
cargoType: string | null;
|
||||
weight: number | null;
|
||||
grnNumber: string | null;
|
||||
inspectionStatus: string | null;
|
||||
status: string;
|
||||
wagonId: string | null;
|
||||
wagonNumber: string | null;
|
||||
sequenceNo: number | null;
|
||||
loadable: boolean;
|
||||
}
|
||||
|
||||
export interface TrainLoadResult {
|
||||
loadedCount: number;
|
||||
skippedCount: number;
|
||||
results: { inventoryId: string; status: string; reason?: string }[];
|
||||
}
|
||||
|
||||
const cleanParams = (params: object) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(params).filter(([, value]) => value !== undefined && value !== '' && value !== null),
|
||||
@@ -120,6 +156,33 @@ export const warehouseService = {
|
||||
return data?.data ?? data ?? [];
|
||||
},
|
||||
|
||||
// ── Load to Train ─────────────────────────────────────────────────────────
|
||||
/** Pre-dispatch EXPORT trains with inventory waiting to be loaded. */
|
||||
getLoadableTrains: async (): Promise<LoadableTrain[]> => {
|
||||
const { data } = await apiClient.get('/warehouse-inventory/loadable-trains');
|
||||
return data?.data ?? data ?? [];
|
||||
},
|
||||
|
||||
/** Container/cargo items assigned to a train, with allocated wagon + stage. */
|
||||
getTrainLoadableItems: async (scheduleId: string): Promise<TrainLoadableItem[]> => {
|
||||
const { data } = await apiClient.get(
|
||||
`/warehouse-inventory/train/${scheduleId}/loadable-items`,
|
||||
);
|
||||
return data?.data ?? data ?? [];
|
||||
},
|
||||
|
||||
/** Load selected inventory items onto their allocated wagons for a train. */
|
||||
loadItemsOntoTrain: async (
|
||||
scheduleId: string,
|
||||
inventoryIds: string[],
|
||||
): Promise<TrainLoadResult> => {
|
||||
const { data } = await apiClient.post(
|
||||
`/warehouse-inventory/train/${scheduleId}/load`,
|
||||
{ inventoryIds },
|
||||
);
|
||||
return data?.data ?? data ?? { loadedCount: 0, skippedCount: 0, results: [] };
|
||||
},
|
||||
|
||||
// ── Warehouses ──────────────────────────────────────────────────────────
|
||||
list: (filter?: WarehouseFilter) =>
|
||||
apiClient.get<Warehouse[]>(URL_CONSTANTS.WAREHOUSES.BASE, {
|
||||
|
||||
Reference in New Issue
Block a user