/* global React, ReactDOM, TweaksPanel, TweakSection, TweakColor, TweakRadio, TweakText, TweakToggle, useTweaks */ const { useRef, useEffect } = React; const DATA = { phone1: "+91 97404 22863", phone2: "+91 99801 11468", email: "vtechbuildingsystems@gmail.com", }; const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{ "brandColor": "#0e4b8c", "accentColor": "#e85a1a", "heroVariant": "Quote", "headline": "Premium *uPVC Windows* & Doors **for Indian homes that last**", "formHeadline": "Book Free Site Consultation", "formSub": "Our expert will visit, measure & quote — all free.", "offerLine": "✨ Limited: ₹0 site visit + Free design preview", "ctaLabel": "Submit Details", "showFinishes": true, "showGallery": true, "showClients": true, "showReviews": true }/*EDITMODE-END*/; function App() { const [t, setTweak] = useTweaks(TWEAK_DEFAULTS); const leadFormRef = useRef(null); // Apply color tweaks live as CSS variables useEffect(() => { const root = document.documentElement; root.style.setProperty('--brand', t.brandColor); root.style.setProperty('--brand-ink', shade(t.brandColor, -0.35)); root.style.setProperty('--brand-soft', shade(t.brandColor, 0.15)); root.style.setProperty('--accent', t.accentColor); root.style.setProperty('--accent-deep', shade(t.accentColor, -0.2)); root.style.setProperty('--accent-soft', tint(t.accentColor, 0.85)); }, [t.brandColor, t.accentColor]); const scrollToForm = () => leadFormRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' }); const variantCopy = { Quote: { headline: t.headline, formHeadline: t.formHeadline, formSub: t.formSub, offer: t.offerLine, cta: t.ctaLabel, }, Discount: { headline: "**Save up to ₹40,000** on Premium *uPVC Windows*", formHeadline: "Claim Your Monsoon Discount", formSub: "Limited-period offer for Bangalore homes. Book before stock runs out.", offer: "🎉 Up to 15% off + Free German hardware upgrade", cta: "Claim Discount", }, Visit: { headline: "*Free Site Visit* by India's **#1 uPVC Window Brand**", formHeadline: "Schedule Your Free Visit", formSub: "An expert visits at your convenience. No pushy sales — just honest advice.", offer: "📅 Same-day visit available • Mon to Sun", cta: "Book Free Visit", }, }; const copy = variantCopy[t.heroVariant] || variantCopy.Quote; const formProps = { headline: copy.formHeadline, sub: copy.formSub, offer: copy.offer, ctaLabel: copy.cta, onSubmit: (data) => { console.log("lead submitted", data); // Save details in sessionStorage for the personalized thank-you page try { sessionStorage.setItem("vtech_lead", JSON.stringify({ name: data.first, phone: data.phone })); } catch (_) {} const goThanks = () => { window.location.href = "thank-you.html"; }; // Submit lead securely via SMTP & CSV Catcher fetch("submit-lead.php", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(data), }) .then(res => res.json()) .then(res => { console.log("Lead captured:", res); goThanks(); }) .catch(err => { console.error("Error capturing lead:", err); goThanks(); // Fallback redirect anyway so the customer isn't stuck! }); }, }; return ( <>
{t.showFinishes && } {t.showGallery && } {t.showClients && } {t.showReviews && }
setTweak('brandColor', v)} /> setTweak('accentColor', v)} /> setTweak('heroVariant', v)} /> setTweak('headline', v)} /> setTweak('formHeadline', v)} /> setTweak('formSub', v)} /> setTweak('offerLine', v)} /> setTweak('ctaLabel', v)} /> setTweak('showFinishes', v)} /> setTweak('showGallery', v)} /> setTweak('showClients', v)} /> setTweak('showReviews', v)} /> ); } /* ---------- helpers ---------- */ function hexToRgb(h) { const m = h.replace('#','').match(/^([0-9a-f]{6})$/i); if (!m) return { r: 0, g: 0, b: 0 }; const n = parseInt(m[1], 16); return { r: (n>>16)&255, g: (n>>8)&255, b: n&255 }; } function rgbToHex({ r, g, b }) { const c = (v) => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2,'0'); return `#${c(r)}${c(g)}${c(b)}`; } function shade(hex, amount) { const { r, g, b } = hexToRgb(hex); if (amount < 0) { const k = 1 + amount; return rgbToHex({ r: r*k, g: g*k, b: b*k }); } return rgbToHex({ r: r + (255-r)*amount, g: g + (255-g)*amount, b: b + (255-b)*amount }); } function tint(hex, amount) { const { r, g, b } = hexToRgb(hex); return rgbToHex({ r: r + (255-r)*amount, g: g + (255-g)*amount, b: b + (255-b)*amount }); } window.App = App; ReactDOM.createRoot(document.getElementById('root')).render();