feat(comparacao): exibir selos de cada consultor no modal de comparacao
This commit is contained in:
@@ -1,6 +1,78 @@
|
||||
import React from 'react';
|
||||
import './CompararModal.css';
|
||||
|
||||
const SELOS = {
|
||||
PRESID_CAMARA: { label: 'Pres. Câmara', icone: '👑' },
|
||||
COORD_PPG: { label: 'Coord. PPG', icone: '🎓' },
|
||||
BPQ: { label: 'BPQ', icone: '🏅' },
|
||||
AUTOR_GP: { label: 'Autor GP', icone: '🏆' },
|
||||
AUTOR_PREMIO: { label: 'Autor Prêmio', icone: '🥇' },
|
||||
AUTOR_MENCAO: { label: 'Autor Menção', icone: '🥈' },
|
||||
ORIENT_GP: { label: 'Orient. GP', icone: '🏆' },
|
||||
ORIENT_PREMIO: { label: 'Orient. Prêmio', icone: '🎖️' },
|
||||
ORIENT_MENCAO: { label: 'Orient. Menção', icone: '📜' },
|
||||
COORIENT_GP: { label: 'Coorient. GP', icone: '🏆' },
|
||||
COORIENT_PREMIO: { label: 'Coorient. Prêmio', icone: '🎖️' },
|
||||
COORIENT_MENCAO: { label: 'Coorient. Menção', icone: '📜' },
|
||||
ORIENT_POS_DOC: { label: 'Orient. Pós-Doc', icone: '🔬' },
|
||||
ORIENT_TESE: { label: 'Orient. Tese', icone: '📚' },
|
||||
ORIENT_DISS: { label: 'Orient. Diss.', icone: '📄' },
|
||||
CO_ORIENT_POS_DOC: { label: 'Coorient. Pós-Doc', icone: '🔬' },
|
||||
CO_ORIENT_TESE: { label: 'Coorient. Tese', icone: '📚' },
|
||||
CO_ORIENT_DISS: { label: 'Coorient. Diss.', icone: '📄' },
|
||||
};
|
||||
|
||||
const gerarSelos = (consultor) => {
|
||||
const selos = [];
|
||||
|
||||
const isPresidCamara = consultor.coordenacoes_capes?.some(
|
||||
(c) => c.codigo === 'CAM' && c.presidente && (c.ativo ?? !c.fim)
|
||||
);
|
||||
if (isPresidCamara) selos.push({ ...SELOS.PRESID_CAMARA, qtd: 1 });
|
||||
|
||||
if (consultor.coordenador_ppg) selos.push({ ...SELOS.COORD_PPG, qtd: 1 });
|
||||
|
||||
const bolsas = Array.isArray(consultor.bolsas_cnpq) ? consultor.bolsas_cnpq : [];
|
||||
if (bolsas.length > 0) selos.push({ ...SELOS.BPQ, qtd: bolsas.length });
|
||||
|
||||
const premiacoes = Array.isArray(consultor.premiacoes) ? consultor.premiacoes : [];
|
||||
const contarPrem = (papel, codigo) => premiacoes.filter(
|
||||
(p) => (p.papel || '').toLowerCase() === papel && p.codigo === codigo
|
||||
).length;
|
||||
|
||||
const addPremSelo = (papel, codBase, seloGP, seloPremio, seloMencao) => {
|
||||
const gp = contarPrem(papel, 'PREMIACAO');
|
||||
const premio = contarPrem(papel, 'PREMIACAO_GP');
|
||||
const mencao = contarPrem(papel, 'MENCAO');
|
||||
if (gp > 0) selos.push({ ...seloGP, qtd: gp });
|
||||
if (premio > 0) selos.push({ ...seloPremio, qtd: premio });
|
||||
if (mencao > 0) selos.push({ ...seloMencao, qtd: mencao });
|
||||
};
|
||||
|
||||
addPremSelo('autor', '', SELOS.AUTOR_GP, SELOS.AUTOR_PREMIO, SELOS.AUTOR_MENCAO);
|
||||
addPremSelo('orientador', '', SELOS.ORIENT_GP, SELOS.ORIENT_PREMIO, SELOS.ORIENT_MENCAO);
|
||||
addPremSelo('coorientador', '', SELOS.COORIENT_GP, SELOS.COORIENT_PREMIO, SELOS.COORIENT_MENCAO);
|
||||
|
||||
const orientacoes = Array.isArray(consultor.orientacoes) ? consultor.orientacoes : [];
|
||||
const contarOrient = (codigo, coorient) => orientacoes.filter(
|
||||
(o) => o.codigo === codigo && (coorient ? o.coorientacao : !o.coorientacao)
|
||||
).length;
|
||||
|
||||
const addOrientSelo = (codigo, coorient, selo) => {
|
||||
const qtd = contarOrient(codigo, coorient);
|
||||
if (qtd > 0) selos.push({ ...selo, qtd });
|
||||
};
|
||||
|
||||
addOrientSelo('ORIENT_POS_DOC', false, SELOS.ORIENT_POS_DOC);
|
||||
addOrientSelo('ORIENT_TESE', false, SELOS.ORIENT_TESE);
|
||||
addOrientSelo('ORIENT_DISS', false, SELOS.ORIENT_DISS);
|
||||
addOrientSelo('CO_ORIENT_POS_DOC', true, SELOS.CO_ORIENT_POS_DOC);
|
||||
addOrientSelo('CO_ORIENT_TESE', true, SELOS.CO_ORIENT_TESE);
|
||||
addOrientSelo('CO_ORIENT_DISS', true, SELOS.CO_ORIENT_DISS);
|
||||
|
||||
return selos;
|
||||
};
|
||||
|
||||
const CompararModal = ({ consultor1, consultor2, onClose }) => {
|
||||
if (!consultor1 || !consultor2) return null;
|
||||
|
||||
@@ -82,6 +154,28 @@ const CompararModal = ({ consultor1, consultor2, onClose }) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="comparacao-selos">
|
||||
<div className="selos-lista selos-1">
|
||||
{gerarSelos(consultor1).map((selo, i) => (
|
||||
<span key={i} className="selo-badge" title={selo.label}>
|
||||
<span className="selo-icone">{selo.icone}</span>
|
||||
{selo.qtd > 1 && <span className="selo-qtd">{selo.qtd}</span>}
|
||||
</span>
|
||||
))}
|
||||
{gerarSelos(consultor1).length === 0 && <span className="sem-selos">Sem selos</span>}
|
||||
</div>
|
||||
<div className="selos-label">SELOS</div>
|
||||
<div className="selos-lista selos-2">
|
||||
{gerarSelos(consultor2).map((selo, i) => (
|
||||
<span key={i} className="selo-badge" title={selo.label}>
|
||||
<span className="selo-icone">{selo.icone}</span>
|
||||
{selo.qtd > 1 && <span className="selo-qtd">{selo.qtd}</span>}
|
||||
</span>
|
||||
))}
|
||||
{gerarSelos(consultor2).length === 0 && <span className="sem-selos">Sem selos</span>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="comparacao-secao">
|
||||
<h3>Pontuacao Total</h3>
|
||||
{renderLinhaComparacao('TOTAL', total1, total2, 'var(--accent)')}
|
||||
|
||||
Reference in New Issue
Block a user