// Diagnostic.jsx — multi-step form, fully functional const { useState: useStateD, useEffect: useEffectD, useRef: useRefD } = React; const STEPS = [ { id: 'segment', label: 'Segmento da empresa', q: 'Qual é o segmento da sua empresa?', options: [ { id: 'comercio', label: 'Comércio', hint: 'Varejo, atacado, distribuição' }, { id: 'servicos', label: 'Serviços', hint: 'Profissionais, tech, agências' }, { id: 'industria', label: 'Indústria', hint: 'Manuf., transformação, insumos' }, { id: 'outro', label: 'Outro', hint: 'Agro, construção, saúde, outros' }, ], }, { id: 'regime', label: 'Regime tributário', q: 'Qual é o regime tributário atual?', options: [ { id: 'simples', label: 'Simples Nacional', hint: 'Anexos I a V' }, { id: 'presumido', label: 'Lucro Presumido', hint: 'Apuração trimestral' }, { id: 'real', label: 'Lucro Real', hint: 'Apuração mensal/trimestral' }, { id: 'naosei', label: 'Não sei informar', hint: 'Tudo bem, a gente descobre' }, ], }, { id: 'faturamento', label: 'Faturamento anual', q: 'Qual é o faturamento anual aproximado?', options: [ { id: 'a1', label: 'Até R\$ 360 mil', hint: 'MEI / ME pequeno' }, { id: 'a2', label: 'R\$ 361 mil a R\$ 4,8 mi', hint: 'Simples Nacional' }, { id: 'a3', label: 'R\$ 4,8 mi a R\$ 10 mi', hint: 'Presumido comum' }, { id: 'a4', label: 'Acima de R\$ 10 mi', hint: 'Real / obrigatório' }, ], }, { id: 'autuacao', label: 'Notificação ou autuação', q: 'Já recebeu notificação ou autuação fiscal?', options: [ { id: 'ativa', label: 'Sim, pendência ativa', hint: 'Precisa resposta urgente' }, { id: 'resolvi', label: 'Sim, já resolvi', hint: 'Mas ainda tem dúvidas' }, { id: 'nao', label: 'Não', hint: 'Quero prevenir' }, { id: 'naosei', label: 'Não sei verificar', hint: 'A gente confere pra você' }, ], }, { id: 'dor', label: 'Principal dificuldade', q: 'Qual é a principal dificuldade tributária hoje?', options: [ { id: 'muito', label: 'Pago muito imposto', hint: 'Suspeito pagar a mais' }, { id: 'autuacao', label: 'Recebi uma autuação', hint: 'Preciso impugnar' }, { id: 'plan', label: 'Nunca fiz planejamento', hint: 'Quero estratégia' }, { id: 'recuperar', label: 'Suspeito ter a recuperar', hint: 'Créditos parados' }, ], }, { id: 'contato', label: 'Contato', q: 'Quase lá. Para onde enviamos a análise?', contact: true, }, ]; function Diagnostic({ prefillSegment, jumpToken }) { const [step, setStep] = useStateD(0); const [answers, setAnswers] = useStateD({}); const [sent, setSent] = useStateD(false); const [nameVal, setNameVal] = useStateD(''); const [phoneVal, setPhoneVal] = useStateD(''); const [errors, setErrors] = useStateD({}); const [transitioning, setTransitioning] = useStateD(false); const rootRef = useRefD(null); useEffectD(() => { if (prefillSegment && !sent) { setAnswers(a => ({ ...a, segment: prefillSegment })); setStep(1); } }, [jumpToken]); const current = STEPS[step]; const pct = Math.round(((step) / (STEPS.length - 1)) * 100); const pick = (val) => { setTransitioning(true); setAnswers(a => ({ ...a, [current.id]: val })); setTimeout(() => { setStep(s => Math.min(STEPS.length - 1, s + 1)); setTransitioning(false); }, 260); }; const prev = () => setStep(s => Math.max(0, s - 1)); const phoneFmt = (raw) => { const d = raw.replace(/\D/g, '').slice(0, 11); if (d.length <= 2) return d; if (d.length <= 6) return `(${d.slice(0,2)}) ${d.slice(2)}`; if (d.length <= 10) return `(${d.slice(0,2)}) ${d.slice(2,6)}-${d.slice(6)}`; return `(${d.slice(0,2)}) ${d.slice(2,7)}-${d.slice(7)}`; }; const submit = async () => { const errs = {}; if (nameVal.trim().length < 2) errs.name = 'Informe seu nome'; const digits = phoneVal.replace(/\D/g, ''); if (digits.length < 10) errs.phone = 'WhatsApp inválido'; setErrors(errs); if (Object.keys(errs).length) return; try { await fetch('/submit.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: nameVal, phone: phoneVal, ...answers }), }); } catch (_) {} setSent(true); }; const reset = () => { setSent(false); setStep(0); setAnswers({}); setNameVal(''); setPhoneVal(''); setErrors({}); }; return (
Diagnóstico Tributário

