'use client'
import { useState, Suspense } from 'react'
import { useRouter, useSearchParams } from 'next/navigation'
import { useTranslations, useLocale } from 'next-intl'
import {
Container,
Paper,
Box,
Typography,
Tabs,
Tab,
Link,
Card,
CardContent,
Divider,
CircularProgress
} from '@mui/material'
import {
MenuBook,
Login as LoginIcon,
PersonAdd
} from '@mui/icons-material'
import { LoginForm } from '@/components/auth/login-form'
import { RegisterForm } from '@/components/auth/register-form'
function AuthContent() {
const [activeTab, setActiveTab] = useState(0)
const router = useRouter()
const locale = useLocale()
const searchParams = useSearchParams()
const t = useTranslations('auth')
const handleAuthSuccess = () => {
const redirect = searchParams.get('redirect')
if (redirect) {
router.push(redirect)
} else {
router.push(`/${locale}`)
}
}
const handleTabChange = (event: React.SyntheticEvent, newValue: number) => {
setActiveTab(newValue)
}
const getSubtitle = () => {
if (locale === 'en') {
return activeTab === 0
? 'Sign in to continue exploring Scripture'
: 'Create an account to begin your spiritual journey'
}
return activeTab === 0
? 'Conectează-te pentru a continua explorarea Scripturii'
: 'Creează un cont pentru a începe călătoria ta spirituală'
}
return (
{/* Header */}
{activeTab === 0 ? t('welcomeBack') : t('joinUs')}
{getSubtitle()}
{/* Tabs */}
}
iconPosition="start"
label={t('login')}
/>
}
iconPosition="start"
label={t('register')}
/>
{/* Forms */}
{activeTab === 0 ? (
) : (
)}
{/* Switch Form Link */}
{activeTab === 0 ? t('noAccount') : t('alreadyHaveAccount')}{' '}
setActiveTab(activeTab === 0 ? 1 : 0)}
sx={{
textDecoration: 'none',
fontWeight: 600,
'&:hover': {
textDecoration: 'underline'
}
}}
>
{activeTab === 0 ? t('createAccount') : t('login')}
)
}
export default function AuthPage() {
return (
}>
)
}