fixed event completed Workflow
This commit is contained in:
@@ -19,6 +19,7 @@ router.post("/set-standard-name", async (req, res) => {
|
|||||||
id: userId,
|
id: userId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
console.log(`Setting standard name for user ${userId} (${user?.publicId}) to member ${memberId}`);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
res.status(404).json({ error: "User not found" });
|
res.status(404).json({ error: "User not found" });
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ export const handleParticipantFinished = async (
|
|||||||
id: participant.id,
|
id: participant.id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
completetionWorkflowFinished: true,
|
|
||||||
statusLog: {
|
statusLog: {
|
||||||
push: {
|
push: {
|
||||||
event: "Berechtigungen und Badges vergeben",
|
event: "Berechtigungen und Badges vergeben",
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ router.post("/handle-participant-finished", async (req, res) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
console.log("Handeling Participant-completed", participant?.User.publicId);
|
||||||
if (!participant) {
|
if (!participant) {
|
||||||
res.status(404).json({ error: "Participant not found" });
|
res.status(404).json({ error: "Participant not found" });
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Event, Participant } from "@repo/db";
|
import { Event, Participant } from "@repo/db";
|
||||||
import { EventAppointmentOptionalDefaults } from "@repo/db/zod";
|
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 { useSession } from "next-auth/react";
|
||||||
import { RefObject, useRef } from "react";
|
import { RefObject, useRef } from "react";
|
||||||
import { UseFormReturn } from "react-hook-form";
|
import { UseFormReturn } from "react-hook-form";
|
||||||
@@ -10,6 +10,7 @@ import { DateInput } from "../../../../_components/ui/DateInput";
|
|||||||
import { upsertParticipant } from "../../../events/actions";
|
import { upsertParticipant } from "../../../events/actions";
|
||||||
import { deleteAppoinement, upsertAppointment } from "../action";
|
import { deleteAppoinement, upsertAppointment } from "../action";
|
||||||
import { handleParticipantFinished } from "../../../../../helper/events";
|
import { handleParticipantFinished } from "../../../../../helper/events";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
interface AppointmentModalProps {
|
interface AppointmentModalProps {
|
||||||
event?: Event;
|
event?: Event;
|
||||||
@@ -74,101 +75,111 @@ export const AppointmentModal = ({
|
|||||||
<PaginatedTable
|
<PaginatedTable
|
||||||
hide={appointmentForm.watch("id") === undefined}
|
hide={appointmentForm.watch("id") === undefined}
|
||||||
ref={participantTableRef}
|
ref={participantTableRef}
|
||||||
columns={[
|
columns={
|
||||||
{
|
[
|
||||||
accessorKey: "User.firstname",
|
{
|
||||||
header: "Vorname",
|
accessorKey: "User.firstname",
|
||||||
},
|
header: "Vorname",
|
||||||
{
|
|
||||||
accessorKey: "User.lastname",
|
|
||||||
header: "Nachname",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
accessorKey: "enscriptionDate",
|
|
||||||
header: "Einschreibedatum",
|
|
||||||
cell: ({ row }: CellContext<Participant, any>) => {
|
|
||||||
return <span>{new Date(row.original.enscriptionDate).toLocaleString()}</span>;
|
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
accessorKey: "User.lastname",
|
||||||
header: "Anwesend",
|
header: "Nachname",
|
||||||
cell: ({ row }: CellContext<Participant, any>) => {
|
|
||||||
if (row.original.attended) {
|
|
||||||
return <span className="text-green-500">Ja</span>;
|
|
||||||
} else if (row.original.appointmentCancelled) {
|
|
||||||
return <span className="text-red-500">Nein (Termin abgesagt)</span>;
|
|
||||||
} else {
|
|
||||||
return <span>?</span>;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
accessorKey: "enscriptionDate",
|
||||||
header: "Aktion",
|
header: "Einschreibedatum",
|
||||||
|
cell: ({ row }) => {
|
||||||
|
return <span>{new Date(row.original.enscriptionDate).toLocaleString()}</span>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Anwesend",
|
||||||
|
cell: ({ row }) => {
|
||||||
|
if (row.original.attended) {
|
||||||
|
return <span className="text-green-500">Ja</span>;
|
||||||
|
} else if (row.original.appointmentCancelled) {
|
||||||
|
return <span className="text-red-500">Nein (Termin abgesagt)</span>;
|
||||||
|
} else {
|
||||||
|
return <span>?</span>;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: "Aktion",
|
||||||
|
|
||||||
cell: ({ row }: CellContext<Participant, any>) => {
|
cell: ({ row }) => {
|
||||||
return (
|
return (
|
||||||
<div className="space-x-2">
|
<div className="space-x-2">
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
participantForm.reset(row.original);
|
|
||||||
participantModal.current?.showModal();
|
|
||||||
}}
|
|
||||||
className="btn btn-outline btn-sm"
|
|
||||||
>
|
|
||||||
anzeigen
|
|
||||||
</button>
|
|
||||||
{!row.original.attended && event?.hasPresenceEvents && (
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
onClick={() => {
|
||||||
onSubmit={() => {}}
|
participantForm.reset(row.original);
|
||||||
onClick={async () => {
|
participantModal.current?.showModal();
|
||||||
await upsertParticipant({
|
|
||||||
eventId: event!.id,
|
|
||||||
userId: row.original.userId,
|
|
||||||
attended: true,
|
|
||||||
appointmentCancelled: false,
|
|
||||||
});
|
|
||||||
if (!event.finisherMoodleCourseId) {
|
|
||||||
await handleParticipantFinished(row.original.id.toString());
|
|
||||||
}
|
|
||||||
participantTableRef.current?.refresh();
|
|
||||||
}}
|
}}
|
||||||
className="btn btn-outline btn-info btn-sm"
|
className="btn btn-outline btn-sm"
|
||||||
>
|
>
|
||||||
Anwesend
|
anzeigen
|
||||||
</button>
|
</button>
|
||||||
)}
|
{!row.original.attended && event?.hasPresenceEvents && (
|
||||||
{!row.original.appointmentCancelled && event?.hasPresenceEvents && (
|
<button
|
||||||
<button
|
type="button"
|
||||||
type="button"
|
onSubmit={() => {}}
|
||||||
onSubmit={() => {}}
|
onClick={async () => {
|
||||||
onClick={async () => {
|
await upsertParticipant({
|
||||||
await upsertParticipant({
|
eventId: event!.id,
|
||||||
eventId: event!.id,
|
userId: row.original.userId,
|
||||||
userId: row.original.userId,
|
attended: true,
|
||||||
attended: false,
|
appointmentCancelled: false,
|
||||||
appointmentCancelled: true,
|
});
|
||||||
statusLog: [
|
console.log(
|
||||||
...(row.original.statusLog as any),
|
"Participant attended",
|
||||||
{
|
event.finisherMoodleCourseId,
|
||||||
event: "Gefehlt an Event",
|
!event.finisherMoodleCourseId?.length,
|
||||||
timestamp: new Date().toISOString(),
|
);
|
||||||
user: `${session?.user?.firstname} ${session?.user?.lastname} - ${session?.user?.publicId}`,
|
if (!event.finisherMoodleCourseId?.length) {
|
||||||
},
|
toast(
|
||||||
],
|
"Teilnehmer hat das event abgeschlossen, workflow ausgeführt",
|
||||||
});
|
);
|
||||||
participantTableRef.current?.refresh();
|
await handleParticipantFinished(row.original.id.toString());
|
||||||
}}
|
}
|
||||||
className="btn btn-outline btn-error btn-sm"
|
participantTableRef.current?.refresh();
|
||||||
>
|
}}
|
||||||
abwesend
|
className="btn btn-outline btn-info btn-sm"
|
||||||
</button>
|
>
|
||||||
)}
|
Anwesend
|
||||||
</div>
|
</button>
|
||||||
);
|
)}
|
||||||
|
{!row.original.appointmentCancelled && event?.hasPresenceEvents && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onSubmit={() => {}}
|
||||||
|
onClick={async () => {
|
||||||
|
await upsertParticipant({
|
||||||
|
eventId: event!.id,
|
||||||
|
userId: row.original.userId,
|
||||||
|
attended: false,
|
||||||
|
appointmentCancelled: true,
|
||||||
|
statusLog: [
|
||||||
|
...(row.original.statusLog as any),
|
||||||
|
{
|
||||||
|
event: "Gefehlt an Event",
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
user: `${session?.user?.firstname} ${session?.user?.lastname} - ${session?.user?.publicId}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
participantTableRef.current?.refresh();
|
||||||
|
}}
|
||||||
|
className="btn btn-outline btn-error btn-sm"
|
||||||
|
>
|
||||||
|
abwesend
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
] as ColumnDef<Participant, any>[]
|
||||||
]}
|
}
|
||||||
prismaModel={"participant"}
|
prismaModel={"participant"}
|
||||||
filter={{
|
filter={{
|
||||||
eventAppointmentId: appointmentForm.watch("id"),
|
eventAppointmentId: appointmentForm.watch("id"),
|
||||||
|
|||||||
@@ -61,16 +61,6 @@ export const ParticipantModal = ({ participantForm, ref }: ParticipantModalProps
|
|||||||
name="finisherMoodleCurseCompleted"
|
name="finisherMoodleCurseCompleted"
|
||||||
label="Abschluss-Moodle-Kurs abgeschlossen"
|
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">
|
<div className="w-full">
|
||||||
<h3 className="text-xl">Termine</h3>
|
<h3 className="text-xl">Termine</h3>
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ model Participant {
|
|||||||
finisherMoodleCurseCompleted Boolean @default(false)
|
finisherMoodleCurseCompleted Boolean @default(false)
|
||||||
attended Boolean @default(false)
|
attended Boolean @default(false)
|
||||||
appointmentCancelled Boolean @default(false)
|
appointmentCancelled Boolean @default(false)
|
||||||
completetionWorkflowFinished Boolean @default(false)
|
|
||||||
inscriptionWorkflowCompleted Boolean @default(false)
|
|
||||||
eventAppointmentId Int?
|
eventAppointmentId Int?
|
||||||
enscriptionDate DateTime @default(now())
|
enscriptionDate DateTime @default(now())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user