mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 11:45:34 +00:00
refactor(api): changed fetching data from the new api endpoint
This commit is contained in:
+4
-1
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ export interface IVehicleData {
|
||||
cabinName: string | null;
|
||||
restrictions: IVehicleRestrictions | null;
|
||||
vehicleGroupsId: number;
|
||||
simulatorVersion: string;
|
||||
group: IVehicleGroup;
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user