Moodle-überprüfungs option für admins hinzugefügt
This commit is contained in:
@@ -5,7 +5,7 @@ import { UseFormReturn } from "react-hook-form";
|
||||
import { upsertParticipant } from "../../../events/actions";
|
||||
import { RefObject } from "react";
|
||||
import { deleteParticipant } from "../action";
|
||||
import { handleParticipantFinished } from "../../../../../helper/events";
|
||||
import { checkMoodleResults, handleParticipantFinished } from "../../../../../helper/events";
|
||||
import { AxiosError } from "axios";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
@@ -22,6 +22,7 @@ export const ParticipantModal = ({ participantForm, ref }: ParticipantModalProps
|
||||
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button>
|
||||
</form>
|
||||
<h1 className="text-2xl">Teilnehmer bearbeiten</h1>
|
||||
|
||||
<form
|
||||
onSubmit={participantForm.handleSubmit(async (data) => {
|
||||
await upsertParticipant({
|
||||
@@ -33,27 +34,6 @@ export const ParticipantModal = ({ participantForm, ref }: ParticipantModalProps
|
||||
})}
|
||||
className="space-y-1"
|
||||
>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
if (!participantForm.watch("id")) return;
|
||||
|
||||
const participant = participantForm.getValues();
|
||||
await handleParticipantFinished(participant.id.toString()).catch((e) => {
|
||||
const error = e as AxiosError;
|
||||
if (
|
||||
error.response?.data &&
|
||||
typeof error.response.data === "object" &&
|
||||
"error" in error.response.data
|
||||
) {
|
||||
toast.error(`Fehler: ${error.response.data.error}`);
|
||||
} else {
|
||||
toast.error("Unbekannter Fehler beim ausführen des Workflows");
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
Event-abgeschlossen Workflow ausführen
|
||||
</Button>
|
||||
<Switch form={participantForm} name="attended" label="Termin Teilgenommen" />
|
||||
<Switch form={participantForm} name="appointmentCancelled" label="Termin abgesagt" />
|
||||
<Switch
|
||||
@@ -61,6 +41,57 @@ export const ParticipantModal = ({ participantForm, ref }: ParticipantModalProps
|
||||
name="finisherMoodleCurseCompleted"
|
||||
label="Abschluss-Moodle-Kurs abgeschlossen"
|
||||
/>
|
||||
<div>
|
||||
<h3 className="text-xl">Debug</h3>
|
||||
|
||||
<div className="flex gap-3">
|
||||
<Button
|
||||
className="btn-sm"
|
||||
onClick={async () => {
|
||||
if (!participantForm.watch("id")) return;
|
||||
|
||||
const participant = participantForm.getValues();
|
||||
await handleParticipantFinished(participant.id.toString()).catch((e) => {
|
||||
const error = e as AxiosError;
|
||||
if (
|
||||
error.response?.data &&
|
||||
typeof error.response.data === "object" &&
|
||||
"error" in error.response.data
|
||||
) {
|
||||
toast.error(`Fehler: ${error.response.data.error}`);
|
||||
} else {
|
||||
toast.error("Unbekannter Fehler beim ausführen des Workflows");
|
||||
}
|
||||
toast.success("Workflow erfolgreich ausgeführt");
|
||||
});
|
||||
}}
|
||||
>
|
||||
Event-abgeschlossen Workflow ausführen
|
||||
</Button>
|
||||
<Button
|
||||
className="btn-sm"
|
||||
onClick={async () => {
|
||||
if (!participantForm.watch("id")) return;
|
||||
|
||||
const participant = participantForm.getValues();
|
||||
await checkMoodleResults(participant.id.toString()).catch((e) => {
|
||||
const error = e as AxiosError;
|
||||
if (
|
||||
error.response?.data &&
|
||||
typeof error.response.data === "object" &&
|
||||
"error" in error.response.data
|
||||
) {
|
||||
toast.error(`Fehler: ${error.response.data.error}`);
|
||||
} else {
|
||||
toast.error("Unbekannter Fehler beim ausführen des Workflows");
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
Moodle-Kurs aktualisieren
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<h3 className="text-xl">Termine</h3>
|
||||
|
||||
@@ -79,21 +110,23 @@ export const ParticipantModal = ({ participantForm, ref }: ParticipantModalProps
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Button type="submit" className="btn btn-primary">
|
||||
Speichern
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
className="btn btn-error btn-outline"
|
||||
onSubmit={() => false}
|
||||
onClick={() => {
|
||||
deleteParticipant(participantForm.watch("id"));
|
||||
participantForm.reset();
|
||||
ref.current?.close();
|
||||
}}
|
||||
>
|
||||
Löschen
|
||||
</Button>
|
||||
<div className="flex gap-2 w-full justify-center">
|
||||
<Button type="submit" className="btn btn-primary">
|
||||
Speichern
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
className="btn btn-error btn-outline"
|
||||
onSubmit={() => false}
|
||||
onClick={() => {
|
||||
deleteParticipant(participantForm.watch("id"));
|
||||
participantForm.reset();
|
||||
ref.current?.close();
|
||||
}}
|
||||
>
|
||||
Löschen
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
Reference in New Issue
Block a user