fix architecture and write new tests

This commit is contained in:
root
2026-06-10 00:40:19 -04:00
parent 560da1cadf
commit 80a597bc10
377 changed files with 84020 additions and 1337 deletions
+20 -6
View File
@@ -38,16 +38,30 @@ export default function AdminDashboardLayout({ children }: { children: React.Rea
const [ready, setReady] = useState(false)
useEffect(() => {
const token = localStorage.getItem('admin_token')
if (!token) {
window.location.replace(buildUnifiedLoginUrl(pathname))
} else {
setReady(true)
let cancelled = false
fetch(`${process.env.NEXT_PUBLIC_API_URL ?? '/admin/api/v1'}/admin/auth/me`, {
credentials: 'include',
})
.then((response) => {
if (cancelled) return
if (response.ok) {
setReady(true)
} else {
window.location.replace(buildUnifiedLoginUrl(pathname))
}
})
.catch(() => {
if (!cancelled) window.location.replace(buildUnifiedLoginUrl(pathname))
})
return () => {
cancelled = true
}
}, [pathname])
function handleLogout() {
localStorage.removeItem('admin_token')
void fetch('/admin/api/v1/admin/auth/logout', { method: 'POST', credentials: 'include' })
window.location.href = buildUnifiedLoginUrl('/dashboard')
}