Fixed Automatische alarmierung nach validierung #45
This commit is contained in:
@@ -165,16 +165,6 @@ export const MissionForm = () => {
|
||||
...(mission as unknown as Prisma.MissionCreateInput),
|
||||
hpgSelectedMissionString: szenarioCode,
|
||||
});
|
||||
if (validationRequired) {
|
||||
await startHpgValidation(newMission.id, {
|
||||
alertWhenValid,
|
||||
}).catch((error) => {
|
||||
toast.error(`Fehler beim Starten der HPG-Validierung: ${error.message}`);
|
||||
});
|
||||
} else if (alertWhenValid) {
|
||||
await sendAlertMutation.mutateAsync(newMission.id);
|
||||
}
|
||||
return newMission;
|
||||
} else {
|
||||
newMission = await editMissionMutation.mutateAsync({
|
||||
id: Number(editingMissionId),
|
||||
@@ -189,14 +179,18 @@ export const MissionForm = () => {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (validationRequired) {
|
||||
await startHpgValidation(newMission.id, {}).catch((error) => {
|
||||
await startHpgValidation(newMission.id, {
|
||||
alertWhenValid,
|
||||
}).catch((error) => {
|
||||
toast.error(`Fehler beim Starten der HPG-Validierung: ${error.message}`);
|
||||
});
|
||||
} else if (alertWhenValid) {
|
||||
await sendAlertMutation.mutateAsync(newMission.id);
|
||||
}
|
||||
return newMission;
|
||||
};
|
||||
console.log(form.watch("missionStationIds"));
|
||||
return (
|
||||
<form className="space-y-4">
|
||||
{/* Koorinaten Section */}
|
||||
@@ -421,97 +415,59 @@ export const MissionForm = () => {
|
||||
|
||||
<div className="form-control min-h-[140px]">
|
||||
<div className="flex gap-2">
|
||||
{editingMissionId ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary flex-1"
|
||||
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
||||
try {
|
||||
console.log("Saving mission", mission.addressOSMways);
|
||||
const newMission = await saveMission(mission);
|
||||
toast.success(`Einsatz ${newMission.publicId} aktualisiert`);
|
||||
setSearchElements([]); // Reset search elements
|
||||
setEditingMission(null); // Reset editing state
|
||||
form.reset(); // Reset the form
|
||||
setOpen(false);
|
||||
} catch (error) {
|
||||
if (error instanceof AxiosError) {
|
||||
toast.error(
|
||||
`Fehler beim Bearbeiten des Einsatzes: ${error.response?.data.error}`,
|
||||
);
|
||||
} else {
|
||||
toast.error(
|
||||
`Fehler beim Bearbeiten des Einsatzes: ${(error as Error).message}`,
|
||||
);
|
||||
}
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-warning"
|
||||
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
||||
try {
|
||||
const newMission = await saveMission(mission, {
|
||||
createNewMission: !editingMissionId,
|
||||
alertWhenValid: true,
|
||||
});
|
||||
|
||||
setSearchElements([]); // Reset search elements
|
||||
setEditingMission(null);
|
||||
setContextMenu(null);
|
||||
toast.success(`Einsatz ${newMission.publicId} erstellt`);
|
||||
form.reset();
|
||||
setOpen(false);
|
||||
} catch (error) {
|
||||
if (error instanceof AxiosError) {
|
||||
toast.error(`Fehler beim Erstellen des Einsatzes: ${error.response?.data.error}`);
|
||||
} else {
|
||||
toast.error(`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`);
|
||||
}
|
||||
})}
|
||||
>
|
||||
Änderungen speichern
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-warning"
|
||||
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
||||
try {
|
||||
const newMission = await saveMission(mission, {
|
||||
createNewMission: true,
|
||||
alertWhenValid: true,
|
||||
});
|
||||
}
|
||||
})}
|
||||
>
|
||||
<BellRing className="h-4 w-4" /> Alarmieren
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-primary flex-1"
|
||||
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
||||
try {
|
||||
const newMission = await saveMission(mission, {
|
||||
createNewMission: !editingMissionId,
|
||||
});
|
||||
|
||||
setSearchElements([]); // Reset search elements
|
||||
setContextMenu(null);
|
||||
toast.success(`Einsatz ${newMission.publicId} erstellt`);
|
||||
form.reset();
|
||||
setOpen(false);
|
||||
} catch (error) {
|
||||
if (error instanceof AxiosError) {
|
||||
toast.error(
|
||||
`Fehler beim Erstellen des Einsatzes: ${error.response?.data.error}`,
|
||||
);
|
||||
} else {
|
||||
toast.error(
|
||||
`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
})}
|
||||
>
|
||||
<BellRing className="h-4 w-4" /> Alarmieren
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-primary flex-1"
|
||||
onClick={form.handleSubmit(async (mission: MissionOptionalDefaults) => {
|
||||
try {
|
||||
const newMission = await saveMission(mission, {
|
||||
createNewMission: true,
|
||||
});
|
||||
|
||||
setSearchElements([]); // Reset search elements
|
||||
setContextMenu(null);
|
||||
toast.success(`Einsatz ${newMission.publicId} erstellt`);
|
||||
form.reset();
|
||||
setOpen(false);
|
||||
} catch (error) {
|
||||
if (error instanceof AxiosError) {
|
||||
toast.error(
|
||||
`Fehler beim Erstellen des Einsatzes: ${error.response?.data.error}`,
|
||||
);
|
||||
} else {
|
||||
toast.error(
|
||||
`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
})}
|
||||
>
|
||||
<BookmarkPlus className="h-5 w-5" /> Einsatz vorbereiten
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
setSearchElements([]); // Reset search elements
|
||||
setContextMenu(null);
|
||||
toast.success(`Einsatz ${newMission.publicId} erstellt`);
|
||||
form.reset();
|
||||
setOpen(false);
|
||||
} catch (error) {
|
||||
if (error instanceof AxiosError) {
|
||||
toast.error(`Fehler beim Erstellen des Einsatzes: ${error.response?.data.error}`);
|
||||
} else {
|
||||
toast.error(`Fehler beim Erstellen des Einsatzes: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
})}
|
||||
>
|
||||
<BookmarkPlus className="h-5 w-5" />{" "}
|
||||
{editingMissionId ? "Einsatz bearbeiten" : "Einsatz Vorbereiten"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -741,7 +741,9 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
|
||||
</li>
|
||||
);
|
||||
if (entry.type === "alert-log") {
|
||||
const alertReceiver = entry.data.station?.bosCallsignShort || entry.data.vehicle;
|
||||
const alertReceiver = entry.auto
|
||||
? null
|
||||
: entry.data.station?.bosCallsignShort || entry.data.vehicle;
|
||||
return (
|
||||
<li key={index} className="flex items-center gap-2">
|
||||
<span className="text-base-content">
|
||||
@@ -756,8 +758,13 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
|
||||
color: FMS_STATUS_TEXT_COLORS[6],
|
||||
}}
|
||||
>
|
||||
{entry.data.user.firstname?.[0]?.toUpperCase() ?? "?"}
|
||||
{entry.data.user.lastname?.[0]?.toUpperCase() ?? "?"}
|
||||
{!entry.auto && (
|
||||
<>
|
||||
{entry.data.user.firstname?.[0]?.toUpperCase() ?? "?"}
|
||||
{entry.data.user.lastname?.[0]?.toUpperCase() ?? "?"}
|
||||
</>
|
||||
)}
|
||||
{entry.auto && "AUTO"}
|
||||
{alertReceiver && (
|
||||
<>
|
||||
<svg
|
||||
|
||||
Reference in New Issue
Block a user