import { useState } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { Database, Table2, ChevronDown, ChevronRight, GitFork, ShoppingCart } from 'lucide-react' import { useStore } from '../store/useStore' import type { Difficulty } from '../lib/types' const DIFFICULTY_CONFIG: Record = { easy: { label: 'Easy', bg: 'bg-green-500/10', text: 'text-green-400', border: 'border-green-500/30' }, medium: { label: 'Medium', bg: 'bg-amber-500/10', text: 'text-amber-400', border: 'border-amber-500/30' }, hard: { label: 'Hard', bg: 'bg-red-500/10', text: 'text-red-400', border: 'border-red-500/30' }, } export function LeftSidebar() { const { tables, taskDifficulty, setTaskDifficulty, dbSeeded, isCustomDb, dbLabel } = useStore() const [tablesExpanded, setTablesExpanded] = useState(true) const cfg = DIFFICULTY_CONFIG[taskDifficulty] return (
{/* Task Difficulty — hidden for custom databases */} {!isCustomDb && (
Task Difficulty
{(Object.keys(DIFFICULTY_CONFIG) as Difficulty[]).map((d) => { const c = DIFFICULTY_CONFIG[d] const active = d === taskDifficulty return ( ) })}
)} {/* Schema Tables */}
{tablesExpanded && ( {dbSeeded && tables.length > 0 ? (
{tables.map((t) => (
{t.name}
{t.rows.toLocaleString()}
))}
) : (
{[120, 80, 95, 60, 70].map((w, i) => (
))}
)} )}
{/* Business Context */}
Business Context
{isCustomDb ? (

Connected to {dbLabel}. Ask questions about your data in natural language.

) : ( <>

E-Commerce Marketplace

Multi-vendor marketplace with products, orders, sellers, users, and reviews. Supports complex analytical queries across sales, inventory, and user behavior.

{['Products', 'Orders', 'Sellers', 'Users', 'Reviews', 'Categories'].map((t) => ( {t} ))}
)}
{/* Current task badge — hidden for custom databases */} {!isCustomDb && (
Current Task {cfg.label}

{taskDifficulty === 'easy' ? 'Simple SELECT queries, basic filtering and aggregation' : taskDifficulty === 'medium' ? 'Multi-table JOINs, GROUP BY, subqueries, window functions' : 'Complex CTEs, rolling aggregations, cohort analysis, ranking'}

)}
) }