Skip to content

Commit ad9fd06

Browse files
authored
Update autoridade.html
1 parent bde5d01 commit ad9fd06

File tree

1 file changed

+117
-42
lines changed

1 file changed

+117
-42
lines changed

autoridade.html

Lines changed: 117 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<title>Painel de Autoridade — Terra Dourada</title>
77
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pouchdb.min.js"></script>
88
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html2canvas.min.js"></script>
9+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
910

1011
<style>
1112
body {
@@ -218,6 +219,41 @@
218219
margin-bottom: 10px;
219220
}
220221

222+
/* Novo estilo para o campo de tipo */
223+
.tipo-eleicao {
224+
display: grid;
225+
grid-template-columns: 1fr 1fr;
226+
gap: 15px;
227+
margin-bottom: 20px;
228+
}
229+
.tipo-option {
230+
background: #1a1a1a;
231+
border: 1px solid #d4af37;
232+
border-radius: 10px;
233+
padding: 15px;
234+
text-align: center;
235+
cursor: pointer;
236+
transition: 0.3s;
237+
}
238+
.tipo-option:hover {
239+
background: rgba(212,175,55,0.1);
240+
}
241+
.tipo-option.selecionado {
242+
background: rgba(212,175,55,0.2);
243+
border-color: #d4af37;
244+
}
245+
.tipo-option i {
246+
font-size: 1.5rem;
247+
margin-bottom: 8px;
248+
display: block;
249+
}
250+
.tipo-option small {
251+
display: block;
252+
margin-top: 5px;
253+
color: #888;
254+
font-size: 0.8rem;
255+
}
256+
221257
/* Tela de confirmação */
222258
.confirmation-screen {
223259
display: none;
@@ -348,6 +384,23 @@ <h2 style="text-align: center; color: #d4af37; margin-bottom: 30px;">Criar Nova
348384
<label for="electionName">Nome da Eleição</label>
349385
<input type="text" id="electionName" placeholder="Ex: Eleições Municipais 2024">
350386
</div>
387+
388+
<!-- NOVO CAMPO: Tipo da Eleição -->
389+
<div class="form-group">
390+
<label>Tipo da Eleição</label>
391+
<div class="tipo-eleicao">
392+
<div class="tipo-option selecionado" onclick="selecionarTipo('online', this)">
393+
<i class="fas fa-globe"></i>
394+
<strong>🌐 Online</strong>
395+
<small>Votação remota por link</small>
396+
</div>
397+
<div class="tipo-option" onclick="selecionarTipo('presencial', this)">
398+
<i class="fas fa-building"></i>
399+
<strong>🏛️ Presencial</strong>
400+
<small>Votação física com mesário</small>
401+
</div>
402+
</div>
403+
</div>
351404

352405
<div class="form-group">
353406
<label for="position">Cargos em Disputa</label>
@@ -375,6 +428,7 @@ <h2 style="text-align: center; color: #d4af37; margin-bottom: 30px;">Criar Nova
375428
<h2>Confirmação de Eleição</h2>
376429
<p>Você está prestes a criar a eleição:</p>
377430
<h3 id="confirmationElectionName" style="color: #d4af37; margin: 10px 0 20px;"></h3>
431+
<p id="confirmationTipo" style="margin-bottom: 10px;"></p>
378432
<p id="confirmationPosition" style="margin-bottom: 10px;"></p>
379433
<p id="confirmationDescription" style="margin-bottom: 20px; color: #bbb;"></p>
380434
<p>Tem certeza de que deseja confirmar a criação?</p>
@@ -395,6 +449,7 @@ <h3 id="confirmationElectionName" style="color: #d4af37; margin: 10px 0 20px;"><
395449
// Variáveis
396450
let photoBase64 = null;
397451
let electionData = null;
452+
let tipoEleicao = 'online'; // Padrão: online
398453

399454
// --- CONTROLE DE ABAS ---
400455
function showTab(tab) {
@@ -403,7 +458,7 @@ <h3 id="confirmationElectionName" style="color: #d4af37; margin: 10px 0 20px;"><
403458
document.querySelectorAll('[id^="tab-"]').forEach(c => c.style.display = 'none');
404459

405460
// Ativar aba atual
406-
document.querySelector(`button[onclick="showTab('${tab}')"]`).classList.add('active');
461+
event.currentTarget.classList.add('active');
407462
document.getElementById(`tab-${tab}`).style.display = 'block';
408463

409464
// Recarregar eleições se for a aba de listagem
@@ -412,40 +467,58 @@ <h3 id="confirmationElectionName" style="color: #d4af37; margin: 10px 0 20px;"><
412467
}
413468
}
414469

