diff --git a/apps/dispatch-server/routes/mission.ts b/apps/dispatch-server/routes/mission.ts index ff9705f1..b6758b82 100644 --- a/apps/dispatch-server/routes/mission.ts +++ b/apps/dispatch-server/routes/mission.ts @@ -88,7 +88,16 @@ router.patch("/:id", async (req, res) => { }); io.to("dispatchers").emit("update-mission", { updatedMission }); if (req.body.state === "finished") { - updatedMission.missionStationUserIds?.forEach((userId) => { + const missionUsers = await prisma.missionOnStationUsers.findMany({ + where: { + missionId: updatedMission.id, + }, + select: { + userId: true, + }, + }); + console.log("Notifying users about mission closure:", missionUsers); + missionUsers?.forEach(({ userId }) => { io.to(`user:${userId}`).emit("notification", { type: "mission-closed", status: "closed", diff --git a/apps/dispatch/app/(app)/dispatch/_components/pannel/MissionForm.tsx b/apps/dispatch/app/(app)/dispatch/_components/pannel/MissionForm.tsx index b5301041..76e87f11 100644 --- a/apps/dispatch/app/(app)/dispatch/_components/pannel/MissionForm.tsx +++ b/apps/dispatch/app/(app)/dispatch/_components/pannel/MissionForm.tsx @@ -164,6 +164,7 @@ export const MissionForm = () => { const newFormValues = JSON.stringify(values); if (currentStoreValues !== newFormValues) { + console.debug("Updating store missionFormValues", values); setMissionFormValues(values as MissionOptionalDefaults); } }); diff --git a/apps/dispatch/app/_components/QueryProvider.tsx b/apps/dispatch/app/_components/QueryProvider.tsx index 2b2af938..41bb2ce1 100644 --- a/apps/dispatch/app/_components/QueryProvider.tsx +++ b/apps/dispatch/app/_components/QueryProvider.tsx @@ -22,7 +22,7 @@ export function QueryProvider({ children }: { children: ReactNode }) { defaultOptions: { mutations: { onError: (error) => { - toast.error("An error occurred: " + (error as Error).message, { + toast.error("Ein Fehler ist aufgetreten: " + (error as Error).message, { position: "top-right", }); }, @@ -88,6 +88,9 @@ export function QueryProvider({ children }: { children: ReactNode }) { }, ); break; + case "mission-closed": + toast("Dein aktueller Einsatz wurde geschlossen."); + break; default: toast("unbekanntes Notification-Event"); break; diff --git a/apps/dispatch/app/_components/map/MapAdditionals.tsx b/apps/dispatch/app/_components/map/MapAdditionals.tsx index ff70d4f9..f2c8b7df 100644 --- a/apps/dispatch/app/_components/map/MapAdditionals.tsx +++ b/apps/dispatch/app/_components/map/MapAdditionals.tsx @@ -58,8 +58,6 @@ export const MapAdditionals = () => { openMissionMarker.find((openMission) => openMission.id === m.id), ); - console.log("markersNeedingAttention", showDetailedAdditionals); - return ( <> {missionFormValues?.addressLat && missionFormValues?.addressLng && isOpen && ( @@ -70,7 +68,18 @@ export const MapAdditionals = () => { iconSize: [40, 40], iconAnchor: [20, 35], })} - interactive={false} + draggable={true} + eventHandlers={{ + dragend: (e) => { + const marker = e.target; + const position = marker.getLatLng(); + setMissionFormValues({ + ...missionFormValues, + addressLat: position.lat, + addressLng: position.lng, + }); + }, + }} /> )} {showDetailedAdditionals &&