mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 02:58:11 +00:00
Trains management CRUD issues solved
This commit is contained in:
@@ -19,8 +19,11 @@ export interface Cargo {
|
||||
|
||||
export const cargoService = {
|
||||
getAll: () => apiClient.get<Cargo[]>('/cargoes'),
|
||||
getById: (id: string) => apiClient.get<Cargo>(`/cargoes/${id}`),
|
||||
getByContainer: (containerId: string) => apiClient.get<Cargo[]>(`/cargoes?containerId=${containerId}`),
|
||||
create: (data: any) => apiClient.post('/cargoes', data),
|
||||
create: (data: Partial<Cargo>) => apiClient.post('/cargoes', data),
|
||||
update: (id: string, data: Partial<Cargo>) => apiClient.patch(`/cargoes/${id}`, data),
|
||||
delete: (id: string) => apiClient.delete(`/cargoes/${id}`),
|
||||
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`),
|
||||
|
||||
@@ -16,8 +16,12 @@ export interface Container {
|
||||
|
||||
export const containerService = {
|
||||
getAll: () => apiClient.get<Container[]>('/containers'),
|
||||
getById: (id: string) => apiClient.get<Container>(`/containers/${id}`),
|
||||
getByWagon: (wagonId: string) => apiClient.get<Container[]>(`/containers?wagonId=${wagonId}`),
|
||||
create: (data: Partial<Container>) => apiClient.post('/containers', data),
|
||||
update: (id: string, data: Partial<Container>) => apiClient.patch(`/containers/${id}`, data),
|
||||
delete: (id: string) => apiClient.delete(`/containers/${id}`),
|
||||
assignToWagon: (containerId: string, wagonId: string, position?: number) =>
|
||||
apiClient.post(`/containers/${containerId}/assign-wagon`, { wagonId, position }),
|
||||
unassign: (containerId: string) => apiClient.post(`/containers/${containerId}/unassign-wagon`),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ import type {
|
||||
} from '@/types/trainScheduling';
|
||||
|
||||
interface BookingReferenceDataResponse {
|
||||
yard?: YardOption[];
|
||||
yard?: Array<YardOption & { label?: string }>;
|
||||
}
|
||||
|
||||
export const trainSchedulingService = {
|
||||
@@ -82,6 +82,11 @@ export const trainSchedulingService = {
|
||||
URL_CONSTANTS.BOOKINGS.REFERENCE_DATA,
|
||||
);
|
||||
const data = unwrap(response.data);
|
||||
return data.yard ?? [];
|
||||
return (data.yard ?? []).map((yard) => ({
|
||||
id: yard.id,
|
||||
name: yard.name ?? yard.label ?? yard.code,
|
||||
code: yard.code,
|
||||
country: yard.country,
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,13 +14,14 @@ export interface Wagon {
|
||||
|
||||
export const wagonService = {
|
||||
getAll: () => apiClient.get<Wagon[]>('/wagons'),
|
||||
getById: (id: string) => apiClient.get<Wagon>(`/wagons/${id}`),
|
||||
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),
|
||||
|
||||
};
|
||||
create: (data: Partial<Wagon>) => apiClient.post('/wagons', data),
|
||||
update: (id: string, data: Partial<Wagon>) => apiClient.patch(`/wagons/${id}`, data),
|
||||
delete: (id: string) => apiClient.delete(`/wagons/${id}`),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user