import { prisma } from "@repo/db"; import { getServerSession } from "../../api/auth/[...nextauth]/auth"; import { KursItem } from "./_components/item"; import { RocketIcon } from "@radix-ui/react-icons"; const page = async () => { const session = await getServerSession(); if (!session) return null; const user = session.user; if (!user) return null; const events = await prisma.event.findMany({ include: { appointments: { where: { appointmentDate: { gte: new Date(), }, }, }, participants: { where: { userId: user.id, }, }, }, }); const appointments = await prisma.eventAppointment.findMany({ where: { appointmentDate: { gte: new Date(), }, }, include: { Participants: { select: { enscriptionDate: true, id: true, userId: true, }, orderBy: { enscriptionDate: "asc", }, }, _count: { select: { Participants: true, }, }, }, }); const userAppointments = await prisma.eventAppointment.findMany({ where: { Participants: { some: { userId: user.id, }, }, }, }); return (

Events & Kurse

{events.map((event) => { return ( ); })}
); }; export default page;