react-permissions-dynamic
Version:
This is a package with react-permissions
14 lines (13 loc) • 535 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAllowed = void 0;
const react_1 = require("react");
const useCheckPermissions_1 = require("./useCheckPermissions");
const useAllowed = (actions) => {
const result = (0, useCheckPermissions_1.useCheckPermissions)(actions);
return (0, react_1.useMemo)(() => {
const set = new Set(result.filter(a => a.allowed).map(a => a.action));
return actions.filter(a => set.has(a));
}, [result]);
};
exports.useAllowed = useAllowed;