// Shared components: nav, footer, brand mark, seal SVG, common bits
const { useState, useEffect, useRef } = React;
// Reveal-on-scroll
function Reveal({ children, delay = 0, ...rest }) {
const ref = useRef(null);
const [seen, setSeen] = useState(false);
useEffect(() => {
if (!ref.current) return;
const io = new IntersectionObserver(
(entries) => {
entries.forEach((e) => {
if (e.isIntersecting) {
setTimeout(() => setSeen(true), delay);
io.disconnect();
}
});
},
{ threshold: 0.1, rootMargin: "0px 0px -60px 0px" }
);
io.observe(ref.current);
return () => io.disconnect();
}, [delay]);
return (
{children}
);
}
function BrandMark({ size = 44, className = "" }) {
return (
NM
);
}
function Brand({ onClick }) {
return (
{ e.preventDefault(); onClick && onClick(); }}>
Nasser Malalla
Advocates & Legal Consultants
);
}
function Seal() {
return (
);
}
// TOPBAR
function TopBar({ t }) {
return (
{CONTACT.address.split(",").slice(0, 2).join(",")}
);
}
// HEADER
function Header({ route, navigate, lang, setLang, t }) {
const [open, setOpen] = useState(false);
const langs = [
{ id: "en", label: "EN" },
{ id: "ar", label: "AR" },
{ id: "ru", label: "RU" },
];
const links = [
{ id: "home", label: t.nav.home },
{ id: "practice", label: t.nav.practice },
{ id: "firm", label: t.nav.firm },
{ id: "insights", label: t.nav.insights },
{ id: "contact", label: t.nav.contact },
];
const onNav = (id) => {
setOpen(false);
navigate(id);
};
return (
);
}
// FOOTER
function Footer({ t, navigate, setLang, lang }) {
return (
);
}
// CONSULTATION FORM — used both on Contact page and inline
function ConsultationForm({ defaultArea = "", t, compact = false }) {
const [data, setData] = useState({
name: "",
email: "",
phone: "",
area: defaultArea,
message: "",
});
const [errors, setErrors] = useState({});
const [sent, setSent] = useState(false);
const [submitting, setSubmitting] = useState(false);
const update = (k) => (e) => {
setData({ ...data, [k]: e.target.value });
if (errors[k]) setErrors({ ...errors, [k]: null });
};
const validate = () => {
const e = {};
if (!data.name.trim()) e.name = "Required";
if (!data.email.trim()) e.email = "Required";
else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email)) e.email = "Invalid email";
if (!data.message.trim()) e.message = "Tell us briefly what the matter concerns";
return e;
};
const submit = (e) => {
e.preventDefault();
const v = validate();
setErrors(v);
if (Object.keys(v).length) return;
setSubmitting(true);
setTimeout(() => {
setSubmitting(false);
setSent(true);
}, 900);
};
if (sent) {
return (
Your request is received.
A member of the firm will reply to {data.email} within two working days. For urgent matters, please call {CONTACT.phone}.
);
}
return (
);
}
Object.assign(window, { Reveal, Brand, BrandMark, Seal, Header, Footer, ConsultationForm });