1import { useState, useEffect } from 'react';
2import { apiFetch } from '../lib/api';
4export function useAgentData(agentId) {
5 const [agent, setAgent] = useState(null);
6 const [loading, setLoading] = useState(false);
7 const [error, setError] = useState(null);
13 apiFetch(`/agent/${agentId}`, {
14 credentials: 'include',
17 if (!res.ok) throw new Error('Agent not found');
26 setError(err.message || 'Failed to load agent');
28 .finally(() => setLoading(false));
31 return { agent, loading, error };