'use client' import { useState } from 'react' import Link from 'next/link' import { useRouter } from 'next/navigation' import { Mail, Lock, Loader2, Sparkles, AlertCircle } from 'lucide-react' import { useAuth } from '@/context/AuthContext' import { cn } from '@/lib/utils' export default function LoginPage() { const router = useRouter() const { login, isAuthenticated } = useAuth() const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const [loading, setLoading] = useState(false) // Redirect if already authenticated if (isAuthenticated) { router.push('/') return null } const validateForm = (): string | null => { if (!email.trim()) { return 'Введіть email адресу' } // Basic email validation const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/ if (!emailRegex.test(email)) { return 'Введіть коректну email адресу' } if (!password) { return 'Введіть пароль' } if (password.length < 8) { return 'Пароль повинен містити мінімум 8 символів' } return null } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError('') // Client-side validation const validationError = validateForm() if (validationError) { setError(validationError) return } setLoading(true) try { await login(email, password) router.push('/') } catch (err) { setError(err instanceof Error ? err.message : 'Помилка входу. Перевірте дані та спробуйте ще раз.') } finally { setLoading(false) } } return (
{/* Logo */}
DAARION

Вхід в акаунт

Увійдіть, щоб продовжити у DAARION.city

{/* Form */}
{/* Error */} {error && (
{error}
)} {/* Email */}
setEmail(e.target.value)} placeholder="your@email.com" autoComplete="email" className={cn( 'w-full pl-10 pr-4 py-3 bg-slate-800/50 border border-white/10 rounded-xl', 'text-white placeholder-slate-500', 'focus:outline-none focus:border-cyan-500/50 focus:ring-1 focus:ring-cyan-500/20', 'transition-all' )} />
{/* Password */}
setPassword(e.target.value)} placeholder="••••••••" autoComplete="current-password" className={cn( 'w-full pl-10 pr-4 py-3 bg-slate-800/50 border border-white/10 rounded-xl', 'text-white placeholder-slate-500', 'focus:outline-none focus:border-cyan-500/50 focus:ring-1 focus:ring-cyan-500/20', 'transition-all' )} />
{/* Submit */}
{/* Divider */}
або
{/* Register link */}

Немає акаунту?{' '} Зареєструватися

{/* Back to home */}

← Повернутися на головну

) }