import { useState, useEffect } from 'react'; import axios from 'axios'; import { Plus, Clock, CheckCircle2, XCircle, ChevronRight, Trash2 } from 'lucide-react'; export default function Sidebar({ onSelectResult, onNewAssessment }) { const [history, setHistory] = useState([]); const [loading, setLoading] = useState(true); const fetchHistory = async () => { try { setLoading(true); const res = await axios.get('/api/history?limit=20'); setHistory(res.data); } catch (error) { console.error("Failed to load history", error); } finally { setLoading(false); } }; const handleClearHistory = async () => { if (window.confirm("Are you sure you want to clear all history? This action cannot be undone.")) { try { await axios.delete('/api/history'); setHistory([]); } catch (error) { console.error("Failed to clear history", error); alert("Could not clear history"); } } }; useEffect(() => { fetchHistory(); }, []); return (