// LessonCard โ€” grid card for a standalone Lesson. Shared by LessonsList.jsx and // Dashboard.jsx's "Featured Lessons" section. Mirrors UnitCard.jsx; a Lesson has // no lesson_count/quiz_id of its own โ€” shows unit_count instead (how many Units // it's attached to). import { Timer, LockIcon, Layers } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { cn } from "@/lib/utils"; function formatDuration(seconds = 0) { if (!seconds) return null; const h = Math.floor(seconds / 3600); const m = Math.floor((seconds % 3600) / 60); if (h && m) return `${h}h ${m}m`; if (h) return `${h}h`; return `${m}m`; } export const LessonCard = ({ lesson, onViewDetails }) => { const locked = lesson.is_locked; const duration = formatDuration(lesson.duration_seconds); const unitCount = Number(lesson.unit_count ?? 0); const courses = lesson.courses ?? []; return (
onViewDetails(lesson)} >
{locked && ( Locked )} {unitCount > 0 ? ( In {unitCount} unit{unitCount === 1 ? "" : "s"} {courses[0] && ( <> {" "}ยท {courses[0].title} {courses.length > 1 ? ` +${courses.length - 1}` : ""} )} ) : ( !locked && Standalone )}

{lesson.title}

{lesson.description && (

{lesson.description}

)}
{duration ?? "โ€”"}
{locked && ( Upgrade to unlock )}
); }; export const LessonCardSkeleton = () => (
);