chore(history): import initial web product snapshot
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { useAuthStore } from '@/app/store/auth'
|
||||
import { ROLE_PERMISSIONS, type Permission, type RoleKey } from '@/config/roles'
|
||||
|
||||
export function usePermission() {
|
||||
const role = useAuthStore((s) => s.user?.role ?? 'viewer') as RoleKey
|
||||
const perms = ROLE_PERMISSIONS[role] ?? []
|
||||
return {
|
||||
role,
|
||||
can: (p: Permission) => perms.includes(p),
|
||||
canAny: (...ps: Permission[]) => ps.some((p) => perms.includes(p)),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user