-
- {!isAddingNote ? (
-
- ) : (
-
-
setNote(e.target.value)}
- />
-
-
+ {typeof window !== "undefined" &&
+ !window.location.pathname.startsWith("/pilot") && (
+
+
+ {!isAddingNote ? (
+
+ ) : (
+
+
setNote(e.target.value)}
+ />
+
+
+
+ )}
+
+
)}
-
-
{(mission.missionLog as unknown as MissionLog[])
.slice()
@@ -483,6 +498,11 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
return null;
})}
+ {!mission.missionLog.length && (
+
+ Keine Notizen verfügbar
+
+ )}
);
};
diff --git a/apps/dispatch/app/dispatch/_components/pannel/MissionForm.tsx b/apps/dispatch/app/dispatch/_components/pannel/MissionForm.tsx
index 6ac3ebf1..d47820a7 100644
--- a/apps/dispatch/app/dispatch/_components/pannel/MissionForm.tsx
+++ b/apps/dispatch/app/dispatch/_components/pannel/MissionForm.tsx
@@ -13,7 +13,11 @@ import { usePannelStore } from "_store/pannelStore";
import { useSession } from "next-auth/react";
import { toast } from "react-hot-toast";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
-import { createMissionAPI, editMissionAPI } from "querys/missions";
+import {
+ createMissionAPI,
+ editMissionAPI,
+ sendMissionAPI,
+} from "querys/missions";
import { getKeywordsAPI } from "querys/keywords";
import { getStationsAPI } from "querys/stations";
import { useMapStore } from "_store/mapStore";
@@ -60,6 +64,21 @@ export const MissionForm = () => {
},
});
+ 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 session = useSession();
const defaultFormValues = React.useMemo(
() =>
@@ -344,12 +363,14 @@ export const MissionForm = () => {
async (mission: MissionOptionalDefaults) => {
try {
const newMission =
- await createMissionMutation.mutateAsync(
- mission as unknown as Prisma.MissionCreateInput,
- );
+ await createMissionMutation.mutateAsync({
+ ...(mission as unknown as Prisma.MissionCreateInput),
+ state: "running",
+ });
+ sendAlertMutation.mutate(newMission.id);
setSeachOSMElements([]); // Reset search elements
- toast.success(`Einsatz ${newMission.id} erstellt`);
- // TODO: Einsatz alarmieren
+ toast.success(`Einsatz ${newMission.publicId} erstellt`);
+ form.reset();
setOpen(false);
} catch (error) {
toast.error(