From 54235d8dfed8e99729ff68e01c7522036a7bfdcf Mon Sep 17 00:00:00 2001 From: jimsu Date: Sun, 22 Jun 2025 22:32:33 -0700 Subject: Add /auth/login and /auth/signup routes --- apps/web/src/app/auth/signup/page.tsx | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 apps/web/src/app/auth/signup/page.tsx (limited to 'apps/web/src/app/auth/signup/page.tsx') diff --git a/apps/web/src/app/auth/signup/page.tsx b/apps/web/src/app/auth/signup/page.tsx new file mode 100644 index 00000000..f328851c --- /dev/null +++ b/apps/web/src/app/auth/signup/page.tsx @@ -0,0 +1,108 @@ +"use client"; + +import { useSearchParams, useRouter } from "next/navigation"; +import { authClient } from "@/lib/auth-client"; +import { Button } from "@/components/ui/button"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { Suspense, useState } from "react"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import Link from "next/link"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; + +function SignUpForm() { + const searchParams = useSearchParams(); + const router = useRouter(); + const redirectUrl = searchParams.get("redirect"); + const [name, setName] = useState(""); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(null); + + const handleSignUp = async () => { + setError(null); + const { error } = await authClient.signUp.email({ + name, + email, + password, + }); + + if (error) { + setError(error.message || "An unexpected error occurred."); + return; + } + + router.push(redirectUrl || "/"); + }; + + return ( +
+ {error && ( + + Error + {error} + + )} +
+ + setName(e.target.value)} + /> +
+
+ + setEmail(e.target.value)} + /> +
+
+ + setPassword(e.target.value)} + /> +
+ +
+ ); +} + +export default function SignUpPage() { + return ( +
+ + + Sign Up + Create an account to get started. + + + Loading...
}> + + +
+ Already have an account?{" "} + + Login + +
+ + + + ); +} -- cgit v1.3.1