Einsatz geschlossen event wird richtig an piloten gesendet
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user