Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.6 kB
4
Indexable
import { useDispatch, useSelector } from 'react-redux';
import { MenuItem } from '@mui/material';
import Iconify from 'src/components/iconify/Iconify';
import MenuPopover from 'src/components/menu-popover/MenuPopover';
import { setDeletePopup, setDeletePopupData, setOpenPopoverMenu } from 'src/store/slices/tasksSlice';
import { IRootState } from 'src/store';
import { PopoverDataInterface } from '../../types/types';

const SELECTED_TABS = {
  COMPLETED: 'COMPLETED',
  SCHEDULED: 'SCHEDULED',
};

const ViewInMarketplaceMenuItem = ({ link }: { link: string }) => (
  <MenuItem
    onClick={() => window.open(link, '_blank')}
  >
    <Iconify
      icon="eva:external-link-outline"
      fontSize="small"
      mr={1}
    />
    View in Marketplace
  </MenuItem>
);

const DeleteTaskRecordMenuItem = ({ name }: { name: string }) => {
  const dispatch = useDispatch();

  const handleClick = () => {
    dispatch(setDeletePopup(true));
    dispatch(setDeletePopupData(name));
    dispatch(setOpenPopoverMenu(null));
  };

  return (
    <MenuItem
      onClick={handleClick}
      sx={{ color: 'error.main' }}
    >
      <Iconify
        icon="eva:trash-2-outline"
        fontSize="small"
        mr={1}
      />
      Delete Task Record
    </MenuItem>
  );
};

const ActionMenuPopover = () => {
  const dispatch = useDispatch();
  const { openPopoverMenu, popoverData, selectedTab } = useSelector((state: IRootState) => state.tasks);

  const handleClose = () => dispatch(setOpenPopoverMenu(null));

  return (
    <MenuPopover
      open={openPopoverMenu}
      onClose={handle