Reorganized component structure for modularity, introducing `AppHeader`, `Sidebar`, and page-specific components. Simplified state management with `LogProvider` context. Added custom Tailwind CSS themes for consistent app styling.
24 lines
714 B
JavaScript
24 lines
714 B
JavaScript
import { useCallback, useState } from 'react';
|
|
|
|
export function useExtractionResults(extractionApi) {
|
|
const [rows, setRows] = useState([]);
|
|
const [loading, setLoading] = useState(false);
|
|
const [error, setError] = useState(null);
|
|
|
|
const load = useCallback(async ({ sessionId, modelId }) => {
|
|
if (!extractionApi) return;
|
|
setLoading(true);
|
|
setError(null);
|
|
try {
|
|
const data = await extractionApi.listResultsBySessionModel({ sessionId, modelId });
|
|
setRows(Array.isArray(data) ? data : []);
|
|
} catch (e) {
|
|
setError(e?.message ?? 'Erro ao carregar resultados');
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}, [extractionApi]);
|
|
|
|
return { rows, loading, error, load };
|
|
}
|