'use client'; import { useState, useEffect, useRef } from 'react'; import { LayoutDashboard, Users, CreditCard, Package, Settings, Shield, TrendingUp, Bell, LogOut, User, CheckCircle, AlertCircle } from 'lucide-react'; import AdminDashboard from '@/components/AdminDashboard'; import Tenants from '@/components/Tenants'; import Plans from '@/components/Plans'; import Payments from '@/components/Payments'; import AdminSettings from '@/components/AdminSettings'; const navItems = [ { section: 'Visão Geral' }, { id: 'dashboard', label: 'Dashboard', icon: LayoutDashboard }, { section: 'Gestão' }, { id: 'tenants', label: 'Assinantes', icon: Users }, { id: 'plans', label: 'Planos', icon: Package }, { id: 'payments', label: 'Pagamentos', icon: CreditCard }, { section: 'Sistema' }, { id: 'settings', label: 'Configurações', icon: Settings }, ]; const pages: Record = { dashboard: { title: 'Dashboard', subtitle: 'Visão geral das assinaturas' }, tenants: { title: 'Assinantes', subtitle: 'Gerenciar estabelecimentos' }, plans: { title: 'Planos', subtitle: 'Gerenciar planos de assinatura' }, payments: { title: 'Pagamentos', subtitle: 'Histórico de cobranças' }, settings: { title: 'Configurações', subtitle: 'Configurações do sistema' }, }; const mockNotifications = [ { id: 1, title: 'Nova Assinatura', message: 'Barbearia do Zé contratou o plano Starter', type: 'success', time: '5 min atrás', read: false }, { id: 2, title: 'Falha no Pagamento', message: 'Salão Glamour não conseguiu renovar a assinatura', type: 'warning', time: '1 hora atrás', read: true }, { id: 3, title: 'Ticket de Suporte', message: 'Novo chamado aberto por Studio Bella Nails', type: 'info', time: '2 horas atrás', read: true }, ]; export default function AdminPage() { const [currentPage, setCurrentPage] = useState('dashboard'); const [showNotifications, setShowNotifications] = useState(false); const [showProfile, setShowProfile] = useState(false); const [notifications, setNotifications] = useState(mockNotifications); const notifRef = useRef(null); const profileRef = useRef(null); useEffect(() => { const handleClickOutside = (e: MouseEvent) => { if (notifRef.current && !notifRef.current.contains(e.target as Node)) setShowNotifications(false); if (profileRef.current && !profileRef.current.contains(e.target as Node)) setShowProfile(false); }; document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); }, []); const playNotificationSound = () => { try { const audioCtx = new (window.AudioContext || (window as any).webkitAudioContext)(); const oscillator = audioCtx.createOscillator(); const gainNode = audioCtx.createGain(); oscillator.type = 'sine'; oscillator.frequency.setValueAtTime(880, audioCtx.currentTime); // A5 oscillator.frequency.exponentialRampToValueAtTime(1760, audioCtx.currentTime + 0.1); // A6 gainNode.gain.setValueAtTime(0.1, audioCtx.currentTime); gainNode.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 0.3); oscillator.connect(gainNode); gainNode.connect(audioCtx.destination); oscillator.start(); oscillator.stop(audioCtx.currentTime + 0.3); } catch (e) { console.log('Audio not supported or blocked'); } }; const handleNotificationClick = () => { if (!showNotifications) { const unreadCount = notifications.filter(n => !n.read).length; if (unreadCount > 0) { playNotificationSound(); } } setShowNotifications(!showNotifications); setShowProfile(false); }; const handleProfileClick = () => { setShowProfile(!showProfile); setShowNotifications(false); }; const markAllAsRead = () => { setNotifications(notifications.map(n => ({ ...n, read: true }))); }; const logout = () => { window.location.href = '/'; }; const unreadCount = notifications.filter(n => !n.read).length; const renderPage = () => { switch (currentPage) { case 'dashboard': return ; case 'tenants': return ; case 'plans': return ; case 'payments': return ; case 'settings': return ; default: return ; } }; return (

{pages[currentPage]?.title}

{pages[currentPage]?.subtitle}

{showNotifications && (

Notificações

{unreadCount > 0 && ( )}
{notifications.map(n => (
{n.type === 'success' ? : n.type === 'warning' ? : }
{n.title}
{n.message}
{n.time}
))}
)}
SA
{showProfile && (
Super Admin
admin@agendapro.com
)}
{renderPage()}
); }