- pricing: pilot-stage banner (pilot_label/pilot_text) on home + founders; price-range checklist on the founders page — selections fire consent-gated Umami events (price-range-*) via the new data-umami-event listener and ride the Zoho payload as price_range - forms: Zoho needs only name + email — founders form drops first/last split, stage, sector, country, heard; hubs form drops country/programme select (country deduced downstream from locale, which already rides the payload) - journey: moved to its own /journey/ page (six phases), nav entry added - home: reduced to hero + pilot banner + two audience cards linking to the value-proposition pages; verbose blocks rewritten - nav bug fix: the nav was built from the CURRENT page's alternates, so every page rendered a one-entry nav; now built from all pages of the locale - CMS: config.yml + custom preview gain the pilot banner, price checklist and card-link fields
165 lines
6.8 KiB
Plaintext
165 lines
6.8 KiB
Plaintext
---
|
|
// The lead form used by both audience pages. Labels come from the shared
|
|
// per-locale strings; on submit a small fetch POSTs the payload to the
|
|
// page's Zoho Flow webhook (token-in-URL authentication, no server code).
|
|
// Deliberately minimal — the CRM only needs a name and an email; country
|
|
// is deduced downstream from the submitted locale or the IP address.
|
|
// The hubs variant carries a hidden "capabilities" field (set by the
|
|
// capability checklist) and the founders variant a hidden "price_range"
|
|
// field (set by the pricing checklist) — leads arrive in the CRM already
|
|
// tagged with what interested them.
|
|
const { type: pageId, locale, strings, site } = Astro.props;
|
|
// pageId arrives as the route id ("for-founders"/"for-innovation-hubs")
|
|
// — normalise to the form kind:
|
|
const type = pageId === "for-founders" ? "founders" : "hubs";
|
|
|
|
const fields =
|
|
type === "founders"
|
|
? [
|
|
{ name: "name", label: strings.field_name, input: "text", required: true },
|
|
{ name: "email", label: strings.field_email, input: "email", required: true },
|
|
]
|
|
: [
|
|
{ name: "organisation", label: strings.field_organisation, input: "text", required: true },
|
|
{ name: "name", label: strings.field_name, input: "text", required: true },
|
|
{ name: "email", label: strings.field_email, input: "email", required: true },
|
|
{ name: "message", label: strings.field_message, input: "textarea" },
|
|
];
|
|
|
|
const webhook =
|
|
type === "founders" ? site.zoho_webhook_founders : site.zoho_webhook_hubs;
|
|
const title = type === "founders" ? strings.form_founders_title : strings.form_hubs_title;
|
|
const note = type === "founders" ? strings.form_founders_note : strings.form_hubs_note;
|
|
---
|
|
<section class="lead-wrap">
|
|
<form
|
|
id="lead-form"
|
|
class="lead"
|
|
data-webhook={webhook}
|
|
data-sending-label={strings.form_sending}
|
|
data-locale={locale}
|
|
data-type={type}
|
|
data-i18n-success={strings.form_success}
|
|
data-i18n-error={strings.form_error}
|
|
data-contact-email={site.contact_email}
|
|
>
|
|
<h2 id="lead-form">{title}</h2>
|
|
<p class="lead-note">{note}</p>
|
|
<p class="cap-selection" id="cap-selection" hidden></p>
|
|
<p class="cap-selection" id="price-selection" hidden></p>
|
|
{fields.map((f) => (
|
|
<label>
|
|
{f.label}{f.required ? " *" : ""}
|
|
{f.input === "select" ? (
|
|
<select name={f.name} required={f.required ?? false}>
|
|
{f.options.map(([value, label]) => (
|
|
<option value={value}>{label}</option>
|
|
))}
|
|
</select>
|
|
) : f.input === "textarea" ? (
|
|
<textarea name={f.name} required={f.required ?? false}></textarea>
|
|
) : (
|
|
<input type={f.input} name={f.name} required={f.required ?? false} />
|
|
)}
|
|
</label>
|
|
))}
|
|
<input
|
|
class="hp"
|
|
type="text"
|
|
name="website"
|
|
tabindex="-1"
|
|
autocomplete="off"
|
|
aria-hidden="true"
|
|
/>
|
|
<input type="hidden" name="capabilities" value="" />
|
|
<input type="hidden" name="price_range" value="" />
|
|
<input type="hidden" name="locale" value={locale} />
|
|
<input type="hidden" name="source" value={type} />
|
|
<label class="consent">
|
|
<input type="checkbox" name="consent" required />
|
|
<span>{strings.form_consent}</span>
|
|
</label>
|
|
<button class="button" type="submit">{strings.form_send}</button>
|
|
</form>
|
|
<script is:inline>
|
|
(() => {
|
|
const form = document.getElementById("lead-form");
|
|
if (!form || form.dataset.bound) return;
|
|
form.dataset.bound = "1";
|
|
|
|
const STRINGS = {
|
|
sending: form.dataset.sendingLabel,
|
|
};
|
|
|
|
// CHECKLISTS above the form (capabilities on the hubs page, price
|
|
// ranges on the founders page): collect the checked boxes at submit
|
|
// time so each selection rides the payload — both as machine keys
|
|
// and as a human-readable line in the message. One echo element per
|
|
// checklist mirrors the live selection back to the visitor.
|
|
const collect = (attrName, containerId) => {
|
|
const field = form.querySelector(`input[name="${attrName === "data-cap" ? "capabilities" : "price_range"}"]`);
|
|
const echo = document.getElementById(containerId);
|
|
const refresh = () => {
|
|
const checked = [...document.querySelectorAll(`[${attrName}]:checked`)];
|
|
if (echo) {
|
|
echo.textContent = checked.map((c) => c.dataset.capLabel || c.dataset.priceLabel || c.dataset.cap || c.dataset.price).join(", ");
|
|
echo.hidden = !checked.length;
|
|
}
|
|
};
|
|
document.querySelectorAll(`[${attrName}]`).forEach((el) => {
|
|
el.addEventListener("change", () => {
|
|
if (field) field.value = checkedKeys(attrName).join(",");
|
|
refresh();
|
|
});
|
|
});
|
|
refresh();
|
|
return { field, refresh };
|
|
};
|
|
const checkedKeys = (attrName) =>
|
|
[...document.querySelectorAll(`[${attrName}]:checked`)].map((c) =>
|
|
attrName === "data-cap" ? c.dataset.cap : c.dataset.price
|
|
);
|
|
const caps = collect("data-cap", "cap-selection");
|
|
const prices = collect("data-price", "price-selection");
|
|
|
|
form.addEventListener("submit", async (event) => {
|
|
event.preventDefault();
|
|
const button = form.querySelector('button[type="submit"]');
|
|
const data = new FormData(form);
|
|
const payload = {};
|
|
data.forEach((v, k) => { payload[k] = v; });
|
|
// consent as a JSON boolean (the Flow/CRM mapping expects true/false,
|
|
// not the checkbox's literal "on"; an unchecked box never arrives)
|
|
payload.consent = data.get("consent") === "on";
|
|
if (payload.website) return; // honeypot: pretend success, send nothing
|
|
if (caps.field) payload.capabilities = caps.field.value;
|
|
if (prices.field) payload.price_range = prices.field.value;
|
|
button.disabled = true;
|
|
button.textContent = STRINGS.sending || "Sending…";
|
|
try {
|
|
const res = await fetch(form.dataset.webhook, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(payload),
|
|
});
|
|
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
form.innerHTML =
|
|
'<p class="lead-ok"></p>';
|
|
form.querySelector(".lead-ok").textContent = form.dataset.i18nSuccess;
|
|
} catch {
|
|
const p = document.createElement("p");
|
|
p.className = "lead-err";
|
|
p.textContent = form.dataset.i18nError + " ";
|
|
const a = document.createElement("a");
|
|
a.href = `mailto:${form.dataset.contactEmail}?subject=Validation%20Lab`;
|
|
a.textContent = form.dataset.contactEmail;
|
|
p.appendChild(a);
|
|
form.innerHTML = "";
|
|
form.appendChild(p);
|
|
button.disabled = false;
|
|
}
|
|
});
|
|
})();
|
|
</script>
|
|
</section>
|