mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
feat(train-scheduling): implement API and types for bookable schedules
This commit is contained in:
@@ -96,4 +96,8 @@ export const URL_CONSTANTS = {
|
||||
CANCEL: (id: string | number) => `/api/bookings/${id}/cancel`,
|
||||
CONFIRM: (id: string | number) => `/api/bookings/${id}/confirm`,
|
||||
},
|
||||
|
||||
TRAIN_SCHEDULING: {
|
||||
BOOKABLE_SCHEDULES: "/api/train-scheduling/bookable-schedules",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -185,6 +185,13 @@ export const api = {
|
||||
"checkPayment",
|
||||
({ orderId }) => bookingsService.checkPayment(orderId),
|
||||
),
|
||||
|
||||
getBookableSchedules: endpoint<
|
||||
{ originYardId?: string; destinationYardId?: string },
|
||||
Freight.BookableScheduleItem[]
|
||||
>("train-scheduling", "bookableSchedules", ({ originYardId, destinationYardId }) =>
|
||||
bookingsService.getBookableSchedules({ originYardId, destinationYardId }),
|
||||
),
|
||||
},
|
||||
|
||||
consignments: {
|
||||
|
||||
@@ -151,4 +151,14 @@ export const bookingsService = {
|
||||
const { data } = await client.post(B.CONTRACT_SIGN(id), payload);
|
||||
return data.data ?? data;
|
||||
},
|
||||
|
||||
getBookableSchedules: async (
|
||||
query: Freight.BookableSchedulesQuery = {},
|
||||
): Promise<Freight.BookableScheduleItem[]> => {
|
||||
const { data } = await client.get(
|
||||
URL_CONSTANTS.TRAIN_SCHEDULING.BOOKABLE_SCHEDULES,
|
||||
{ params: query },
|
||||
);
|
||||
return data.data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -420,6 +420,39 @@ export interface BookingReferenceData {
|
||||
cargo_type: BookingReferenceCargoTypeGroup[];
|
||||
}
|
||||
|
||||
// ── Train Scheduling (bookable schedules) ──────────────────────────────────────
|
||||
|
||||
export interface BookableSchedulesQuery {
|
||||
originYardId?: string;
|
||||
destinationYardId?: string;
|
||||
}
|
||||
|
||||
export interface BookableScheduleLocomotive {
|
||||
id: string;
|
||||
code: string;
|
||||
name: string | null;
|
||||
readiness: string | null;
|
||||
}
|
||||
|
||||
export interface BookableScheduleItem {
|
||||
id: string;
|
||||
scheduleDate: string;
|
||||
trainNumber: string | null;
|
||||
routeName: string | null;
|
||||
origin: string | null;
|
||||
destination: string | null;
|
||||
locomotive: BookableScheduleLocomotive | null;
|
||||
wagonCount: number;
|
||||
totalWeightTons: number;
|
||||
totalLengthMeters: number;
|
||||
bookingsCount: number;
|
||||
freightType: FreightType | "MIXED" | null;
|
||||
status: TrainScheduleStatus;
|
||||
bookingWindowStatus: ScheduleBookingWindow;
|
||||
maxWagons: number;
|
||||
remainingWagons: number;
|
||||
}
|
||||
|
||||
// ── DTOs ───────────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface CreateBookingContainerDto {
|
||||
|
||||
Reference in New Issue
Block a user