import { FC } from 'react';

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

import { IconCalendarClock } 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 { groupsRoutes } from 'src/pages/dashboard/groups/routes';
import { useLokaliseTranslation as useTranslation } from 'src/utils/i18n';

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

const GroupRescheduleMenuItem: FC<GroupRescheduleMenuItemProps> = props => {
  const { id, groupId, ...menuProps } = props;

  const { t } = useTranslation(['post']);
  const navigate = useNavigate();

  const handleClick = () => navigate(groupsRoutes.post.edit(groupId, id));

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

export default GroupRescheduleMenuItem;
