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({ |   const { data, isLoading, error } = useQuery({ | ||||||
|     queryKey: ['homeResumenNacional', eleccionId, categoriaId], |     queryKey: ['homeResumenNacional', eleccionId, categoriaId], | ||||||
|     queryFn: () => getHomeResumenNacional(eleccionId, categoriaId), |     queryFn: () => getHomeResumenNacional(eleccionId, categoriaId), | ||||||
|   }); |     refetchInterval: 30000, | ||||||
|  |   }) | ||||||
|  |  | ||||||
|   if (isLoading) return <div>Cargando widget...</div>; |   if (isLoading) return <div>Cargando widget...</div>; | ||||||
|   if (error || !data) return <div>No se pudieron cargar los datos.</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({ |     const { data, isLoading, error } = useQuery({ | ||||||
|         queryKey: ['homeResumen', eleccionId, distritoId, categoriaId], |         queryKey: ['homeResumen', eleccionId, distritoId, categoriaId], | ||||||
|         queryFn: () => getHomeResumen(eleccionId, distritoId, categoriaId), |         queryFn: () => getHomeResumen(eleccionId, distritoId, categoriaId), | ||||||
|  |         refetchInterval: 30000, | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     if (isLoading) return <div>Cargando widget...</div>; |     if (isLoading) return <div>Cargando widget...</div>; | ||||||
|   | |||||||
| @@ -73,6 +73,7 @@ const MobileResultsCard = ({ | |||||||
|   const { data } = useSuspenseQuery<PanelElectoralDto>({ |   const { data } = useSuspenseQuery<PanelElectoralDto>({ | ||||||
|     queryKey: ['panelElectoral', eleccionId, ambitoId, categoriaId], |     queryKey: ['panelElectoral', eleccionId, ambitoId, categoriaId], | ||||||
|     queryFn: () => getPanelElectoral(eleccionId, ambitoId, categoriaId), |     queryFn: () => getPanelElectoral(eleccionId, ambitoId, categoriaId), | ||||||
|  |     refetchInterval: 30000, | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
| @@ -157,6 +158,7 @@ const PanelContenido = ({ eleccionId, ambitoActual, categoriaId }: { eleccionId: | |||||||
|   const { data } = useSuspenseQuery<PanelElectoralDto>({ |   const { data } = useSuspenseQuery<PanelElectoralDto>({ | ||||||
|     queryKey: ['panelElectoral', eleccionId, ambitoActual.id, categoriaId], |     queryKey: ['panelElectoral', eleccionId, ambitoActual.id, categoriaId], | ||||||
|     queryFn: () => getPanelElectoral(eleccionId, ambitoActual.id, categoriaId), |     queryFn: () => getPanelElectoral(eleccionId, ambitoActual.id, categoriaId), | ||||||
|  |     refetchInterval: 30000, | ||||||
|   }); |   }); | ||||||
|   // Si la API devolvió la bandera 'sinDatos', mostramos un mensaje. |   // Si la API devolvió la bandera 'sinDatos', mostramos un mensaje. | ||||||
|   if (data.sinDatos) { |   if (data.sinDatos) { | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ export const ResultadosNacionalesCardsWidget = ({ | |||||||
|             focoCategoriaId, |             focoCategoriaId, | ||||||
|             cantidadResultados |             cantidadResultados | ||||||
|         }), |         }), | ||||||
|  |         refetchInterval: 30000, | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     if (isLoading) return <div>Cargando resultados por provincia...</div>; |     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); |       const response = await axios.get(url); | ||||||
|       return response.data; |       return response.data; | ||||||
|     }, |     }, | ||||||
|  |     refetchInterval: 30000, | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   const { data: geoDataNacional } = useSuspenseQuery<any>({ |   const { data: geoDataNacional } = useSuspenseQuery<any>({ | ||||||
| @@ -119,8 +120,8 @@ export const MapaNacional = ({ eleccionId, categoriaId, nivel, nombreAmbito, nom | |||||||
|       } |       } | ||||||
|  |  | ||||||
|       if (provinceConfig) { |       if (provinceConfig) { | ||||||
|           setPosition(provinceConfig); |         setPosition(provinceConfig); | ||||||
|           initialProvincePositionRef.current = provinceConfig; |         initialProvincePositionRef.current = provinceConfig; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   }, [nivel, nombreAmbito, geoDataNacional, isMobileView, isMobileSmall]); |   }, [nivel, nombreAmbito, geoDataNacional, isMobileView, isMobileSmall]); | ||||||
| @@ -195,7 +196,7 @@ export const MapaNacional = ({ eleccionId, categoriaId, nivel, nombreAmbito, nom | |||||||
|       if (newZoom > initialProvincePositionRef.current.zoom) { |       if (newZoom > initialProvincePositionRef.current.zoom) { | ||||||
|         toast.success('Desplazamiento Habilitado', { |         toast.success('Desplazamiento Habilitado', { | ||||||
|           icon: '🖐️', |           icon: '🖐️', | ||||||
|           style: { background: '#32e5f1ff', color: 'white', zIndex: 9999}, |           style: { background: '#32e5f1ff', color: 'white', zIndex: 9999 }, | ||||||
|           duration: 1000, |           duration: 1000, | ||||||
|         }); |         }); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -31,6 +31,7 @@ export const MapaProvincial = ({ eleccionId, categoriaId, distritoId, nombreProv | |||||||
|       const response = await axios.get(url); |       const response = await axios.get(url); | ||||||
|       return response.data; |       return response.data; | ||||||
|     }, |     }, | ||||||
|  |     refetchInterval: 30000, | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   const { data: geoData } = useSuspenseQuery<any>({ |   const { data: geoData } = useSuspenseQuery<any>({ | ||||||
| @@ -49,10 +50,10 @@ export const MapaProvincial = ({ eleccionId, categoriaId, distritoId, nombreProv | |||||||
|       if (municipioGeo) { |       if (municipioGeo) { | ||||||
|         const municipioFeature = feature(geoData, municipioGeo); |         const municipioFeature = feature(geoData, municipioGeo); | ||||||
|         const centroid = geoCentroid(municipioFeature); |         const centroid = geoCentroid(municipioFeature); | ||||||
|         if(nombreProvincia.toUpperCase() === 'CAPITAL FEDERAL'){ |         if (nombreProvincia.toUpperCase() === 'CAPITAL FEDERAL') { | ||||||
|           onCalculatedCenter(centroid as PointTuple, 180); |           onCalculatedCenter(centroid as PointTuple, 180); | ||||||
|         } else { |         } else { | ||||||
|         onCalculatedCenter(centroid as PointTuple, 10); |           onCalculatedCenter(centroid as PointTuple, 10); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user