Merge branch 'main' of https://github.com/VAR-Virtual-Air-Rescue/var-monorepo
This commit is contained in:
@@ -86,51 +86,53 @@ const Einsatzdetails = ({ mission }: { mission: Mission }) => {
|
|||||||
<h2 className="flex items-center gap-2 text-lg font-bold">
|
<h2 className="flex items-center gap-2 text-lg font-bold">
|
||||||
<Flag /> Einsatzdetails
|
<Flag /> Einsatzdetails
|
||||||
</h2>
|
</h2>
|
||||||
{mission.state !== "draft" && (
|
{mission.state !== "draft" &&
|
||||||
<div className="space-x-2">
|
typeof window !== "undefined" &&
|
||||||
<div
|
!window.location.pathname.startsWith("/pilot") && (
|
||||||
className="tooltip tooltip-primary tooltip-left font-semibold"
|
<div className="space-x-2">
|
||||||
data-tip="Einsatzdaten übernehmen"
|
<div
|
||||||
>
|
className="tooltip tooltip-primary tooltip-left font-semibold"
|
||||||
<button
|
data-tip="Einsatzdaten übernehmen"
|
||||||
className="btn btn-xs btn-primary btn-dash flex items-center gap-2"
|
|
||||||
onClick={() => {
|
|
||||||
setMissionFormValues({
|
|
||||||
...mission,
|
|
||||||
id: undefined,
|
|
||||||
hpgAmbulanceState: null,
|
|
||||||
hpgFireEngineState: null,
|
|
||||||
hpgPoliceState: null,
|
|
||||||
hpgLocationLat: undefined,
|
|
||||||
hpgLocationLng: undefined,
|
|
||||||
state: "draft",
|
|
||||||
});
|
|
||||||
setOpen(true);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Repeat2 size={16} />
|
<button
|
||||||
</button>
|
className="btn btn-xs btn-primary btn-dash flex items-center gap-2"
|
||||||
</div>
|
onClick={() => {
|
||||||
<div
|
setMissionFormValues({
|
||||||
className="tooltip tooltip-warning tooltip-left font-semibold z-[9999]"
|
...mission,
|
||||||
data-tip="Einsatz abschließen"
|
id: undefined,
|
||||||
>
|
hpgAmbulanceState: null,
|
||||||
<button
|
hpgFireEngineState: null,
|
||||||
className="btn btn-xs btn-warning flex items-center gap-2"
|
hpgPoliceState: null,
|
||||||
onClick={() => {
|
hpgLocationLat: undefined,
|
||||||
editMissionMutation.mutate({
|
hpgLocationLng: undefined,
|
||||||
id: mission.id,
|
state: "draft",
|
||||||
mission: {
|
});
|
||||||
state: "finished",
|
setOpen(true);
|
||||||
},
|
}}
|
||||||
});
|
>
|
||||||
}}
|
<Repeat2 size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="tooltip tooltip-warning tooltip-left font-semibold z-[9999]"
|
||||||
|
data-tip="Einsatz abschließen"
|
||||||
>
|
>
|
||||||
<CheckCheck size={16} />
|
<button
|
||||||
</button>
|
className="btn btn-xs btn-warning flex items-center gap-2"
|
||||||
|
onClick={() => {
|
||||||
|
editMissionMutation.mutate({
|
||||||
|
id: mission.id,
|
||||||
|
mission: {
|
||||||
|
state: "finished",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CheckCheck size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<ul className="text-base-content font-semibold">
|
<ul className="text-base-content font-semibold">
|
||||||
<li className="flex items-center gap-2 mb-1">
|
<li className="flex items-center gap-2 mb-1">
|
||||||
@@ -304,19 +306,22 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
<h2 className="flex items-center gap-2 text-lg font-bold mb-3">
|
<h2 className="flex items-center gap-2 text-lg font-bold mb-3">
|
||||||
<SmartphoneNfc /> Rettungsmittel
|
<SmartphoneNfc /> Rettungsmittel
|
||||||
</h2>
|
</h2>
|
||||||
<div
|
{typeof window !== "undefined" &&
|
||||||
className="tooltip tooltip-primary tooltip-left font-semibold"
|
!window.location.pathname.startsWith("/pilot") && (
|
||||||
data-tip="Einsatz erneut alarmieren"
|
<div
|
||||||
>
|
className="tooltip tooltip-primary tooltip-left font-semibold"
|
||||||
<button
|
data-tip="Einsatz erneut alarmieren"
|
||||||
className="btn btn-xs btn-primary btn-outline"
|
>
|
||||||
onClick={() => {
|
<button
|
||||||
sendAlertMutation.mutate({ id: mission.id });
|
className="btn btn-xs btn-primary btn-outline"
|
||||||
}}
|
onClick={() => {
|
||||||
>
|
sendAlertMutation.mutate({ id: mission.id });
|
||||||
<BellRing size={16} />
|
}}
|
||||||
</button>
|
>
|
||||||
</div>
|
<BellRing size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto">
|
<ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto">
|
||||||
{missionStations?.map((station, index) => {
|
{missionStations?.map((station, index) => {
|
||||||
@@ -354,66 +359,12 @@ const Rettungsmittel = ({ mission }: { mission: Mission }) => {
|
|||||||
<div className="divider mt-0 mb-0" />
|
<div className="divider mt-0 mb-0" />
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{/* TODO: make it a small multiselect */}
|
{/* TODO: make it a small multiselect */}
|
||||||
<select
|
<select className="select select-sm select-primary select-bordered flex-1">
|
||||||
className="select select-sm select-primary select-bordered flex-1"
|
<option value="1">Feuerwehr</option>
|
||||||
onChange={(e) => {
|
<option value="2">RTW</option>
|
||||||
const selected = allStations?.find(
|
<option value="3">Polizei</option>
|
||||||
(s) => s.id.toString() === e.target.value,
|
|
||||||
);
|
|
||||||
if (selected) {
|
|
||||||
setSelectedStation(selected);
|
|
||||||
} else {
|
|
||||||
setSelectedStation(
|
|
||||||
e.target.value as "ambulance" | "police" | "firebrigade",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
value={
|
|
||||||
typeof selectedStation === "string"
|
|
||||||
? selectedStation
|
|
||||||
: selectedStation?.id
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{allStations
|
|
||||||
?.filter((s) => !mission.missionStationIds.includes(s.id))
|
|
||||||
?.map((station) => (
|
|
||||||
<option
|
|
||||||
key={station.id}
|
|
||||||
value={station.id}
|
|
||||||
onClick={() => {
|
|
||||||
setSelectedStation(station);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{station.bosCallsign}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
<option disabled>Fahrzeuge:</option>
|
|
||||||
<option value="firebrigade">Feuerwehr</option>
|
|
||||||
<option value="ambulance">RTW</option>
|
|
||||||
<option value="police">Polizei</option>
|
|
||||||
</select>
|
</select>
|
||||||
<button
|
<button className="btn btn-sm btn-primary btn-outline">
|
||||||
className="btn btn-sm btn-primary btn-outline"
|
|
||||||
onClick={async () => {
|
|
||||||
if (typeof selectedStation === "string") {
|
|
||||||
toast.error("Fahrzeuge werden aktuell nicht unterstützt");
|
|
||||||
} else {
|
|
||||||
if (!selectedStation?.id) return;
|
|
||||||
await updateMissionMutation.mutateAsync({
|
|
||||||
id: mission.id,
|
|
||||||
missionEdit: {
|
|
||||||
missionStationIds: {
|
|
||||||
push: selectedStation?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
await sendAlertMutation.mutate({
|
|
||||||
id: mission.id,
|
|
||||||
stationId: selectedStation?.id ?? 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span className="text-base-content flex items-center gap-2">
|
<span className="text-base-content flex items-center gap-2">
|
||||||
<BellRing size={16} /> Nachalarmieren
|
<BellRing size={16} /> Nachalarmieren
|
||||||
</span>
|
</span>
|
||||||
@@ -447,69 +398,74 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
|
|||||||
if (!session.data?.user) return null;
|
if (!session.data?.user) return null;
|
||||||
return (
|
return (
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
<div className="flex items-center gap-2">
|
{typeof window !== "undefined" &&
|
||||||
{!isAddingNote ? (
|
!window.location.pathname.startsWith("/pilot") && (
|
||||||
<button
|
<div>
|
||||||
className="text-base-content text-base cursor-pointer"
|
<div className="flex items-center gap-2">
|
||||||
onClick={() => setIsAddingNote(true)}
|
{!isAddingNote ? (
|
||||||
>
|
<button
|
||||||
<span className="flex items-center gap-2">
|
className="text-base-content text-base cursor-pointer"
|
||||||
<Plus size={18} /> Notiz hinzufügen
|
onClick={() => setIsAddingNote(true)}
|
||||||
</span>
|
>
|
||||||
</button>
|
<span className="flex items-center gap-2">
|
||||||
) : (
|
<Plus size={18} /> Notiz hinzufügen
|
||||||
<div className="flex items-center gap-2 w-full">
|
</span>
|
||||||
<input
|
</button>
|
||||||
type="text"
|
) : (
|
||||||
placeholder=""
|
<div className="flex items-center gap-2 w-full">
|
||||||
className="input input-sm text-base-content flex-1"
|
<input
|
||||||
value={note}
|
type="text"
|
||||||
onChange={(e) => setNote(e.target.value)}
|
placeholder=""
|
||||||
/>
|
className="input input-sm text-base-content flex-1"
|
||||||
<button
|
value={note}
|
||||||
className="btn btn-sm btn-primary btn-outline"
|
onChange={(e) => setNote(e.target.value)}
|
||||||
onClick={() => {
|
/>
|
||||||
const newMissionLog = [
|
<button
|
||||||
...mission.missionLog,
|
className="btn btn-sm btn-primary btn-outline"
|
||||||
{
|
onClick={() => {
|
||||||
type: "message-log",
|
const newMissionLog = [
|
||||||
auto: false,
|
...mission.missionLog,
|
||||||
timeStamp: new Date().toISOString(),
|
{
|
||||||
data: {
|
type: "message-log",
|
||||||
message: note,
|
auto: false,
|
||||||
user: getPublicUser(session.data?.user),
|
timeStamp: new Date().toISOString(),
|
||||||
},
|
data: {
|
||||||
} as MissionMessageLog,
|
message: note,
|
||||||
];
|
user: getPublicUser(session.data?.user),
|
||||||
editMissionMutation
|
},
|
||||||
.mutateAsync({
|
} as MissionMessageLog,
|
||||||
id: mission.id,
|
];
|
||||||
mission: {
|
editMissionMutation
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
.mutateAsync({
|
||||||
missionLog: newMissionLog as any,
|
id: mission.id,
|
||||||
},
|
mission: {
|
||||||
})
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
.then(() => {
|
missionLog: newMissionLog as any,
|
||||||
setIsAddingNote(false);
|
},
|
||||||
setNote("");
|
})
|
||||||
});
|
.then(() => {
|
||||||
}}
|
setIsAddingNote(false);
|
||||||
>
|
setNote("");
|
||||||
<Plus size={20} />
|
});
|
||||||
</button>
|
}}
|
||||||
<button
|
>
|
||||||
className="btn btn-sm btn-outline"
|
<Plus size={20} />
|
||||||
onClick={() => {
|
</button>
|
||||||
setIsAddingNote(false);
|
<button
|
||||||
setNote("");
|
className="btn btn-sm btn-outline"
|
||||||
}}
|
onClick={() => {
|
||||||
>
|
setIsAddingNote(false);
|
||||||
<Ban size={20} />
|
setNote("");
|
||||||
</button>
|
}}
|
||||||
|
>
|
||||||
|
<Ban size={20} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="divider m-0" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
|
||||||
<div className="divider m-0" />
|
|
||||||
<ul className="space-y-1 max-h-[300px] overflow-y-auto overflow-x-auto">
|
<ul className="space-y-1 max-h-[300px] overflow-y-auto overflow-x-auto">
|
||||||
{(mission.missionLog as unknown as MissionLog[])
|
{(mission.missionLog as unknown as MissionLog[])
|
||||||
.slice()
|
.slice()
|
||||||
@@ -584,6 +540,11 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
|
|||||||
return null;
|
return null;
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
{!mission.missionLog.length && (
|
||||||
|
<p className="text-gray-500 w-full text-center my-10 font-semibold">
|
||||||
|
Keine Notizen verfügbar
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -75,6 +75,21 @@ export const MissionForm = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const sendAlertMutation = useMutation({
|
||||||
|
mutationKey: ["missions"],
|
||||||
|
mutationFn: sendMissionAPI,
|
||||||
|
onError: (error) => {
|
||||||
|
console.error(error);
|
||||||
|
toast.error("Fehler beim Alarmieren");
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
toast.success(data.message);
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["missions"],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const defaultFormValues = React.useMemo(
|
const defaultFormValues = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -364,7 +379,8 @@ export const MissionForm = () => {
|
|||||||
);
|
);
|
||||||
await sendAlertMutation.mutateAsync(newMission.id);
|
await sendAlertMutation.mutateAsync(newMission.id);
|
||||||
setSeachOSMElements([]); // Reset search elements
|
setSeachOSMElements([]); // Reset search elements
|
||||||
|
toast.success(`Einsatz ${newMission.id} erstellt`);
|
||||||
|
// TODO: Einsatz alarmieren
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(
|
toast.error(
|
||||||
|
|||||||
Reference in New Issue
Block a user