| import { |
| hasPermissions, |
| useGetEffectivePermissionsQuery, |
| } from 'librechat-data-provider/react-query'; |
| import type { ResourceType } from 'librechat-data-provider'; |
|
|
| |
| |
| |
| |
| |
| |
| |
| export const useResourcePermissions = (resourceType: ResourceType, resourceId: string) => { |
| const { data, isLoading } = useGetEffectivePermissionsQuery(resourceType, resourceId); |
|
|
| const hasPermission = (requiredPermission: number): boolean => { |
| return data ? hasPermissions(data.permissionBits, requiredPermission) : false; |
| }; |
|
|
| return { |
| hasPermission, |
| isLoading, |
| permissionBits: data?.permissionBits || 0, |
| }; |
| }; |
|
|