470+
// --- NOVA FUNÇÃO: Selecionar Tipo ---
471+
function selecionarTipo(tipo, element) {
472+
tipoEleicao = tipo;
473+
474+
// Atualizar interface
475+
document.querySelectorAll('.tipo-option').forEach(opt => {
476+
opt.classList.remove('selecionado');
477+
});
478+
element.classList.add('selecionado');
479+
}
480+
415481
// --- CARREGAR ELEIÇÕES ---
416482
async function carregarEleicoes() {
417-
const res = await dbEleicoes.allDocs({ include_docs: true });
418-
const cont = document.getElementById('eleicoes-list');
419-
420-
if (res.rows.length === 0) {
421-
cont.innerHTML = `
422-
<div class="empty-state">
423-
<h3>Nenhuma eleição cadastrada</h3>
424-
<p>Clique em "Nova Eleição" para criar sua primeira eleição</p>
425-
</div>
426-
`;
427-
return;
428-
}
483+
try {
484+
const res = await dbEleicoes.allDocs({ include_docs: true });
485+
const cont = document.getElementById('eleicoes-list');
486+
487+
if (res.rows.length === 0) {
488+
cont.innerHTML = `
489+
<div class="empty-state">
490+
<h3>Nenhuma eleição cadastrada</h3>
491+
<p>Clique em "Nova Eleição" para criar sua primeira eleição</p>
492+
</div>
493+
`;
494+
return;
495+
}
429496

430-
cont.innerHTML = res.rows.map(r => {
431-
const eleicao = r.doc;
432-
const status = eleicao.status === 'ativa' ? 'status-ativa' : 'status-inativa';
433-
const statusText = eleicao.status === 'ativa' ? 'Ativa' : 'Inativa';
434-
const logo = eleicao.photo || 'https://via.placeholder.com/80/1a1a1a/d4af37?text=🗳️';
435-
436-
return `
437-
<div class="eleicao-card" onclick="abrirPainelEleicao('${eleicao._id}')">
438-
<img src="${logo}" alt="${eleicao.name}" class="eleicao-logo">
439-
<h3>${eleicao.name}</h3>
440-
<p><strong>Cargo:</strong> ${eleicao.position}</p>
441-
<p><strong>Criada em:</strong> ${new Date(eleicao.createdAt).toLocaleDateString()}</p>
442-
<span class="status-badge ${status}">${statusText}</span>
443-
<p style="margin-top: 15px; font-size: 0.8rem; color: #888;">
444-
Clique para gerenciar esta eleição
445-
</p>
446-
</div>
447-
`;
448-
}).join('');
497+
cont.innerHTML = res.rows.map(r => {
498+
const eleicao = r.doc;
499+
const status = eleicao.status === 'ativa' ? 'status-ativa' : 'status-inativa';
500+
const statusText = eleicao.status === 'ativa' ? 'Ativa' : 'Inativa';
501+
const logo = eleicao.photo || 'https://via.placeholder.com/80/1a1a1a/d4af37?text=🗳️';
502+
const tipoIcon = eleicao.tipo === 'presencial' ? '🏛️' : '🌐';
503+
const tipoText = eleicao.tipo === 'presencial' ? 'Presencial' : 'Online';
504+
505+
return `
506+
<div class="eleicao-card" onclick="abrirPainelEleicao('${eleicao._id}')">
507+
<img src="${logo}" alt="${eleicao.name}" class="eleicao-logo">
508+
<h3>${eleicao.name}</h3>
509+
<p><strong>Tipo:</strong> ${tipoIcon} ${tipoText}</p>
510+
<p><strong>Cargo:</strong> ${eleicao.position}</p>
511+
<p><strong>Criada em:</strong> ${new Date(eleicao.createdAt).toLocaleDateString()}</p>
512+
<span class="status-badge ${status}">${statusText}</span>
513+
<p style="margin-top: 15px; font-size: 0.8rem; color: #888;">
514+
Clique para gerenciar esta eleição
515+
</p>
516+
</div>
517+
`;
518+
}).join('');
519+
} catch (error) {
520+
console.error('Erro ao carregar eleições:', error);
521+
}
449522
}
450523

