// site-contact.jsx — Contact page with live PHP backend + newsletter.
// ── Configuration ─────────────────────────────────────────
// Path to contact.php on your server. Change if you host it elsewhere.
const CONTACT_PHP = 'contact.php';
// Expose accent colour for PHP emails
try { const d = window.loadFestivalData?.(); if (d?.festival?.accentColor) window.__festivalAccent = d.festival.accentColor; if (d?.festival?.logoImage) window.__festivalLogoImage = d.festival.logoImage; } catch(e) {}
function Contact() {
const d = useSite();
const pg = d.festival?.pages?.contact || {};
const sidebarRows = pg.sidebarRows || [
{ id: "f", label: "Festival", value: "LJMU MA Short Film Festival" },
{ id: "ed", label: "Edition", value: "Sixth — March 2026" },
{ id: "h", label: "Host", value: "Liverpool John Moores University" },
{ id: "l", label: "Location", value: "Liverpool, UK" },
{ id: "em", label: "Email", value: "ljmumasff@gmail.com" },
];
const social = pg.social || [
{ id: "ig", name: "Instagram", url: "https://www.instagram.com/ljmumasff/" },
{ id: "fb", name: "Facebook", url: "https://www.facebook.com/LJMUMASFF" },
{ id: "tt", name: "TikTok", url: "https://www.tiktok.com/@ljmumasff" },
{ id: "yt", name: "YouTube", url: "https://www.youtube.com/@ljmumashortfilmfestival6785" },
];
// ── Contact form state ──────────────────────────────────
const [form, setForm] = React.useState({ name: "", email: "", website: "", subject: "General enquiry", message: "" });
const [status, setStatus] = React.useState("idle"); // idle | sending | sent | error
const [errors, setErrors] = React.useState({});
const [serverErr, setServerErr] = React.useState("");
const set = (k, v) => setForm(f => ({ ...f, [k]: v }));
const validateForm = () => {
const errs = {};
if (!form.name.trim()) errs.name = true;
if (!form.email.trim() || !/^\S+@\S+\.\S+$/.test(form.email)) errs.email = true;
if (!form.message.trim()) errs.message = true;
setErrors(errs);
return !Object.keys(errs).length;
};
const submitContact = async (e) => {
e.preventDefault();
if (!validateForm()) return;
setStatus("sending");
setServerErr("");
try {
const body = new FormData();
body.append("action", "contact");
body.append("accent_color", (window.__festivalAccent || "#cb5640"));
body.append("logo_image", (window.__festivalLogoImage || ""));
body.append("name", form.name);
body.append("email", form.email);
body.append("website", form.website);
body.append("subject", form.subject);
body.append("message", form.message);
body.append("_hp", ""); // honeypot — must stay empty
const res = await fetch(CONTACT_PHP, { method: "POST", body });
const data = await res.json();
if (data.success) {
setStatus("sent");
window.scrollTo({ top: 0, behavior: "smooth" });
} else {
setServerErr(data.error || "Something went wrong. Please try again.");
setStatus("idle");
}
} catch {
setServerErr("Could not reach the server. Please check your connection and try again.");
setStatus("idle");
}
};
const errStyle = (k) => errors[k]
? { borderColor: "var(--coral)", boxShadow: "0 0 0 3px rgba(203,86,64,0.15)" }
: {};
// ── Success screen ──────────────────────────────────────
if (status === "sent") {
return (
Thank you, {form.name}. We'll be in touch at{" "}
{form.email} soon.
A confirmation has been sent to your inbox.
Message sent.
{pg.heroTitle || "Get in touch."}
Check your inbox for a confirmation email.
Programme announcements, Q&A sessions, award news — straight to your inbox.