import React, { useState, useEffect } from 'react'; import { getJobsHistory } from '../services/api'; import { History, LoaderCircle } from 'lucide-react'; function HistoryPanel({ onSelectJob }) { const [history, setHistory] = useState([]); const [isLoading, setIsLoading] = useState(false); const [isOpen, setIsOpen] = useState(false); const fetchHistory = () => { setIsLoading(true); getJobsHistory() .then(response => { setHistory(response.data.filter(job => job.status === 'SUCCESS' || job.status === 'FAILED')); }) .catch(error => console.error("Failed to fetch history:", error)) .finally(() => setIsLoading(false)); }; const togglePanel = () => { const newIsOpen = !isOpen; setIsOpen(newIsOpen); if (newIsOpen) { fetchHistory(); } }; const handleSelect = (job) => { onSelectJob(job); setIsOpen(false); } return ( <> {isOpen &&
No past analyses found.
Complete an analysis to see it here.
{job.ticker}