Merge branch 'freight_feature/schedule' of github.com:Tria-plc/edr-platform into freight_feature/schedule

This commit is contained in:
Marshal
2026-06-11 11:15:29 +00:00
451 changed files with 47780 additions and 6293 deletions

View File

@@ -2,14 +2,28 @@ import { api } from "../auth/http";
type ListResponse<T> = T[] | { data: T[] };
export interface WagonType {
id: string;
code: string;
name: string;
capacityTons: number;
lengthMeters: number;
maxWagonsPerTrain?: number | null;
supportedLoadTypes: string[];
isActive: boolean;
}
const asList = <T>(payload: ListResponse<T>): T[] =>
Array.isArray(payload) ? payload : payload.data;
export const wagonTypesService = {
async getWagonTypes() {
const response = await api.get<ListResponse<unknown>>('/wagon-types', {
params: { isActive: true, pageSize: 500 },
const response = await api.get<ListResponse<WagonType>>('/wagon-types', {
params: { isActive: 'all', pageSize: 500 },
});
return asList(response.data);
},
create: (data: Partial<WagonType>) => api.post('/wagon-types', data),
update: (id: string, data: Partial<WagonType>) => api.patch(`/wagon-types/${id}`, data),
delete: (id: string) => api.delete(`/wagon-types/${id}`),
};