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

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

import useCustomServerTranslation from 'src/hooks/useCustomServerTranslation';

import { peopleRoutes } from 'src/components/dashboard/people/routes';

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

const { key, titleTranslationKey } = itemsConfig.people;

const PATH = peopleRoutes.people();
const MODULE = 'PEOPLE';

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

  const title = useCustomServerTranslation({
    module: MODULE,
    defaultTranslationKey: titleTranslationKey,
    namespace: 'dashboard_sidebar_app',
  });

  const { Icon } = useGetSidebarIcon({
    defaultIcon: IconUsers,
    key: 'People',
  });

  const isActive = isActiveProp ?? getItemIsActive(PATH);

  return (
    <HuSidebarNavItem
      key={key}
      depth={0}
      title={title}
      icon={<Icon />}
      path={PATH}
      isCollapsed={isCollapsed}
      onClick={onClick}
      active={isActive}
    />
  );
};

export default NavPeopleItem;
