"use client"; import { useEffect } from "react"; import { CheckCircledIcon, CalendarIcon, EnterIcon, } from "@radix-ui/react-icons"; import { Event, EventAppointment, Participant, User } from "@repo/db"; import { cn } from "../../../../helper/cn"; import { addParticipant, inscribeToMoodleCourse } from "../actions"; import { useSession } from "next-auth/react"; interface ModalBtnProps { title: string; event: Event; dates: EventAppointment[]; participant?: Participant; user: User; modalId: string; } const ModalBtn = ({ title, dates, modalId, participant, event, user, }: ModalBtnProps) => { useEffect(() => { const modal = document.getElementById(modalId) as HTMLDialogElement; const handleOpen = () => { document.body.classList.add("modal-open"); }; const handleClose = () => { document.body.classList.remove("modal-open"); }; modal?.addEventListener("show", handleOpen); modal?.addEventListener("close", handleClose); return () => { modal?.removeEventListener("show", handleOpen); modal?.removeEventListener("close", handleClose); }; }, [modalId]); const openModal = () => { const modal = document.getElementById(modalId) as HTMLDialogElement; document.body.classList.add("modal-open"); modal?.showModal(); }; const closeModal = () => { const modal = document.getElementById(modalId) as HTMLDialogElement; document.body.classList.remove("modal-open"); modal?.close(); }; return ( <>

{title}

{event.hasPresenceEvents && (

Bitte finde dich an diesem Termin in unserem Discord ein.

)} {event.finisherMoodleCourseId && ( )}
{event.hasPresenceEvents && ( )}
); }; export default ModalBtn; const MoodleCourseIndicator = ({ completed, moodleCourseId, eventId, user, }: { completed?: boolean; moodleCourseId: string; eventId: number; user: User; }) => { const courseUrl = `${process.env.NEXT_PUBLIC_MOODLE_URL}/course/view.php?id=${moodleCourseId}`; if (completed) return (

Moodle Kurs abgeschlossen

); return (

Moodle-Kurs Benötigt

); };