small improvements
All checks were successful
Frontend Build and Deploy / build (push) Successful in 22s

This commit is contained in:
José Henrique 2025-06-13 20:21:57 -03:00
parent 02e1663594
commit 2e94f46b5b

View File

@ -13,6 +13,7 @@ const StatisticsGraphs: React.FC<StatisticsGraphsProps> = ({
error,
statisticsData,
}) => {
const [currentEnrichmentIndex, setCurrentEnrichmentIndex] = React.useState(0);
if (error) {
return (
<GlassCard className="flex items-center justify-center h-64">
@ -62,15 +63,34 @@ const StatisticsGraphs: React.FC<StatisticsGraphsProps> = ({
}
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 (
<GlassCard>
<div>
<div className="relative">
<h3 className="text-lg font-semibold text-gray-900 mb-4">{title}</h3>
<div className="space-y-3">
<div className="flex justify-between items-center">
<span className="text-gray-600">Candidato:</span>
<span className="text-gray-900 font-medium">{enrichmentData.nome}</span>
<a
href={`/candidato/${enrichmentData.idCandidato}`}
className="text-gray-900 font-medium hover:text-blue-600 hover:underline transition-colors duration-200"
>
{enrichmentData.nome}
</a>
</div>
<div className="flex justify-between items-center">
<span className="text-gray-600">Patrimônio Inicial (<span className="text-xs text-gray-500">{enrichmentData.anoInicial}</span>):</span>
@ -97,6 +117,45 @@ const StatisticsGraphs: React.FC<StatisticsGraphsProps> = ({
</div>
</div>
</div>
{/* Navigation buttons */}
{hasMultipleItems && (
<div className="flex justify-between items-center mt-4 pt-3 border-t border-gray-200">
<button
onClick={handleBack}
disabled={currentEnrichmentIndex === 0}
className={`flex items-center px-3 py-2 rounded-lg text-sm font-medium transition-all duration-200 ${
currentEnrichmentIndex === 0
? 'text-gray-400 cursor-not-allowed opacity-50'
: 'text-gray-600 hover:text-gray-900 hover:bg-gray-100 active:bg-gray-200'
}`}
>
<svg className="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
</svg>
Anterior
</button>
<div className="text-xs text-gray-500">
{currentEnrichmentIndex + 1} de {data.length}
</div>
<button
onClick={handleNext}
disabled={currentEnrichmentIndex === data.length - 1}
className={`flex items-center px-3 py-2 rounded-lg text-sm font-medium transition-all duration-200 ${
currentEnrichmentIndex === data.length - 1
? 'text-gray-400 cursor-not-allowed opacity-50'
: 'text-gray-600 hover:text-gray-900 hover:bg-gray-100 active:bg-gray-200'
}`}
>
Próximo
<svg className="w-4 h-4 ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
</button>
</div>
)}
</div>
</GlassCard>
);
@ -129,9 +188,11 @@ const StatisticsGraphs: React.FC<StatisticsGraphsProps> = ({
{data.slice(0, 5).map((item, index) => (
<tr key={index} className="border-b border-gray-100 hover:bg-gray-50 transition-colors duration-150">
{type === 'candidate' && (
<>
<td className="py-3 text-gray-900">{item.nome || 'N/A'}</td>
</>
<a href={`/candidato/${item.idCandidato}`}
className="text-gray-900 font-medium hover:text-blue-600 hover:underline transition-colors duration-200"
>
<td className="py-3">{item.nome || 'N/A'}</td>
</a>
)}
{type === 'party' && (
<td className="py-3 text-gray-900">{item.sgpartido || 'N/A'}</td>