changed toast timer, redirect behavior in disptach, VehicleNames

This commit is contained in:
PxlLoewe
2025-06-06 15:05:50 -07:00
parent fa6321b808
commit b178167762
7 changed files with 70 additions and 44 deletions

View File

@@ -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,
},
});
});

View File

@@ -63,7 +63,7 @@ export function QueryProvider({ children }: { children: ReactNode }) {
toast.custom(
(t) => <HPGnotificationToast event={notification} mapStore={mapStore} t={t} />,
{
duration: 99999,
duration: 15000,
},
);

View File

@@ -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<Station | "RTW" | "POL" | "FW" | null>(
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}
</option>
))}
<option disabled>Fahrzeuge:</option>
<option value="firebrigade">Feuerwehr</option>
<option value="ambulance">RTW</option>
<option value="police">Polizei</option>
<option disabled value={"default"}>
Fahrzeuge:
</option>
{stationsOptions.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
<button
className="btn btn-sm btn-primary btn-outline"
onClick={async () => {
console.log("Selected Station:", selectedStation);
if (typeof selectedStation === "string") {
await sendAlertMutation.mutate({
id: mission.id,

View File

@@ -57,7 +57,7 @@ export const sendMissionAPI = async (
vehicleName,
}: {
stationId?: number;
vehicleName?: "ambulance" | "police" | "firebrigade";
vehicleName?: "RTW" | "POL" | "FW";
},
) => {
const respone = await serverApi.post<{

View File

@@ -8,7 +8,11 @@ export default () => {
const session = useSession();
useEffect(() => {
if (session.status === "authenticated" && session.data?.user) {
if (session.status !== "authenticated") {
router.replace("/login");
return;
}
if (session.data?.user) {
const hasDispoPermission = session.data.user.permissions?.includes("DISPO");
if (hasDispoPermission) {

View File

@@ -24,10 +24,7 @@ export const ReportSenderInfo = ({
const { Reported, Sender } = report;
return (
<div className="card-body">
<Link
href={`/admin/user/${Reported?.id}`}
className="card-title link link-hover"
>
<Link href={`/admin/user/${Reported?.id}`} className="card-title link link-hover">
{Reported?.firstname} {Reported?.lastname} ({Reported?.publicId})
</Link>
<div className="textarea w-full text-left">{report.text}</div>
@@ -35,8 +32,8 @@ export const ReportSenderInfo = ({
href={`/admin/user/${Reported?.id}`}
className="text-sm text-gray-600 text-right link link-hover"
>
Meldet Nutzer {Sender?.firstname} {Sender?.lastname} ({Sender?.publicId}
) am {new Date(report.timestamp).toLocaleString()}
gemeldet von Nutzer {Sender?.firstname} {Sender?.lastname} ({Sender?.publicId}) am{" "}
{new Date(report.timestamp).toLocaleString()}
</Link>
</div>
);
@@ -82,20 +79,12 @@ export const ReportAdmin = ({
})}
>
<h2 className="card-title">Staff Kommentar</h2>
<textarea
{...form.register("reviewerComment")}
className="textarea w-full"
placeholder=""
/>
<textarea {...form.register("reviewerComment")} className="textarea w-full" placeholder="" />
<p className="text-sm text-gray-600 text-right">
{report.Reviewer &&
`Kommentar von ${Reviewer?.firstname} ${Reviewer?.lastname} (${Reviewer?.publicId})`}
</p>
<Switch
form={form}
name="reviewed"
label="Report als geklärt markieren"
/>
<Switch form={form} name="reviewed" label="Report als geklärt markieren" />
<div className="card-actions flex justify-between">
<Button
role="submit"

View File

@@ -8,6 +8,12 @@ const AdminUserPage = async () => {
showEditButton
prismaModel="user"
searchFields={["publicId", "firstname", "lastname", "email"]}
initialOrderBy={[
{
id: "publicId",
desc: false,
},
]}
columns={[
{
header: "ID",