changed toast timer, redirect behavior in disptach, VehicleNames
This commit is contained in:
@@ -63,7 +63,7 @@ export function QueryProvider({ children }: { children: ReactNode }) {
|
||||
toast.custom(
|
||||
(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({
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user