dev
This commit is contained in:
@@ -122,9 +122,13 @@ router.post("/:id/send-alert", async (req, res) => {
|
|||||||
res.status(404).json({ error: "Mission not found" });
|
res.status(404).json({ error: "Mission not found" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// connectedAircrafts the alert is sent to
|
||||||
const connectedAircrafts = await prisma.connectedAircraft.findMany({
|
const connectedAircrafts = await prisma.connectedAircraft.findMany({
|
||||||
where: {
|
where: {
|
||||||
stationId: {
|
stationId: stationId
|
||||||
|
? stationId
|
||||||
|
: {
|
||||||
in: mission.missionStationIds,
|
in: mission.missionStationIds,
|
||||||
},
|
},
|
||||||
logoutTime: null,
|
logoutTime: null,
|
||||||
@@ -135,7 +139,6 @@ router.post("/:id/send-alert", async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (const aircraft of connectedAircrafts) {
|
for (const aircraft of connectedAircrafts) {
|
||||||
if (stationId && stationId !== aircraft.stationId) continue;
|
|
||||||
console.log(`Sending mission to: station:${aircraft.stationId}`);
|
console.log(`Sending mission to: station:${aircraft.stationId}`);
|
||||||
io.to(`station:${aircraft.stationId}`).emit("mission-alert", {
|
io.to(`station:${aircraft.stationId}`).emit("mission-alert", {
|
||||||
...mission,
|
...mission,
|
||||||
|
|||||||
@@ -47,17 +47,6 @@ export const MissionForm = () => {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const sendAlertMutation = useMutation({
|
|
||||||
mutationKey: ["missions"],
|
|
||||||
mutationFn: (id: number) => sendMissionAPI(id, {}),
|
|
||||||
onError: (error) => {
|
|
||||||
console.error(error);
|
|
||||||
toast.error("Fehler beim Alarmieren");
|
|
||||||
},
|
|
||||||
onSuccess: (data) => {
|
|
||||||
toast.success(data.message);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const editMissionMutation = useMutation({
|
const editMissionMutation = useMutation({
|
||||||
mutationFn: ({
|
mutationFn: ({
|
||||||
@@ -77,7 +66,7 @@ export const MissionForm = () => {
|
|||||||
|
|
||||||
const sendAlertMutation = useMutation({
|
const sendAlertMutation = useMutation({
|
||||||
mutationKey: ["missions"],
|
mutationKey: ["missions"],
|
||||||
mutationFn: sendMissionAPI,
|
mutationFn: (id: number) => sendMissionAPI(id, {}),
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error("Fehler beim Alarmieren");
|
toast.error("Fehler beim Alarmieren");
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user