diff --git a/site/src/pages/tools/fcc-compliance-check.astro b/site/src/pages/tools/fcc-compliance-check.astro index 6b01b35..74bac72 100644 --- a/site/src/pages/tools/fcc-compliance-check.astro +++ b/site/src/pages/tools/fcc-compliance-check.astro @@ -119,7 +119,21 @@ import Base from "../../layouts/Base.astro"; @@ -242,6 +256,77 @@ import Base from "../../layouts/Base.astro"; } } + // --- Quote request form --- + document.getElementById("btn-request-quote")?.addEventListener("click", () => { + document.getElementById("quote-form")?.classList.remove("hidden"); + }); + + document.getElementById("btn-submit-quote")?.addEventListener("click", async () => { + const name = (document.getElementById("quote-name") as HTMLInputElement).value.trim(); + const email = (document.getElementById("quote-email") as HTMLInputElement).value.trim(); + const statusEl = document.getElementById("quote-status")!; + const btn = document.getElementById("btn-submit-quote") as HTMLButtonElement; + + if (!email || !email.includes("@")) { + statusEl.textContent = "Please enter a valid email address."; + statusEl.className = "mt-2 text-xs text-red-600"; + statusEl.classList.remove("hidden"); + return; + } + + btn.disabled = true; + btn.textContent = "Submitting..."; + + // Build message from compliance check data + const entityName = document.getElementById("entity-name")?.textContent || ""; + const frn = document.getElementById("entity-frn")?.textContent || ""; + const redChecks = (lastData?.checks || []) + .filter((c: any) => c.status === "red") + .map((c: any) => `• ${c.label}: ${c.detail}`) + .join("\n"); + + const message = [ + `Compliance assessment request from FCC Compliance Check tool.`, + ``, + `Entity: ${entityName}`, + `FRN: ${frn}`, + ``, + `Overdue items:`, + redChecks || "(none)", + ``, + `Contact: ${name} <${email}>`, + ].join("\n"); + + try { + const res = await fetch(`${API}/api/v1/tickets`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + category: "quote", + subject: `FCC Compliance Assessment — ${entityName || frn}`, + message, + email, + name: name || undefined, + page: window.location.href, + }), + }); + + if (res.ok) { + statusEl.textContent = "✓ Request submitted! We'll email you within 1 business day."; + statusEl.className = "mt-2 text-xs text-green-700"; + btn.textContent = "Sent ✓"; + } else { + throw new Error("Failed"); + } + } catch { + statusEl.textContent = "Something went wrong. Email info@performancewest.net instead."; + statusEl.className = "mt-2 text-xs text-red-600"; + btn.textContent = "Request Assessment"; + btn.disabled = false; + } + statusEl.classList.remove("hidden"); + }); + // --- FRN compliance check --- frnCheckBtn.addEventListener("click", runCheck); frnInput.addEventListener("keydown", (e) => { if (e.key === "Enter") runCheck(); });