"use client";
import { useLeftMenuStore } from "_store/leftMenuStore";
import { cn } from "_helpers/cn";
import { ListCollapse, Plane } from "lucide-react";
import { useQuery } from "@tanstack/react-query";
import { getMissionsAPI } from "_querys/missions";
import { 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 dispatcherConnected = useDispatchConnectionStore((state) => state.status === "connected");
const { data: missions } = useQuery({
queryKey: ["missions", "missions-on-stations"],
queryFn: () =>
getMissionsAPI(
{
state: {
not: "finished",
},
},
{
MissionsOnStations: {
include: {
Station: true,
},
},
},
{
createdAt: "desc",
},
),
});
const { data: connectedAircrafts } = useQuery({
queryKey: ["aircrafts"],
queryFn: () => getConnectedAircraftsAPI(),
});
const { setOpenAircraftMarker, setOpenMissionMarker, setMap } = useMapStore((state) => state);
console.log("station", connectedAircrafts);
return (
{situationTabOpen && (
Einsatzliste
{/* head */}
| E-Nr. |
Stichwort |
Stadt |
Stationen |
{/* row 1 */}
{missions?.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}
className={cn(mission.state === "draft" && "missionListItem")}
>
| {mission.publicId} |
{mission.missionKeywordAbbreviation} |
{mission.addressCity} |
{(mission as any).MissionsOnStations?.map(
(mos: { Station: Station }) => 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} |
))}
)}
);
};