import { useState, useEffect } from 'react' import { Input, Select, Tag, Empty, Spin } from 'antd' import { SearchOutlined, UserOutlined } from '@ant-design/icons' import { getSessions, type Session as SessionType } from '@/services/api' const statusColors: Record = { active: 'blue', ended: 'green', archived: 'default' } const statusLabels: Record = { active: '进行中', ended: '已结束', waiting: '等待中' } const ChatHistory = () => { const [sessions, setSessions] = useState([]) const [loading, setLoading] = useState(true) const [search, setSearch] = useState('') const [statusFilter, setStatusFilter] = useState() const [selectedId, setSelectedId] = useState(null) useEffect(() => { loadSessions() }, [statusFilter]) const loadSessions = async () => { setLoading(true) try { const res = await getSessions({ status: statusFilter }) setSessions(res.list) if (res.list.length > 0 && !selectedId) setSelectedId(res.list[0].id) } catch { setSessions([]) } finally { setLoading(false) } } const selected = sessions.find(s => s.id === selectedId) return (
} placeholder="搜索访客..." value={search} onChange={e => setSearch(e.target.value)} allowClear size="small" />