RedHatInsights/insights-rbac-ui

View on GitHub
src/smart-components/role/role-selectors.js

Summary

Maintainability
A
0 mins
Test Coverage
export const roleSelector = (state, roleId) => {
  const {
    roleReducer: { roles = { data: [] }, selectedRole },
  } = state;
  if (selectedRole?.uuid === roleId) {
    return selectedRole;
  }

  return roles.data.find(({ uuid }) => uuid === roleId);
};

export const roleNameSelector = (state, roleId) => roleSelector(state, roleId)?.display_name;