@@ -6,6 +6,7 @@ interface Props {
66 title: string ;
77 lead: string ;
88 turnstileSiteKey: string ;
9+ contactBackend: string ;
910}
1011const props = Astro .props ;
1112---
@@ -64,21 +65,18 @@ const props = Astro.props;
6465 src =" https://challenges.cloudflare.com/turnstile/v0/api.js"
6566 defer ></script >
6667
67- <script >
68+ <script define:vars = { { props } } is:inline >
6869 // Add event listener for form submission
6970 document.querySelector("form")?.addEventListener("submit", async (e) => {
7071 e.preventDefault();
71- const formData = new FormData(e.target! as HTMLFormElement );
72+ const formData = new FormData(e.target);
7273
7374 // Call the contact webhook
7475 try {
75- const response = await fetch(
76- "https://wediy-life-contact.deno.dev/contact",
77- {
78- method: "POST",
79- body: formData,
80- }
81- );
76+ const response = await fetch(props.contactBackend, {
77+ method: "POST",
78+ body: formData,
79+ });
8280
8381 if (!response.ok) {
8482 throw new Error("Network response was not ok");
@@ -94,9 +92,7 @@ const props = Astro.props;
9492 // Clear the form fields
9593 document
9694 .querySelectorAll("input,textarea")
97- .forEach(
98- (x) => ((x as HTMLInputElement | HTMLTextAreaElement).value = "")
99- );
95+ .forEach((x) => (x.value = ""));
10096 } catch (error) {
10197 console.error("Error sending message:", error);
10298 window
0 commit comments