refactor: revamped vehicle manager adjusted for new API, improved file structure

This commit is contained in:
2025-11-24 02:13:47 +01:00
parent a176e46eef
commit 8c7449a7e3
8 changed files with 396 additions and 271 deletions
+32 -9
View File
@@ -1,4 +1,14 @@
export type VehicleAPIResponse = IVehicle[];
export type VehicleAPIResponse = IVehicleAPI[];
export type VehicleGroupAPIResponse = IVehicleGroup[];
export interface IVehicleAPI {
id: number;
name: string;
type: string;
cabinName?: string;
restrictions?: IVehicleRestrictions;
vehicleGroupsId: number;
}
export interface IVehicle {
id: number;
@@ -6,7 +16,6 @@ export interface IVehicle {
type: string;
cabinName?: string;
restrictions?: IVehicleRestrictions;
vehicleGroupsId: number;
group: IVehicleGroup;
}
@@ -15,14 +24,24 @@ export interface IVehicleRestrictions {
teamOnly?: boolean;
}
export interface IVehicleGroupMassSpeeds {
none: number;
passenger: Record<number, number> | null;
cargo: Record<number, number> | null;
}
export interface IVehicleGroup {
id: number;
name: string;
speed: number;
speedLoaded: number | null;
speedLoco: number | null;
length: number;
weight: number;
cargoTypes?: IVehicleCargoType[];
locoProps?: IVehicleLocoProps;
cargoTypes: IVehicleCargoType[] | null;
locoProps: IVehicleLocoProps | null;
massSpeeds: IVehicleGroupMassSpeeds | null;
_count: { vehicles: number };
}
export interface IVehicleCargoType {
@@ -37,17 +56,21 @@ export interface IVehicleLocoProps {
export interface IVehicleTableRow {
vehicleRef: IVehicle;
pendingChanges: Partial<IVehicle>;
// pendingChanges: Partial<IVehicle>;
}
export interface IVehicleGroupTableRow {
vehicleGroupRef: IVehicleGroup;
// pendingChanges: Partial<IVehicleGroup>;
}
export enum VehicleEditRowKey {
NAME = 'name',
TYPE = 'type',
CABIN = 'cabinName',
}
export enum VehicleEditRestrictionKey {
SPONSOR_ONLY = "sponsorOnly",
TEAM_ONLY = "teamOnly"
}
SPONSOR_ONLY = 'sponsorOnly',
TEAM_ONLY = 'teamOnly',
}