'use client'; import { useForm } from 'react-hook-form'; import { Button } from '@/components/ui/button'; import InputField from '@/components/forms/InputField'; import FooterLink from '@/components/forms/FooterLink'; import { signInWithEmail, signUpWithEmail } from "@/lib/actions/auth.actions"; import { toast } from "sonner"; import { signInEmail } from "better-auth/api"; import { useRouter } from "next/navigation"; import OpenDevSocietyBranding from "@/components/OpenDevSocietyBranding"; import React from "react"; const SignIn = () => { const router = useRouter() const { register, handleSubmit, formState: { errors, isSubmitting }, } = useForm({ defaultValues: { email: '', password: '', }, mode: 'onBlur', }); const onSubmit = async (data: SignInFormData) => { try { const result = await signInWithEmail(data); if (result.success) { router.push('/'); return; } toast.error('Sign in failed', { description: result.error ?? 'Invalid email or password.', }); } catch (e) { console.error(e); toast.error('Sign in failed', { description: e instanceof Error ? e.message : 'Failed to sign in.' }) } } return ( <>

Welcome back

); }; export default SignIn;