Files
forwarder/admin-ui/src/components/Layout.tsx
T
XikaandPaperclip d476cb0204 feat(admin-ui): add login page and HTTP Basic auth
- AuthProvider + useAuth hook (sessionStorage, base64 creds)
- Login.tsx validates credentials against /api/stats before accepting
- api.ts injects Authorization: Basic header on all requests
- App.tsx gates all routes behind login, redirects unknown paths
- Layout.tsx adds logout button
- .gitignore: allow admin-ui/src/lib/ (was blocked by root lib/ rule)

Co-Authored-By: Paperclip <[email protected]>
2026-06-30 23:50:01 +00:00

57 lines
1.9 KiB
TypeScript

import { NavLink, Outlet } from 'react-router-dom'
import { LayoutDashboard, Users, Mail, Wifi, LogOut } from 'lucide-react'
import { useAuth } from '../auth'
const nav = [
{ to: '/', label: 'Dashboard', icon: LayoutDashboard },
{ to: '/accounts', label: 'Contas', icon: Users },
{ to: '/emails', label: 'Emails', icon: Mail },
{ to: '/connection-test', label: 'Teste Ligação', icon: Wifi },
]
export default function Layout() {
const { logout } = useAuth()
return (
<div className="flex h-screen">
<aside className="w-56 bg-gray-900 text-white flex flex-col">
<div className="px-5 py-4 border-b border-gray-700">
<h1 className="text-sm font-semibold text-gray-200 leading-tight">BizDocs Forwarder</h1>
<p className="text-xs text-gray-500 mt-0.5">Admin</p>
</div>
<nav className="flex-1 p-3 space-y-1">
{nav.map(({ to, label, icon: Icon }) => (
<NavLink
key={to}
to={to}
end={to === '/'}
className={({ isActive }) =>
`flex items-center gap-3 px-3 py-2 rounded-md text-sm transition-colors ${
isActive
? 'bg-indigo-600 text-white'
: 'text-gray-400 hover:bg-gray-800 hover:text-white'
}`
}
>
<Icon size={16} />
{label}
</NavLink>
))}
</nav>
<div className="p-3 border-t border-gray-700">
<button
onClick={logout}
className="flex items-center gap-3 px-3 py-2 w-full rounded-md text-sm text-gray-400 hover:bg-gray-800 hover:text-white transition-colors"
>
<LogOut size={16} />
Sair
</button>
</div>
</aside>
<main className="flex-1 overflow-auto">
<Outlet />
</main>
</div>
)
}