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