useHasFunctionality
#
DescriptionUse this hook to determine if a user may or may not do something in EVA.
#
Usageimport { useCallback } from 'react';import { FunctionalityScope, useHasFunctionality,} from '@springtree/eva-suite-react-hooks';
interface IExampleProps { organizationUnitID: number;}
const Example = ({ organizationUnitID }: IExampleProps) => { const userCanCreateOrders = useHasFunctionality( 'orders', FunctionalityScope.Create, organizationUnitID, );
const handleClick = useCallback( () => { // ... if (userCanCreateOrders) { navigate() } }, [userCanCreateOrders], );
return ( <button disabled={!userCanCreateOrders} onClick={handleClick}> Create order </button> )};
export default Example;