Spaces:
Build error
Build error
Upload components/SearchForm.jsx with huggingface_hub
Browse files- components/SearchForm.jsx +90 -39
components/SearchForm.jsx
CHANGED
|
@@ -1,62 +1,113 @@
|
|
| 1 |
import { useState } from 'react';
|
| 2 |
-
import { FiSearch } from 'react-icons/fi';
|
| 3 |
|
| 4 |
export default function SearchForm({ onSearch }) {
|
| 5 |
const [query, setQuery] = useState('');
|
| 6 |
const [locationType, setLocationType] = useState('municipio');
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
const handleSubmit = (e) => {
|
| 9 |
e.preventDefault();
|
| 10 |
if (query.trim()) {
|
| 11 |
-
onSearch({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
};
|
| 14 |
|
| 15 |
return (
|
| 16 |
<div className="bg-white rounded-lg shadow-md p-6 mb-8">
|
| 17 |
<form onSubmit={handleSubmit} className="space-y-4">
|
| 18 |
-
<div>
|
| 19 |
-
<
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
</div>
|
| 51 |
</div>
|
| 52 |
</div>
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
</form>
|
| 61 |
</div>
|
| 62 |
);
|
|
|
|
| 1 |
import { useState } from 'react';
|
| 2 |
+
import { FiSearch, FiSettings } from 'react-icons/fi';
|
| 3 |
|
| 4 |
export default function SearchForm({ onSearch }) {
|
| 5 |
const [query, setQuery] = useState('');
|
| 6 |
const [locationType, setLocationType] = useState('municipio');
|
| 7 |
+
const [startDate, setStartDate] = useState('');
|
| 8 |
+
const [endDate, setEndDate] = useState('');
|
| 9 |
+
const [advancedOptions, setAdvancedOptions] = useState(false);
|
| 10 |
|
| 11 |
const handleSubmit = (e) => {
|
| 12 |
e.preventDefault();
|
| 13 |
if (query.trim()) {
|
| 14 |
+
onSearch({
|
| 15 |
+
query,
|
| 16 |
+
locationType,
|
| 17 |
+
startDate: startDate || null,
|
| 18 |
+
endDate: endDate || null
|
| 19 |
+
});
|
| 20 |
}
|
| 21 |
};
|
| 22 |
|
| 23 |
return (
|
| 24 |
<div className="bg-white rounded-lg shadow-md p-6 mb-8">
|
| 25 |
<form onSubmit={handleSubmit} className="space-y-4">
|
| 26 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 27 |
+
<div>
|
| 28 |
+
<label htmlFor="locationType" className="block text-sm font-medium text-gray-700 mb-1">
|
| 29 |
+
Tipo de Localização
|
| 30 |
+
</label>
|
| 31 |
+
<select
|
| 32 |
+
id="locationType"
|
| 33 |
+
value={locationType}
|
| 34 |
+
onChange={(e) => setLocationType(e.target.value)}
|
| 35 |
+
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"
|
| 36 |
+
>
|
| 37 |
+
<option value="municipio">Município</option>
|
| 38 |
+
<option value="cidade">Cidade</option>
|
| 39 |
+
<option value="estado">Estado</option>
|
| 40 |
+
</select>
|
| 41 |
+
</div>
|
| 42 |
|
| 43 |
+
<div>
|
| 44 |
+
<label htmlFor="query" className="block text-sm font-medium text-gray-700 mb-1">
|
| 45 |
+
Nome da Localização
|
| 46 |
+
</label>
|
| 47 |
+
<div className="relative">
|
| 48 |
+
<input
|
| 49 |
+
type="text"
|
| 50 |
+
id="query"
|
| 51 |
+
value={query}
|
| 52 |
+
onChange={(e) => setQuery(e.target.value)}
|
| 53 |
+
placeholder={`Digite o nome do ${locationType}`}
|
| 54 |
+
className="w-full px-4 py-2 pl-10 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"
|
| 55 |
+
required
|
| 56 |
+
/>
|
| 57 |
+
<div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
| 58 |
+
<FiSearch className="h-5 w-5 text-gray-400" />
|
| 59 |
+
</div>
|
| 60 |
</div>
|
| 61 |
</div>
|
| 62 |
</div>
|
| 63 |
|
| 64 |
+
{advancedOptions && (
|
| 65 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 66 |
+
<div>
|
| 67 |
+
<label htmlFor="startDate" className="block text-sm font-medium text-gray-700 mb-1">
|
| 68 |
+
Data Inicial
|
| 69 |
+
</label>
|
| 70 |
+
<input
|
| 71 |
+
type="date"
|
| 72 |
+
id="startDate"
|
| 73 |
+
value={startDate}
|
| 74 |
+
onChange={(e) => setStartDate(e.target.value)}
|
| 75 |
+
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"
|
| 76 |
+
/>
|
| 77 |
+
</div>
|
| 78 |
+
<div>
|
| 79 |
+
<label htmlFor="endDate" className="block text-sm font-medium text-gray-700 mb-1">
|
| 80 |
+
Data Final
|
| 81 |
+
</label>
|
| 82 |
+
<input
|
| 83 |
+
type="date"
|
| 84 |
+
id="endDate"
|
| 85 |
+
value={endDate}
|
| 86 |
+
onChange={(e) => setEndDate(e.target.value)}
|
| 87 |
+
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"
|
| 88 |
+
/>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
)}
|
| 92 |
+
|
| 93 |
+
<div className="flex flex-col sm:flex-row gap-4">
|
| 94 |
+
<button
|
| 95 |
+
type="button"
|
| 96 |
+
onClick={() => setAdvancedOptions(!advancedOptions)}
|
| 97 |
+
className="flex items-center justify-center px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"
|
| 98 |
+
>
|
| 99 |
+
<FiSettings className="mr-2" />
|
| 100 |
+
{advancedOptions ? 'Ocultar' : 'Opções Avançadas'}
|
| 101 |
+
</button>
|
| 102 |
+
|
| 103 |
+
<button
|
| 104 |
+
type="submit"
|
| 105 |
+
className="flex-1 bg-primary hover:bg-secondary text-white font-medium py-2 px-4 rounded-md transition duration-200 flex items-center justify-center"
|
| 106 |
+
>
|
| 107 |
+
<FiSearch className="mr-2" />
|
| 108 |
+
Pesquisar Agentes Públicos
|
| 109 |
+
</button>
|
| 110 |
+
</div>
|
| 111 |
</form>
|
| 112 |
</div>
|
| 113 |
);
|