@pagamio/frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
52 lines (51 loc) • 1.78 kB
JavaScript
import { getUserPermissions, hasAllPermissions, hasAnyPermission, hasIQRetailAccess, hasPermission, hasRole, } from './utils';
/**
* Hook wrapper for hasPermission
* @param user - The user object to check permissions for
* @param permission - The permission to check
* @returns boolean indicating if the user has the permission
*/
export const useHasPermission = (user, permission) => {
return hasPermission(user, permission);
};
/**
* Hook wrapper for hasRole
* @param user - The user object to check role for
* @param roleName - The role name to check against
* @returns boolean indicating if the user has the specified role
*/
export const useHasRole = (user, roleName) => {
return hasRole(user, roleName);
};
/**
* Hook wrapper for hasAnyPermission
* @param user - The user object to check permissions for
* @param permissions - Array of permissions to check
* @returns boolean indicating if the user has any of the permissions
*/
export const useHasAnyPermission = (user, permissions) => {
return hasAnyPermission(user, permissions);
};
/**
* Hook wrapper for hasAllPermissions
* @param user - The user object to check permissions for
* @param permissions - Array of permissions to check
* @returns boolean indicating if the user has all of the permissions
*/
export const useHasAllPermissions = (user, permissions) => {
return hasAllPermissions(user, permissions);
};
/**
* Hook wrapper for getUserPermissions
* @param user - The user object to get permissions for
* @returns Array of permissions the user has
*/
export const useGetUserPermissions = (user) => {
return getUserPermissions(user);
};
/**
* Hook wrapper for IQ Retail access
*/
export const useHasIQRetailAccess = (user) => {
return hasIQRetailAccess(user);
};