'use client' import { useState } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { Lightbulb, ChevronDown, ChevronUp, CheckCircle, XCircle, Clock, Circle } from 'lucide-react' import { type Question } from '@/lib/questions' import { getProblemStatus } from '@/lib/progress' import ReactMarkdown from 'react-markdown' interface QuestionDisplayProps { question: Question } export default function QuestionDisplay({ question }: QuestionDisplayProps) { const [showHints, setShowHints] = useState(false) const [hintIndex, setHintIndex] = useState(0) const problemStatus = getProblemStatus(question.id) const difficultyColors = { Easy: 'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400', Medium: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400', Hard: 'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400', } const statusConfig = { solved: { icon: CheckCircle, color: 'text-green-600 dark:text-green-400', bg: 'bg-green-50 dark:bg-green-900/20', border: 'border-green-200 dark:border-green-800', label: 'Solved', }, attempted: { icon: Clock, color: 'text-yellow-600 dark:text-yellow-400', bg: 'bg-yellow-50 dark:bg-yellow-900/20', border: 'border-yellow-200 dark:border-yellow-800', label: 'Attempted', }, not_started: { icon: Circle, color: 'text-gray-400 dark:text-gray-500', bg: 'bg-gray-50 dark:bg-gray-800', border: 'border-gray-200 dark:border-gray-700', label: 'Not Started', }, } const status = statusConfig[problemStatus] const StatusIcon = status.icon return (
{/* Header */}

{question.title}

{/* Status Indicator - Only show if Solved */} {problemStatus === 'solved' && (
{status.label}
)} {question.difficulty} {question.topic}
{/* Description */}
{question.description}
{/* Examples */}

Examples:

{question.examples.map((example, index) => (
Input: {example.input}
Output: {example.output}
{example.explanation && (
Explanation: {example.explanation}
)}
))}
{/* Hints */}
setShowHints(!showHints)} className="flex items-center gap-2 w-full px-3 sm:px-4 py-2 sm:py-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors" > {showHints ? 'Hide Hints' : 'Show Hints'} {showHints ? ( ) : ( )} {showHints && ( {question.hints.slice(0, hintIndex + 1).map((hint, index) => ( {index + 1}

{hint}

))} {hintIndex < question.hints.length - 1 && ( setHintIndex(hintIndex + 1)} className="w-full px-4 py-2 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded-lg font-medium hover:bg-blue-200 dark:hover:bg-blue-900/40 transition-colors" > Show Next Hint )}
)}
) }