changes pilot socket to reperate pilto socket, added pilot stats

This commit is contained in:
PxlLoewe
2025-05-17 23:51:04 -07:00
parent 16e05a08a6
commit 6b58f564b2
16 changed files with 583 additions and 352 deletions

View File

@@ -1,9 +1,7 @@
"use client";
import React, { useState } from "react";
import { FMS_STATUS_TEXT_COLORS } from "../AircraftMarker";
/* import { Select } from "_components/Select";
import { Station } from "@repo/db";
import { getStations } from "dispatch/_components/pannel/action"; */
import { toast } from "react-hot-toast";
import {
Ban,
BellRing,
@@ -29,7 +27,11 @@ import {
import { usePannelStore } from "_store/pannelStore";
import { useSession } from "next-auth/react";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { deleteMissionAPI, editMissionAPI } from "querys/missions";
import {
deleteMissionAPI,
editMissionAPI,
sendMissionAPI,
} from "querys/missions";
const Einsatzdetails = ({ mission }: { mission: Mission }) => {
const queryClient = useQueryClient();
@@ -42,6 +44,20 @@ const Einsatzdetails = ({ mission }: { mission: Mission }) => {
});
},
});
const sendAlertMutation = useMutation({
mutationKey: ["missions"],
mutationFn: sendMissionAPI,
onError: (error) => {
console.error(error);
toast.error("Fehler beim Alarmieren");
},
onSuccess: (data) => {
toast.success(data.message);
queryClient.invalidateQueries({
queryKey: ["missions"],
});
},
});
const { setMissionFormValues, setOpen } = usePannelStore((state) => state);
return (
<div className="p-4 text-base-content">
@@ -76,7 +92,10 @@ const Einsatzdetails = ({ mission }: { mission: Mission }) => {
</div>
<div className="divider mt-0 mb-0" />
<div className="flex items-center gap-2 w-full">
<button className="btn btn-sm btn-info btn-outline flex-3">
<button
className="btn btn-sm btn-info btn-outline flex-3"
onClick={() => sendAlertMutation.mutate(mission.id)}
>
<span className="flex items-center gap-2">
<BellRing size={16} /> Alarmieren
</span>

View File

@@ -176,7 +176,7 @@ export const MissionForm = () => {
form={form}
options={stations?.map((s) => ({
label: s.bosCallsign,
value: s.id.toString(),
value: s.id,
}))}
/>
</div>

View File

@@ -1,4 +1,4 @@
import { pilotSocket } from "pilot/socket";
"use client";
import { io } from "socket.io-client";
export const dispatchSocket = io(process.env.NEXT_PUBLIC_DISPATCH_SERVER_URL, {