changed toast timer, redirect behavior in disptach, VehicleNames
This commit is contained in:
@@ -1,19 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
getPublicUser,
|
getPublicUser,
|
||||||
HpgValidationState,
|
HpgValidationState,
|
||||||
MissionAlertLog,
|
|
||||||
MissionSdsLog,
|
MissionSdsLog,
|
||||||
MissionStationLog,
|
|
||||||
NotificationPayload,
|
NotificationPayload,
|
||||||
Prisma,
|
|
||||||
prisma,
|
prisma,
|
||||||
User,
|
User,
|
||||||
} from "@repo/db";
|
} from "@repo/db";
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { io } from "../index";
|
import { io } from "../index";
|
||||||
import { sendNtfyMission } from "modules/ntfy";
|
|
||||||
import { sendAlert } from "modules/mission";
|
import { sendAlert } from "modules/mission";
|
||||||
import { userInfo } from "os";
|
|
||||||
|
|
||||||
const router: Router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
@@ -119,7 +114,7 @@ router.post("/:id/send-alert", async (req, res) => {
|
|||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
const { stationId, vehicleName } = req.body as {
|
const { stationId, vehicleName } = req.body as {
|
||||||
stationId?: number;
|
stationId?: number;
|
||||||
vehicleName?: "ambulance" | "police" | "firebrigade";
|
vehicleName?: "RTW" | "POL" | "FW";
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!req.user) {
|
if (!req.user) {
|
||||||
@@ -142,9 +137,9 @@ router.post("/:id/send-alert", async (req, res) => {
|
|||||||
id: Number(id),
|
id: Number(id),
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
hpgAmbulanceState: vehicleName === "ambulance" ? "DISPATCHED" : undefined,
|
hpgAmbulanceState: vehicleName === "RTW" ? "DISPATCHED" : undefined,
|
||||||
hpgFireEngineState: vehicleName === "firebrigade" ? "DISPATCHED" : undefined,
|
hpgFireEngineState: vehicleName === "FW" ? "DISPATCHED" : undefined,
|
||||||
hpgPoliceState: vehicleName === "police" ? "DISPATCHED" : undefined,
|
hpgPoliceState: vehicleName === "POL" ? "DISPATCHED" : undefined,
|
||||||
missionLog: {
|
missionLog: {
|
||||||
push: {
|
push: {
|
||||||
type: "alert-log",
|
type: "alert-log",
|
||||||
@@ -152,7 +147,7 @@ router.post("/:id/send-alert", async (req, res) => {
|
|||||||
timeStamp: new Date().toISOString(),
|
timeStamp: new Date().toISOString(),
|
||||||
data: {
|
data: {
|
||||||
vehicle: vehicleName,
|
vehicle: vehicleName,
|
||||||
user: getPublicUser(req.user as User),
|
user: getPublicUser(req.user as User, { ignorePrivacy: true }),
|
||||||
},
|
},
|
||||||
} as any,
|
} as any,
|
||||||
},
|
},
|
||||||
@@ -162,9 +157,9 @@ router.post("/:id/send-alert", async (req, res) => {
|
|||||||
io.to(`desktop:${aircraft.userId}`).emit("hpg-vehicle-update", {
|
io.to(`desktop:${aircraft.userId}`).emit("hpg-vehicle-update", {
|
||||||
missionId: id,
|
missionId: id,
|
||||||
vehicleData: {
|
vehicleData: {
|
||||||
ambulanceState: newMission.hpgAmbulanceState,
|
RTWState: newMission.hpgAmbulanceState,
|
||||||
fireEngineState: newMission.hpgFireEngineState,
|
fireEngineState: newMission.hpgFireEngineState,
|
||||||
policeState: newMission.hpgPoliceState,
|
POLState: newMission.hpgPoliceState,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export function QueryProvider({ children }: { children: ReactNode }) {
|
|||||||
toast.custom(
|
toast.custom(
|
||||||
(t) => <HPGnotificationToast event={notification} mapStore={mapStore} t={t} />,
|
(t) => <HPGnotificationToast event={notification} mapStore={mapStore} t={t} />,
|
||||||
{
|
{
|
||||||
duration: 99999,
|
duration: 15000,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,6 @@ const Einsatzdetails = ({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { data: aircrafts } = useQuery({
|
|
||||||
queryKey: ["aircrafts"],
|
|
||||||
queryFn: getConnectedAircraftsAPI,
|
|
||||||
});
|
|
||||||
const sendAlertMutation = useMutation({
|
const sendAlertMutation = useMutation({
|
||||||
mutationKey: ["missions"],
|
mutationKey: ["missions"],
|
||||||
mutationFn: (id: number) => sendMissionAPI(id, {}),
|
mutationFn: (id: number) => sendMissionAPI(id, {}),
|
||||||
@@ -343,9 +339,9 @@ const Patientdetails = ({ mission }: { mission: Mission }) => {
|
|||||||
|
|
||||||
const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [selectedStation, setSelectedStation] = useState<
|
const [selectedStation, setSelectedStation] = useState<Station | "RTW" | "POL" | "FW" | null>(
|
||||||
Station | "ambulance" | "police" | "firebrigade" | null
|
null,
|
||||||
>(null);
|
);
|
||||||
const { data: conenctedAircrafts } = useQuery({
|
const { data: conenctedAircrafts } = useQuery({
|
||||||
queryKey: ["aircrafts"],
|
queryKey: ["aircrafts"],
|
||||||
queryFn: getConnectedAircraftsAPI,
|
queryFn: getConnectedAircraftsAPI,
|
||||||
@@ -405,7 +401,7 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
}: {
|
}: {
|
||||||
id: number;
|
id: number;
|
||||||
stationId?: number;
|
stationId?: number;
|
||||||
vehicleName?: "ambulance" | "police" | "firebrigade";
|
vehicleName?: "RTW" | "POL" | "FW";
|
||||||
}) => sendMissionAPI(id, { stationId, vehicleName }),
|
}) => sendMissionAPI(id, { stationId, vehicleName }),
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error(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 dispatcherConnected = useDispatchConnectionStore((s) => s.status) === "connected";
|
||||||
|
|
||||||
const HPGVehicle = ({ state, name }: { state: HpgState; name: string }) => (
|
const HPGVehicle = ({ state, name }: { state: HpgState; name: string }) => (
|
||||||
@@ -511,7 +538,7 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
if (selected) {
|
if (selected) {
|
||||||
setSelectedStation(selected);
|
setSelectedStation(selected);
|
||||||
} else {
|
} else {
|
||||||
setSelectedStation(e.target.value as "ambulance" | "police" | "firebrigade");
|
setSelectedStation(e.target.value as "RTW" | "POL" | "FW");
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
value={typeof selectedStation === "string" ? selectedStation : selectedStation?.id}
|
value={typeof selectedStation === "string" ? selectedStation : selectedStation?.id}
|
||||||
@@ -529,14 +556,19 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
{station.bosCallsign}
|
{station.bosCallsign}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
<option disabled>Fahrzeuge:</option>
|
<option disabled value={"default"}>
|
||||||
<option value="firebrigade">Feuerwehr</option>
|
Fahrzeuge:
|
||||||
<option value="ambulance">RTW</option>
|
</option>
|
||||||
<option value="police">Polizei</option>
|
{stationsOptions.map((option) => (
|
||||||
|
<option key={option.value} value={option.value}>
|
||||||
|
{option.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-primary btn-outline"
|
className="btn btn-sm btn-primary btn-outline"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
console.log("Selected Station:", selectedStation);
|
||||||
if (typeof selectedStation === "string") {
|
if (typeof selectedStation === "string") {
|
||||||
await sendAlertMutation.mutate({
|
await sendAlertMutation.mutate({
|
||||||
id: mission.id,
|
id: mission.id,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const sendMissionAPI = async (
|
|||||||
vehicleName,
|
vehicleName,
|
||||||
}: {
|
}: {
|
||||||
stationId?: number;
|
stationId?: number;
|
||||||
vehicleName?: "ambulance" | "police" | "firebrigade";
|
vehicleName?: "RTW" | "POL" | "FW";
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
const respone = await serverApi.post<{
|
const respone = await serverApi.post<{
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ export default () => {
|
|||||||
const session = useSession();
|
const session = useSession();
|
||||||
|
|
||||||
useEffect(() => {
|
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");
|
const hasDispoPermission = session.data.user.permissions?.includes("DISPO");
|
||||||
|
|
||||||
if (hasDispoPermission) {
|
if (hasDispoPermission) {
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ export const ReportSenderInfo = ({
|
|||||||
const { Reported, Sender } = report;
|
const { Reported, Sender } = report;
|
||||||
return (
|
return (
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
<Link
|
<Link href={`/admin/user/${Reported?.id}`} className="card-title link link-hover">
|
||||||
href={`/admin/user/${Reported?.id}`}
|
|
||||||
className="card-title link link-hover"
|
|
||||||
>
|
|
||||||
{Reported?.firstname} {Reported?.lastname} ({Reported?.publicId})
|
{Reported?.firstname} {Reported?.lastname} ({Reported?.publicId})
|
||||||
</Link>
|
</Link>
|
||||||
<div className="textarea w-full text-left">{report.text}</div>
|
<div className="textarea w-full text-left">{report.text}</div>
|
||||||
@@ -35,8 +32,8 @@ export const ReportSenderInfo = ({
|
|||||||
href={`/admin/user/${Reported?.id}`}
|
href={`/admin/user/${Reported?.id}`}
|
||||||
className="text-sm text-gray-600 text-right link link-hover"
|
className="text-sm text-gray-600 text-right link link-hover"
|
||||||
>
|
>
|
||||||
Meldet Nutzer {Sender?.firstname} {Sender?.lastname} ({Sender?.publicId}
|
gemeldet von Nutzer {Sender?.firstname} {Sender?.lastname} ({Sender?.publicId}) am{" "}
|
||||||
) am {new Date(report.timestamp).toLocaleString()}
|
{new Date(report.timestamp).toLocaleString()}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -82,20 +79,12 @@ export const ReportAdmin = ({
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<h2 className="card-title">Staff Kommentar</h2>
|
<h2 className="card-title">Staff Kommentar</h2>
|
||||||
<textarea
|
<textarea {...form.register("reviewerComment")} className="textarea w-full" placeholder="" />
|
||||||
{...form.register("reviewerComment")}
|
|
||||||
className="textarea w-full"
|
|
||||||
placeholder=""
|
|
||||||
/>
|
|
||||||
<p className="text-sm text-gray-600 text-right">
|
<p className="text-sm text-gray-600 text-right">
|
||||||
{report.Reviewer &&
|
{report.Reviewer &&
|
||||||
`Kommentar von ${Reviewer?.firstname} ${Reviewer?.lastname} (${Reviewer?.publicId})`}
|
`Kommentar von ${Reviewer?.firstname} ${Reviewer?.lastname} (${Reviewer?.publicId})`}
|
||||||
</p>
|
</p>
|
||||||
<Switch
|
<Switch form={form} name="reviewed" label="Report als geklärt markieren" />
|
||||||
form={form}
|
|
||||||
name="reviewed"
|
|
||||||
label="Report als geklärt markieren"
|
|
||||||
/>
|
|
||||||
<div className="card-actions flex justify-between">
|
<div className="card-actions flex justify-between">
|
||||||
<Button
|
<Button
|
||||||
role="submit"
|
role="submit"
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ const AdminUserPage = async () => {
|
|||||||
showEditButton
|
showEditButton
|
||||||
prismaModel="user"
|
prismaModel="user"
|
||||||
searchFields={["publicId", "firstname", "lastname", "email"]}
|
searchFields={["publicId", "firstname", "lastname", "email"]}
|
||||||
|
initialOrderBy={[
|
||||||
|
{
|
||||||
|
id: "publicId",
|
||||||
|
desc: false,
|
||||||
|
},
|
||||||
|
]}
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
header: "ID",
|
header: "ID",
|
||||||
|
|||||||
Reference in New Issue
Block a user