import Link from "next/link"; import type { Category, Course, CourseCategory } from "@prisma/client"; import { formatMoney, billingLabel } from "@/lib/format"; import { firstLessonPath } from "@/lib/course-queries"; type CourseWithCats = Course & { categories: (CourseCategory & { category: Category })[]; modules: { lessons: { slug: string }[] }[]; }; export function CourseCard({ course, enrolled, }: { course: CourseWithCats; enrolled: boolean; }) { const cats = course.categories.map((c) => c.category.name).join(", "); const first = firstLessonPath(course); const isFree = course.priceCents === 0; const priceSuffix = billingLabel(course.billingInterval); return (

{course.title}

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

{course.ratingCount > 0 ? ( <> {course.ratingAverage.toFixed(2)} ({course.ratingCount}) ) : ( Noch keine Bewertungen )}
{!isFree && (

{formatMoney(course.priceCents, course.currency)} {priceSuffix ? ` ${priceSuffix}` : ""}

)}
{enrolled && first ? ( Mit dem Lernen beginnen ) : enrolled ? ( Keine Lektionen ) : isFree ? ( In diesen Kurs einschreiben ) : ( Details & Kauf )}
); }