Fix to Prod
This commit is contained in:
		| @@ -107,7 +107,7 @@ export const BancasWidget = () => { | ||||
|         error | ||||
|     } = useQuery<ProyeccionBancas, Error>({ | ||||
|         queryKey: ['bancasPorSeccion', selectedSeccion?.value, camaraActiva], | ||||
|         queryFn: () => getBancasPorSeccion(selectedSeccion!.value, camaraActiva), | ||||
|         queryFn: () => getBancasPorSeccion(1,selectedSeccion!.value, camaraActiva), | ||||
|         enabled: !!selectedSeccion && camarasDisponibles.includes(camaraActiva), | ||||
|         retry: (failureCount, error: any) => { | ||||
|             if (error.response?.status === 404) return false; | ||||
|   | ||||
| @@ -60,7 +60,7 @@ export const ConcejalesPorSeccionWidget = () => { | ||||
|   // Query para obtener los resultados de la sección seleccionada | ||||
|   const { data, isLoading: isLoadingResultados } = useQuery<ApiResponseResultadosPorSeccion>({ | ||||
|     queryKey: ['resultadosPorSeccion', selectedSeccion?.value, CATEGORIA_ID], | ||||
|     queryFn: () => getResultadosPorSeccion(selectedSeccion!.value, CATEGORIA_ID), | ||||
|     queryFn: () => getResultadosPorSeccion(1, selectedSeccion!.value, CATEGORIA_ID), | ||||
|     enabled: !!selectedSeccion, | ||||
|   }); | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ const CATEGORIA_ID = 7; // ID para Concejales | ||||
| export const ConcejalesTickerWidget = () => { | ||||
|   const { data: categorias, isLoading, error } = useQuery<CategoriaResumen[]>({ | ||||
|     queryKey: ['resumenProvincial'], | ||||
|     queryFn: getResumenProvincial, | ||||
|     queryFn: () => getResumenProvincial(1), | ||||
|     refetchInterval: 30000, | ||||
|   }); | ||||
|  | ||||
| @@ -33,9 +33,25 @@ export const ConcejalesTickerWidget = () => { | ||||
|   if (error || !ConcejalesData) return <div className="ticker-card error"><p>Datos de Concejales no disponibles.</p></div>; | ||||
|  | ||||
|   // Lógica para "Otros" | ||||
|   let displayResults: ResultadoTicker[] = ConcejalesData.resultados; | ||||
|   let displayResults: ResultadoTicker[] = ConcejalesData.resultados.map((r: any) => ({ | ||||
|     id: r.id, | ||||
|     nombre: r.nombre, | ||||
|     nombreCorto: r.nombreCorto || r.nombre, | ||||
|     color: r.color, | ||||
|     logoUrl: r.logoUrl, | ||||
|     votos: r.votos, | ||||
|     porcentaje: r.porcentaje, | ||||
|   })); | ||||
|   if (ConcejalesData.resultados.length > cantidadAMostrar) { | ||||
|     const topParties = ConcejalesData.resultados.slice(0, cantidadAMostrar - 1); | ||||
|     const topParties = ConcejalesData.resultados.slice(0, cantidadAMostrar - 1).map((r: any) => ({ | ||||
|       id: r.id, | ||||
|       nombre: r.nombre, | ||||
|       nombreCorto: r.nombreCorto || r.nombre, | ||||
|       color: r.color, | ||||
|       logoUrl: r.logoUrl, | ||||
|       votos: r.votos, | ||||
|       porcentaje: r.porcentaje, | ||||
|     })); | ||||
|     const otherParties = ConcejalesData.resultados.slice(cantidadAMostrar - 1); | ||||
|     const otrosPorcentaje = otherParties.reduce((sum, party) => sum + party.porcentaje, 0); | ||||
|     const otrosEntry: ResultadoTicker = { | ||||
| @@ -49,7 +65,15 @@ export const ConcejalesTickerWidget = () => { | ||||
|     }; | ||||
|     displayResults = [...topParties, otrosEntry]; | ||||
|   } else { | ||||
|     displayResults = ConcejalesData.resultados.slice(0, cantidadAMostrar); | ||||
|     displayResults = ConcejalesData.resultados.slice(0, cantidadAMostrar).map((r: any) => ({ | ||||
|       id: r.id, | ||||
|       nombre: r.nombre, | ||||
|       nombreCorto: r.nombreCorto || r.nombre, | ||||
|       color: r.color, | ||||
|       logoUrl: r.logoUrl, | ||||
|       votos: r.votos, | ||||
|       porcentaje: r.porcentaje, | ||||
|     })); | ||||
|   } | ||||
|  | ||||
|   return ( | ||||
|   | ||||
| @@ -53,7 +53,7 @@ export const ConcejalesWidget = () => { | ||||
|  | ||||
|   const { data: resultados, isLoading: isLoadingResultados } = useQuery<ResultadoTicker[]>({ | ||||
|     queryKey: ['resultadosPorMunicipio', selectedMunicipio?.value, CATEGORIA_ID], | ||||
|     queryFn: () => getResultadosPorMunicipio(selectedMunicipio!.value, CATEGORIA_ID), | ||||
|     queryFn: () => getResultadosPorMunicipio(1,selectedMunicipio!.value, CATEGORIA_ID), | ||||
|     enabled: !!selectedMunicipio, | ||||
|   }); | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,7 @@ const formatPercent = (num: number) => `${(num || 0).toFixed(2).replace('.', ',' | ||||
| export const DipSenTickerWidget = () => { | ||||
|   const { data: categorias, isLoading, error } = useQuery<CategoriaResumen[]>({ | ||||
|     queryKey: ['resumenProvincial'], | ||||
|     queryFn: getResumenProvincial, | ||||
|     queryFn: () => getResumenProvincial(1), | ||||
|     refetchInterval: 180000, | ||||
|   }); | ||||
|  | ||||
| @@ -34,10 +34,26 @@ export const DipSenTickerWidget = () => { | ||||
|     <div className="ticker-wrapper"> | ||||
|       {categoriasFiltradas.map(categoria => { | ||||
|  | ||||
|         let displayResults: ResultadoTicker[] = categoria.resultados; | ||||
|         let displayResults: ResultadoTicker[] = categoria.resultados.map((r: any) => ({ | ||||
|           id: r.id ?? r.candidatoId ?? '', | ||||
|           nombre: r.nombre ?? r.candidatoNombre ?? '', | ||||
|           nombreCorto: r.nombreCorto ?? r.candidatoNombreCorto ?? r.nombre ?? '', | ||||
|           color: r.color ?? '#888888', | ||||
|           logoUrl: r.logoUrl ?? null, | ||||
|           votos: r.votos ?? 0, | ||||
|           porcentaje: r.porcentaje ?? 0, | ||||
|         })); | ||||
|  | ||||
|         if (categoria.resultados.length > cantidadAMostrar) { | ||||
|           const topParties = categoria.resultados.slice(0, cantidadAMostrar - 1); | ||||
|           const topParties = categoria.resultados.slice(0, cantidadAMostrar - 1).map((r: any) => ({ | ||||
|             id: r.id ?? r.candidatoId ?? '', | ||||
|             nombre: r.nombre ?? r.candidatoNombre ?? '', | ||||
|             nombreCorto: r.nombreCorto ?? r.candidatoNombreCorto ?? r.nombre ?? '', | ||||
|             color: r.color ?? '#888888', | ||||
|             logoUrl: r.logoUrl ?? null, | ||||
|             votos: r.votos ?? 0, | ||||
|             porcentaje: r.porcentaje ?? 0, | ||||
|           })); | ||||
|           const otherParties = categoria.resultados.slice(cantidadAMostrar - 1); | ||||
|           const otrosPorcentaje = otherParties.reduce((sum, party) => sum + party.porcentaje, 0); | ||||
|  | ||||
| @@ -53,7 +69,15 @@ export const DipSenTickerWidget = () => { | ||||
|  | ||||
|           displayResults = [...topParties, otrosEntry]; | ||||
|         } else { | ||||
|           displayResults = categoria.resultados.slice(0, cantidadAMostrar); | ||||
|           displayResults = categoria.resultados.slice(0, cantidadAMostrar).map((r: any) => ({ | ||||
|             id: r.id ?? r.candidatoId ?? '', | ||||
|             nombre: r.nombre ?? r.candidatoNombre ?? '', | ||||
|             nombreCorto: r.nombreCorto ?? r.candidatoNombreCorto ?? r.nombre ?? '', | ||||
|             color: r.color ?? '#888888', | ||||
|             logoUrl: r.logoUrl ?? null, | ||||
|             votos: r.votos ?? 0, | ||||
|             porcentaje: r.porcentaje ?? 0, | ||||
|           })); | ||||
|         } | ||||
|  | ||||
|         return ( | ||||
|   | ||||
| @@ -64,7 +64,7 @@ export const DiputadosPorSeccionWidget = () => { | ||||
|  | ||||
|   const { data, isLoading: isLoadingResultados } = useQuery<ApiResponseResultadosPorSeccion>({ | ||||
|     queryKey: ['resultadosPorSeccion', selectedSeccion?.value, CATEGORIA_ID], | ||||
|     queryFn: () => getResultadosPorSeccion(selectedSeccion!.value, CATEGORIA_ID), | ||||
|     queryFn: () => getResultadosPorSeccion(1,selectedSeccion!.value, CATEGORIA_ID), | ||||
|     enabled: !!selectedSeccion, | ||||
|   }); | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ const CATEGORIA_ID = 6; // ID para Diputados | ||||
| export const DiputadosTickerWidget = () => { | ||||
|   const { data: categorias, isLoading, error } = useQuery<CategoriaResumen[]>({ | ||||
|     queryKey: ['resumenProvincial'], | ||||
|     queryFn: getResumenProvincial, | ||||
|     queryFn: () => getResumenProvincial(1), | ||||
|     refetchInterval: 30000, | ||||
|   }); | ||||
|  | ||||
| @@ -33,7 +33,15 @@ export const DiputadosTickerWidget = () => { | ||||
|   if (error || !diputadosData) return <div className="ticker-card error"><p>Datos de Diputados no disponibles.</p></div>; | ||||
|  | ||||
|   // Lógica para "Otros" | ||||
|   let displayResults: ResultadoTicker[] = diputadosData.resultados; | ||||
|   let displayResults: ResultadoTicker[] = diputadosData.resultados.map((r: any) => ({ | ||||
|     id: r.id ?? '', | ||||
|     nombre: r.nombre ?? '', | ||||
|     nombreCorto: r.nombreCorto ?? r.nombre ?? '', | ||||
|     color: r.color ?? '#888888', | ||||
|     logoUrl: r.logoUrl ?? null, | ||||
|     votos: r.votos ?? 0, | ||||
|     porcentaje: r.porcentaje ?? 0, | ||||
|   })); | ||||
|   if (diputadosData.resultados.length > cantidadAMostrar) { | ||||
|     const topParties = diputadosData.resultados.slice(0, cantidadAMostrar - 1); | ||||
|     const otherParties = diputadosData.resultados.slice(cantidadAMostrar - 1); | ||||
| @@ -47,9 +55,28 @@ export const DiputadosTickerWidget = () => { | ||||
|       votos: 0, | ||||
|       porcentaje: otrosPorcentaje, | ||||
|     }; | ||||
|     displayResults = [...topParties, otrosEntry]; | ||||
|     displayResults = [ | ||||
|       ...topParties.map(party => ({ | ||||
|         id: party.agrupacionId ?? '', | ||||
|         nombre: party.nombreCandidato ?? '', | ||||
|         nombreCorto: party.nombreCortoAgrupacion ?? party.nombreCortoAgrupacion ?? '', | ||||
|         color: party.color ?? '#888888', | ||||
|         logoUrl: party.fotoUrl ?? null, | ||||
|         votos: party.votos ?? 0, | ||||
|         porcentaje: party.porcentaje ?? 0, | ||||
|       })), | ||||
|       otrosEntry | ||||
|     ]; | ||||
|   } else { | ||||
|     displayResults = diputadosData.resultados.slice(0, cantidadAMostrar); | ||||
|     displayResults = diputadosData.resultados.slice(0, cantidadAMostrar).map((r: any) => ({ | ||||
|       id: r.id ?? '', | ||||
|       nombre: r.nombre ?? '', | ||||
|       nombreCorto: r.nombreCorto ?? r.nombre ?? '', | ||||
|       color: r.color ?? '#888888', | ||||
|       logoUrl: r.logoUrl ?? null, | ||||
|       votos: r.votos ?? 0, | ||||
|       porcentaje: r.porcentaje ?? 0, | ||||
|     })); | ||||
|   } | ||||
|  | ||||
|   return ( | ||||
|   | ||||
| @@ -55,7 +55,7 @@ export const DiputadosWidget = () => { | ||||
|  | ||||
|   const { data: resultados, isLoading: isLoadingResultados } = useQuery<ResultadoTicker[]>({ | ||||
|     queryKey: ['resultadosMunicipio', selectedMunicipio?.value, CATEGORIA_ID], | ||||
|     queryFn: () => getResultadosPorMunicipio(selectedMunicipio!.value, CATEGORIA_ID), | ||||
|     queryFn: () => getResultadosPorMunicipio(1,selectedMunicipio!.value, CATEGORIA_ID), | ||||
|     enabled: !!selectedMunicipio, | ||||
|   }); | ||||
|  | ||||
|   | ||||
| @@ -45,7 +45,7 @@ const DetalleSeccion = ({ seccion, categoriaId, onReset }: { seccion: SeccionGeo | ||||
|  | ||||
|     const { data: resultadosDetalle, isLoading, error } = useQuery<ResultadoDetalleSeccion[]>({ | ||||
|         queryKey: ['detalleSeccion', seccionId, categoriaId], | ||||
|         queryFn: () => getDetalleSeccion(seccionId!, categoriaId), | ||||
|         queryFn: () => getDetalleSeccion(1,seccionId!, categoriaId), | ||||
|         enabled: !!seccionId, | ||||
|     }); | ||||
|  | ||||
|   | ||||
| @@ -144,8 +144,24 @@ export const ResultadosRankingMunicipioWidget = () => { | ||||
|                                     <td className="sticky-col">{municipio.municipioNombre}</td> | ||||
|                                     {rankingData.categorias.flatMap(cat => { | ||||
|                                         const resCategoria = municipio.resultadosPorCategoria[cat.id]; | ||||
|                                         const primerPuesto = resCategoria?.ranking[0]; | ||||
|                                         const segundoPuesto = resCategoria?.ranking[1]; | ||||
|                                         const primerPuestoRaw = resCategoria?.ranking[0]; | ||||
|                                         const segundoPuestoRaw = resCategoria?.ranking[1]; | ||||
|  | ||||
|                                         // Asegurarse que los objetos tengan la propiedad 'votos' | ||||
|                                         const primerPuesto = primerPuestoRaw | ||||
|                                             ? { | ||||
|                                                 nombreCorto: primerPuestoRaw.nombreCorto, | ||||
|                                                 porcentaje: primerPuestoRaw.porcentaje, | ||||
|                                                 votos: 'votos' in primerPuestoRaw ? (primerPuestoRaw as any).votos : 0 | ||||
|                                             } | ||||
|                                             : undefined; | ||||
|                                         const segundoPuesto = segundoPuestoRaw | ||||
|                                             ? { | ||||
|                                                 nombreCorto: segundoPuestoRaw.nombreCorto, | ||||
|                                                 porcentaje: segundoPuestoRaw.porcentaje, | ||||
|                                                 votos: 'votos' in segundoPuestoRaw ? (segundoPuestoRaw as any).votos : 0 | ||||
|                                             } | ||||
|                                             : undefined; | ||||
|  | ||||
|                                         return [ | ||||
|                                             // --- Celdas para el 1° Puesto --- | ||||
|   | ||||
| @@ -11,7 +11,7 @@ const formatPercent = (num: number) => `${(num || 0).toFixed(2).replace('.', ',' | ||||
| export const ResumenGeneralWidget = () => { | ||||
|   const { data: categorias, isLoading, error } = useQuery<CategoriaResumen[]>({ | ||||
|     queryKey: ['resumenProvincial'], | ||||
|     queryFn: getResumenProvincial, | ||||
|     queryFn: () => getResumenProvincial(1), | ||||
|     refetchInterval: 180000, | ||||
|   }); | ||||
|  | ||||
| @@ -33,12 +33,19 @@ export const ResumenGeneralWidget = () => { | ||||
|      | ||||
|     legislativeCategories.forEach(category => { | ||||
|       category.resultados.forEach(party => { | ||||
|         const existing = partyMap.get(party.id); | ||||
|         const existing = partyMap.get(party.agrupacionId); | ||||
|         if (existing) { | ||||
|           existing.votos += party.votos; | ||||
|         } else { | ||||
|           // Clonamos el objeto para no modificar el original | ||||
|           partyMap.set(party.id, { ...party });  | ||||
|           // Clonamos el objeto para no modificar el original y adaptamos las propiedades | ||||
|           partyMap.set(party.agrupacionId, { | ||||
|             id: party.agrupacionId, | ||||
|             nombre: party.nombreAgrupacion, | ||||
|             nombreCorto: party.nombreCortoAgrupacion ?? party.nombreAgrupacion, | ||||
|             logoUrl: party.fotoUrl, | ||||
|             color: party.color, | ||||
|             votos: party.votos, | ||||
|           }); | ||||
|         } | ||||
|       }); | ||||
|     }); | ||||
|   | ||||
| @@ -64,7 +64,7 @@ export const SenadoresPorSeccionWidget = () => { | ||||
|  | ||||
|   const { data, isLoading: isLoadingResultados } = useQuery<ApiResponseResultadosPorSeccion>({ | ||||
|     queryKey: ['resultadosPorSeccion', selectedSeccion?.value, CATEGORIA_ID], | ||||
|     queryFn: () => getResultadosPorSeccion(selectedSeccion!.value, CATEGORIA_ID), | ||||
|     queryFn: () => getResultadosPorSeccion(1,selectedSeccion!.value, CATEGORIA_ID), | ||||
|     enabled: !!selectedSeccion, | ||||
|   }); | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ const CATEGORIA_ID = 5; // ID para Senadores | ||||
| export const SenadoresTickerWidget = () => { | ||||
|   const { data: categorias, isLoading, error } = useQuery<CategoriaResumen[]>({ | ||||
|     queryKey: ['resumenProvincial'], | ||||
|     queryFn: getResumenProvincial, | ||||
|     queryFn: () => getResumenProvincial(1), | ||||
|     refetchInterval: 30000, | ||||
|   }); | ||||
|  | ||||
| @@ -33,7 +33,15 @@ export const SenadoresTickerWidget = () => { | ||||
|   if (error || !senadoresData) return <div className="ticker-card error"><p>Datos de Senadores no disponibles.</p></div>; | ||||
|  | ||||
|   // Lógica para "Otros" | ||||
|   let displayResults: ResultadoTicker[] = senadoresData.resultados; | ||||
|   let displayResults: ResultadoTicker[] = senadoresData.resultados.map((r: any) => ({ | ||||
|     id: r.id, | ||||
|     nombre: r.nombre, | ||||
|     nombreCorto: r.nombreCorto ?? r.nombre, | ||||
|     color: r.color ?? '#888888', | ||||
|     logoUrl: r.logoUrl ?? null, | ||||
|     votos: r.votos ?? 0, | ||||
|     porcentaje: r.porcentaje ?? 0, | ||||
|   })); | ||||
|   if (senadoresData.resultados.length > cantidadAMostrar) { | ||||
|     const topParties = senadoresData.resultados.slice(0, cantidadAMostrar - 1); | ||||
|     const otherParties = senadoresData.resultados.slice(cantidadAMostrar - 1); | ||||
| @@ -47,9 +55,28 @@ export const SenadoresTickerWidget = () => { | ||||
|       votos: 0, | ||||
|       porcentaje: otrosPorcentaje, | ||||
|     }; | ||||
|     displayResults = [...topParties, otrosEntry]; | ||||
|     displayResults = [ | ||||
|       ...topParties.map((r: any) => ({ | ||||
|         id: r.id, | ||||
|         nombre: r.nombre, | ||||
|         nombreCorto: r.nombreCorto ?? r.nombre, | ||||
|         color: r.color ?? '#888888', | ||||
|         logoUrl: r.logoUrl ?? null, | ||||
|         votos: r.votos ?? 0, | ||||
|         porcentaje: r.porcentaje ?? 0, | ||||
|       })), | ||||
|       otrosEntry | ||||
|     ]; | ||||
|   } else { | ||||
|     displayResults = senadoresData.resultados.slice(0, cantidadAMostrar); | ||||
|     displayResults = senadoresData.resultados.slice(0, cantidadAMostrar).map((r: any) => ({ | ||||
|       id: r.id, | ||||
|       nombre: r.nombre, | ||||
|       nombreCorto: r.nombreCorto ?? r.nombre, | ||||
|       color: r.color ?? '#888888', | ||||
|       logoUrl: r.logoUrl ?? null, | ||||
|       votos: r.votos ?? 0, | ||||
|       porcentaje: r.porcentaje ?? 0, | ||||
|     })); | ||||
|   } | ||||
|  | ||||
|   return ( | ||||
|   | ||||
| @@ -54,7 +54,7 @@ export const SenadoresWidget = () => { | ||||
|  | ||||
|   const { data: resultados, isLoading: isLoadingResultados } = useQuery<ResultadoTicker[]>({ | ||||
|     queryKey: ['resultadosMunicipio', selectedMunicipio?.value, CATEGORIA_ID], | ||||
|     queryFn: () => getResultadosPorMunicipio(selectedMunicipio!.value, CATEGORIA_ID), | ||||
|     queryFn: () => getResultadosPorMunicipio(1,selectedMunicipio!.value, CATEGORIA_ID), | ||||
|     enabled: !!selectedMunicipio, | ||||
|   }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user