/* global React, Icon */ // Form submits to a Google Apps Script Web App that appends a row // to the Dynawins leads Google Sheet. // // Setup: see google-apps-script.gs in this folder for the full guide. // Paste your deployed Web App URL into window.__DYNAWINS_FLOW_URL in index.html. const FLOW_URL = window.__DYNAWINS_FLOW_URL || ''; // empty = simulate locally const ContactPage = () => { const [form, setForm] = React.useState({ name: '', email: '', phone: '', product: 'Smart Panel AI', description: '' }); const [status, setStatus] = React.useState('idle'); // idle | sending | sent | error const [errMsg, setErrMsg] = React.useState(''); const upd = (k) => (e) => setForm({ ...form, [k]: e.target.value }); const submit = async (e) => { e.preventDefault(); setStatus('sending'); setErrMsg(''); const payload = { "Name": form.name, "Email": form.email, "Phone": form.phone, "Interested Product": form.product, "Description": form.description, // bonus: timestamp for the flow to write to a hidden col if you add one "SubmittedAt": new Date().toISOString(), }; try { if (!FLOW_URL) { // No URL configured — simulate so prototype still demos. await new Promise((r) => setTimeout(r, 800)); console.log('[Dynawins] Form payload (would POST to Google Sheets):', payload); setStatus('sent'); return; } // Apps Script Web Apps return a 302 redirect that browsers can't follow // with a POST + JSON body in CORS mode. Use no-cors: the request fires // and Google appends the row, but we get an opaque response. await fetch(FLOW_URL, { method: 'POST', mode: 'no-cors', headers: { 'Content-Type': 'text/plain;charset=utf-8' }, body: JSON.stringify(payload), }); console.log('[Dynawins] POST sent to Sheet (opaque response)'); setStatus('sent'); } catch (err) { setStatus('error'); setErrMsg(err.message || 'Something went wrong. Please email us instead.'); } }; return (
Tell us about your D365 setup and what you're trying to fix. We'll reply with a tailored demo and a sandbox link within one business day.
Two minutes of typing. One business day to a sandbox link.
Your details are now a row in our leads workbook. We'll reply within one business day.