"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"; import { Cross } from "lucide-react"; interface ModalBtnProps { title: string; event: Event; dates: EventAppointment[]; selectedAppointments: EventAppointment[]; participant?: Participant; user: User; modalId: string; } const ModalBtn = ({ title, dates, modalId, participant, selectedAppointments, 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 canSelectDate = event.hasPresenceEvents && !participant?.attended && (selectedAppointments.length === 0 || participant?.appointmentCancelled); 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 ( <> > ); }; export default ModalBtn; const MoodleCourseIndicator = ({ completed, moodleCourseId, event, participant, user, }: { user: User; participant?: Participant; completed?: boolean; moodleCourseId: string; event: Event; }) => { const courseUrl = `${process.env.NEXT_PUBLIC_MOODLE_URL}/course/view.php?id=${moodleCourseId}`; if (completed) return (
Moodle-Kurs Benötigt
); };