mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
30 lines
835 B
TypeScript
30 lines
835 B
TypeScript
import type { Freight, PaginatedResponse } from "@edr/types";
|
|
|
|
import { api } from "../utils/api";
|
|
|
|
export interface CreateBookingPayload {
|
|
reference: string;
|
|
customerId: string;
|
|
scheduledDate: string;
|
|
totalAmount: number;
|
|
trainId?: string;
|
|
}
|
|
|
|
export const bookingsService = {
|
|
list: async (): Promise<PaginatedResponse<Freight.IBooking>> => {
|
|
const { data } = await api.get("/bookings");
|
|
return data.data;
|
|
},
|
|
get: async (id: string): Promise<Freight.IBooking> => {
|
|
const { data } = await api.get(`/bookings/${id}`);
|
|
return data.data;
|
|
},
|
|
create: async (payload: CreateBookingPayload): Promise<Freight.IBooking> => {
|
|
const { data } = await api.post("/bookings", payload);
|
|
return data.data;
|
|
},
|
|
remove: async (id: string): Promise<void> => {
|
|
await api.delete(`/bookings/${id}`);
|
|
},
|
|
};
|