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

@@ -1,5 +1,5 @@
"use client";
import { DrawingPinFilledIcon, EnterIcon } from "@radix-ui/react-icons";
import { DrawingPinFilledIcon } from "@radix-ui/react-icons";
import { Event, Participant, EventAppointment, User } from "@repo/db";
import ModalBtn from "./modalBtn";
import MDEditor from "@uiw/react-md-editor";
@@ -26,14 +26,10 @@ export const KursItem = ({
<h2 className="card-title">{event.name}</h2>
<div className="absolute top-0 right-0 m-4">
{event.type === "COURSE" && (
<span className="badge badge-info badge-outline">
Zusatzqualifikation
</span>
<span className="badge badge-info badge-outline">Zusatzqualifikation</span>
)}
{event.type === "OBLIGATED_COURSE" && (
<span className="badge badge-secondary badge-outline">
Verpflichtend
</span>
<span className="badge badge-secondary badge-outline">Verpflichtend</span>
)}
</div>
<div className="grid grid-cols-6 gap-4">
@@ -65,10 +61,7 @@ export const KursItem = ({
<b className="text-gray-600 text-left mr-2">Abzeichen:</b>
<div className="flex gap-2">
{event.requiredBadges.map((badge) => (
<div
className="badge badge-secondary badge-outline"
key={badge}
>
<div className="badge badge-secondary badge-outline" key={badge}>
{badge}
</div>
))}

View File

@@ -11,7 +11,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { Select } from "../../../_components/ui/Select";
import toast from "react-hot-toast";
import { useRouter } from "next/navigation";
import { eventCompleted } from "../../../../helper/events";
import { eventCompleted, handleParticipantEnrolled } from "../../../../helper/events";
interface ModalBtnProps {
title: string;
@@ -123,13 +123,12 @@ const ModalBtn = ({
<div className="flex items-center gap-2 justify-center">
<CalendarIcon />
{!!dates.length && (
// TODO: Prevent users from selecting an appointment that is full
<Select
form={selectAppointmentForm as any}
form={selectAppointmentForm}
options={dates.map((date) => ({
label: `${new Date(
date.appointmentDate,
).toLocaleString()} - (${(date as any)._count.Participants}/${event.maxParticipants})`,
).toLocaleString()} - (${(date as any).Participants.length}/${event.maxParticipants})`,
value: date.id,
}))}
name="eventAppointmentId"
@@ -226,12 +225,14 @@ const ModalBtn = ({
const data = selectAppointmentForm.getValues();
if (!data.eventAppointmentId) return;
await upsertParticipant({
const participant = await upsertParticipant({
...data,
enscriptionDate: new Date(),
statusLog: data.statusLog?.filter((log) => log !== null),
appointmentCancelled: false,
});
await handleParticipantEnrolled(participant.id.toString());
router.refresh();
closeModal();
}}