From 1caea88b0b9a7dcae30fd85a97b42e2c076fd7bc Mon Sep 17 00:00:00 2001 From: bender Date: Sun, 22 Mar 2026 13:54:30 +0000 Subject: [PATCH] Add src/app/register/page.tsx --- src/app/register/page.tsx | 281 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 src/app/register/page.tsx diff --git a/src/app/register/page.tsx b/src/app/register/page.tsx new file mode 100644 index 0000000..11535c1 --- /dev/null +++ b/src/app/register/page.tsx @@ -0,0 +1,281 @@ +"use client"; + +import { useState } from "react"; +import Link from "next/link"; +import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; +import NavbarStyleFullscreen from "@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen"; +import FooterSimple from "@/components/sections/footer/FooterSimple"; + +export default function RegisterPage() { + const [formData, setFormData] = useState({ + name: "", email: "", password: "", confirmPassword: ""}); + const [errors, setErrors] = useState>({}); + const [isSubmitting, setIsSubmitting] = useState(false); + const [successMessage, setSuccessMessage] = useState(""); + + const navItems = [ + { name: "Home", id: "home" }, + { name: "Features", id: "features" }, + { name: "AI Models", id: "models" }, + { name: "Pricing", id: "pricing" }, + { name: "About", id: "about" }, + { name: "Contact", id: "contact" }, + ]; + + const footerColumns = [ + { + title: "Product", items: [ + { label: "Features", href: "/#features" }, + { label: "Pricing", href: "/#pricing" }, + { label: "AI Models", href: "/#models" }, + { label: "Blog", href: "#" }, + ], + }, + { + title: "Company", items: [ + { label: "About Us", href: "/about" }, + { label: "Contact", href: "/#contact" }, + { label: "Careers", href: "#" }, + { label: "Press", href: "#" }, + ], + }, + { + title: "Resources", items: [ + { label: "Documentation", href: "#" }, + { label: "Community", href: "#" }, + { label: "Guides", href: "#" }, + { label: "Support", href: "#" }, + ], + }, + { + title: "Legal", items: [ + { label: "Privacy Policy", href: "#" }, + { label: "Terms of Service", href: "#" }, + { label: "Cookie Policy", href: "#" }, + { label: "Disclaimer", href: "#" }, + ], + }, + ]; + + const validateForm = () => { + const newErrors: Record = {}; + + if (!formData.name.trim()) { + newErrors.name = "Name is required"; + } + + if (!formData.email.trim()) { + newErrors.email = "Email is required"; + } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) { + newErrors.email = "Please enter a valid email"; + } + + if (!formData.password) { + newErrors.password = "Password is required"; + } else if (formData.password.length < 8) { + newErrors.password = "Password must be at least 8 characters"; + } + + if (formData.password !== formData.confirmPassword) { + newErrors.confirmPassword = "Passwords do not match"; + } + + setErrors(newErrors); + return Object.keys(newErrors).length === 0; + }; + + const handleInputChange = (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(); + setSuccessMessage(""); + + if (!validateForm()) { + return; + } + + setIsSubmitting(true); + + try { + const userData = { + name: formData.name, + email: formData.email, + password: formData.password, + createdAt: new Date().toISOString(), + preferences: { + theme: "light", notifications: true, + language: "en"}, + }; + + localStorage.setItem(`user_${formData.email}`, JSON.stringify(userData)); + localStorage.setItem("currentUser", JSON.stringify(userData)); + + setSuccessMessage("Account created successfully! Redirecting to login..."); + setFormData({ name: "", email: "", password: "", confirmPassword: "" }); + + setTimeout(() => { + window.location.href = "/login"; + }, 2000); + } catch (error) { + setErrors({ form: "An error occurred. Please try again." }); + } finally { + setIsSubmitting(false); + } + }; + + return ( + + + +
+
+
+

Create Account

+

+ Join Aarti AI and start your spiritual journey +

+ + {successMessage && ( +
+ {successMessage} +
+ )} + + {errors.form && ( +
+ {errors.form} +
+ )} + +
+
+ + + {errors.name && ( +

{errors.name}

+ )} +
+ +
+ + + {errors.email && ( +

{errors.email}

+ )} +
+ +
+ + + {errors.password && ( +

{errors.password}

+ )} +
+ +
+ + + {errors.confirmPassword && ( +

{errors.confirmPassword}

+ )} +
+ + +
+ +

+ Already have an account?{" "} + + Sign In + +

+
+
+
+ + +
+ ); +} \ No newline at end of file