mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 13:38:13 +00:00
refactor: code organization
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
export enum AuthState {
|
||||
'LOADING' = 0,
|
||||
'AUTHORIZED' = 1,
|
||||
'UNAUTHORIZED' = 2,
|
||||
}
|
||||
|
||||
export interface IUser {
|
||||
name: string;
|
||||
id: number;
|
||||
iat?: number;
|
||||
}
|
||||
|
||||
export interface ILoginResponse {
|
||||
token: string;
|
||||
user: IUser;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export enum LoadingState {
|
||||
LOADING = 0,
|
||||
SUCCESS = 1,
|
||||
ERROR = 2,
|
||||
INIT = 3,
|
||||
}
|
||||
@@ -1,129 +1,114 @@
|
||||
export type Availability = 'default' | 'unavailable' | 'nonPublic' | 'abandoned' | 'nonDefault';
|
||||
export type ChangeProp =
|
||||
| 'name'
|
||||
| 'hash'
|
||||
| 'url'
|
||||
| 'lines'
|
||||
| 'project'
|
||||
| 'projectUrl'
|
||||
| 'reqLevel'
|
||||
| 'signalType'
|
||||
| 'controlType'
|
||||
| 'SUP'
|
||||
| 'ASDEK'
|
||||
| 'routesInfo'
|
||||
| 'checkpoints'
|
||||
| 'authors'
|
||||
| 'availability'
|
||||
| 'hidden';
|
||||
|
||||
export enum HeaderTypes {
|
||||
name = 'Nazwa',
|
||||
abbr = 'Skrót posterunku',
|
||||
url = 'URL',
|
||||
hash = 'Hash',
|
||||
lines = 'Linie',
|
||||
project = 'Projekt',
|
||||
projectUrl = 'URL projektu',
|
||||
reqLevel = 'Wym. poziom',
|
||||
signalType = 'Sygnalizacja',
|
||||
controlType = 'Sterowanie',
|
||||
SUP = 'SUP',
|
||||
ASDEK = 'ASDEK',
|
||||
authors = 'Autorzy',
|
||||
routesInfo = 'Szlaki',
|
||||
checkpoints = 'Posterunki',
|
||||
availability = 'Dostępność',
|
||||
hidden = 'Ukryty',
|
||||
toRemove = 'Usuń',
|
||||
}
|
||||
|
||||
export enum AvailabilityTypes {
|
||||
'default' = 'w paczce',
|
||||
'nonDefault' = 'poza paczką',
|
||||
'nonPublic' = 'niepubliczna',
|
||||
'abandoned' = 'wycofana',
|
||||
'unavailable' = 'niedostępna',
|
||||
}
|
||||
|
||||
export interface SceneryRoutesInfo {
|
||||
routeName: string;
|
||||
isElectric: boolean;
|
||||
isRouteSBL: boolean;
|
||||
isInternal: boolean;
|
||||
routeSpeed: number;
|
||||
routeLength: number;
|
||||
routeTracks: number;
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
export interface SceneryRowItem {
|
||||
id: string | number;
|
||||
hash: string;
|
||||
name: string;
|
||||
abbr: string;
|
||||
url: string;
|
||||
lines: string;
|
||||
project: string | null;
|
||||
projectUrl: string | null;
|
||||
reqLevel: number;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
SUP: boolean;
|
||||
ASDEK: boolean;
|
||||
hidden: boolean;
|
||||
routesInfo: SceneryRoutesInfo[];
|
||||
checkpoints: string;
|
||||
authors: string;
|
||||
availability: Availability;
|
||||
}
|
||||
|
||||
export type ChangeItem = {
|
||||
[key in ChangeProp]?: any;
|
||||
} & {
|
||||
id: string | number;
|
||||
name: string;
|
||||
|
||||
toRemove?: boolean;
|
||||
};
|
||||
|
||||
export enum AuthState {
|
||||
'LOADING' = 0,
|
||||
'AUTHORIZED' = 1,
|
||||
'UNAUTHORIZED' = 2,
|
||||
}
|
||||
|
||||
export interface IUser {
|
||||
name: string;
|
||||
id: number;
|
||||
iat?: number;
|
||||
}
|
||||
|
||||
export interface IStore {
|
||||
dataState: string;
|
||||
authState: AuthState;
|
||||
|
||||
stationList: SceneryRowItem[];
|
||||
backupList: SceneryRowItem[];
|
||||
stationsToRemove: string[];
|
||||
searchedSceneryName: string;
|
||||
changeList: ChangeItem[];
|
||||
newStationsCount: number;
|
||||
routesModalVisible: boolean;
|
||||
currentStation: SceneryRowItem | null;
|
||||
selectedStationName: string;
|
||||
// token: string | null;
|
||||
user: IUser | null;
|
||||
notifyDiscord: boolean;
|
||||
alertMessage: string;
|
||||
confirmMessage: string;
|
||||
|
||||
maxVisibleResults: number;
|
||||
|
||||
changesResponse: string[];
|
||||
}
|
||||
|
||||
export interface ILoginResponse {
|
||||
token: string;
|
||||
user: IUser;
|
||||
}
|
||||
import { AuthState, IUser } from './auth.types';
|
||||
|
||||
export interface ISceneriesStore {
|
||||
dataState: string;
|
||||
authState: AuthState;
|
||||
|
||||
stationList: SceneryRowItem[];
|
||||
backupList: SceneryRowItem[];
|
||||
stationsToRemove: string[];
|
||||
searchedSceneryName: string;
|
||||
changeList: ChangeItem[];
|
||||
newStationsCount: number;
|
||||
routesModalVisible: boolean;
|
||||
currentStation: SceneryRowItem | null;
|
||||
selectedStationName: string;
|
||||
// token: string | null;
|
||||
user: IUser | null;
|
||||
notifyDiscord: boolean;
|
||||
alertMessage: string;
|
||||
confirmMessage: string;
|
||||
|
||||
maxVisibleResults: number;
|
||||
|
||||
changesResponse: string[];
|
||||
}
|
||||
|
||||
export type Availability = 'default' | 'unavailable' | 'nonPublic' | 'abandoned' | 'nonDefault';
|
||||
export type ChangeProp =
|
||||
| 'name'
|
||||
| 'hash'
|
||||
| 'url'
|
||||
| 'lines'
|
||||
| 'project'
|
||||
| 'projectUrl'
|
||||
| 'reqLevel'
|
||||
| 'signalType'
|
||||
| 'controlType'
|
||||
| 'SUP'
|
||||
| 'ASDEK'
|
||||
| 'routesInfo'
|
||||
| 'checkpoints'
|
||||
| 'authors'
|
||||
| 'availability'
|
||||
| 'hidden';
|
||||
|
||||
export enum HeaderTypes {
|
||||
name = 'Nazwa',
|
||||
abbr = 'Skrót posterunku',
|
||||
url = 'URL',
|
||||
hash = 'Hash',
|
||||
lines = 'Linie',
|
||||
project = 'Projekt',
|
||||
projectUrl = 'URL projektu',
|
||||
reqLevel = 'Wym. poziom',
|
||||
signalType = 'Sygnalizacja',
|
||||
controlType = 'Sterowanie',
|
||||
SUP = 'SUP',
|
||||
ASDEK = 'ASDEK',
|
||||
authors = 'Autorzy',
|
||||
routesInfo = 'Szlaki',
|
||||
checkpoints = 'Posterunki',
|
||||
availability = 'Dostępność',
|
||||
hidden = 'Ukryty',
|
||||
toRemove = 'Usuń',
|
||||
}
|
||||
|
||||
export enum AvailabilityTypes {
|
||||
'default' = 'w paczce',
|
||||
'nonDefault' = 'poza paczką',
|
||||
'nonPublic' = 'niepubliczna',
|
||||
'abandoned' = 'wycofana',
|
||||
'unavailable' = 'niedostępna',
|
||||
}
|
||||
|
||||
export interface SceneryRoutesInfo {
|
||||
routeName: string;
|
||||
isElectric: boolean;
|
||||
isRouteSBL: boolean;
|
||||
isInternal: boolean;
|
||||
routeSpeed: number;
|
||||
routeLength: number;
|
||||
routeTracks: number;
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
export interface SceneryRowItem {
|
||||
id: string | number;
|
||||
hash: string;
|
||||
name: string;
|
||||
abbr: string;
|
||||
url: string;
|
||||
lines: string;
|
||||
project: string | null;
|
||||
projectUrl: string | null;
|
||||
reqLevel: number;
|
||||
signalType: string;
|
||||
controlType: string;
|
||||
SUP: boolean;
|
||||
ASDEK: boolean;
|
||||
hidden: boolean;
|
||||
routesInfo: SceneryRoutesInfo[];
|
||||
checkpoints: string;
|
||||
authors: string;
|
||||
availability: Availability;
|
||||
}
|
||||
|
||||
export type ChangeItem = {
|
||||
[key in ChangeProp]?: any;
|
||||
} & {
|
||||
id: string | number;
|
||||
name: string;
|
||||
|
||||
toRemove?: boolean;
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
import { Availability, AvailabilityTypes } from './types';
|
||||
|
||||
export function getAvailabilityValue(availability: Availability) {
|
||||
return AvailabilityTypes[availability];
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
export type VehicleAPIResponse = IVehicle[];
|
||||
|
||||
export interface IVehicle {
|
||||
id: number;
|
||||
name: string;
|
||||
type: string;
|
||||
cabinName?: string;
|
||||
restrictions?: IVehicleRestrictions;
|
||||
vehicleGroupsId: number;
|
||||
group: IVehicleGroup;
|
||||
}
|
||||
|
||||
export interface IVehicleRestrictions {
|
||||
sponsorOnly?: number;
|
||||
teamOnly?: boolean;
|
||||
}
|
||||
|
||||
export interface IVehicleGroup {
|
||||
id: number;
|
||||
name: string;
|
||||
speed: number;
|
||||
length: number;
|
||||
weight: number;
|
||||
cargoTypes?: IVehicleCargoType[];
|
||||
locoProps?: IVehicleLocoProps;
|
||||
}
|
||||
|
||||
export interface IVehicleCargoType {
|
||||
id: string;
|
||||
weight: number;
|
||||
}
|
||||
|
||||
export interface IVehicleLocoProps {
|
||||
coldStart: boolean;
|
||||
doubleManned: boolean;
|
||||
}
|
||||
|
||||
export interface IVehicleTableRow {
|
||||
vehicleRef: IVehicle;
|
||||
pendingChanges: Partial<IVehicle>;
|
||||
}
|
||||
|
||||
export enum VehicleEditRowKey {
|
||||
NAME = 'name',
|
||||
TYPE = 'type',
|
||||
CABIN = 'cabinName',
|
||||
|
||||
}
|
||||
|
||||
export enum VehicleEditRestrictionKey {
|
||||
SPONSOR_ONLY = "sponsorOnly",
|
||||
TEAM_ONLY = "teamOnly"
|
||||
}
|
||||
Reference in New Issue
Block a user