From cd201c7cd8db7e3300127876996d60687cccba60 Mon Sep 17 00:00:00 2001 From: Pheonix <150040105+ArshiBansal@users.noreply.github.com> Date: Thu, 28 May 2026 13:59:39 +0530 Subject: [PATCH] Update page.tsx --- src/app/contact/page.tsx | 182 ++++++++++++++++++++++++++++++--------- 1 file changed, 140 insertions(+), 42 deletions(-) diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index 13b04261..5fb57cb3 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -1,51 +1,149 @@ -import type { Metadata } from "next"; +"use client"; + import Link from "next/link"; -export const metadata: Metadata = { - title: "Contact — Reframe", - description: "Get in touch with the Reframe team.", -}; -export default function ContactPage() { +import { useState } from "react"; + +export default function ContactClient() { + const [formData, setFormData] = useState({ + name: "", + email: "", + github: "", + socials: "", + message: "", + }); + + const [errors, setErrors] = useState>({}); + const [success, setSuccess] = useState(""); + const [loading, setLoading] = useState(false); + + const validate = () => { + const newErrors: Record = {}; + + if (!formData.name.trim()) newErrors.name = "Name is required."; + + if (!formData.email.trim()) { + newErrors.email = "Email is required."; + } else if ( + !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(formData.email) + ) { + newErrors.email = "Invalid email address."; + } + + if (!formData.message.trim()) { + newErrors.message = "Message is required."; + } else if (formData.message.trim().length < 10) { + newErrors.message = "Message should be at least 10 characters."; + } + + setErrors(newErrors); + return Object.keys(newErrors).length === 0; + }; + + const handleChange = ( + e: React.ChangeEvent + ) => { + const { name, value } = e.target; + + setFormData((prev) => ({ + ...prev, + [name]: value, + })); + + if (errors[name]) { + setErrors((prev) => ({ ...prev, [name]: "" })); + } + }; + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + + setSuccess(""); + + if (!validate()) return; + + try { + setLoading(true); + + await new Promise((r) => setTimeout(r, 1200)); + + setSuccess("Your message has been sent successfully!"); + + setFormData({ + name: "", + email: "", + github: "", + socials: "", + message: "", + }); + } catch { + setErrors({ + submit: "Something went wrong. Please try again.", + }); + } finally { + setLoading(false); + } + }; + return ( -
-
- - ← Back to Reframe - -
-

Contact

- -

- Have a question, feedback, or found a bug? -

- -
-