refactor: stock & vehicle typings

This commit is contained in:
2024-04-15 18:32:19 +02:00
parent 61c7f15fcf
commit 541572e415
13 changed files with 175 additions and 133 deletions
+9 -6
View File
@@ -13,6 +13,7 @@ import { defineStore } from 'pinia';
import {
acceptableWeight,
carDataList,
isTractionUnit,
isTrainPassenger,
locoDataList,
maxStockSpeed,
@@ -96,25 +97,27 @@ export const useStore = defineStore({
stockSupportsColdStart: (state) => {
if (state.stockList.length == 0) return false;
if (!state.stockList[0].isLoco) return false;
if (!isTractionUnit(state.stockList[0].vehicleRef)) return false;
const headingLoco = state.stockList[0];
return (
state.vehiclesData?.vehicleProps.find((stock) => stock.type == headingLoco.constructionType)
?.coldStart ?? false
state.vehiclesData?.vehicleProps.find(
(stock) => stock.type == headingLoco.vehicleRef.constructionType
)?.coldStart ?? false
);
},
stockSupportsDoubleManning: (state) => {
if (state.stockList.length == 0) return false;
if (!state.stockList[0].isLoco) return false;
if (!isTractionUnit(state.stockList[0].vehicleRef)) return false;
const headingLoco = state.stockList[0];
return (
state.vehiclesData?.vehicleProps.find((stock) => stock.type == headingLoco.constructionType)
?.doubleManned ?? false
state.vehiclesData?.vehicleProps.find(
(stock) => stock.type == headingLoco.vehicleRef.constructionType
)?.doubleManned ?? false
);
},
},