import { App, Button, Empty, Space, Switch, Tag, Typography, theme, Spin, Avatar, Card, Tooltip, } from 'antd'; import { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router'; import { getAgentList, updateAgent } from '@/api/ai/agent.ts'; import type { IAgent } from '@/domain/iAgents.ts'; const { Title, Text, Paragraph } = Typography; export default function AgentPage() { const { t } = useTranslation(); const { token } = theme.useToken(); const { message } = App.useApp(); const navigate = useNavigate(); const [agents, setAgents] = useState([]); const [loading, setLoading] = useState(false); const loadAgents = useCallback(async () => { setLoading(true); try { const res = await getAgentList(); setAgents(res.data.data ?? []); } finally { setLoading(false); } }, []); useEffect(() => { loadAgents(); }, [loadAgents]); const handleToggleEnabled = async (id: number, enabled: boolean) => { try { await updateAgent(id, { enabled }); setAgents((prev) => prev.map((a) => (a.id === id ? { ...a, enabled } : a)), ); message.success(t('ai.agent.update.success')); } catch { message.error(t('ai.agent.update.failed')); } }; return ( <>
{t('ai.agent.page.title')} {t('ai.agent.page.description')}
{agents.length > 0 ? (
{agents.map((agent) => (
{agent.name} handleToggleEnabled(agent.id!, checked) } />
{agent.description} {agent.tags?.map((tag) => ( {tag} ))}
))}
) : ( )}
); }