import { IconReportMoney } from '@material-hu/icons/tabler';

import HuSidebarNavItem from '@material-hu/components/design-system/Sidebar/components/NavItem';

import { canShowBanBajio } from 'src/constants/banBajio';
import { useAuth } from 'src/contexts/JWTContext';
import { banBajioRoutes } from 'src/pages/dashboard/banBajio/routes';
import { useLokaliseTranslation } from 'src/utils/i18n';

import itemsConfig from '../constants';
import { SidebarItemProps } from '../types';
import { getItemIsActive } from '../utils';

const { key, titleTranslationKey } = itemsConfig.banBajio;

const PATH = banBajioRoutes.home();

const NavBanBajioRequests = (props: SidebarItemProps) => {
  const { isCollapsed, onClick, isActive: isActiveProp } = props;
  const { instance } = useAuth();

  const { t } = useLokaliseTranslation('dashboard_sidebar_app');

  const isActive = isActiveProp ?? getItemIsActive(PATH);

  if (canShowBanBajio(instance!.id)) {
    return (
      <HuSidebarNavItem
        key={key}
        depth={0}
        title={t(titleTranslationKey)}
        icon={<IconReportMoney />}
        path={PATH}
        isCollapsed={isCollapsed}
        onClick={onClick}
        active={isActive}
      />
    );
  }
};

export default NavBanBajioRequests;
