Improved StationSelect

This commit is contained in:
PxlLoewe
2025-07-15 23:46:22 -07:00
parent 7be21a738a
commit 515ff6d6c3
2 changed files with 59 additions and 12 deletions

View File

@@ -107,8 +107,27 @@ export function StationsSelect({
menuPlacement={menuPlacement}
isMulti={isMulti}
onChange={(v) => {
console.log("Selected values:", v);
setValue(v);
if (!isMulti) return onChange?.(v);
if (!isMulti) {
const singleValue = v as string;
const isVehicle = ["RTW", "FW", "POL"].includes(singleValue);
const hpgAmbulanceState =
singleValue === "RTW" ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED;
const hpgFireEngineState =
singleValue === "FW" ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED;
const hpgPoliceState =
singleValue === "POL" ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED;
onChange?.({
selectedStationIds: isVehicle ? [] : [Number(singleValue)],
hpgAmbulanceState,
hpgFireEngineState,
hpgPoliceState,
});
return;
}
const hpgAmbulanceState = v.includes("RTW") ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED;
const hpgFireEngineState = v.includes("FW") ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED;
const hpgPoliceState = v.includes("POL") ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED;