import { FC } from 'react';

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

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

import HuListItem from '@material-hu/components/design-system/List/components/ListItem';
import HuMenuItem from '@material-hu/components/design-system/Menu/components/MenuItem';
import { MenuItemProps } from '@material-hu/components/design-system/Menu/components/MenuItem/types';

import { feedRoutes } from 'src/pages/dashboard/feed/routes';
import { useLokaliseTranslation as useTranslation } from 'src/utils/i18n';

export type InsightsMenuItemProps = Omit<MenuItemProps, 'id'> & {
  id: number;
};

const InsightsMenuItem: FC<InsightsMenuItemProps> = props => {
  const { id, ...menuProps } = props;

  const navigate = useNavigate();
  const { t } = useTranslation();

  const handleClick = () => {
    navigate(feedRoutes.post.insights(id));
  };

  return (
    <HuMenuItem
      {...menuProps}
      onClick={handleClick}
      sx={{ p: 0 }}
    >
      <HuListItem
        sx={{ p: 0 }}
        avatar={{ Icon: IconChartBar }}
        text={{ title: t('INSIGHTS') }}
      />
    </HuMenuItem>
  );
};

export default InsightsMenuItem;
