import { useMutation } from "@tanstack/react-query" import { createFileRoute } from "@tanstack/react-router" import { GalleryVerticalEnd } from "lucide-react" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card" import { Field, FieldDescription, FieldGroup, FieldLabel, FieldSeparator, } from "@/components/ui/field" import { Input } from "@/components/ui/input" import { cn } from "@/lib/utils" import { type AuthErrorCode, authClient, BetterAuthError } from "../auth" export const Route = createFileRoute("/login")({ component: RouteComponent, }) function RouteComponent() { return (
Drexa
) } function LoginFormCard({ className, ...props }: React.ComponentProps<"div">) { return (
Welcome back Login with your Apple or Google account By clicking continue, you agree to our{" "} Terms of Service and{" "} Privacy Policy.
) } function LoginForm() { const { mutate: signIn, isPending, error: signInError, } = useMutation({ mutationFn: async ({ email, password, }: { email: string password: string }) => { const { data: signInData, error } = await authClient.signIn.email({ email, password, callbackURL: "/home", rememberMe: true, }) if (error) { throw new BetterAuthError(error.code as AuthErrorCode) } return signInData }, }) const handleSubmit = (event: React.FormEvent) => { event.preventDefault() const formData = new FormData(event.currentTarget) signIn({ email: formData.get("email") as string, password: formData.get("password") as string, }) } return (
Or continue with Email
Password Forgot your password?
Don't have an account? Sign up
) }