import { useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; import { useNavigate, useParams } from 'react-router-dom'; import userService from '../api/services/userService'; import ArrowLeft from '../assets/arrow-left.svg'; import Spinner from '../components/Spinner'; import { selectToken } from '../preferences/preferenceSlice'; import Analytics from '../settings/Analytics'; import Logs from '../settings/Logs'; import { Agent } from './types'; export default function AgentLogs() { const navigate = useNavigate(); const { agentId } = useParams(); const token = useSelector(selectToken); const [agent, setAgent] = useState(); const [loadingAgent, setLoadingAgent] = useState(true); const fetchAgent = async (agentId: string) => { setLoadingAgent(true); try { const response = await userService.getAgent(agentId ?? '', token); if (!response.ok) throw new Error('Failed to fetch Chatbots'); const agent = await response.json(); setAgent(agent); } catch (error) { console.error(error); } finally { setLoadingAgent(false); } }; useEffect(() => { if (agentId) fetchAgent(agentId); }, [agentId, token]); return (

Back to all agents

Agent Logs

{agent && (

{agent.name}

{agent.last_used_at ? 'Last used at ' + new Date(agent.last_used_at).toLocaleString() : 'No usage history'}

)}
{loadingAgent ? (
) : ( agent && )} {loadingAgent ? (
{' '}
) : ( agent && )}
); }