feat(filtros): agrupa las provincias del desplegable por comunidad autónoma
PROVINCIAS_POR_COMUNIDAD (17 comunidades, 50 provincias) pasa a ser la fuente única y PROVINCIAS se deriva de ella, así ningún listado queda desincronizado. El desplegable de filtros y el de la pasarela de propuesta usan <optgroup> con el nombre de la comunidad. 148/148 tests y build en verde.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { CATEGORIAS, NOMBRES_CATEGORIAS } from "../constants/categorias.js";
|
||||
import { PROVINCIAS } from "../constants/provincias.js";
|
||||
import { PROVINCIAS_POR_COMUNIDAD } from "../constants/provincias.js";
|
||||
import { inputStyle } from "../styles/shared.js";
|
||||
|
||||
// UI de filtrado del directorio. El estado vive en App.jsx (la derivación de
|
||||
@@ -77,7 +77,11 @@ export default function BarraFiltros({
|
||||
/>
|
||||
<select style={{ ...inputStyle, width: "auto", flexShrink: 0 }} value={filtroProvincia} onChange={(e) => setFiltroProvincia(e.target.value)} aria-label="Filtrar por provincia">
|
||||
<option value="">📍 Todas las provincias</option>
|
||||
{PROVINCIAS.map((p) => <option key={p} value={p}>{p}</option>)}
|
||||
{Object.entries(PROVINCIAS_POR_COMUNIDAD).map(([comunidad, provincias]) => (
|
||||
<optgroup key={comunidad} label={comunidad}>
|
||||
{provincias.map((p) => <option key={p} value={p}>{p}</option>)}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { inputStyle } from "../styles/shared.js";
|
||||
import { PROVINCIAS } from "../constants/provincias.js";
|
||||
import { PROVINCIAS_POR_COMUNIDAD } from "../constants/provincias.js";
|
||||
|
||||
const etiqueta = { fontSize: 12, color: "var(--color-text-secondary)", display: "block", marginBottom: 4 };
|
||||
|
||||
@@ -49,7 +49,11 @@ export default function PasoDatosLocal({ form, setForm }) {
|
||||
onChange={(e) => setForm((f) => ({ ...f, provincia: e.target.value }))}
|
||||
>
|
||||
<option value="">Selecciona provincia...</option>
|
||||
{PROVINCIAS.map((p) => <option key={p} value={p}>{p}</option>)}
|
||||
{Object.entries(PROVINCIAS_POR_COMUNIDAD).map(([comunidad, provincias]) => (
|
||||
<optgroup key={comunidad} label={comunidad}>
|
||||
{provincias.map((p) => <option key={p} value={p}>{p}</option>)}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user