Fix Alarm & Remove Dispatch functionality from Pilots
This commit is contained in:
@@ -87,7 +87,9 @@ const Einsatzdetails = ({ mission }: { mission: Mission }) => {
|
|||||||
<h2 className="flex items-center gap-2 text-lg font-bold">
|
<h2 className="flex items-center gap-2 text-lg font-bold">
|
||||||
<Flag /> Einsatzdetails
|
<Flag /> Einsatzdetails
|
||||||
</h2>
|
</h2>
|
||||||
{mission.state !== "draft" && (
|
{mission.state !== "draft" &&
|
||||||
|
typeof window !== "undefined" &&
|
||||||
|
!window.location.pathname.startsWith("/pilot") && (
|
||||||
<div className="space-x-2">
|
<div className="space-x-2">
|
||||||
<div
|
<div
|
||||||
className="tooltip tooltip-primary tooltip-left font-semibold"
|
className="tooltip tooltip-primary tooltip-left font-semibold"
|
||||||
@@ -257,6 +259,8 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
<h2 className="flex items-center gap-2 text-lg font-bold mb-3">
|
<h2 className="flex items-center gap-2 text-lg font-bold mb-3">
|
||||||
<SmartphoneNfc /> Rettungsmittel
|
<SmartphoneNfc /> Rettungsmittel
|
||||||
</h2>
|
</h2>
|
||||||
|
{typeof window !== "undefined" &&
|
||||||
|
!window.location.pathname.startsWith("/pilot") && (
|
||||||
<div
|
<div
|
||||||
className="tooltip tooltip-primary tooltip-left font-semibold"
|
className="tooltip tooltip-primary tooltip-left font-semibold"
|
||||||
data-tip="Einsatz erneut alarmieren"
|
data-tip="Einsatz erneut alarmieren"
|
||||||
@@ -270,6 +274,7 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
<BellRing size={16} />
|
<BellRing size={16} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto">
|
<ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto">
|
||||||
{stations?.map((station, index) => {
|
{stations?.map((station, index) => {
|
||||||
@@ -304,6 +309,9 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
{typeof window !== "undefined" &&
|
||||||
|
!window.location.pathname.startsWith("/pilot") && (
|
||||||
|
<div>
|
||||||
<div className="divider mt-0 mb-0" />
|
<div className="divider mt-0 mb-0" />
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{/* TODO: make it a small multiselect */}
|
{/* TODO: make it a small multiselect */}
|
||||||
@@ -319,6 +327,8 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -346,6 +356,9 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
|
|||||||
if (!session.data?.user) return null;
|
if (!session.data?.user) return null;
|
||||||
return (
|
return (
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
|
{typeof window !== "undefined" &&
|
||||||
|
!window.location.pathname.startsWith("/pilot") && (
|
||||||
|
<div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{!isAddingNote ? (
|
{!isAddingNote ? (
|
||||||
<button
|
<button
|
||||||
@@ -409,6 +422,8 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="divider m-0" />
|
<div className="divider m-0" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<ul className="space-y-1 max-h-[300px] overflow-y-auto overflow-x-auto">
|
<ul className="space-y-1 max-h-[300px] overflow-y-auto overflow-x-auto">
|
||||||
{(mission.missionLog as unknown as MissionLog[])
|
{(mission.missionLog as unknown as MissionLog[])
|
||||||
.slice()
|
.slice()
|
||||||
@@ -483,6 +498,11 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
|
|||||||
return null;
|
return null;
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
{!mission.missionLog.length && (
|
||||||
|
<p className="text-gray-500 w-full text-center my-10 font-semibold">
|
||||||
|
Keine Notizen verfügbar
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ import { usePannelStore } from "_store/pannelStore";
|
|||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
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 { getKeywordsAPI } from "querys/keywords";
|
||||||
import { getStationsAPI } from "querys/stations";
|
import { getStationsAPI } from "querys/stations";
|
||||||
import { useMapStore } from "_store/mapStore";
|
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 session = useSession();
|
||||||
const defaultFormValues = React.useMemo(
|
const defaultFormValues = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -344,12 +363,14 @@ export const MissionForm = () => {
|
|||||||
async (mission: MissionOptionalDefaults) => {
|
async (mission: MissionOptionalDefaults) => {
|
||||||
try {
|
try {
|
||||||
const newMission =
|
const newMission =
|
||||||
await createMissionMutation.mutateAsync(
|
await createMissionMutation.mutateAsync({
|
||||||
mission as unknown as Prisma.MissionCreateInput,
|
...(mission as unknown as Prisma.MissionCreateInput),
|
||||||
);
|
state: "running",
|
||||||
|
});
|
||||||
|
sendAlertMutation.mutate(newMission.id);
|
||||||
setSeachOSMElements([]); // Reset search elements
|
setSeachOSMElements([]); // Reset search elements
|
||||||
toast.success(`Einsatz ${newMission.id} erstellt`);
|
toast.success(`Einsatz ${newMission.publicId} erstellt`);
|
||||||
// TODO: Einsatz alarmieren
|
form.reset();
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(
|
toast.error(
|
||||||
|
|||||||
Reference in New Issue
Block a user