mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 11:21:18 +00:00
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
// import { apiClient } from '@/lib/axios';
|
|
import { api as apiClient } from "../auth/http";
|
|
|
|
|
|
export interface Cargo {
|
|
id: string;
|
|
cargoReference: string;
|
|
shipmentId: string;
|
|
containerId: string;
|
|
cargoTypeId?: string;
|
|
description?: string;
|
|
quantity: number;
|
|
weight: number;
|
|
volume?: number;
|
|
status: 'PENDING' | 'LOADED' | 'IN_TRANSIT' | 'DELIVERED' | 'UNLOADED';
|
|
loadedAt?: string;
|
|
unloadedAt?: string;
|
|
receiverName?: string | null;
|
|
deliveredAt?: string | null;
|
|
deliveryRemarks?: string | null;
|
|
}
|
|
|
|
export interface DeliverCargoPayload {
|
|
receiverName?: string;
|
|
pickupDate?: string;
|
|
deliveryRemarks?: string;
|
|
}
|
|
|
|
export const cargoService = {
|
|
getAll: () => apiClient.get<Cargo[]>('/cargoes'),
|
|
getById: (id: string) => apiClient.get<Cargo>(`/cargoes/${id}`),
|
|
getByContainer: (containerId: string) => apiClient.get<Cargo[]>(`/cargoes?containerId=${containerId}`),
|
|
create: (data: Partial<Cargo>) => apiClient.post('/cargoes', data),
|
|
update: (id: string, data: Partial<Cargo>) => apiClient.patch(`/cargoes/${id}`, data),
|
|
delete: (id: string) => apiClient.delete(`/cargoes/${id}`),
|
|
load: (cargoId: string, quantity: number, weight: number, volume?: number) =>
|
|
apiClient.post(`/cargoes/${cargoId}/load`, { quantity, weight, volume }),
|
|
deliver: (cargoId: string, payload?: DeliverCargoPayload) =>
|
|
apiClient.post(`/cargoes/${cargoId}/deliver`, payload ?? {}),
|
|
unload: (cargoId: string) => apiClient.post(`/cargoes/${cargoId}/unload`),
|
|
};
|