'use client';
import { useActionState } from 'react';
import { useFormStatus } from 'react-dom';
import { authenticate } from '@/app/actions/auth';
import Link from 'next/link';
import { Mail, Lock, ArrowRight, Sparkles } from 'lucide-react';
import { useLanguage } from '@/lib/i18n';
import { GoogleSignInButton } from '@/components/google-sign-in-button';
function AuthDivider({ label }: { label: string }) {
return (
);
}
function LoginButton() {
const { pending } = useFormStatus();
const { t } = useLanguage();
return (
);
}
export function LoginForm({
allowRegister = true,
googleAuthEnabled = false,
authError,
}: {
allowRegister?: boolean;
googleAuthEnabled?: boolean;
authError?: string;
}) {
const [errorMessage, dispatch] = useActionState(authenticate, undefined);
const { t } = useLanguage();
const oauthError =
authError === 'SessionRequired'
? t('auth.sessionExpired')
: authError === 'OAuthAccountNotLinked'
? t('auth.oauthAccountNotLinked')
: authError ?? null;
return (
{t('auth.welcomeBack')}
{t('auth.welcomeBackSubtitle')}
{oauthError && (
{oauthError}
)}
{googleAuthEnabled && (
<>
>
)}
{allowRegister && (
{t('auth.noAccount')}{' '}
{t('auth.signUp')}
)}
);
}