fixed event completed Workflow

This commit is contained in:
PxlLoewe
2025-06-06 12:32:19 -07:00
parent b1262c4278
commit fa6321b808
6 changed files with 101 additions and 101 deletions

View File

@@ -19,6 +19,7 @@ router.post("/set-standard-name", async (req, res) => {
id: userId,
},
});
console.log(`Setting standard name for user ${userId} (${user?.publicId}) to member ${memberId}`);
if (!user) {
res.status(404).json({ error: "User not found" });
return;

View File

@@ -47,7 +47,6 @@ export const handleParticipantFinished = async (
id: participant.id,
},
data: {
completetionWorkflowFinished: true,
statusLog: {
push: {
event: "Berechtigungen und Badges vergeben",

View File

@@ -24,6 +24,7 @@ router.post("/handle-participant-finished", async (req, res) => {
},
},
});
console.log("Handeling Participant-completed", participant?.User.publicId);
if (!participant) {
res.status(404).json({ error: "Participant not found" });
return;

View File

@@ -1,6 +1,6 @@
import { Event, Participant } from "@repo/db";
import { EventAppointmentOptionalDefaults } from "@repo/db/zod";
import { CellContext } from "@tanstack/react-table";
import { ColumnDef } from "@tanstack/react-table";
import { useSession } from "next-auth/react";
import { RefObject, useRef } from "react";
import { UseFormReturn } from "react-hook-form";
@@ -10,6 +10,7 @@ import { DateInput } from "../../../../_components/ui/DateInput";
import { upsertParticipant } from "../../../events/actions";
import { deleteAppoinement, upsertAppointment } from "../action";
import { handleParticipantFinished } from "../../../../../helper/events";
import toast from "react-hot-toast";
interface AppointmentModalProps {
event?: Event;
@@ -74,7 +75,8 @@ export const AppointmentModal = ({
<PaginatedTable
hide={appointmentForm.watch("id") === undefined}
ref={participantTableRef}
columns={[
columns={
[
{
accessorKey: "User.firstname",
header: "Vorname",
@@ -86,13 +88,13 @@ export const AppointmentModal = ({
{
accessorKey: "enscriptionDate",
header: "Einschreibedatum",
cell: ({ row }: CellContext<Participant, any>) => {
cell: ({ row }) => {
return <span>{new Date(row.original.enscriptionDate).toLocaleString()}</span>;
},
},
{
header: "Anwesend",
cell: ({ row }: CellContext<Participant, any>) => {
cell: ({ row }) => {
if (row.original.attended) {
return <span className="text-green-500">Ja</span>;
} else if (row.original.appointmentCancelled) {
@@ -105,7 +107,7 @@ export const AppointmentModal = ({
{
header: "Aktion",
cell: ({ row }: CellContext<Participant, any>) => {
cell: ({ row }) => {
return (
<div className="space-x-2">
<button
@@ -128,7 +130,15 @@ export const AppointmentModal = ({
attended: true,
appointmentCancelled: false,
});
if (!event.finisherMoodleCourseId) {
console.log(
"Participant attended",
event.finisherMoodleCourseId,
!event.finisherMoodleCourseId?.length,
);
if (!event.finisherMoodleCourseId?.length) {
toast(
"Teilnehmer hat das event abgeschlossen, workflow ausgeführt",
);
await handleParticipantFinished(row.original.id.toString());
}
participantTableRef.current?.refresh();
@@ -168,7 +178,8 @@ export const AppointmentModal = ({
);
},
},
]}
] as ColumnDef<Participant, any>[]
}
prismaModel={"participant"}
filter={{
eventAppointmentId: appointmentForm.watch("id"),

View File

@@ -61,16 +61,6 @@ export const ParticipantModal = ({ participantForm, ref }: ParticipantModalProps
name="finisherMoodleCurseCompleted"
label="Abschluss-Moodle-Kurs abgeschlossen"
/>
<Switch
form={participantForm}
name="inscriptionWorkflowCompleted"
label="Anmeldeprozess abgeschlossen (Discord-rollen vergeben)"
/>
<Switch
form={participantForm}
name="completetionWorkflowFinished"
label="Abgeschlossen (E-Mail-Benachrichtigung senden)"
/>
<div className="w-full">
<h3 className="text-xl">Termine</h3>

View File

@@ -22,8 +22,6 @@ model Participant {
finisherMoodleCurseCompleted Boolean @default(false)
attended Boolean @default(false)
appointmentCancelled Boolean @default(false)
completetionWorkflowFinished Boolean @default(false)
inscriptionWorkflowCompleted Boolean @default(false)
eventAppointmentId Int?
enscriptionDate DateTime @default(now())