Spaces:
Build error
Build error
Upload pages/index.js with huggingface_hub
Browse files- pages/index.js +63 -0
pages/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useState } from 'react';
|
| 2 |
+
import SearchForm from '../components/SearchForm';
|
| 3 |
+
import Results from '../components/Results';
|
| 4 |
+
|
| 5 |
+
export default function Home() {
|
| 6 |
+
const [results, setResults] = useState([]);
|
| 7 |
+
const [loading, setLoading] = useState(false);
|
| 8 |
+
const [error, setError] = useState(null);
|
| 9 |
+
|
| 10 |
+
const handleSearch = async ({ query, locationType }) => {
|
| 11 |
+
setLoading(true);
|
| 12 |
+
setError(null);
|
| 13 |
+
|
| 14 |
+
try {
|
| 15 |
+
// Simulating API call
|
| 16 |
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
| 17 |
+
|
| 18 |
+
// Mock data - in a real app, this would come from your API
|
| 19 |
+
const mockData = [
|
| 20 |
+
{
|
| 21 |
+
name: 'João Silva',
|
| 22 |
+
position: 'Prefeito',
|
| 23 |
+
location: `${query} - ${locationType === 'estado' ? 'Estado' : 'Município'}`,
|
| 24 |
+
status: 'ativo',
|
| 25 |
+
details: 'Gestor público com 10 anos de experiência em administração municipal.'
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
name: 'Maria Santos',
|
| 29 |
+
position: 'Secretária de Educação',
|
| 30 |
+
location: `${query} - ${locationType === 'estado' ? 'Estado' : 'Município'}`,
|
| 31 |
+
status: 'ativo',
|
| 32 |
+
details: 'Especialista em políticas educacionais com foco em inclusão social.'
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
name: 'Carlos Oliveira',
|
| 36 |
+
position: 'Secretário de Saúde',
|
| 37 |
+
location: `${query} - ${locationType === 'estado' ? 'Estado' : 'Município'}`,
|
| 38 |
+
status: 'inativo',
|
| 39 |
+
details: 'Médico com experiência em gestão de sistemas públicos de saúde.'
|
| 40 |
+
}
|
| 41 |
+
];
|
| 42 |
+
|
| 43 |
+
setResults(mockData);
|
| 44 |
+
} catch (err) {
|
| 45 |
+
setError('Ocorreu um erro ao buscar os dados. Por favor, tente novamente.');
|
| 46 |
+
console.error(err);
|
| 47 |
+
} finally {
|
| 48 |
+
setLoading(false);
|
| 49 |
+
}
|
| 50 |
+
};
|
| 51 |
+
|
| 52 |
+
return (
|
| 53 |
+
<div className="max-w-4xl mx-auto">
|
| 54 |
+
<h1 className="text-3xl font-bold text-gray-900 mb-2">Pesquisa Forense de Agentes Públicos</h1>
|
| 55 |
+
<p className="text-gray-600 mb-8">
|
| 56 |
+
Digite o município, cidade ou estado para analisar os agentes públicos da região.
|
| 57 |
+
</p>
|
| 58 |
+
|
| 59 |
+
<SearchForm onSearch={handleSearch} />
|
| 60 |
+
<Results data={results} loading={loading} error={error} />
|
| 61 |
+
</div>
|
| 62 |
+
);
|
| 63 |
+
}
|