Germinal commited on
Commit
e9fbb6e
·
verified ·
1 Parent(s): 3ec25a5

Upload components/SearchForm.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. 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({ query, locationType });
 
 
 
 
 
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
- <label htmlFor="locationType" className="block text-sm font-medium text-gray-700 mb-1">
20
- Tipo de Localização
21
- </label>
22
- <select
23
- id="locationType"
24
- value={locationType}
25
- onChange={(e) => setLocationType(e.target.value)}
26
- className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary focus:border-primary"
27
- >
28
- <option value="municipio">Município</option>
29
- <option value="cidade">Cidade</option>
30
- <option value="estado">Estado</option>
31
- </select>
32
- </div>
 
33
 
34
- <div>
35
- <label htmlFor="query" className="block text-sm font-medium text-gray-700 mb-1">
36
- Nome da Localização
37
- </label>
38
- <div className="relative">
39
- <input
40
- type="text"
41
- id="query"
42
- value={query}
43
- onChange={(e) => setQuery(e.target.value)}
44
- placeholder={`Digite o nome do ${locationType}`}
45
- 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"
46
- required
47
- />
48
- <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
49
- <FiSearch className="h-5 w-5 text-gray-400" />
 
50
  </div>
51
  </div>
52
  </div>
53
 
54
- <button
55
- type="submit"
56
- className="w-full bg-primary hover:bg-secondary text-white font-medium py-2 px-4 rounded-md transition duration-200"
57
- >
58
- Pesquisar Agentes Públicos
59
- </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  );