refactor(api): changed fetching data from the new api endpoint

This commit is contained in:
2026-04-04 21:13:43 +02:00
parent a37c9916b5
commit a86ba561ea
4 changed files with 19 additions and 13 deletions
+4 -1
View File
@@ -130,7 +130,10 @@ export const useStore = defineStore('store', {
async fetchVehiclesAPI() {
try {
const response = await this.httpClient.get<API.VehiclesData.Response>('api/getVehiclesData');
// this.vehiclesData = response.;
this.vehiclesData = response.vehicles.map((v) => ({
...v,
group: response.vehicleGroups.find((g) => g.id == v.vehicleGroupsId)!,
}));
console.log(response);
} catch (error) {
+4 -1
View File
@@ -1,3 +1,5 @@
import { IVehicleRestrictions } from './common.types';
// API namespace
export namespace API {
export namespace VehiclesData {
@@ -6,7 +8,8 @@ export namespace API {
name: string;
type: string;
cabinName: string | null;
restrictions: Record<string, any> | null;
restrictions: IVehicleRestrictions | null;
vehicleGroupsId: number;
}
-1
View File
@@ -74,7 +74,6 @@ export interface IVehicleData {
cabinName: string | null;
restrictions: IVehicleRestrictions | null;
vehicleGroupsId: number;
simulatorVersion: string;
group: IVehicleGroup;
}
+11 -10
View File
@@ -95,16 +95,17 @@ export function carDataList(vehiclesData: IVehicleData[] | undefined) {
const cargoTypes = data.group.cargoTypes || [];
if (/412Z|627Z/.test(data.group.name)) {
cargoTypes.push(
...additionalCargoTypes
.filter((c) => c.groupType == data.group.name)
.map((c) => ({
id: c.id,
weight: c.weight,
}))
);
}
// UNUSED - ADDITIONAL CARGO TYPES FOR INTERMODALS
// if (/412Z|627Z/.test(data.group.name)) {
// cargoTypes.push(
// ...additionalCargoTypes
// .filter((c) => c.groupType == data.group.name)
// .map((c) => ({
// id: c.id,
// weight: c.weight,
// }))
// );
// }
acc.push({
group: data.type as WagonGroupType,