import { Form, Link, redirect, useNavigate } from "react-router"; import { useState } from "react"; import { auth } from "../../lib/auth"; import { authClient } from "~/lib/auth-client"; import { Input } from "~/components/ui/input"; import { Button } from "~/components/ui/button"; export default function Signup() { const navigate = useNavigate(); const [error, setError] = useState(null); const [pending, setPending] = useState(false); async function onSubmit(event: React.FormEvent) { event.preventDefault(); setError(null); setPending(true); const formData = new FormData(event.currentTarget); const { error } = await authClient.signUp.email({ name: String(formData.get("name")), email: String(formData.get("email")), password: String(formData.get("password")), }); setPending(false); if (error) { setError(error.message ?? "Could not create account."); return; } navigate("/"); } return (
Sign up Create your Coppie account.
{error ?

{error}

: null}

Already have an account?{" "} Log in

); }