/* global React, ReactDOM, COPY */
const { useState, useEffect, useRef } = React;
const INNER_LINKS = {
es: [
{ href: "/", idx: "01", label: "Inicio" },
{ href: "/nosotros.html", idx: "02", label: "Nosotros" },
{ href: "/soluciones.html", idx: "03", label: "Soluciones" },
{ href: "/desarrollos.html", idx: "04", label: "Desarrollos" },
{ href: "/contacto.html", idx: "05", label: "Contacto" },
],
en: [
{ href: "/", idx: "01", label: "Home" },
{ href: "/nosotros.html", idx: "02", label: "About" },
{ href: "/soluciones.html", idx: "03", label: "Solutions" },
{ href: "/desarrollos.html", idx: "04", label: "Lab" },
{ href: "/contacto.html", idx: "05", label: "Contact" },
],
};
function ContactHero({ p }) {
return (
{p.tag}
{p.title1}
{p.title2}
);
}
function ContactLeft({ p }) {
return (
{p.intro}
{p.do.title}
{p.do.items.map((item, i) => - {item}
)}
{p.dont.title}
{p.dont.items.map((item, i) => - {item}
)}
{p.expect.title}
{p.expect.steps.map((s, i) => - {s}
)}
{p.contact.map((c, i) => (
))}
);
}
function ContactForm({ p }) {
const [status, setStatus] = useState(null);
const [msg, setMsg] = useState("");
const formRef = useRef(null);
function handleSubmit(e) {
e.preventDefault();
if (status === "sending") return;
setStatus("sending");
setMsg("");
fetch("send_email.php", { method: "POST", body: new FormData(formRef.current) })
.then(r => r.json())
.then(res => {
setMsg(res.message);
if (res.status === "success") {
setStatus("success");
formRef.current.reset();
} else {
setStatus("error");
}
})
.catch(() => {
setMsg("Error de conexión. Por favor intenta de nuevo.");
setStatus("error");
});
}
return (
{p.title}
{p.sub}
{msg &&
{msg}
}
);
}
function ContactApp() {
const [lang, setLang] = useState("es");
const [direction, setDirection] = useState("a");
useEffect(() => { document.documentElement.setAttribute("data-lang", lang); }, [lang]);
useEffect(() => { document.documentElement.setAttribute("data-direction", direction); }, [direction]);
useEffect(() => { if (typeof initChat === "function") initChat(); }, []);
useReveal();
const t = COPY[lang];
const p = t.contacto;
return (
<>