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