mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 05:58:18 +00:00
Project Initialization
This commit is contained in:
29
apps/edr-freight-web/portal/src/services/bookings.service.ts
Normal file
29
apps/edr-freight-web/portal/src/services/bookings.service.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
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}`);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { Freight, PaginatedResponse } from '@edr/types';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
|
||||
export const consignmentsService = {
|
||||
list: async (): Promise<PaginatedResponse<Freight.IConsignment>> => {
|
||||
const { data } = await api.get('/consignments');
|
||||
return data.data;
|
||||
},
|
||||
get: async (id: string): Promise<Freight.IConsignment> => {
|
||||
const { data } = await api.get(`/consignments/${id}`);
|
||||
return data.data;
|
||||
},
|
||||
};
|
||||
10
apps/edr-freight-web/portal/src/services/tracking.service.ts
Normal file
10
apps/edr-freight-web/portal/src/services/tracking.service.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Freight } from '@edr/types';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
|
||||
export const trackingService = {
|
||||
forConsignment: async (consignmentId: string): Promise<Freight.ITrackingEvent[]> => {
|
||||
const { data } = await api.get(`/tracking/${consignmentId}`);
|
||||
return data.data;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user