"use client";
import { useLeftMenuStore } from "_store/leftMenuStore";
import { cn } from "@repo/shared-components";
import { ListCollapse, Plane } from "lucide-react";
import { useQuery } from "@tanstack/react-query";
import { getMissionsAPI } from "_querys/missions";
import { Mission, Station } from "@repo/db";
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
import { FMS_STATUS_COLORS, FMS_STATUS_TEXT_COLORS } from "_helpers/fmsStatusColors";
import { useMapStore } from "_store/mapStore";
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
export const SituationBoard = () => {
const { setSituationTabOpen, situationTabOpen } = useLeftMenuStore();
const { status, setHideDraftMissions, hideDraftMissions } = useDispatchConnectionStore(
(state) => state,
);
const dispatcherConnected = status === "connected";
const { data: missions } = useQuery({
queryKey: ["missions", "missions-on-stations"],
queryFn: () =>
getMissionsAPI<
Mission & {
MissionsOnStations: (Station & {
Station: Station;
})[];
}
>(
{
state: {
not: "finished",
},
},
{
MissionsOnStations: {
include: {
Station: true,
},
},
},
{
createdAt: "desc",
},
),
});
const filteredMissions = missions?.filter(
(mission) => !hideDraftMissions || mission.state !== "draft",
);
const { data: connectedAircrafts } = useQuery({
queryKey: ["aircrafts"],
queryFn: () => getConnectedAircraftsAPI(),
});
const { setOpenAircraftMarker, setOpenMissionMarker, setMap } = useMapStore((state) => state);
return (
{situationTabOpen && (
Einsatzliste{" "}
{/* head */}
| E-Nr. |
Stichwort |
Stadt |
Stationen |
{filteredMissions?.map(
(mission) =>
(dispatcherConnected || mission.state !== "draft") && (
{
setOpenMissionMarker({
open: [
{
id: mission.id,
tab: "home",
},
],
close: [],
});
setMap({
center: {
lat: mission.addressLat,
lng: mission.addressLng,
},
zoom: 14,
});
}}
key={mission.id}
>
| {mission.publicId.replace("ENr.: ", "")} |
{mission.missionKeywordAbbreviation} |
{mission.addressCity} |
{mission.MissionsOnStations?.map(
(mos) => mos.Station?.bosCallsignShort,
).join(", ")}
|
),
)}
Stationen
| BOS Name |
Status |
LST |
{connectedAircrafts?.map((station) => (
{
setOpenAircraftMarker({
open: [
{
id: station.id,
tab: "home",
},
],
close: [],
});
if (station.posLat === null || station.posLng === null) return;
setMap({
center: {
lat: station.posLat,
lng: station.posLng,
},
zoom: 14,
});
}}
>
| {station.Station.bosCallsignShort} |
{station.fmsStatus}
|
{station.Station.bosRadioArea} |
))}
)}
);
};