mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 09:58:12 +00:00
merge conflict
This commit is contained in:
@@ -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}`),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user