// Trend Home — unit detail panel + contact form
// ─────────────────────────────────────────────────────────────────
// UNIT DETAIL — slide-up overlay with floorplan, gallery, summary, CTA
// ─────────────────────────────────────────────────────────────────
function UnitDetail({ unit, onClose, onRequestVisit }) {
const [tab, setTab] = React.useState('plani');
const [galleryIdx, setGalleryIdx] = React.useState(0);
const u = unit || TH_FEATURED_UNIT;
React.useEffect(() => {
if (!unit) return;
const onKey = (e) => { if (e.key === 'Escape') onClose(); };
window.addEventListener('keydown', onKey);
document.body.style.overflow = 'hidden';
return () => {
window.removeEventListener('keydown', onKey);
document.body.style.overflow = '';
};
}, [unit, onClose]);
if (!unit) return null;
return (
);
}
// ─────────────────────────────────────────────────────────────────
// CONTACT / VIEWING FORM
// ─────────────────────────────────────────────────────────────────
function ContactForm({ prefilledUnit }) {
const [form, setForm] = React.useState({
name: '', phone: '', email: '',
complex: prefilledUnit ? 'kristal' : '',
unitInterest: prefilledUnit?.id || '',
when: 'mengjes',
message: '',
});
const [sent, setSent] = React.useState(false);
const [step, setStep] = React.useState(1);
React.useEffect(() => {
if (prefilledUnit) {
setForm((f) => ({ ...f, complex: 'kristal', unitInterest: prefilledUnit.id }));
setStep(2);
}
}, [prefilledUnit]);
const upd = (k, v) => setForm((f) => ({ ...f, [k]: v }));
const valid1 = form.complex && form.unitInterest;
const valid2 = form.name.trim().length > 1 && (form.phone.length > 5 || form.email.includes('@'));
const submit = (e) => {
e.preventDefault();
if (!valid2) return;
setSent(true);
};
return (
Cakto një vizitë
Eja, shih banesën, pastaj vendos.
Ekipi ynë i shitjeve do të të takojë në vendndodhje brenda 48 orëve.
Pa zotim, pa presion. Vetëm kafe dhe pyetje.
);
}
Object.assign(window, { UnitDetail, ContactForm });