import { FC } from 'react';

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

import ListItem from '@material-hu/components/design-system/List/components/ListItem';
import MenuItem from '@material-hu/components/design-system/Menu/components/MenuItem';

import { useMoreMenu } from 'src/contexts/MoreMenuContext';
import { useLokaliseTranslation as useTranslation } from 'src/utils/i18n';

type EventPostEditProps = {
  onEdit: () => void;
};

const EventPostEdit: FC<EventPostEditProps> = ({ onEdit }) => {
  const { t } = useTranslation(['general']);
  const { closeMenu } = useMoreMenu();

  const handleClick = () => {
    closeMenu();
    onEdit();
  };

  return (
    <MenuItem
      onClick={handleClick}
      sx={{ p: 0 }}
    >
      <ListItem
        sx={{ p: 0 }}
        avatar={{ Icon: IconEdit }}
        text={{ title: t('general:edit') }}
      />
    </MenuItem>
  );
};

export default EventPostEdit;
