removed event-chronjobs, used Events in hub-app insteand, added admin Btn to set Discord-User and run Event-completed-workflow. Fixed Bug of wrong participants-count in Event-Modal

This commit is contained in:
PxlLoewe
2025-06-05 23:02:34 -07:00
parent 91d811e289
commit 587884dfd9
21 changed files with 341 additions and 232 deletions

View File

@@ -9,6 +9,7 @@ import { Button } from "../../../../_components/ui/Button";
import { DateInput } from "../../../../_components/ui/DateInput";
import { upsertParticipant } from "../../../events/actions";
import { deleteAppoinement, upsertAppointment } from "../action";
import { handleParticipantFinished } from "../../../../../helper/events";
interface AppointmentModalProps {
event?: Event;
@@ -127,6 +128,9 @@ export const AppointmentModal = ({
attended: true,
appointmentCancelled: false,
});
if (!event.finisherMoodleCourseId) {
await handleParticipantFinished(row.original.id.toString());
}
participantTableRef.current?.refresh();
}}
className="btn btn-outline btn-info btn-sm"

View File

@@ -5,6 +5,9 @@ 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 { AxiosError } from "axios";
import toast from "react-hot-toast";
interface ParticipantModalProps {
participantForm: UseFormReturn<Participant>;
@@ -30,6 +33,27 @@ 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