From b1781677628cc79aa3ba83e0b69b27fa3723dcfb Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:05:50 -0700 Subject: [PATCH] changed toast timer, redirect behavior in disptach, VehicleNames --- apps/dispatch-server/routes/mission.ts | 19 +++--- .../app/_components/QueryProvider.tsx | 2 +- .../map/_components/MissionMarkerTabs.tsx | 58 ++++++++++++++----- apps/dispatch/app/_querys/missions.ts | 2 +- apps/dispatch/app/page.tsx | 6 +- .../(app)/admin/report/_components/form.tsx | 21 ++----- apps/hub/app/(app)/admin/user/page.tsx | 6 ++ 7 files changed, 70 insertions(+), 44 deletions(-) diff --git a/apps/dispatch-server/routes/mission.ts b/apps/dispatch-server/routes/mission.ts index a52f0737..458eed75 100644 --- a/apps/dispatch-server/routes/mission.ts +++ b/apps/dispatch-server/routes/mission.ts @@ -1,19 +1,14 @@ import { getPublicUser, HpgValidationState, - MissionAlertLog, MissionSdsLog, - MissionStationLog, NotificationPayload, - Prisma, prisma, User, } from "@repo/db"; import { Router } from "express"; import { io } from "../index"; -import { sendNtfyMission } from "modules/ntfy"; import { sendAlert } from "modules/mission"; -import { userInfo } from "os"; const router: Router = Router(); @@ -119,7 +114,7 @@ router.post("/:id/send-alert", async (req, res) => { const { id } = req.params; const { stationId, vehicleName } = req.body as { stationId?: number; - vehicleName?: "ambulance" | "police" | "firebrigade"; + vehicleName?: "RTW" | "POL" | "FW"; }; if (!req.user) { @@ -142,9 +137,9 @@ router.post("/:id/send-alert", async (req, res) => { id: Number(id), }, data: { - hpgAmbulanceState: vehicleName === "ambulance" ? "DISPATCHED" : undefined, - hpgFireEngineState: vehicleName === "firebrigade" ? "DISPATCHED" : undefined, - hpgPoliceState: vehicleName === "police" ? "DISPATCHED" : undefined, + hpgAmbulanceState: vehicleName === "RTW" ? "DISPATCHED" : undefined, + hpgFireEngineState: vehicleName === "FW" ? "DISPATCHED" : undefined, + hpgPoliceState: vehicleName === "POL" ? "DISPATCHED" : undefined, missionLog: { push: { type: "alert-log", @@ -152,7 +147,7 @@ router.post("/:id/send-alert", async (req, res) => { timeStamp: new Date().toISOString(), data: { vehicle: vehicleName, - user: getPublicUser(req.user as User), + user: getPublicUser(req.user as User, { ignorePrivacy: true }), }, } as any, }, @@ -162,9 +157,9 @@ router.post("/:id/send-alert", async (req, res) => { io.to(`desktop:${aircraft.userId}`).emit("hpg-vehicle-update", { missionId: id, vehicleData: { - ambulanceState: newMission.hpgAmbulanceState, + RTWState: newMission.hpgAmbulanceState, fireEngineState: newMission.hpgFireEngineState, - policeState: newMission.hpgPoliceState, + POLState: newMission.hpgPoliceState, }, }); }); diff --git a/apps/dispatch/app/_components/QueryProvider.tsx b/apps/dispatch/app/_components/QueryProvider.tsx index 39eacfcb..754fea34 100644 --- a/apps/dispatch/app/_components/QueryProvider.tsx +++ b/apps/dispatch/app/_components/QueryProvider.tsx @@ -63,7 +63,7 @@ export function QueryProvider({ children }: { children: ReactNode }) { toast.custom( (t) => , { - duration: 99999, + duration: 15000, }, ); diff --git a/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx b/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx index c8299554..94103970 100644 --- a/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx +++ b/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx @@ -60,10 +60,6 @@ const Einsatzdetails = ({ }); }, }); - const { data: aircrafts } = useQuery({ - queryKey: ["aircrafts"], - queryFn: getConnectedAircraftsAPI, - }); const sendAlertMutation = useMutation({ mutationKey: ["missions"], mutationFn: (id: number) => sendMissionAPI(id, {}), @@ -343,9 +339,9 @@ const Patientdetails = ({ mission }: { mission: Mission }) => { const Rettungsmittel = ({ mission }: { mission: Mission }) => { const queryClient = useQueryClient(); - const [selectedStation, setSelectedStation] = useState< - Station | "ambulance" | "police" | "firebrigade" | null - >(null); + const [selectedStation, setSelectedStation] = useState( + null, + ); const { data: conenctedAircrafts } = useQuery({ queryKey: ["aircrafts"], queryFn: getConnectedAircraftsAPI, @@ -405,7 +401,7 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => { }: { id: number; stationId?: number; - vehicleName?: "ambulance" | "police" | "firebrigade"; + vehicleName?: "RTW" | "POL" | "FW"; }) => sendMissionAPI(id, { stationId, vehicleName }), onError: (error) => { console.error(error); @@ -416,6 +412,37 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => { }, }); + const stationsOptions = [ + ...(allStations + ?.filter((s) => !mission.missionStationIds.includes(s.id)) + ?.map((station) => ({ + label: station.bosCallsign, + value: station.id, + type: "station" as const, + })) || []), + ...(!mission.hpgFireEngineState || mission.hpgFireEngineState === "NOT_REQUESTED" + ? [{ label: "Feuerwehr", value: "FW", type: "vehicle" as const }] + : []), + ...(!mission.hpgAmbulanceState || mission.hpgAmbulanceState === "NOT_REQUESTED" + ? [{ label: "Rettungsdienst", value: "RTW", type: "vehicle" as const }] + : []), + ...(!mission.hpgPoliceState || mission.hpgPoliceState === "NOT_REQUESTED" + ? [{ label: "POLizei", value: "POL", type: "vehicle" as const }] + : []), + ]; + + useEffect(() => { + const firstOption = stationsOptions[0]; + if (!firstOption) { + setSelectedStation(null); + } else if (firstOption.type === "station") { + const station = allStations?.find((s) => s.id === firstOption.value); + setSelectedStation(station ?? null); + } else { + setSelectedStation(firstOption.value as "RTW" | "POL" | "FW"); + } + }, [stationsOptions, allStations]); + const dispatcherConnected = useDispatchConnectionStore((s) => s.status) === "connected"; const HPGVehicle = ({ state, name }: { state: HpgState; name: string }) => ( @@ -511,7 +538,7 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => { if (selected) { setSelectedStation(selected); } else { - setSelectedStation(e.target.value as "ambulance" | "police" | "firebrigade"); + setSelectedStation(e.target.value as "RTW" | "POL" | "FW"); } }} value={typeof selectedStation === "string" ? selectedStation : selectedStation?.id} @@ -529,14 +556,19 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => { {station.bosCallsign} ))} - - - - + + {stationsOptions.map((option) => ( + + ))}