mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 08:48:11 +00:00
trains, wagons,containers and cargoes schema and API
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { apiClient } from '@/lib/axios';
|
||||
|
||||
export interface Cargo {
|
||||
id: string;
|
||||
cargoReference: string;
|
||||
shipmentId: string;
|
||||
containerId: string;
|
||||
cargoTypeId?: string;
|
||||
description?: string;
|
||||
quantity: number;
|
||||
weight: number;
|
||||
volume?: number;
|
||||
status: 'PENDING' | 'LOADED' | 'IN_TRANSIT' | 'DELIVERED' | 'UNLOADED';
|
||||
loadedAt?: string;
|
||||
unloadedAt?: string;
|
||||
}
|
||||
|
||||
export const cargoService = {
|
||||
getAll: () => apiClient.get<Cargo[]>('/cargoes'),
|
||||
getByContainer: (containerId: string) => apiClient.get<Cargo[]>(`/cargoes?containerId=${containerId}`),
|
||||
create: (data: any) => apiClient.post('/cargoes', data),
|
||||
load: (cargoId: string, quantity: number, weight: number, volume?: number) =>
|
||||
apiClient.post(`/cargoes/${cargoId}/load`, { quantity, weight, volume }),
|
||||
deliver: (cargoId: string) => apiClient.post(`/cargoes/${cargoId}/deliver`),
|
||||
unload: (cargoId: string) => apiClient.post(`/cargoes/${cargoId}/unload`),
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import { apiClient } from '@/lib/axios';
|
||||
|
||||
export interface Container {
|
||||
id: string;
|
||||
containerNumber: string;
|
||||
containerTypeId: string;
|
||||
wagonId: string | null;
|
||||
position: number | null;
|
||||
tareWeight: number;
|
||||
maxGrossWeight: number;
|
||||
sealNumber?: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
export const containerService = {
|
||||
getAll: () => apiClient.get<Container[]>('/containers'),
|
||||
getByWagon: (wagonId: string) => apiClient.get<Container[]>(`/containers?wagonId=${wagonId}`),
|
||||
assignToWagon: (containerId: string, wagonId: string, position?: number) =>
|
||||
apiClient.post(`/containers/${containerId}/assign-wagon`, { wagonId, position }),
|
||||
unassign: (containerId: string) => apiClient.post(`/containers/${containerId}/unassign-wagon`),
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
import { apiClient } from '@/lib/axios';
|
||||
|
||||
export interface Train {
|
||||
id: string;
|
||||
code: string;
|
||||
capacityTons: number;
|
||||
trainNumber?: string;
|
||||
trainName?: string;
|
||||
routeId?: string;
|
||||
originStationId?: string;
|
||||
destinationStationId?: string;
|
||||
departureTime?: string;
|
||||
arrivalTime?: string;
|
||||
locomotiveNumber?: string;
|
||||
status: string;
|
||||
remarks?: string;
|
||||
}
|
||||
|
||||
export const trainService = {
|
||||
getAll: () => apiClient.get<Train[]>('/trains'),
|
||||
getById: (id: string) => apiClient.get<Train>(`/trains/${id}`),
|
||||
create: (data: Partial<Train>) => apiClient.post('/trains', data),
|
||||
update: (id: string, data: Partial<Train>) => apiClient.patch(`/trains/${id}`, data),
|
||||
delete: (id: string) => apiClient.delete(`/trains/${id}`),
|
||||
getDetails: (id: string) => apiClient.get(`/trains/${id}/details`),
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
import { apiClient } from '@/lib/axios';
|
||||
|
||||
export interface Wagon {
|
||||
id: string;
|
||||
wagonNumber: string;
|
||||
wagonTypeId: string;
|
||||
trainId: string | null;
|
||||
sequenceNumber: number | null;
|
||||
tareWeight: number;
|
||||
maxPayloadWeight: number;
|
||||
status: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export const wagonService = {
|
||||
getAll: () => apiClient.get<Wagon[]>('/wagons'),
|
||||
getByTrain: (trainId: string) => apiClient.get<Wagon[]>(`/wagons?trainId=${trainId}`),
|
||||
assignToTrain: (wagonId: string, trainId: string, sequenceNumber?: number) =>
|
||||
apiClient.post(`/wagons/${wagonId}/assign-train`, { trainId, sequenceNumber }),
|
||||
unassign: (wagonId: string) => apiClient.post(`/wagons/${wagonId}/unassign-train`),
|
||||
reorder: (trainId: string, wagonIds: string[]) =>
|
||||
apiClient.post(`/trains/${trainId}/reorder-wagons`, { wagonIds }),
|
||||
create: (data: Partial<Wagon>) => apiClient.post('/wagons', data),
|
||||
update: (id: string, data: Partial<Wagon>) => apiClient.patch(`/wagons/${id}`, data),
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user