feat(train-scheduling): implement API and types for bookable schedules

This commit is contained in:
ghost2023
2026-06-13 09:29:45 +03:00
parent 28f9d58e0a
commit 6058b870a1
4 changed files with 54 additions and 0 deletions

View File

@@ -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",
},
};

View File

@@ -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: {

View File

@@ -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;
},
};

View File

@@ -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 {