'use client' import {signIn} from 'next-auth/react' import {useRouter} from 'next/navigation' import {useState} from 'react' import AuthForm from '@/components/auth-form/index.js' import AuthAlert from '@/components/auth-form/auth-alert.js' export default function LoginForm() { const router = useRouter() const [error, setError] = useState('') const [isOpen, setIsOpen] = useState(false) const handleFormSubmit = async data => { const response = await signIn('credentials', { email: data.email, password: data.password, redirect: false }) if (response?.error) { setError(response.error) setIsOpen(true) } else { router.push('/') router.refresh() } } return ( <> {error && } ) }