'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import Link from 'next/link' import { useAuth } from '@/hooks/useAuth' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Alert, AlertDescription } from '@/components/ui/alert' export default function LoginAdminPage() { const [credentials, setCredentials] = useState({ email: '', password: '' }) const [error, setError] = useState('') const [loading, setLoading] = useState(false) const router = useRouter() const { login } = useAuth() const handleLogin = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) setError('') // Simular delay de autenticação await new Promise(resolve => setTimeout(resolve, 1000)) // Tentar fazer login usando o contexto com tipo administrador const success = login(credentials.email, credentials.password, 'administrador') if (success) { // Redirecionar para o dashboard do administrador setTimeout(() => { router.push('/dashboard') // Fallback: usar window.location se router.push não funcionar setTimeout(() => { if (window.location.pathname === '/login-admin') { window.location.href = '/dashboard' } }, 100) }, 100) } else { setError('Email ou senha incorretos') } setLoading(false) } return (
Entre com suas credenciais para acessar o sistema administrativo