/* Shared UI primitives + Nav + Footer + Modal + WhatsApp FAB */
const { useState, useEffect, useRef, useMemo, Fragment } = React;
/* ============================================================
NAV
============================================================ */
function Nav({ page, navigate, light, openEnquire, lang, setLang }) {
const [scrolled, setScrolled] = useState(false);
useEffect(() => {
const onScroll = () => setScrolled(window.scrollY > 30);
onScroll();
window.addEventListener("scroll", onScroll);
return () => window.removeEventListener("scroll", onScroll);
}, []);
const items = [
{ id: "collection", label: "Collection" },
{ id: "wanted", label: "Wanted" },
{ id: "services", label: "Services" },
{ id: "about", label: "About" },
{ id: "faqs", label: "FAQs" },
{ id: "media", label: "Media" },
{ id: "contact", label: "Contact" },
];
return (
);
}
/* ============================================================
FOOTER
============================================================ */
function Footer({ navigate, openEnquire }) {
return (
);
}
/* ============================================================
ENQUIRE MODAL (kind: 'general' | 'vehicle' | 'viewing' | 'valuation' | 'storage' | 'sell')
============================================================ */
function EnquireModal({ kind, vehicle, onClose, onSubmit, whatsappOn, defaultTab }) {
const tabs = useMemo(() => [
{ id: "enquire", label: "Enquire" },
{ id: "details", label: "Request Details" },
{ id: "viewing", label: "Book Viewing" },
], []);
const [tab, setTab] = useState(defaultTab || (kind === "viewing" ? "viewing" : "enquire"));
const [sent, setSent] = useState(false);
const title = useMemo(() => {
if (kind === "vehicle") return `Enquire — ${vehicle.year} ${vehicle.make} ${vehicle.model}`;
if (kind === "valuation") return "Request a Valuation";
if (kind === "storage") return "Storage Enquiry";
if (kind === "sell") return "Sell Us Your Car";
if (kind === "viewing") return "Book a Viewing";
return "Enquire";
}, [kind, vehicle]);
const deck = useMemo(() => {
if (kind === "vehicle") return "We'll come back to you personally — usually within one business day.";
if (kind === "sell") return "Tell us about your car. If it fits our profile of post-war collectible sportscars, we'll be in touch.";
if (kind === "storage") return "White-glove, climate-controlled, monthly. Minimum one month — twenty-four-hour access by prior arrangement.";
return "A direct line to our Classics team. We answer in person, not by template.";
}, [kind]);
function submit(e) {
e.preventDefault();
setSent(true);
onSubmit && onSubmit({ kind, tab, vehicle });
}
return (
e.stopPropagation()}>
{!sent ? (
{title}
{deck}
{kind === "vehicle" && (
{tabs.map(t => (
))}
)}
) : (
✓
Thank you.
Your enquiry has reached our Classics team. Expect a personal reply, usually within one business day.
)}
);
}
/* ============================================================
WHATSAPP FAB (only when toggled on)
============================================================ */
function WhatsAppFab({ enabled, onClick }) {
if (!enabled) return null;
return (
);
}
/* ============================================================
VEHICLE CARD
============================================================ */
function VehicleCard({ v, navigate }) {
const statusLabel = {
available: "Available",
sold: "Sold",
reserved: "Reserved",
}[v.status] || "";
return (
navigate("vehicle", v.id)}>

{statusLabel &&
{statusLabel}}
{v.year}
{v.make} {v.model}
{v.price === "Sold" ? "Sold" : "POA"}
{v.bodyType}
{v.transmission.split(" ")[0]}
{v.colorExt}
);
}
/* ============================================================
PRESS STRIP
============================================================ */
function PressStrip() {
return (
The National
Petrolicious
Gulf News
Automobili Ardent
Friday
);
}
Object.assign(window, { Nav, Footer, EnquireModal, WhatsAppFab, VehicleCard, PressStrip });