UNPKG

@orchestrator-ui/orchestrator-ui-components

Version:

Library of UI Components used to display the workflow orchestrator frontend

16 lines (11 loc) 370 B
import { useContext } from 'react'; import { useRouter } from 'next/router'; import { PolicyContext } from '@/contexts'; export const usePolicy = () => { const { isAllowedHandler } = useContext(PolicyContext); const router = useRouter(); return { isAllowed: (resource?: string) => isAllowedHandler(router.asPath, resource), }; };