Files
clube67.com/frontend/app/login/page.tsx
T

87 lines
4.4 KiB
TypeScript

'use client';
import { useState } from 'react';
import Link from 'next/link';
import { motion } from 'framer-motion';
import { useAuth } from '@/lib/auth';
export default function LoginPage() {
const { login } = useAuth();
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setError('');
setLoading(true);
try {
await login(email, password);
} catch (err: any) {
setError(err.message || 'Erro ao fazer login');
} finally {
setLoading(false);
}
};
return (
<div className="min-h-screen flex items-center justify-center px-4 relative">
<div className="absolute top-20 left-10 w-72 h-72 bg-brand-600/20 rounded-full blur-[100px]" />
<div className="absolute bottom-20 right-10 w-96 h-96 bg-purple-600/15 rounded-full blur-[120px]" />
<motion.div initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }}
className="w-full max-w-md relative z-10">
<div className="text-center mb-8">
<Link href="/" className="text-3xl font-bold gradient-text">Clube67</Link>
<h1 className="text-2xl font-bold mt-4">Bem-vindo de volta</h1>
<p className="text-dark-400 mt-2">Entre na sua conta para continuar</p>
</div>
<div className="glass rounded-2xl p-8">
<form onSubmit={handleSubmit} className="space-y-5">
{error && (
<div className="bg-red-500/10 border border-red-500/30 text-red-400 px-4 py-3 rounded-xl text-sm">
{error}
</div>
)}
<div>
<label className="block text-sm font-medium text-dark-300 mb-2">E-mail</label>
<input type="email" value={email} onChange={e => setEmail(e.target.value)} required
className="w-full px-4 py-3 bg-dark-900 border border-dark-700 rounded-xl text-white focus:border-brand-500 focus:ring-1 focus:ring-brand-500/50 transition-all outline-none"
placeholder="seu@email.com" />
</div>
<div>
<label className="block text-sm font-medium text-dark-300 mb-2">Senha</label>
<input type="password" value={password} onChange={e => setPassword(e.target.value)} required
className="w-full px-4 py-3 bg-dark-900 border border-dark-700 rounded-xl text-white focus:border-brand-500 focus:ring-1 focus:ring-brand-500/50 transition-all outline-none"
placeholder="••••••••" />
</div>
<button type="submit" disabled={loading}
className="w-full py-3.5 bg-brand-600 hover:bg-brand-500 rounded-xl font-semibold transition-all shadow-lg shadow-brand-600/25 disabled:opacity-50 disabled:cursor-not-allowed">
{loading ? (
<span className="flex items-center justify-center gap-2">
<svg className="animate-spin h-5 w-5" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none" className="opacity-25" /><path d="M4 12a8 8 0 018-8" stroke="currentColor" strokeWidth="4" fill="none" strokeLinecap="round" /></svg>
Entrando...
</span>
) : 'Entrar'}
</button>
</form>
<div className="mt-6 text-center">
<p className="text-dark-400 text-sm">
Não tem conta?{' '}
<Link href="/register" className="text-brand-400 hover:text-brand-300 font-medium">
Criar conta
</Link>
</p>
</div>
</div>
</motion.div>
</div>
);
}