Skip to content

Commit

Permalink
bugfix(WithPermissions): check specific provided permission on `rende…
Browse files Browse the repository at this point in the history
…rContent`. (#1645)
  • Loading branch information
AndreyNenashev authored Feb 27, 2024
1 parent 0fee7ac commit 5887dbd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const WithPermissions: React.FC<WithPermissionsProps> = ({
extraCheck,
children,
}) => {
const { isAllowedTo, hasAccessTo } = usePermissions();
const { hasAccessTo } = usePermissions();

if (renderContent) {
return <>{renderContent({ isAllowedTo })}</>;
return <>{renderContent({ isAllowedTo: hasAccessTo(permissionTo) })}</>;
}

if (children && extraCheck !== undefined) {
Expand Down
3 changes: 1 addition & 2 deletions odd-platform-ui/src/lib/hooks/usePermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ interface UsePermissionReturn {
}

const usePermissions = (): UsePermissionReturn => {
const { isAllowedTo, getHasAccessTo } = useContext(PermissionContext);
const hasAccessTo = getHasAccessTo;
const { isAllowedTo, getHasAccessTo: hasAccessTo } = useContext(PermissionContext);

return { isAllowedTo, hasAccessTo };
};
Expand Down

0 comments on commit 5887dbd

Please sign in to comment.