// 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 (
Responda 5 perguntas. Você vai entender onde está o problema e chega à conversa com nossa especialista com clareza sobre o que precisa resolver.
Gratuito.
Rápido.
Sem enrolação.
{[
'100% gratuito, sem compromisso',
'Suas informações são confidenciais',
'Retorno por WhatsApp com especialista',
'Atendimento em até 24 horas úteis',
].map((t, i) => (
{current.q}
Sua especialista retorna em até 24h úteis com o primeiro parecer.
Sem spam. Seus dados são usados apenas para o contato.
> ); } function SentState({ answers, name, onReset }) { return (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.