From 2e94f46b5b761a8dda9c03bff53102a0a61ccf12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique?= Date: Fri, 13 Jun 2025 20:21:57 -0300 Subject: [PATCH] small improvements --- .../StatisticsPage/StatisticsGraphs.tsx | 73 +++++++++++++++++-- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/src/components/StatisticsPage/StatisticsGraphs.tsx b/src/components/StatisticsPage/StatisticsGraphs.tsx index 5c9140b..71913a5 100644 --- a/src/components/StatisticsPage/StatisticsGraphs.tsx +++ b/src/components/StatisticsPage/StatisticsGraphs.tsx @@ -13,6 +13,7 @@ const StatisticsGraphs: React.FC = ({ error, statisticsData, }) => { + const [currentEnrichmentIndex, setCurrentEnrichmentIndex] = React.useState(0); if (error) { return ( @@ -62,15 +63,34 @@ const StatisticsGraphs: React.FC = ({ } if (type === 'enrichment') { - const enrichmentData = data[0]; // Single enrichment response + const enrichmentData = data[currentEnrichmentIndex]; // Use current index instead of always first item + const hasMultipleItems = data.length > 1; + + const handleNext = () => { + if (currentEnrichmentIndex < data.length - 1) { + setCurrentEnrichmentIndex(currentEnrichmentIndex + 1); + } + }; + + const handleBack = () => { + if (currentEnrichmentIndex > 0) { + setCurrentEnrichmentIndex(currentEnrichmentIndex - 1); + } + }; + return ( -
+

{title}

Candidato: - {enrichmentData.nome} + + {enrichmentData.nome} +
Patrimônio Inicial ({enrichmentData.anoInicial}): @@ -97,6 +117,45 @@ const StatisticsGraphs: React.FC = ({
+ + {/* Navigation buttons */} + {hasMultipleItems && ( +
+ + +
+ {currentEnrichmentIndex + 1} de {data.length} +
+ + +
+ )}
); @@ -129,9 +188,11 @@ const StatisticsGraphs: React.FC = ({ {data.slice(0, 5).map((item, index) => ( {type === 'candidate' && ( - <> - {item.nome || 'N/A'} - + + {item.nome || 'N/A'} + )} {type === 'party' && ( {item.sgpartido || 'N/A'}