"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { Badge } from "@/components/ui/badge"; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { getDifficultyVariant, capitalize } from "@/lib/utils"; import { isQuestionCompleted } from "@/lib/progress"; import { CheckCircle, Star } from "lucide-react"; import type { LearningProgression as LearningProgressionType } from "@/types"; interface LearningProgressionProps { progression: LearningProgressionType; } export function LearningProgression({ progression }: LearningProgressionProps) { const [completedSlugs, setCompletedSlugs] = useState>(new Set()); // Load completion status on mount (client-side only) useEffect(() => { const allQuestions = [ ...progression.warmup, ...progression.core, ...progression.challenge, ]; const completed = new Set(); for (const q of allQuestions) { if (isQuestionCompleted(q.slug)) { completed.add(q.slug); } } setCompletedSlugs(completed); }, [progression]); const hasQuestions = progression.warmup.length > 0 || progression.core.length > 0 || progression.challenge.length > 0; if (!hasQuestions) return null; // Calculate completion stats per tier const warmupCompleted = progression.warmup.filter(q => completedSlugs.has(q.slug)).length; const coreCompleted = progression.core.filter(q => completedSlugs.has(q.slug)).length; const challengeCompleted = progression.challenge.filter(q => completedSlugs.has(q.slug)).length; return ( Learning Path
{progression.warmup.length > 0 && (

1 Warmup {progression.warmup.length > 0 && ( {warmupCompleted}/{progression.warmup.length} )}

Start here to build foundational understanding.

{progression.warmup.map((q) => ( ))}
)} {progression.core.length > 0 && (

2 Core Practice {progression.core.length > 0 && ( {coreCompleted}/{progression.core.length} )}

Master the pattern with these representative problems.

{progression.core.map((q) => ( ))}
)} {progression.challenge.length > 0 && (

3 Challenge {progression.challenge.length > 0 && ( {challengeCompleted}/{progression.challenge.length} )}

Test your mastery with complex variations.

{progression.challenge.map((q) => ( ))}
)}
); } interface QuestionLinkProps { question: LearningProgressionType["warmup"][number]; isCompleted: boolean; } function QuestionLink({ question, isCompleted }: QuestionLinkProps) { return (
{isCompleted && ( )} {question.title} {question.is_optimal && ( Optimal )}
{question.leetcode_id && ( #{question.leetcode_id} )} {capitalize(question.difficulty)}
); }