import { FC } from 'react';

import { IconTrash } 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 EventPostDeleteProps = {
  onDelete: () => void;
};

const EventPostDelete: FC<EventPostDeleteProps> = ({ onDelete }) => {
  const { t } = useTranslation(['general']);
  const { closeMenu } = useMoreMenu();

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

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

export default EventPostDelete;
