"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; import { signIn } from "@/lib/auth-client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { toast } from "sonner"; import { Loader2 } from "lucide-react"; export default function LoginPage() { const router = useRouter(); const [loading, setLoading] = useState(false); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setLoading(true); try { const { error } = await signIn.email({ email, password, }); if (error) { toast.error(error.message || "Failed to sign in"); return; } toast.success("Welcome back!"); router.push("/"); router.refresh(); } catch { toast.error("Something went wrong"); } finally { setLoading(false); } } return (
New to gitbruv?{" "} Create an account