From 4104a76f3ef5c1ce73b609f7c665fd7506aab550 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Wed, 4 Dec 2024 23:36:49 -0500 Subject: [PATCH] built out contact form, added env variable might make button island so that i can change the button's text --- frontend/routes/contact/index.tsx | 40 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/frontend/routes/contact/index.tsx b/frontend/routes/contact/index.tsx index 0d65c78..9ecf25d 100644 --- a/frontend/routes/contact/index.tsx +++ b/frontend/routes/contact/index.tsx @@ -11,6 +11,7 @@ interface FormState { message?: string; }; submitted?: boolean; + failed?: boolean; } export const handler: Handlers = { @@ -51,11 +52,19 @@ export const handler: Handlers = { }); } - // TODO: Implement actual form submission logic here - // For example, send email, save to database, etc. - console.log("Form submitted:", state); + const res = await fetch(`${Deno.env.get("EMAIL_FORM")}`, { + method: "POST", + body: formData, + }); + console.log(res); + + if (!res.ok || res.status !== 200) { + return ctx.render({ + ...state, + failed: true, + }); + } - // Return successful submission return ctx.render({ ...state, submitted: true, @@ -66,16 +75,13 @@ export const handler: Handlers = { export default function Contact({ data }: PageProps) { return (
-
+
Contact -

Contact

- - {/* Check if form was successfully submitted */} {data?.submitted && (
) { Your message has been sent successfully!
)} - + {data?.failed && ( + + )}
- {/* Name Input */}
- - {/* Email Input */}
- - {/* Message Textarea */}
- - {/* Submit Button */} +