mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-04 03:58:11 +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() {
|
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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user