import { matchPath } from 'react-router-dom';

export const getItemIsActive = (path: string) =>
  !!matchPath(`${path}/*`, location.pathname);

export const getSubItemIsActive = (path: string) =>
  !!matchPath(path, location.pathname);

export const getConversationsModuleName = ({
  canViewTickets,
  canViewConversations,
  canViewChats,
}: {
  canViewTickets: boolean;
  canViewConversations: boolean;
  canViewChats: boolean;
}): string => {
  if (canViewConversations) {
    return 'CHATS';
  }
  if (canViewTickets && !canViewChats) {
    return 'TICKETS';
  }

  return 'CHATS';
};
