Fix: Refresh de Datos Widgets
This commit is contained in:
		| @@ -47,7 +47,8 @@ export const HomeCarouselNacionalWidget = ({ eleccionId, categoriaId, titulo }: | ||||
|   const { data, isLoading, error } = useQuery({ | ||||
|     queryKey: ['homeResumenNacional', eleccionId, categoriaId], | ||||
|     queryFn: () => getHomeResumenNacional(eleccionId, categoriaId), | ||||
|   }); | ||||
|     refetchInterval: 30000, | ||||
|   }) | ||||
|  | ||||
|   if (isLoading) return <div>Cargando widget...</div>; | ||||
|   if (error || !data) return <div>No se pudieron cargar los datos.</div>; | ||||
|   | ||||
| @@ -48,6 +48,7 @@ export const HomeCarouselWidget = ({ eleccionId, distritoId, categoriaId, titulo | ||||
|     const { data, isLoading, error } = useQuery({ | ||||
|         queryKey: ['homeResumen', eleccionId, distritoId, categoriaId], | ||||
|         queryFn: () => getHomeResumen(eleccionId, distritoId, categoriaId), | ||||
|         refetchInterval: 30000, | ||||
|     }); | ||||
|  | ||||
|     if (isLoading) return <div>Cargando widget...</div>; | ||||
|   | ||||
| @@ -73,6 +73,7 @@ const MobileResultsCard = ({ | ||||
|   const { data } = useSuspenseQuery<PanelElectoralDto>({ | ||||
|     queryKey: ['panelElectoral', eleccionId, ambitoId, categoriaId], | ||||
|     queryFn: () => getPanelElectoral(eleccionId, ambitoId, categoriaId), | ||||
|     refetchInterval: 30000, | ||||
|   }); | ||||
|  | ||||
|   useEffect(() => { | ||||
| @@ -157,6 +158,7 @@ const PanelContenido = ({ eleccionId, ambitoActual, categoriaId }: { eleccionId: | ||||
|   const { data } = useSuspenseQuery<PanelElectoralDto>({ | ||||
|     queryKey: ['panelElectoral', eleccionId, ambitoActual.id, categoriaId], | ||||
|     queryFn: () => getPanelElectoral(eleccionId, ambitoActual.id, categoriaId), | ||||
|     refetchInterval: 30000, | ||||
|   }); | ||||
|   // Si la API devolvió la bandera 'sinDatos', mostramos un mensaje. | ||||
|   if (data.sinDatos) { | ||||
|   | ||||
| @@ -29,6 +29,7 @@ export const ResultadosNacionalesCardsWidget = ({ | ||||
|             focoCategoriaId, | ||||
|             cantidadResultados | ||||
|         }), | ||||
|         refetchInterval: 30000, | ||||
|     }); | ||||
|  | ||||
|     if (isLoading) return <div>Cargando resultados por provincia...</div>; | ||||
|   | ||||
| @@ -84,6 +84,7 @@ export const MapaNacional = ({ eleccionId, categoriaId, nivel, nombreAmbito, nom | ||||
|       const response = await axios.get(url); | ||||
|       return response.data; | ||||
|     }, | ||||
|     refetchInterval: 30000, | ||||
|   }); | ||||
|  | ||||
|   const { data: geoDataNacional } = useSuspenseQuery<any>({ | ||||
| @@ -104,7 +105,7 @@ export const MapaNacional = ({ eleccionId, categoriaId, nivel, nombreAmbito, nom | ||||
|     } else if (nivel === 'provincia') { | ||||
|       const nombreNormalizado = normalizarTexto(nombreAmbito); | ||||
|       const manualConfig = PROVINCE_VIEW_CONFIG[nombreNormalizado]; | ||||
|        | ||||
|  | ||||
|       let provinceConfig: ViewConfig | undefined; | ||||
|  | ||||
|       if (manualConfig) { | ||||
| @@ -119,8 +120,8 @@ export const MapaNacional = ({ eleccionId, categoriaId, nivel, nombreAmbito, nom | ||||
|       } | ||||
|  | ||||
|       if (provinceConfig) { | ||||
|           setPosition(provinceConfig); | ||||
|           initialProvincePositionRef.current = provinceConfig; | ||||
|         setPosition(provinceConfig); | ||||
|         initialProvincePositionRef.current = provinceConfig; | ||||
|       } | ||||
|     } | ||||
|   }, [nivel, nombreAmbito, geoDataNacional, isMobileView, isMobileSmall]); | ||||
| @@ -195,7 +196,7 @@ export const MapaNacional = ({ eleccionId, categoriaId, nivel, nombreAmbito, nom | ||||
|       if (newZoom > initialProvincePositionRef.current.zoom) { | ||||
|         toast.success('Desplazamiento Habilitado', { | ||||
|           icon: '🖐️', | ||||
|           style: { background: '#32e5f1ff', color: 'white', zIndex: 9999}, | ||||
|           style: { background: '#32e5f1ff', color: 'white', zIndex: 9999 }, | ||||
|           duration: 1000, | ||||
|         }); | ||||
|       } | ||||
| @@ -236,7 +237,7 @@ export const MapaNacional = ({ eleccionId, categoriaId, nivel, nombreAmbito, nom | ||||
|   const isZoomOutDisabled = | ||||
|     (nivel === 'provincia' && initialProvincePositionRef.current && position.zoom <= initialProvincePositionRef.current.zoom) || | ||||
|     (nivel === 'pais' && position.zoom <= (isMobileView ? 1.4 : 1.05)); | ||||
|      | ||||
|  | ||||
|   // 2. Todas las props 'className' ahora usan el objeto 'styles' | ||||
|   const mapContainerClasses = `${styles.mapaComponenteContainer} ${panEnabled ? styles.mapPannable : styles.mapLocked}`; | ||||
|  | ||||
|   | ||||
| @@ -31,6 +31,7 @@ export const MapaProvincial = ({ eleccionId, categoriaId, distritoId, nombreProv | ||||
|       const response = await axios.get(url); | ||||
|       return response.data; | ||||
|     }, | ||||
|     refetchInterval: 30000, | ||||
|   }); | ||||
|  | ||||
|   const { data: geoData } = useSuspenseQuery<any>({ | ||||
| @@ -49,10 +50,10 @@ export const MapaProvincial = ({ eleccionId, categoriaId, distritoId, nombreProv | ||||
|       if (municipioGeo) { | ||||
|         const municipioFeature = feature(geoData, municipioGeo); | ||||
|         const centroid = geoCentroid(municipioFeature); | ||||
|         if(nombreProvincia.toUpperCase() === 'CAPITAL FEDERAL'){ | ||||
|         if (nombreProvincia.toUpperCase() === 'CAPITAL FEDERAL') { | ||||
|           onCalculatedCenter(centroid as PointTuple, 180); | ||||
|         } else { | ||||
|         onCalculatedCenter(centroid as PointTuple, 10); | ||||
|           onCalculatedCenter(centroid as PointTuple, 10); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user