Added Data to SituationsBoard
This commit is contained in:
@@ -63,6 +63,7 @@ export const sendAlert = async (
|
||||
stationId: aircraft.stationId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!existingMissionOnStationUser)
|
||||
await prisma.missionOnStationUsers.create({
|
||||
data: {
|
||||
@@ -81,7 +82,7 @@ export const sendAlert = async (
|
||||
stationId,
|
||||
})),
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((err) => {
|
||||
// Ignore if the entry already exists
|
||||
});
|
||||
|
||||
|
||||
@@ -3,10 +3,45 @@ import { useLeftMenuStore } from "_store/leftMenuStore";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { ListCollapse, Plane } from "lucide-react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getMissionsAPI } from "_querys/missions";
|
||||
import { MissionsOnStations, Station } from "@repo/db";
|
||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||
import { FMS_STATUS_COLORS, FMS_STATUS_TEXT_COLORS } from "_components/map/AircraftMarker";
|
||||
import { useMapStore } from "_store/mapStore";
|
||||
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
|
||||
export const SituationBoard = () => {
|
||||
const { setSituationTabOpen, situationTabOpen } = useLeftMenuStore();
|
||||
const session = useSession();
|
||||
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 (
|
||||
<div className={cn("dropdown dropdown-top", situationTabOpen && "dropdown-open")}>
|
||||
@@ -23,19 +58,117 @@ export const SituationBoard = () => {
|
||||
{situationTabOpen && (
|
||||
<div
|
||||
tabIndex={0}
|
||||
className="dropdown-content card bg-base-200 w-150 shadow-md z-[1100] ml-2 border-1 border-info"
|
||||
className="dropdown-content card bg-base-200 shadow-md z-[1100] ml-2 border-1 border-info"
|
||||
>
|
||||
<div className="card-body flex flex-row gap-4">
|
||||
<div className="flex-1">
|
||||
<h2 className="inline-flex items-center gap-2 text-lg font-bold mb-2">
|
||||
<ListCollapse /> Einsatzliste
|
||||
</h2>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="table table-xs">
|
||||
{/* head */}
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Stichwort</th>
|
||||
<th>Stadt</th>
|
||||
<th>Stationen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{/* row 1 */}
|
||||
{missions?.map((mission) => (
|
||||
<tr
|
||||
onDoubleClick={() => {
|
||||
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" && "bg-base-300")}
|
||||
>
|
||||
<td>{mission.publicId}</td>
|
||||
<td>{mission.missionKeywordAbbreviation}</td>
|
||||
<td>{mission.addressCity}</td>
|
||||
<td>
|
||||
{(mission as any).MissionsOnStations?.map(
|
||||
(mos: { Station: Station }) => mos.Station?.bosCallsignShort,
|
||||
).join(", ")}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-px bg-gray-400 mx-2" />
|
||||
<div className="flex-1">
|
||||
<h2 className="inline-flex items-center gap-2 text-lg font-bold mb-2">
|
||||
<Plane /> Stationen
|
||||
</h2>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="table table-xs">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>BOS Name</th>
|
||||
<th>Status</th>
|
||||
<th>LST</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{connectedAircrafts?.map((station) => (
|
||||
<tr
|
||||
key={station.id}
|
||||
onDoubleClick={() => {
|
||||
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,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<td>{station.Station.bosCallsignShort}</td>
|
||||
<td
|
||||
className="text-center font-lg font-semibold"
|
||||
style={{
|
||||
color: FMS_STATUS_TEXT_COLORS[station.fmsStatus],
|
||||
backgroundColor: FMS_STATUS_COLORS[station.fmsStatus],
|
||||
}}
|
||||
>
|
||||
{station.fmsStatus}
|
||||
</td>
|
||||
<td className="whitespace-nowrap">{station.Station.bosRadioArea}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -169,6 +169,8 @@ const MissionPopupContent = ({
|
||||
onClick={() => {
|
||||
setMissionFormValues({
|
||||
...mission,
|
||||
addressMissionLocation: mission.addressMissionLocation ?? undefined,
|
||||
addressAdditionalInfo: mission.addressAdditionalInfo ?? undefined,
|
||||
state: "draft",
|
||||
hpgLocationLat: mission.hpgLocationLat ?? undefined,
|
||||
hpgLocationLng: mission.hpgLocationLng ?? undefined,
|
||||
|
||||
@@ -2,10 +2,16 @@ import { Mission, MissionSdsLog, Prisma } from "@repo/db";
|
||||
import axios from "axios";
|
||||
import { serverApi } from "_helpers/axios";
|
||||
|
||||
export const getMissionsAPI = async (filter?: Prisma.MissionWhereInput) => {
|
||||
export const getMissionsAPI = async (
|
||||
filter?: Prisma.MissionWhereInput,
|
||||
include?: Prisma.MissionInclude,
|
||||
orderBy?: Prisma.MissionOrderByWithRelationInput,
|
||||
) => {
|
||||
const res = await axios.get<Mission[]>("/api/missions", {
|
||||
params: {
|
||||
filter: JSON.stringify(filter),
|
||||
include: JSON.stringify(include),
|
||||
orderBy: JSON.stringify(orderBy),
|
||||
},
|
||||
});
|
||||
if (res.status !== 200) {
|
||||
|
||||
@@ -5,8 +5,12 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const id = searchParams.get("id");
|
||||
const filter = searchParams.get("filter");
|
||||
const include = searchParams.get("include");
|
||||
const orderBy = searchParams.get("orderBy");
|
||||
|
||||
const filterParsed = JSON.parse(filter || "{}");
|
||||
const includeParsed = JSON.parse(include || "{}");
|
||||
const orderByParsed = JSON.parse(orderBy || "{}");
|
||||
|
||||
try {
|
||||
const data = await prisma.mission.findMany({
|
||||
@@ -14,6 +18,12 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
|
||||
id: id ? Number(id) : undefined,
|
||||
...filterParsed,
|
||||
},
|
||||
include: {
|
||||
...includeParsed,
|
||||
},
|
||||
orderBy: {
|
||||
...orderByParsed,
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(data, { status: 200 });
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
"@next-auth/prisma-adapter": "^1.0.7",
|
||||
"@radix-ui/react-icons": "^1.3.2",
|
||||
"@repo/db": "*",
|
||||
"@repo/eslint-config": "*",
|
||||
"@repo/typescript-config": "*",
|
||||
"@tailwindcss/postcss": "^4.1.8",
|
||||
"@tanstack/react-query": "^5.79.0",
|
||||
"@types/jsonwebtoken": "^9.0.9",
|
||||
@@ -50,8 +52,6 @@
|
||||
"zustand-sync-tabs": "^0.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@repo/eslint-config": "*",
|
||||
"@repo/typescript-config": "*",
|
||||
"@types/leaflet": "^1.9.18",
|
||||
"@types/node": "^22.15.29",
|
||||
"@types/react": "^19.1.6",
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
},
|
||||
"packageManager": "pnpm@10.11.0",
|
||||
"devDependencies": {
|
||||
"concurrently": "^9.1.2",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-email/components": "^0.0.41",
|
||||
"@repo/db": "*",
|
||||
"@repo/typescript-config": "*",
|
||||
"@types/cors": "^2.8.18",
|
||||
@@ -16,11 +21,6 @@
|
||||
"@types/node": "^22.15.29",
|
||||
"@types/nodemailer": "^6.4.17",
|
||||
"@types/react": "^19.1.6",
|
||||
"concurrently": "^9.1.2",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-email/components": "^0.0.41",
|
||||
"axios": "^1.9.0",
|
||||
"cors": "^2.8.5",
|
||||
"cron": "^4.3.1",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Award } from "lucide-react";
|
||||
import { getServerSession } from "../../api/auth/[...nextauth]/auth";
|
||||
import { Badge } from "../../_components/Badge/Badge";
|
||||
import { JSX } from "react";
|
||||
|
||||
export const Badges = async () => {
|
||||
export const Badges: () => Promise<JSX.Element> = async () => {
|
||||
const session = await getServerSession();
|
||||
if (!session) return null;
|
||||
if (!session) return <div />;
|
||||
|
||||
return (
|
||||
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
"@next-auth/prisma-adapter": "^1.0.7",
|
||||
"@radix-ui/react-icons": "^1.3.2",
|
||||
"@repo/db": "*",
|
||||
"@repo/eslint-config": "*",
|
||||
"@repo/typescript-config": "*",
|
||||
"@tanstack/react-query": "^5.79.0",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@uiw/react-md-editor": "^4.0.7",
|
||||
@@ -42,19 +44,17 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3",
|
||||
"@repo/eslint-config": "*",
|
||||
"@repo/typescript-config": "*",
|
||||
"@tailwindcss/postcss": "^4.1.8",
|
||||
"@types/bcryptjs": "^3.0.0",
|
||||
"@types/jsonwebtoken": "^9.0.9",
|
||||
"@types/node": "^22.15.29",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/react-dom": "^19.1.5",
|
||||
"daisyui": "^5.0.43",
|
||||
"eslint": "^9",
|
||||
"eslint": "^9.15.0",
|
||||
"eslint-config-next": "^15.3.3",
|
||||
"postcss": "^8.5.4",
|
||||
"tailwindcss": "^4.1.8",
|
||||
"typescript": "^5"
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user