Last active
May 17, 2021 21:05
-
-
Save iskenxan/56f82b698ceba99012243f2b62c54870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function PermissionsGate({ | |
children, | |
RenderError = () => <></>, | |
errorProps = null, | |
scopes = [] | |
}) { | |
const { role } = useGetRole(); | |
const permissions = PERMISSIONS[role]; | |
const permissionGranted = hasPermission({ permissions, scopes }); | |
if (!permissionGranted && !errorProps) return <RenderError />; | |
return <>{children}</>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment