Einsatz geschlossen event wird richtig an piloten gesendet

This commit is contained in:
PxlLoewe
2025-10-28 02:19:55 +01:00
parent da9b957fcf
commit 4d43e2a36d
4 changed files with 27 additions and 5 deletions

View File

@@ -88,7 +88,16 @@ router.patch("/:id", async (req, res) => {
}); });
io.to("dispatchers").emit("update-mission", { updatedMission }); io.to("dispatchers").emit("update-mission", { updatedMission });
if (req.body.state === "finished") { 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", { io.to(`user:${userId}`).emit("notification", {
type: "mission-closed", type: "mission-closed",
status: "closed", status: "closed",

View File

@@ -164,6 +164,7 @@ export const MissionForm = () => {
const newFormValues = JSON.stringify(values); const newFormValues = JSON.stringify(values);
if (currentStoreValues !== newFormValues) { if (currentStoreValues !== newFormValues) {
console.debug("Updating store missionFormValues", values);
setMissionFormValues(values as MissionOptionalDefaults); setMissionFormValues(values as MissionOptionalDefaults);
} }
}); });

View File

@@ -22,7 +22,7 @@ export function QueryProvider({ children }: { children: ReactNode }) {
defaultOptions: { defaultOptions: {
mutations: { mutations: {
onError: (error) => { onError: (error) => {
toast.error("An error occurred: " + (error as Error).message, { toast.error("Ein Fehler ist aufgetreten: " + (error as Error).message, {
position: "top-right", position: "top-right",
}); });
}, },
@@ -88,6 +88,9 @@ export function QueryProvider({ children }: { children: ReactNode }) {
}, },
); );
break; break;
case "mission-closed":
toast("Dein aktueller Einsatz wurde geschlossen.");
break;
default: default:
toast("unbekanntes Notification-Event"); toast("unbekanntes Notification-Event");
break; break;

View File

@@ -58,8 +58,6 @@ export const MapAdditionals = () => {
openMissionMarker.find((openMission) => openMission.id === m.id), openMissionMarker.find((openMission) => openMission.id === m.id),
); );
console.log("markersNeedingAttention", showDetailedAdditionals);
return ( return (
<> <>
{missionFormValues?.addressLat && missionFormValues?.addressLng && isOpen && ( {missionFormValues?.addressLat && missionFormValues?.addressLng && isOpen && (
@@ -70,7 +68,18 @@ export const MapAdditionals = () => {
iconSize: [40, 40], iconSize: [40, 40],
iconAnchor: [20, 35], 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 && {showDetailedAdditionals &&