451524
// --- ABRIR PAINEL DA ELEIÇÃO ---
@@ -486,6 +559,7 @@ <h3>${eleicao.name}</h3>
486559
// Preparar dados
487560
electionData = {
488561
name: name,
562+
tipo: tipoEleicao,
489563
position: position,
490564
description: description,
491565
photo: photoBase64
@@ -499,8 +573,9 @@ <h3>${eleicao.name}</h3>
499573
function abrirTelaConfirmacao(dadosEleicao) {
500574
document.getElementById('confirmationImage').src = dadosEleicao.photo;
501575
document.getElementById('confirmationElectionName').textContent = dadosEleicao.name;
576+
document.getElementById('confirmationTipo').textContent = `Tipo: ${dadosEleicao.tipo === 'presencial' ? '🏛️ Presencial' : '🌐 Online'}`;
502577
document.getElementById('confirmationPosition').textContent = `Cargos: ${dadosEleicao.position}`;
503-
document.getElementById('confirmationDescription').textContent = dadosEleicao.description;
578+
document.getElementById('confirmationDescription').textContent = dadosEleicao.description || 'Sem descrição';
504579

505580
document.getElementById('confirmCadastroButton').onclick = function() {
506581
confirmarEleicao();
@@ -530,6 +605,7 @@ <h3>${eleicao.name}</h3>
530605
const election = {
531606
_id: electionId,
532607
name: electionData.name,
608+
tipo: electionData.tipo,
533609
position: electionData.position,
534610
description: electionData.description,
535611
photo: electionData.photo,
@@ -553,6 +629,13 @@ <h3>${eleicao.name}</h3>
553629
document.getElementById('photoPreview').innerHTML = '<i class="fas fa-image"></i>';
554630
photoBase64 = null;
555631

632+
// Resetar tipo para padrão
633+
document.querySelectorAll('.tipo-option').forEach(opt => {
634+
opt.classList.remove('selecionado');
635+
});
636+
document.querySelector('.tipo-option').classList.add('selecionado');
637+
tipoEleicao = 'online';
638+
556639
fecharTelaConfirmacao();
557640

558641
// Voltar para a aba de eleições e recarregar
@@ -586,15 +669,7 @@ <h3>${eleicao.name}</h3>
586669
// --- INICIALIZAÇÃO ---
587670
document.addEventListener("DOMContentLoaded", () => {
588671
carregarEleicoes();
589-
590-
// Adicionar ícones do Font Awesome
591-
if (!document.querySelector('link[href*="font-awesome"]')) {
592-
const faLink = document.createElement('link');
593-
faLink.rel = 'stylesheet';
594-
faLink.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css';
595-
document.head.appendChild(faLink);
596-
}
597672
});
598673
</script>
599674
</body>
600-
</html>
675+
</html>

0 commit comments

Comments
 (0)