mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
- Introduced StampUpload component for uploading company stamp images. - Integrated stamp upload in contract signing modal, supporting PNG and JPG formats. - Implemented validation for file type and size (max 5 MB). - Added visual feedback for drag-and-drop functionality. - Updated contract-related pages to handle duplicate contract alerts and pricing notices. - Enhanced contract expiry management with a nightly sweep service. - Added unit tests for new features and updated existing tests for contract handling.
66 lines
2.3 KiB
TypeScript
66 lines
2.3 KiB
TypeScript
import { api as apiClient } from '../auth/http';
|
|
|
|
import { URL_CONSTANTS } from '@/constants/URLS';
|
|
|
|
export type LocomotiveType = 'DIESEL' | 'ELECTRIC';
|
|
export type LocomotiveStatus =
|
|
| 'AVAILABLE'
|
|
| 'UNAVAILABLE'
|
|
| 'IMPORT_READY'
|
|
| 'EXPORT_READY'
|
|
| 'MAINTENANCE'
|
|
| 'ASSIGNED'
|
|
| 'OUT_OF_SERVICE';
|
|
|
|
export interface LocomotiveListFilters {
|
|
status?: LocomotiveStatus;
|
|
currentYardId?: string;
|
|
/** Drop locos already coupled to a built train (train-builder picker). */
|
|
excludeCoupled?: boolean;
|
|
/** With excludeCoupled: keep THIS train's own coupled locos in the list. */
|
|
excludeTrainId?: string;
|
|
}
|
|
|
|
export interface Locomotive {
|
|
id: string;
|
|
code: string;
|
|
name?: string | null;
|
|
locomotiveType: LocomotiveType;
|
|
status: LocomotiveStatus;
|
|
currentYardId: string | null;
|
|
currentYard?: { id: string; label?: string; code?: string } | null;
|
|
maxPullWeightTons: number;
|
|
maxTrainLengthMeters: number;
|
|
/** Tons a train may exceed maxPullWeightTons by before scheduling blocks it. */
|
|
overageToleranceTons?: number | null;
|
|
/** Metres a train may exceed maxTrainLengthMeters by before scheduling blocks it. */
|
|
overageToleranceMeters?: number | null;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
}
|
|
|
|
export type SaveLocomotivePayload = Omit<
|
|
Locomotive,
|
|
'id' | 'createdAt' | 'updatedAt'
|
|
>;
|
|
|
|
export const locomotivesService = {
|
|
getAll: (filters: LocomotiveListFilters = {}) => {
|
|
const params = new URLSearchParams();
|
|
if (filters.status) params.set('status', filters.status);
|
|
if (filters.currentYardId) params.set('currentYardId', filters.currentYardId);
|
|
if (filters.excludeCoupled) params.set('excludeCoupled', 'true');
|
|
if (filters.excludeTrainId) params.set('excludeTrainId', filters.excludeTrainId);
|
|
const qs = params.toString();
|
|
return apiClient.get<Locomotive[]>(
|
|
`${URL_CONSTANTS.LOCOMOTIVES.BASE}${qs ? `?${qs}` : ''}`,
|
|
);
|
|
},
|
|
getById: (id: string) => apiClient.get<Locomotive>(URL_CONSTANTS.LOCOMOTIVES.BY_ID(id)),
|
|
create: (data: Partial<SaveLocomotivePayload>) =>
|
|
apiClient.post(URL_CONSTANTS.LOCOMOTIVES.BASE, data),
|
|
update: (id: string, data: Partial<SaveLocomotivePayload>) =>
|
|
apiClient.patch(URL_CONSTANTS.LOCOMOTIVES.BY_ID(id), data),
|
|
decommission: (id: string) => apiClient.post(URL_CONSTANTS.LOCOMOTIVES.DECOMMISSION(id), {}),
|
|
};
|