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:
@@ -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();
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user