Pre Refinamiento Movil

This commit is contained in:
2025-09-19 17:19:10 -03:00
parent 3a8f64bf85
commit 7d2922aaeb
21 changed files with 662 additions and 420 deletions

View File

@@ -32,8 +32,7 @@ export const MapaProvincial = ({ eleccionId, categoriaId, distritoId, nombreProv
return response.data;
},
});
// El nombre del archivo ahora es completamente dinámico
const { data: geoData } = useSuspenseQuery<any>({
queryKey: ['geoDataProvincial', nombreProvincia],
queryFn: async () => {
@@ -43,21 +42,22 @@ export const MapaProvincial = ({ eleccionId, categoriaId, distritoId, nombreProv
},
});
// useEffect para calcular y "exportar" la posición del municipio al padre
// useEffect que calcula y exporta la posición del municipio al padre
useEffect(() => {
if (nivel === 'municipio' && geoData?.objects && nombreMunicipioSeleccionado) {
const geometries = geoData.objects[Object.keys(geoData.objects)[0]].geometries;
const municipioGeo = geometries.find((g: any) => normalizarTexto(g.properties.departamento) === normalizarTexto(nombreMunicipioSeleccionado));
if (municipioGeo) {
const municipioFeature = feature(geoData, municipioGeo);
const centroid = geoCentroid(municipioFeature);
// Usamos un zoom genérico alto para cualquier municipio
onCalculatedCenter(centroid as PointTuple, 40);
const municipioFeature = feature(geoData, municipioGeo);
const centroid = geoCentroid(municipioFeature);
// Llama a la función del padre para que actualice la posición
onCalculatedCenter(centroid as PointTuple, 40);
}
}
}, [nivel, nombreMunicipioSeleccionado, geoData, onCalculatedCenter]);
const resultadosPorNombre = new Map<string, ResultadoMapaDto>(mapaData.map(d => [normalizarTexto(d.ambitoNombre), d]));
const esCABA = normalizarTexto(nombreProvincia) === "CIUDAD AUTONOMA DE BUENOS AIRES";
return (
<Geographies geography={geoData}>
@@ -65,11 +65,19 @@ export const MapaProvincial = ({ eleccionId, categoriaId, distritoId, nombreProv
const resultado = resultadosPorNombre.get(normalizarTexto(geo.properties.departamento));
const esSeleccionado = nombreMunicipioSeleccionado ? normalizarTexto(geo.properties.departamento) === normalizarTexto(nombreMunicipioSeleccionado) : false;
const classNames = [
'rsm-geography',
'mapa-provincial-geography',
esSeleccionado ? 'selected' : '',
nombreMunicipioSeleccionado && !esSeleccionado ? 'rsm-geography-faded-municipality' : '',
esCABA ? 'caba-comuna-geography' : ''
].filter(Boolean).join(' ');
return (
<Geography
key={geo.rsmKey}
geography={geo}
className={`rsm-geography ${esSeleccionado ? 'selected' : ''} ${nombreMunicipioSeleccionado && !esSeleccionado ? 'rsm-geography-faded-municipality' : ''}`}
className={classNames}
fill={resultado?.colorGanador || DEFAULT_MAP_COLOR}
onClick={resultado ? () => onMunicipioSelect(resultado.ambitoId.toString(), resultado.ambitoNombre) : undefined}
data-tooltip-id="mapa-tooltip"