Gratuito.
Rápido.
Sem enrolação.

Responda 5 perguntas. Você vai entender onde está o problema e chega à conversa com nossa especialista com clareza sobre o que precisa resolver.

    {[ '100% gratuito, sem compromisso', 'Suas informações são confidenciais', 'Retorno por WhatsApp com especialista', 'Atendimento em até 24 horas úteis', ].map((t, i) => (
  • {t}
  • ))}
Formulário {sent ? 'Concluído' : `Passo ${String(step+1).padStart(2, '0')} / ${String(STEPS.length).padStart(2, '0')}`}
{STEPS.map((s, i) => { const done = answers[s.id] || (s.contact && sent); const active = i === step && !sent; return ( ); })}
{sent ? ( ) : current.contact ? ( setPhoneVal(phoneFmt(v))} errors={errors} onSubmit={submit} onBack={prev} answers={answers} /> ) : ( <>
Pergunta {String(step+1).padStart(2, '0')} · {current.label}

{current.q}

{current.options.map(o => { const active = answers[current.id] === o.id; return ( ); })}
)}
{!sent && !current.contact && (
Clique uma opção para avançar
)}
); } function ContactForm({ name, setName, phone, setPhone, errors, onSubmit, onBack, answers }) { return ( <>
Pergunta 06 · Contato

Quase lá. Para onde enviamos
a análise?

Sua especialista retorna em até 24h úteis com o primeiro parecer.

setName(e.target.value)} placeholder="Seu nome completo" style={{ width: '100%', padding: '16px 18px', background: 'var(--bg4)', border: `1px solid ${errors.name ? 'var(--danger-soft, #FF6B6B)' : 'var(--border)'}`, borderRadius: 'var(--r-1)', fontSize: '1rem', color: 'var(--white)', fontFamily: 'var(--font-body)' }} onFocus={e => e.target.style.borderColor = 'var(--signal)'} onBlur={e => e.target.style.borderColor = errors.name ? '#FF6B6B' : 'var(--border)'} /> {errors.name &&
{errors.name}
}
setPhone(e.target.value)} placeholder="(11) 99999-9999" style={{ width: '100%', padding: '16px 18px', background: 'var(--bg4)', border: `1px solid ${errors.phone ? '#FF6B6B' : 'var(--border)'}`, borderRadius: 'var(--r-1)', fontSize: '1rem', color: 'var(--white)', fontFamily: 'var(--font-body)' }} onFocus={e => e.target.style.borderColor = 'var(--signal)'} onBlur={e => e.target.style.borderColor = errors.phone ? '#FF6B6B' : 'var(--border)'} /> {errors.phone &&
{errors.phone}
}
Suas respostas
{STEPS.slice(0, 5).map(s => { const ans = s.options?.find(o => o.id === answers[s.id]); return (
{s.label}
{ans?.label || '—'}
); })}

Sem spam. Seus dados são usados apenas para o contato.

); } function SentState({ answers, name, onReset }) { return (

Pronto, {name?.split(' ')[0] || 'empresário'}.

Nossa especialista entra em contato pelo WhatsApp em até 24 horas úteis.

Enquanto isso, você pode checar o case real da impugnação que devolveu R\$ 166 mil ao caixa.

); } window.Diagnostic = Diagnostic;