diff --git a/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx b/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx index 94103970..8e806e2e 100644 --- a/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx +++ b/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx @@ -419,6 +419,7 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => { label: station.bosCallsign, value: station.id, type: "station" as const, + isOnline: !!conenctedAircrafts?.find((a) => a.stationId === station.id), })) || []), ...(!mission.hpgFireEngineState || mission.hpgFireEngineState === "NOT_REQUESTED" ? [{ label: "Feuerwehr", value: "FW", type: "vehicle" as const }] @@ -429,7 +430,21 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => { ...(!mission.hpgPoliceState || mission.hpgPoliceState === "NOT_REQUESTED" ? [{ label: "POLizei", value: "POL", type: "vehicle" as const }] : []), - ]; + ].sort((a, b) => { + // 1. Vehicles first + if (a.type === "vehicle" && b.type !== "vehicle") return -1; + if (a.type !== "vehicle" && b.type === "vehicle") return 1; + + // 2. Online stations before offline stations + if (a.type === "station" && b.type === "station") { + if (a.isOnline && !b.isOnline) return -1; + if (!a.isOnline && b.isOnline) return 1; + } + + // 3. Otherwise, sort alphabetically by label + return a.label.localeCompare(b.label); + return 0; + }); useEffect(() => { const firstOption = stationsOptions[0]; @@ -568,7 +583,6 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {