const { useState, useEffect } = React; function App() { const [userName, setUserName] = useState(''); const [isLogged, setIsLogged] = useState(false); const [choices, setChoices] = useState(null); const [isEditing, setIsEditing] = useState(false); useEffect(() => { const savedName = localStorage.getItem('colinha_nome'); const savedChoices = localStorage.getItem('colinha_choices'); if (savedName) { setUserName(savedName); setIsLogged(true); } if (savedChoices) { setChoices(JSON.parse(savedChoices)); } }, []); const handleLogin = (name) => { localStorage.setItem('colinha_nome', name); setUserName(name); setIsLogged(true); }; const handleSaveChoices = (newChoices) => { localStorage.setItem('colinha_choices', JSON.stringify(newChoices)); setChoices(newChoices); setIsEditing(false); window.scrollTo(0, 0); }; const handleClear = () => { if(confirm("Tem certeza que deseja sair e apagar seus dados deste celular?")) { localStorage.removeItem('colinha_nome'); localStorage.removeItem('colinha_choices'); setUserName(''); setIsLogged(false); setChoices(null); setIsEditing(false); } }; if (!isLogged) { return ; } if (!choices || isEditing) { return {setIsEditing(false); window.scrollTo(0,0);} : null} />; } return {setIsEditing(true); window.scrollTo(0,0);}} onLogout={handleClear} userName={userName} />; } function Login({ onLogin }) { const [name, setName] = useState(''); const handleSubmit = (e) => { e.preventDefault(); if (name.trim()) onLogin(name.trim()); }; return (

Colinha Eleitoral

Crie e salve sua colinha no seu celular.

setName(e.target.value)} required />

Seus dados ficam salvos apenas no seu celular.

); } function TabelaSelecao({ id, label, options, value, onChange, digits }) { const isOutroSelected = value && value.isOutro; return (

{label}

{options.map((o) => { const isSelected = value && !value.isOutro && value.numero === o.numero; return ( onChange({ ...o, isOutro: false })} className={`border-b border-gray-200 cursor-pointer hover:bg-green-50 transition-colors ${isSelected ? 'bg-green-100' : ''}`} > ); })}
Sel. Candidato (Número) Motivo / Alinhamento Perfil / Atuação Região
{isSelected &&
}
{o.nome}
{o.numero}
{o.arg1} {o.arg2} {o.regiao}
{ if (!isOutroSelected) onChange({ nome: '', numero: '', isOutro: true }); }} className={`mt-4 p-4 border-2 rounded-lg cursor-pointer transition-colors ${isOutroSelected ? 'border-bramarelo bg-yellow-50' : 'border-gray-300 bg-white hover:bg-gray-100'}`} >
{isOutroSelected &&
}
Outro candidato (Digitar manualmente)
{isOutroSelected && (
onChange({ ...value, nome: e.target.value, isOutro: true })} /> onChange({ ...value, numero: e.target.value, isOutro: true })} />
)}
); } function Selecao({ onSave, initialChoices, onCancel }) { const [depFederal, setDepFederal] = useState(initialChoices.depFederal || null); const [depEstadual, setDepEstadual] = useState(initialChoices.depEstadual || null); const [senador1, setSenador1] = useState(initialChoices.senador1 || null); const [senador2, setSenador2] = useState(initialChoices.senador2 || null); const [missing, setMissing] = useState([]); const handleSubmit = (e) => { e.preventDefault(); const missingFields = []; if (!depFederal) missingFields.push({ id: 'sec-depFederal', nome: 'Deputado Federal' }); if (!depEstadual) missingFields.push({ id: 'sec-depEstadual', nome: 'Deputado Estadual' }); if (!senador1) missingFields.push({ id: 'sec-senador1', nome: 'Primeiro Senador' }); if (!senador2) missingFields.push({ id: 'sec-senador2', nome: 'Segundo Senador' }); if (missingFields.length > 0) { setMissing(missingFields); // Optional: scroll automatically to the first missing field or the error message document.getElementById('error-box')?.scrollIntoView({ behavior: 'smooth', block: 'center' }); return; } setMissing([]); onSave({ depFederal, depEstadual, senador1, senador2 }); }; const scrollTo = (id) => { document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' }); }; return (

Tabela de Escolha

Leia as informações nas colunas da tabela abaixo e marque a sua escolha para cada cargo.

{ setDepFederal(v); setMissing(missing.filter(m => m.id !== 'sec-depFederal')); }} digits={4} /> { setDepEstadual(v); setMissing(missing.filter(m => m.id !== 'sec-depEstadual')); }} digits={5} /> { setSenador1(v); setMissing(missing.filter(m => m.id !== 'sec-senador1')); }} digits={3} /> !(senador1 && !senador1.isOutro && s.numero === senador1.numero))} value={senador2} onChange={(v) => { setSenador2(v); setMissing(missing.filter(m => m.id !== 'sec-senador2')); }} digits={3} />

Governador e Presidente

Estas opções já estão fixadas na sua colinha.

5º - Governador 22 - Zucco
6º - Presidente 22 - Bolsonaro
{missing.length > 0 && (

Atenção: Faltam algumas escolhas

Por favor, escolha um candidato para os seguintes cargos antes de salvar:

{missing.map((m) => (
{m.nome}
))}
)}
{onCancel && ( )}
); } function UrnaBoxes({ numero, isYellow }) { const chars = String(numero).split(''); return (
{chars.map((char, i) => (
{char}
))}
); } function ColinhaItem({ cargo, candidato, isFixed }) { const isYellow = candidato?.isOutro; return (

{cargo}

{isYellow && Inserido Manualmente}
{candidato?.nome || 'Não definido'}
{/* Informações mantidas na colinha */} {!isYellow && !isFixed && (candidato?.arg1 || candidato?.regiao) && (
{candidato.arg1 &&
Por que escolhi: {candidato.arg1}
} {candidato.arg2 &&
{candidato.arg2}
} {candidato.regiao &&
Região: {candidato.regiao}
}
)}
); } function Colinha({ choices, onEdit, onLogout, userName }) { return (

Olá, {userName}

Sua Colinha

Leve junto no dia da votação para lembrar dos seus escolhidos

); } const root = ReactDOM.createRoot(document.getElementById('root')); root.render();