// 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, Tag } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { cn } from "@/lib/utils"; import { resolveTierBadge, cheapestTierSlug } from "@/utils/tierBadge.util"; 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, tierMap = {}, onViewDetails }) => { const locked = lesson.is_locked; const duration = formatDuration(lesson.duration_seconds); const unitCount = Number(lesson.unit_count ?? 0); const courses = lesson.courses ?? []; const slug = cheapestTierSlug(courses.map((c) => c.subscription), tierMap); const { label, cls, panel } = resolveTierBadge(slug, tierMap); return (
onViewDetails(lesson)} >
{locked ? : } {label} {locked && ( Locked )}

{lesson.title}

{lesson.description || "No information yet provided"}

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