mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 07:38:10 +00:00
resolve conflict
This commit is contained in:
@@ -305,16 +305,10 @@ export const api = {
|
||||
bookingsService.signContract(id, payload),
|
||||
),
|
||||
|
||||
generatePnr: endpoint<{ id: string }, BookingDetail>(
|
||||
payBooking: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"generatePnr",
|
||||
({ id }) => bookingsService.generatePnr(id),
|
||||
),
|
||||
|
||||
verifyPayment: endpoint<{ id: string }, BookingDetail>(
|
||||
"bookings",
|
||||
"verifyPayment",
|
||||
({ id }) => bookingsService.verifyPayment(id),
|
||||
"payBooking",
|
||||
({ id }) => bookingsService.payBooking(id),
|
||||
),
|
||||
|
||||
startTransit: endpoint<{ id: string }, BookingDetail>(
|
||||
|
||||
@@ -7,6 +7,10 @@ const B = URL_CONSTANTS.BOOKINGS;
|
||||
|
||||
export interface BookingListFilter {
|
||||
status?: string;
|
||||
/** Comma-separated statuses for grouped tabs */
|
||||
statuses?: string;
|
||||
/** Tab key for React Query cache (not sent to API) */
|
||||
tab?: string;
|
||||
// customerId?: string;
|
||||
companyId?: string;
|
||||
freightType?: string;
|
||||
@@ -23,6 +27,29 @@ export interface PaginatedBookings {
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface BookingListSummaryMetrics {
|
||||
inQueue: number;
|
||||
onThisPage: number;
|
||||
needsAction: number;
|
||||
urgent: number;
|
||||
}
|
||||
|
||||
export interface BookingListSummaryTabs {
|
||||
all: number;
|
||||
intake: number;
|
||||
in_approval: number;
|
||||
approved_contract: number;
|
||||
payment: number;
|
||||
operations: number;
|
||||
completed: number;
|
||||
closed: number;
|
||||
}
|
||||
|
||||
export interface BookingListSummary {
|
||||
metrics: BookingListSummaryMetrics;
|
||||
tabs: BookingListSummaryTabs;
|
||||
}
|
||||
|
||||
export interface ApproveStepPayload {
|
||||
id: string;
|
||||
stepId: string;
|
||||
@@ -66,9 +93,41 @@ async function postBooking<T>(url: string, body?: unknown): Promise<T> {
|
||||
}
|
||||
|
||||
export const bookingsService = {
|
||||
getListSummary: async (filter?: BookingListFilter): Promise<BookingListSummary> => {
|
||||
const params: Record<string, string | number | boolean | undefined> = {};
|
||||
if (filter) {
|
||||
if (filter.statuses) params.statuses = filter.statuses;
|
||||
else if (filter.status) params.status = filter.status;
|
||||
if (filter.page != null) params.page = filter.page;
|
||||
if (filter.pageSize != null) params.pageSize = filter.pageSize;
|
||||
if (filter.companyId) params.companyId = filter.companyId;
|
||||
if (filter.freightType) params.freightType = filter.freightType;
|
||||
if (filter.tradeDirection) params.tradeDirection = filter.tradeDirection;
|
||||
if (filter.paymentCurrency) params.paymentCurrency = filter.paymentCurrency;
|
||||
}
|
||||
const response = await client.get<BookingListSummary>(B.LIST_SUMMARY, {
|
||||
params,
|
||||
});
|
||||
return unwrap(response.data) as BookingListSummary;
|
||||
},
|
||||
|
||||
list: async (filter?: BookingListFilter): Promise<PaginatedBookings> => {
|
||||
const params: Record<string, string | number | boolean | undefined> = {};
|
||||
if (filter) {
|
||||
if (filter.statuses) params.statuses = filter.statuses;
|
||||
else if (filter.status) params.status = filter.status;
|
||||
// filter.tab is intentionally omitted from API params
|
||||
if (filter.page != null) params.page = filter.page;
|
||||
if (filter.pageSize != null) params.pageSize = filter.pageSize;
|
||||
if (filter.sortBy) params.sortBy = filter.sortBy;
|
||||
if (filter.sortOrder) params.sortOrder = filter.sortOrder;
|
||||
if (filter.companyId) params.companyId = filter.companyId;
|
||||
if (filter.freightType) params.freightType = filter.freightType;
|
||||
if (filter.tradeDirection) params.tradeDirection = filter.tradeDirection;
|
||||
if (filter.paymentCurrency) params.paymentCurrency = filter.paymentCurrency;
|
||||
}
|
||||
const response = await client.get<PaginatedBookings>(B.BASE, {
|
||||
params: filter,
|
||||
params,
|
||||
});
|
||||
const data = unwrap(response.data);
|
||||
return {
|
||||
@@ -112,14 +171,14 @@ export const bookingsService = {
|
||||
const response = await client.get(B.CONTRACT_DOWNLOAD(id), {
|
||||
responseType: "blob",
|
||||
});
|
||||
return response.data as Blob;
|
||||
return ensurePdfBlob(response.data as Blob);
|
||||
},
|
||||
|
||||
downloadContractDocument: async (id: string): Promise<Blob> => {
|
||||
const response = await client.get(B.CONTRACT_DOCUMENT(id), {
|
||||
responseType: "blob",
|
||||
});
|
||||
return response.data as Blob;
|
||||
return ensurePdfBlob(response.data as Blob);
|
||||
},
|
||||
|
||||
signContract: (id: string, payload: SignContractPayload) =>
|
||||
@@ -142,26 +201,7 @@ export const bookingsService = {
|
||||
role: "STAFF",
|
||||
}),
|
||||
|
||||
generatePnr: (id: string) => postBooking<BookingDetail>(B.PAYMENT_PNR(id)),
|
||||
|
||||
submitPaymentProof: async (id: string, file: File): Promise<BookingDetail> => {
|
||||
const form = new FormData();
|
||||
form.append("file", file);
|
||||
const response = await client.post<BookingDetail>(B.PAYMENT_PROOF(id), form, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return unwrap(response.data) as BookingDetail;
|
||||
},
|
||||
|
||||
verifyPayment: (id: string) =>
|
||||
postBooking<BookingDetail>(B.PAYMENT_VERIFY(id)),
|
||||
|
||||
downloadPaymentRequestLetter: async (id: string): Promise<Blob> => {
|
||||
const response = await client.get(B.PAYMENT_REQUEST_LETTER(id), {
|
||||
responseType: "blob",
|
||||
});
|
||||
return response.data as Blob;
|
||||
},
|
||||
payBooking: (id: string) => postBooking<BookingDetail>(B.PAYMENT_PAY(id)),
|
||||
|
||||
startTransit: (id: string) =>
|
||||
postBooking<BookingDetail>(B.START_TRANSIT(id)),
|
||||
@@ -171,3 +211,11 @@ export const bookingsService = {
|
||||
cancel: (id: string, reason: string) =>
|
||||
postBooking<BookingDetail>(B.CANCEL(id), { reason }),
|
||||
};
|
||||
|
||||
async function ensurePdfBlob(blob: Blob): Promise<Blob> {
|
||||
if (blob.type.includes("application/json")) {
|
||||
const body = JSON.parse(await blob.text()) as { message?: string };
|
||||
throw new Error(body.message ?? "Contract PDF download failed");
|
||||
}
|
||||
return blob;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { apiClient } from '@/lib/axios';
|
||||
// import { apiClient } from '@/lib/axios';
|
||||
import { api as apiClient } from "../auth/http";
|
||||
|
||||
|
||||
export interface Cargo {
|
||||
id: string;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { apiClient } from '@/lib/axios';
|
||||
// import { apiClient } from '@/lib/axios';
|
||||
import { api as apiClient } from "../auth/http";
|
||||
|
||||
|
||||
export interface Container {
|
||||
id: string;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
//import { apiClient } from '@/lib/axios';
|
||||
import { api as client } from "@/auth/http";
|
||||
// import { apiClient } from '@/lib/axios';
|
||||
import { api as apiClient } from "../auth/http";
|
||||
|
||||
|
||||
export interface Train {
|
||||
id: string;
|
||||
code: string;
|
||||
@@ -17,10 +19,10 @@ export interface Train {
|
||||
}
|
||||
|
||||
export const trainService = {
|
||||
getAll: () => client.get<Train[]>('/trains'),
|
||||
getById: (id: string) => client.get<Train>(`/trains/${id}`),
|
||||
create: (data: Partial<Train>) => client.post('/trains', data),
|
||||
update: (id: string, data: Partial<Train>) => client.patch(`/trains/${id}`, data),
|
||||
delete: (id: string) => client.delete(`/trains/${id}`),
|
||||
getDetails: (id: string) => client.get(`/trains/${id}/details`),
|
||||
getAll: () => apiClient.get<Train[]>('/trains'),
|
||||
getById: (id: string) => apiClient.get<Train>(`/trains/${id}`),
|
||||
create: (data: Partial<Train>) => apiClient.post('/trains', data),
|
||||
update: (id: string, data: Partial<Train>) => apiClient.patch(`/trains/${id}`, data),
|
||||
delete: (id: string) => apiClient.delete(`/trains/${id}`),
|
||||
getDetails: (id: string) => apiClient .get(`/trains/${id}/details`),
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import { apiClient } from '@/lib/axios';
|
||||
import { api as apiClient } from "../auth/http";
|
||||
|
||||
export interface Wagon {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user