Add visual badges (selos) to ConsultorCard
- Add SELOS constant with 18 badge types (coord, bolsa, premio, orientacoes, etc) - Add gerarSelos() function to extract badges from consultor data - Add SelosBadges component with compact and full display modes - Integrate badges in card header (compact) and expanded details (full) - Add CSS styles with gradient backgrounds and hover effects for each badge type - Badges show achievement counts and support tooltips
This commit is contained in:
@@ -1,6 +1,96 @@
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import './ConsultorCard.css';
|
||||
|
||||
const SELOS = {
|
||||
COORD_PPG: { label: 'Coord. PPG', cor: 'selo-coord', icone: '🎓' },
|
||||
PRESID_CAMARA: { label: 'Presid. Câmara', cor: 'selo-camara', icone: '🏛️' },
|
||||
BPQ: { label: 'Bolsista PQ', cor: 'selo-bpq', icone: '🔬' },
|
||||
GRANDE_PREMIO: { label: 'Grande Prêmio', cor: 'selo-gp', icone: '🏆' },
|
||||
PREMIO: { label: 'Prêmio', cor: 'selo-premio', icone: '🥇' },
|
||||
MENCAO: { label: 'Menção Honrosa', cor: 'selo-mencao', icone: '🎖️' },
|
||||
ORIENT_POS_DOC: { label: 'Orient. Pós-Doc', cor: 'selo-orient', icone: '📚' },
|
||||
ORIENT_POS_DOC_PREM: { label: 'Orient. Pós-Doc Premiada', cor: 'selo-orient-prem', icone: '📚🏆' },
|
||||
ORIENT_TESE: { label: 'Orient. Tese', cor: 'selo-orient', icone: '📖' },
|
||||
ORIENT_TESE_PREM: { label: 'Orient. Tese Premiada', cor: 'selo-orient-prem', icone: '📖🏆' },
|
||||
ORIENT_DISS: { label: 'Orient. Dissertação', cor: 'selo-orient', icone: '📝' },
|
||||
ORIENT_DISS_PREM: { label: 'Orient. Diss. Premiada', cor: 'selo-orient-prem', icone: '📝🏆' },
|
||||
CO_ORIENT_POS_DOC: { label: 'Co-Orient. Pós-Doc', cor: 'selo-coorient', icone: '📚' },
|
||||
CO_ORIENT_POS_DOC_PREM: { label: 'Co-Orient. Pós-Doc Prem.', cor: 'selo-coorient-prem', icone: '📚🏆' },
|
||||
CO_ORIENT_TESE: { label: 'Co-Orient. Tese', cor: 'selo-coorient', icone: '📖' },
|
||||
CO_ORIENT_TESE_PREM: { label: 'Co-Orient. Tese Premiada', cor: 'selo-coorient-prem', icone: '📖🏆' },
|
||||
CO_ORIENT_DISS: { label: 'Co-Orient. Diss.', cor: 'selo-coorient', icone: '📝' },
|
||||
CO_ORIENT_DISS_PREM: { label: 'Co-Orient. Diss. Prem.', cor: 'selo-coorient-prem', icone: '📝🏆' },
|
||||
};
|
||||
|
||||
const gerarSelos = (consultor) => {
|
||||
const selos = [];
|
||||
|
||||
if (consultor.coordenacoes_capes?.some(c => c.codigo === 'CAM' && c.presidente)) {
|
||||
selos.push({ ...SELOS.PRESID_CAMARA, qtd: 1 });
|
||||
}
|
||||
|
||||
if (consultor.coordenador_ppg) {
|
||||
selos.push({ ...SELOS.COORD_PPG, qtd: 1 });
|
||||
}
|
||||
|
||||
if (consultor.bolsas_cnpq?.length > 0) {
|
||||
selos.push({ ...SELOS.BPQ, qtd: consultor.bolsas_cnpq.length });
|
||||
}
|
||||
|
||||
const gp = consultor.premiacoes?.filter(p => p.codigo === 'PREMIACAO')?.length || 0;
|
||||
const premio = consultor.premiacoes?.filter(p => p.codigo === 'PREMIACAO_GP')?.length || 0;
|
||||
const mencao = consultor.premiacoes?.filter(p => p.codigo === 'MENCAO')?.length || 0;
|
||||
|
||||
if (gp > 0) selos.push({ ...SELOS.GRANDE_PREMIO, qtd: gp });
|
||||
if (premio > 0) selos.push({ ...SELOS.PREMIO, qtd: premio });
|
||||
if (mencao > 0) selos.push({ ...SELOS.MENCAO, qtd: mencao });
|
||||
|
||||
const orientPosDoc = consultor.orientacoes?.filter(o => o.codigo === 'ORIENT_POS_DOC')?.length || 0;
|
||||
const orientTese = consultor.orientacoes?.filter(o => o.codigo === 'ORIENT_TESE')?.length || 0;
|
||||
const orientDiss = consultor.orientacoes?.filter(o => o.codigo === 'ORIENT_DISS')?.length || 0;
|
||||
|
||||
const orientPosDocPrem = consultor.orientacoes?.filter(o => o.codigo === 'ORIENT_POS_DOC' && o.premiada)?.length || 0;
|
||||
const orientTesePrem = consultor.orientacoes?.filter(o => o.codigo === 'ORIENT_TESE' && o.premiada)?.length || 0;
|
||||
const orientDissPrem = consultor.orientacoes?.filter(o => o.codigo === 'ORIENT_DISS' && o.premiada)?.length || 0;
|
||||
|
||||
if (orientPosDocPrem > 0) selos.push({ ...SELOS.ORIENT_POS_DOC_PREM, qtd: orientPosDocPrem });
|
||||
else if (orientPosDoc > 0) selos.push({ ...SELOS.ORIENT_POS_DOC, qtd: orientPosDoc });
|
||||
|
||||
if (orientTesePrem > 0) selos.push({ ...SELOS.ORIENT_TESE_PREM, qtd: orientTesePrem });
|
||||
else if (orientTese > 0) selos.push({ ...SELOS.ORIENT_TESE, qtd: orientTese });
|
||||
|
||||
if (orientDissPrem > 0) selos.push({ ...SELOS.ORIENT_DISS_PREM, qtd: orientDissPrem });
|
||||
else if (orientDiss > 0) selos.push({ ...SELOS.ORIENT_DISS, qtd: orientDiss });
|
||||
|
||||
return selos;
|
||||
};
|
||||
|
||||
const SelosBadges = ({ selos, compacto = false }) => {
|
||||
if (!selos || selos.length === 0) return null;
|
||||
|
||||
const selosExibidos = compacto ? selos.slice(0, 4) : selos;
|
||||
const selosOcultos = compacto && selos.length > 4 ? selos.length - 4 : 0;
|
||||
|
||||
return (
|
||||
<div className={`selos-container ${compacto ? 'selos-compacto' : ''}`}>
|
||||
{selosExibidos.map((selo, idx) => (
|
||||
<span
|
||||
key={idx}
|
||||
className={`selo ${selo.cor}`}
|
||||
title={`${selo.label}${selo.qtd > 1 ? ` (${selo.qtd}x)` : ''}`}
|
||||
>
|
||||
<span className="selo-icone">{selo.icone}</span>
|
||||
{!compacto && <span className="selo-label">{selo.label}</span>}
|
||||
{selo.qtd > 1 && <span className="selo-qtd">{selo.qtd}</span>}
|
||||
</span>
|
||||
))}
|
||||
{selosOcultos > 0 && (
|
||||
<span className="selo selo-mais" title={`+${selosOcultos} selos`}>+{selosOcultos}</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const FORMULAS = {
|
||||
bloco_a: {
|
||||
titulo: 'Coordenacao CAPES',
|
||||
@@ -105,6 +195,8 @@ const ConsultorCard = ({ consultor, highlight, selecionado, onToggleSelecionado
|
||||
const blocoD = pontuacao?.bloco_d || { total: consultor.bloco_d || 0 };
|
||||
const pontuacaoTotal = (blocoA.total || 0) + (blocoB.total || 0) + (blocoC.total || 0) + (blocoD.total || 0);
|
||||
|
||||
const selos = gerarSelos(consultor);
|
||||
|
||||
return (
|
||||
<div ref={cardRef} className={`ranking-card ${expanded ? 'expanded' : ''} ${highlight ? 'highlight' : ''} ${selecionado ? 'selecionado' : ''}`} onClick={() => setExpanded(!expanded)}>
|
||||
<div className="card-main">
|
||||
@@ -124,6 +216,7 @@ const ConsultorCard = ({ consultor, highlight, selecionado, onToggleSelecionado
|
||||
{consultor.ativo && <span className="badge badge-ativo">ATIVO</span>}
|
||||
{!consultor.ativo && <span className="badge badge-historico">HISTORICO</span>}
|
||||
{consultor.veterano && <span className="badge badge-veterano">VETERANO</span>}
|
||||
<SelosBadges selos={selos} compacto={true} />
|
||||
</div>
|
||||
<div className="consultant-area">
|
||||
{consultor.anos_atuacao} anos de atuacao
|
||||
@@ -207,6 +300,13 @@ const ConsultorCard = ({ consultor, highlight, selecionado, onToggleSelecionado
|
||||
{blocoD.atuacoes && blocoD.atuacoes.length > 0 && (
|
||||
<BlocoDetalhes titulo="D - Premiacoes/Avaliacoes" bloco={blocoD} cor="var(--bronze)" />
|
||||
)}
|
||||
|
||||
{selos.length > 0 && (
|
||||
<div className="detail-section selos-section">
|
||||
<h4>Selos e Reconhecimentos</h4>
|
||||
<SelosBadges selos={selos} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{consultor.coordenacoes_capes?.length > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user