import { SyntheticEvent } from 'react'; import { useGetLogs } from '../generated/anthoLumeAPIV1'; import { Button } from '../components/Button'; import { LoadingState, TextInput } from '../components'; import { useDebouncedState } from '../hooks/useDebouncedState'; import { Search2Icon } from '../icons'; export default function AdminLogsPage() { const [filter, setFilter, activeFilter, flushFilter] = useDebouncedState('', 300); const { data: logsData, isLoading } = useGetLogs(activeFilter ? { filter: activeFilter } : {}); const logs = logsData?.status === 200 ? (logsData.data.logs ?? []) : []; const handleFilterSubmit = (e: SyntheticEvent) => { e.preventDefault(); flushFilter(); }; return (
setFilter(e.target.value)} className="p-2" placeholder="JQ Filter" />
{isLoading ? ( ) : ( // Key By Index - Log lines have no stable id and can repeat; this list is append-only and fully replaced on refetch. logs.map((log, index) => ( {typeof log === 'string' ? log : JSON.stringify(log)} )) )}
); }