Improved StationSelect
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user