// ============================================ // Shared components: Header, Footer, FloatingWA, LeadModal, Reveal, Accordion // ============================================ const { useState, useEffect, useRef, useCallback } = React; const WA_NUMBER = "5511942107127"; const WA_MSG = encodeURIComponent( "Olá! Vim pelo site do Albuini Advogados e gostaria de fazer a análise gratuita do meu contrato." ); const WA_LINK = `https://wa.me/${WA_NUMBER}?text=${WA_MSG}`; // ---- Reveal on scroll ---- function Reveal({ children, delay = 0, as: As = "div", className = "", ...props }) { const ref = useRef(null); const [shown, setShown] = useState(false); useEffect(() => { if (!ref.current) return; const obs = new IntersectionObserver( (entries) => { entries.forEach((e) => { if (e.isIntersecting) { setShown(true); obs.disconnect(); } }); }, { threshold: 0.12, rootMargin: "0px 0px -60px 0px" } ); obs.observe(ref.current); return () => obs.disconnect(); }, []); const delayClass = delay ? `delay-${delay}` : ""; return ( {children} ); } // ---- Brand mark / logo ---- function BrandMark({ size = 38 }) { return ( Albuini Advogados ); } // ---- Header ---- function Header({ openModal }) { const [scrolled, setScrolled] = useState(false); useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 40); window.addEventListener("scroll", onScroll, { passive: true }); return () => window.removeEventListener("scroll", onScroll); }, []); return (
ALBUINI
Advogados
OAB/SP 504.166
); } // ---- Floating WhatsApp ---- function FloatingWA() { const [shown, setShown] = useState(false); useEffect(() => { const onScroll = () => setShown(window.scrollY > 600); window.addEventListener("scroll", onScroll, { passive: true }); return () => window.removeEventListener("scroll", onScroll); }, []); if (!shown) return null; return ( Falar no WhatsApp ); } // ---- Accordion (reusable for objections + FAQ) ---- function Accordion({ items, allowMultiple = false }) { const [open, setOpen] = useState(new Set()); const refs = useRef({}); const toggle = (i) => { setOpen((prev) => { const next = allowMultiple ? new Set(prev) : new Set(); if (prev.has(i)) next.delete(i); else next.add(i); return next; }); }; // markdown-lite for **bold** const renderText = (text) => { const parts = text.split(/(\*\*[^*]+\*\*)/g); return parts.map((p, idx) => { if (p.startsWith("**") && p.endsWith("**")) { return {p.slice(2, -2)}; } return {p}; }); }; return (
{items.map((item, i) => { const isOpen = open.has(i); return (
(refs.current[i] = el)}> {renderText(item.a)}
); })}
); } // ---- Lead Modal (multi-step form) ---- function LeadModal({ open, onClose }) { const [step, setStep] = useState(0); const [data, setData] = useState({ name: "", phone: "", debt: "", type: "", consent: false }); const [submitted, setSubmitted] = useState(false); useEffect(() => { if (open) { document.body.style.overflow = "hidden"; setStep(0); setSubmitted(false); } else { document.body.style.overflow = ""; } return () => { document.body.style.overflow = ""; }; }, [open]); useEffect(() => { const onKey = (e) => { if (e.key === "Escape" && open) onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [open, onClose]); const update = (k, v) => setData((d) => ({ ...d, [k]: v })); const canAdvance = () => { if (step === 0) return data.name.trim().length >= 2; if (step === 1) return !!data.type; if (step === 2) return data.debt.trim().length > 0; if (step === 3) return data.phone.replace(/\D/g, "").length >= 10 && data.consent; return true; }; const next = () => { if (step < 3) setStep(step + 1); else submit(); }; const back = () => { if (step > 0) setStep(step - 1); }; const submit = () => { // In production, would POST somewhere. Here just simulate success. setSubmitted(true); setTimeout(() => { const msg = encodeURIComponent( `Olá! Sou ${data.name}. Vim pelo site do Albuini Advogados e gostaria de fazer a análise gratuita do meu contrato.\n\n` + `Tipo: ${data.type}\nValor aproximado da dívida: R$ ${data.debt}\nTelefone: ${data.phone}` ); window.open(`https://wa.me/${WA_NUMBER}?text=${msg}`, "_blank"); }, 900); }; const formatBRL = (v) => { const clean = v.replace(/\D/g, ""); if (!clean) return ""; return Number(clean).toLocaleString("pt-BR"); }; const formatPhone = (v) => { const c = v.replace(/\D/g, "").slice(0, 11); if (c.length <= 2) return c; if (c.length <= 7) return `(${c.slice(0, 2)}) ${c.slice(2)}`; if (c.length <= 10) return `(${c.slice(0, 2)}) ${c.slice(2, 6)}-${c.slice(6)}`; return `(${c.slice(0, 2)}) ${c.slice(2, 7)}-${c.slice(7)}`; }; return (
e.target === e.currentTarget && onClose()} >
{submitted ? (
Pronto, {data.name.split(" ")[0]}.

Te redirecionamos pro WhatsApp em instantes pra você concluir o envio dos documentos. Resposta da análise em até 5 dias úteis, sem compromisso.

OAB/SP 504.166

) : ( <>
{[0, 1, 2, 3].map((i) => (
))}
Etapa {step + 1} de 4
{step === 0 && ( <>

Como podemos te chamar?

Análise gratuita do contrato em até 5 dias úteis. Sem compromisso.

update("name", e.target.value)} placeholder="Seu nome" />
)} {step === 1 && ( <>

Qual é o tipo de dívida, {data.name.split(" ")[0]}?

Atuamos especificamente em direito bancário. Selecione abaixo:

{window.CONTRACT_TYPES.map((t) => ( ))}
)} {step === 2 && ( <>

Valor aproximado da dívida?

Estimativa do saldo devedor atual. Usado só pra estimar o caso — você confirma na análise.

R$ update("debt", e.target.value.replace(/\D/g, ""))} placeholder="0" style={{ fontSize: 28, fontFamily: "var(--serif)", border: "none", paddingBottom: 4, color: "var(--ink)", background: "transparent", outline: "none", flex: 1 }} />
)} {step === 3 && ( <>

Pra onde devolvemos com o diagnóstico?

Vamos te chamar no WhatsApp pra receber os documentos e confirmar o caso.

update("phone", e.target.value.replace(/\D/g, ""))} placeholder="(11) 99999-9999" />
)}
{step > 0 ? ( ) : ( )}
)}
); } // ---- Footer ---- function Footer() { return ( ); } Object.assign(window, { Reveal, BrandMark, Header, FloatingWA, Accordion, LeadModal, Footer, WA_LINK, WA_NUMBER });