fix many request issue
Build & Push / Pipeline Tests (push) Successful in 1m53s
Test / Type Check (all packages) (push) Successful in 54s
Build & Push / Build & Push Docker Image (push) Successful in 3m43s
Test / API Unit Tests (push) Successful in 1m15s
Test / Homepage Unit Tests (push) Successful in 47s
Test / Carplace Unit Tests (push) Successful in 42s
Test / Admin Unit Tests (push) Successful in 43s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Successful in 1m10s

This commit is contained in:
root
2026-08-13 01:07:29 -04:00
parent 7e7a76633e
commit 10e061d2c1
+15 -4
View File
@@ -41,12 +41,21 @@ export default function AdminDashboardLayout({ children }: { children: React.Rea
const [ready, setReady] = useState(false)
const [admin, setAdmin] = useState<AdminSessionUser | null>(null)
const [unreadNotifications, setUnreadNotifications] = useState(0)
const redirectingToLogin = useRef(false)
function redirectToLogin() {
if (redirectingToLogin.current) return
redirectingToLogin.current = true
window.location.replace(buildUnifiedLoginUrl(pathname))
}
useEffect(() => {
let cancelled = false
const controller = new AbortController()
fetch(`${ADMIN_API_BASE}/admin/auth/me`, {
credentials: 'include',
signal: controller.signal,
})
.then(async (response) => {
if (cancelled) return
@@ -54,7 +63,7 @@ export default function AdminDashboardLayout({ children }: { children: React.Rea
const json = await response.json().catch(() => null)
const resolvedAdmin = (json?.data ?? json) as AdminSessionUser | null
if (!resolvedAdmin?.id || !resolvedAdmin?.email || !resolvedAdmin?.role) {
window.location.replace(buildUnifiedLoginUrl(pathname))
redirectToLogin()
return
}
setAdmin(resolvedAdmin)
@@ -68,15 +77,17 @@ export default function AdminDashboardLayout({ children }: { children: React.Rea
.catch(() => {})
}
} else {
window.location.replace(buildUnifiedLoginUrl(pathname))
redirectToLogin()
}
})
.catch(() => {
if (!cancelled) window.location.replace(buildUnifiedLoginUrl(pathname))
.catch((err) => {
if (err?.name === 'AbortError') return
if (!cancelled) redirectToLogin()
})
return () => {
cancelled = true
controller.abort()
}
}, [pathname])