All files / src/hooks/common/useUser index.ts

100% Statements 5/5
50% Branches 1/2
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18        68x 1177x 1177x 1177x   1177x                
import useMasqueradeReducer from "@hooks/Reducers/useMasqueradeReducer";
import useUserReducer from "@hooks/Reducers/useUserReducer";
import { Role } from "./types";
 
export const useUser = () => {
  const { role } = useUserReducer();
  const { masqueradeUserRole, isMasqueradeMode } = useMasqueradeReducer();
  const currentUserRole = isMasqueradeMode ? masqueradeUserRole : role;
 
  return {
    isAcquirer: currentUserRole === Role.ACQUIRER,
    isEnterprise: currentUserRole === Role.ENTERPRISE,
    isMerchant: currentUserRole === Role.MERCHANT,
    userRole: currentUserRole as Role,
    originalUserRole: role as Role,
  };
};