Nachalarmieren select
Alarmieren aus Einsatz erstellen Maske Map-Tiles SDS sound: Status J SDS Nachricht: public-User Audio: Es kann nur ein Nutzer gleichzeitig Funken Select in Report und Chat: default value -> OnChange
This commit is contained in:
@@ -397,7 +397,9 @@ const SDSTab = ({
|
||||
stationId: aircraft.Station.id,
|
||||
station: aircraft.Station,
|
||||
message: note,
|
||||
user: getPublicUser(session.data!.user),
|
||||
user: getPublicUser(session.data!.user, {
|
||||
ignorePrivacy: true,
|
||||
}),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -341,10 +341,10 @@ const Patientdetails = ({ mission }: { mission: Mission }) => {
|
||||
|
||||
const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
||||
const queryClient = useQueryClient();
|
||||
const [selectedStation, setSelectedStation] = useState<Station | "RTW" | "POL" | "FW" | null>(
|
||||
const [selectedStation, setSelectedStation] = useState<number | "RTW" | "POL" | "FW" | null>(
|
||||
null,
|
||||
);
|
||||
const { data: conenctedAircrafts } = useQuery({
|
||||
const { data: connectedAircrafts } = useQuery({
|
||||
queryKey: ["aircrafts"],
|
||||
queryFn: getConnectedAircraftsAPI,
|
||||
});
|
||||
@@ -383,17 +383,6 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
||||
queryFn: () => getStationsAPI(),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (allStations) {
|
||||
const stationsNotItMission = allStations.filter(
|
||||
(s) => !mission.missionStationIds.includes(s.id),
|
||||
);
|
||||
if (stationsNotItMission[0]) {
|
||||
setSelectedStation(stationsNotItMission[0]);
|
||||
}
|
||||
}
|
||||
}, [allStations, mission.missionStationIds]);
|
||||
|
||||
const sendAlertMutation = useMutation({
|
||||
mutationKey: ["missions"],
|
||||
mutationFn: ({
|
||||
@@ -421,7 +410,7 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
||||
label: station.bosCallsign,
|
||||
value: station.id,
|
||||
type: "station" as const,
|
||||
isOnline: !!conenctedAircrafts?.find((a) => a.stationId === station.id),
|
||||
isOnline: !!connectedAircrafts?.find((a) => a.stationId === station.id),
|
||||
})) || []),
|
||||
...(!mission.hpgFireEngineState || mission.hpgFireEngineState === "NOT_REQUESTED"
|
||||
? [{ label: "Feuerwehr", value: "FW", type: "vehicle" as const }]
|
||||
@@ -447,18 +436,6 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
||||
return a.label.localeCompare(b.label);
|
||||
});
|
||||
|
||||
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 }) => (
|
||||
@@ -506,7 +483,7 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
||||
</div>
|
||||
<ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto">
|
||||
{missionStations?.map((station, index) => {
|
||||
const connectedAircraft = conenctedAircrafts?.find(
|
||||
const connectedAircraft = connectedAircrafts?.find(
|
||||
(aircraft) => aircraft.stationId === station.id,
|
||||
);
|
||||
|
||||
@@ -550,15 +527,15 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
||||
<select
|
||||
className="select select-sm select-primary select-bordered flex-1"
|
||||
onChange={(e) => {
|
||||
const selected = allStations?.find((s) => s.id.toString() === e.target.value);
|
||||
if (selected) {
|
||||
setSelectedStation(selected);
|
||||
} else {
|
||||
setSelectedStation(e.target.value as "RTW" | "POL" | "FW");
|
||||
}
|
||||
const value = e.target.value;
|
||||
const parsedValue = !isNaN(Number(value)) ? parseInt(value, 10) : value;
|
||||
setSelectedStation(parsedValue as number | "RTW" | "POL" | "FW" | null);
|
||||
}}
|
||||
value={typeof selectedStation === "string" ? selectedStation : selectedStation?.id}
|
||||
value={selectedStation || "default"}
|
||||
>
|
||||
<option disabled value={"default"}>
|
||||
Rettungsmittel auswählen
|
||||
</option>
|
||||
{stationsOptions.map((option) => (
|
||||
<option
|
||||
key={option.value}
|
||||
@@ -582,18 +559,18 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
||||
vehicleName: selectedStation,
|
||||
});
|
||||
} else {
|
||||
if (!selectedStation?.id) return;
|
||||
if (!selectedStation) return;
|
||||
await updateMissionMutation.mutateAsync({
|
||||
id: mission.id,
|
||||
missionEdit: {
|
||||
missionStationIds: {
|
||||
push: selectedStation?.id,
|
||||
push: selectedStation,
|
||||
},
|
||||
},
|
||||
});
|
||||
await sendAlertMutation.mutate({
|
||||
id: mission.id,
|
||||
stationId: selectedStation?.id ?? 0,
|
||||
stationId: selectedStation,
|
||||
});
|
||||
}
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user