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() { async fetchVehiclesAPI() {
try { try {
const response = await this.httpClient.get<API.VehiclesData.Response>('api/getVehiclesData'); 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); console.log(response);
} catch (error) { } catch (error) {
+4 -1
View File
@@ -1,3 +1,5 @@
import { IVehicleRestrictions } from './common.types';
// API namespace // API namespace
export namespace API { export namespace API {
export namespace VehiclesData { export namespace VehiclesData {
@@ -6,7 +8,8 @@ export namespace API {
name: string; name: string;
type: string; type: string;
cabinName: string | null; cabinName: string | null;
restrictions: Record<string, any> | null; restrictions: IVehicleRestrictions | null;
vehicleGroupsId: number; vehicleGroupsId: number;
} }
-1
View File
@@ -74,7 +74,6 @@ export interface IVehicleData {
cabinName: string | null; cabinName: string | null;
restrictions: IVehicleRestrictions | null; restrictions: IVehicleRestrictions | null;
vehicleGroupsId: number; vehicleGroupsId: number;
simulatorVersion: string;
group: IVehicleGroup; group: IVehicleGroup;
} }
+11 -10
View File
@@ -95,16 +95,17 @@ export function carDataList(vehiclesData: IVehicleData[] | undefined) {
const cargoTypes = data.group.cargoTypes || []; const cargoTypes = data.group.cargoTypes || [];
if (/412Z|627Z/.test(data.group.name)) { // UNUSED - ADDITIONAL CARGO TYPES FOR INTERMODALS
cargoTypes.push( // if (/412Z|627Z/.test(data.group.name)) {
...additionalCargoTypes // cargoTypes.push(
.filter((c) => c.groupType == data.group.name) // ...additionalCargoTypes
.map((c) => ({ // .filter((c) => c.groupType == data.group.name)
id: c.id, // .map((c) => ({
weight: c.weight, // id: c.id,
})) // weight: c.weight,
); // }))
} // );
// }
acc.push({ acc.push({
group: data.type as WagonGroupType, group: data.type as WagonGroupType,