mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 11:46:36 +08:00
fix: handle wrapped permission responses
This commit is contained in:
@@ -47,13 +47,13 @@ export function Layout() {
|
||||
}, [location.pathname])
|
||||
|
||||
useEffect(() => {
|
||||
if (user && !isPermissionLoading && Object.keys(permissions).length === 0) {
|
||||
if (user && !isPermissionLoading && Object.keys(permissions ?? {}).length === 0) {
|
||||
fetchPermissions().catch(() => undefined)
|
||||
}
|
||||
}, [fetchPermissions, isPermissionLoading, permissions, user])
|
||||
|
||||
const isAdmin = user?.role === 'admin'
|
||||
const can = (key: string) => isAdmin || isSuper || permissions[key] === true
|
||||
const can = (key: string) => isAdmin || isSuper || (permissions ?? {})[key] === true
|
||||
|
||||
const handleSearchSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
|
||||
Reference in New Issue
Block a user