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

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

import useKudosTitle from 'src/pages/dashboard/acknowledgements/hooks/useKudosTitle';
import { acknowledgementsRoutes } from 'src/pages/dashboard/acknowledgements/routes';

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

const { key } = sidebarItemsConfig.acknowledgements;

const PATH = acknowledgementsRoutes.acknowledgements();

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

  const title = useKudosTitle();

  const { Icon } = useGetSidebarIcon({
    defaultIcon: IconAward,
    key: 'Recognition',
  });

  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 NavAcknowledgementsItem;
