import Link from "next/link"; import { notFound } from "next/navigation"; import { getServerSession } from "next-auth"; import { authOptions } from "@/lib/auth-options"; import { getCourseBySlug, firstLessonPath } from "@/lib/course-queries"; import { formatMoney, billingLabel } from "@/lib/format"; import { prisma } from "@/lib/prisma"; import { EnrollButton } from "@/components/enroll-button"; type Props = { params: Promise<{ slug: string }> }; export default async function CoursePage({ params }: Props) { const { slug } = await params; const course = await getCourseBySlug(slug); if (!course) notFound(); const session = await getServerSession(authOptions); const enrollment = session?.user?.id && (await prisma.enrollment.findUnique({ where: { userId_courseId: { userId: session.user.id, courseId: course.id } }, })); const startPath = firstLessonPath(course); const cats = course.categories.map((c) => c.category.name).join(", "); const priceSuffix = billingLabel(course.billingInterval); const isFree = course.priceCents === 0; return (

← Alle Kurse

{course.title}

Von {course.authorName} {cats ? <> · {cats} : null}

{!isFree && (

{formatMoney(course.priceCents, course.currency)} {priceSuffix ? ` ${priceSuffix}` : ""}{" "} (Zahlungsanbindung in Arbeit – aktuell nicht kaufbar)

)}
{!session ? ( Anmelden, um fortzufahren ) : enrollment && startPath ? ( Mit dem Lernen beginnen ) : enrollment ? ( Noch keine Lektionen. ) : isFree ? ( ) : (

Kostenpflichtige Kurse werden über Stripe angebunden.

)}

Kurrikulum

{course.description ?

{course.description}

: null}
    {course.modules.map((m) => (
  • {m.title}
      {m.lessons.map((lesson) => { const href = `/kurse/${course.slug}/lektionen/${lesson.slug}`; return (
    • {lesson.title}
    • ); })}
  • ))}
); }