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 */} +