"use client"; import { useState } from "react"; import Link from "next/link"; import { useRouter, useSearchParams } from "next/navigation"; import { Loader2 } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { signIn } from "@/lib/auth/auth-client"; import { GoogleButton } from "./google-button"; export function SignInForm({ googleEnabled }: { googleEnabled: boolean }) { const router = useRouter(); const params = useSearchParams(); const redirectTo = params.get("redirect") || "/dashboard"; const [loading, setLoading] = useState(false); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setLoading(true); const form = new FormData(e.currentTarget); const { error } = await signIn.email({ email: String(form.get("email")), password: String(form.get("password")), }); if (error) { toast.error(error.message ?? "Invalid email or password"); setLoading(false); return; } router.push(redirectTo); router.refresh(); } return ( Welcome back Sign in to your PodcastYes account. {googleEnabled && ( <>
or
)}
Forgot?

Don't have an account?{" "} Sign up

); }