diff --git a/src/app/signup/page.tsx b/src/app/signup/page.tsx new file mode 100644 index 0000000..fb30c0e --- /dev/null +++ b/src/app/signup/page.tsx @@ -0,0 +1,124 @@ +"use client"; + +import { useState } from "react"; +import { useAuth } from "@/hooks/useAuth"; +import { useRouter } from "next/navigation"; +import Input from "@/components/form/Input"; +import Link from "next/link"; +import { Loader } from "lucide-react"; + +export default function SignupPage() { + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); + const [error, setError] = useState(""); + const [loading, setLoading] = useState(false); + const { signup } = useAuth(); + const router = useRouter(); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setError(""); + + if (password !== confirmPassword) { + setError("Passwords do not match"); + return; + } + + if (password.length < 6) { + setError("Password must be at least 6 characters"); + return; + } + + setLoading(true); + + try { + await signup(email, password); + router.push("/"); + } catch (err: any) { + setError(err.message || "Signup failed. Please try again."); + } finally { + setLoading(false); + } + }; + + return ( +
+
+

Join MediaHub

+

Create your account and start sharing

+ + {error && ( +
+ {error} +
+ )} + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ +
+

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

+
+
+
+ ); +}