import { IconButton, Popover, Tooltip } from "@mui/material";
import { useState } from "react";
import TuneIcon from "@mui/icons-material/Tune";
import { Grid } from "../../../../components/grid/Grid";
import DeleteIcon from "@mui/icons-material/Delete";

export const SlaughterDailyListOperation = ({ item, updateTable }) => {
  //   const dispatch = useDispatch();
  const [anchorEl, setAnchorEl] = useState(null);

  const handleClick = (event) => {
    setAnchorEl(event.currentTarget);
  };

  const handleClose = () => {
    setAnchorEl(null);
  };

  const open = Boolean(anchorEl);
  const id = open ? "popover" : undefined;

  //   const [openNotif] = useContext(AppContext);
  return (
    <div>
      <IconButton
        aria-describedby={id}
        variant="contained"
        color="primary"
        onClick={handleClick}
      >
        <TuneIcon />
      </IconButton>
      <Popover
        anchorOrigin={{
          vertical: "bottom",
          horizontal: "right",
        }}
        transformOrigin={{
          vertical: "top",
          horizontal: "left",
        }}
        id={id}
        open={open}
        anchorEl={anchorEl}
        onClose={handleClose}
      >
        <div style={{ padding: "20px" }}>
          <Grid container direction="column">
            <Tooltip title={"حذف"} placement="left-start">
              <IconButton
                aria-label="delete"
                color="error"
                onClick={() => {
                  handleClose();
                  //   dispatch(
                  //     OPEN_MODAL({
                  //       title: "آیا مطمئن هستید؟",
                  //       content: (
                  //         <Grid container spacing={2}>
                  //           <Grid item>
                  //             <Button
                  //               variant="contained"
                  //               color="error"
                  //               onClick={() => {
                  //                 dispatch(
                  //                   cityDeleteIncreaseHatchingeService(item?.key)
                  //                 ).then((r) => {
                  //                   if (r.payload.error) {
                  //                     openNotif({
                  //                       vertical: "top",
                  //                       horizontal: "center",
                  //                       msg: r.payload.error,
                  //                       severity: "error",
                  //                     });
                  //                   } else {
                  //                     updateTable();
                  //                     dispatch(CLOSE_MODAL());
                  //                     openNotif({
                  //                       vertical: "top",
                  //                       horizontal: "center",
                  //                       msg: r.payload.data.result,
                  //                       severity: "success",
                  //                     });
                  //                   }
                  //                 });
                  //               }}
                  //             >
                  //               تایید
                  //             </Button>
                  //           </Grid>
                  //           <Grid item>
                  //             <Button
                  //               onClick={() => {
                  //                 dispatch(CLOSE_MODAL());
                  //               }}
                  //             >
                  //               لغو
                  //             </Button>
                  //           </Grid>
                  //         </Grid>
                  //       ),
                  //     })
                  //   );
                }}
              >
                <DeleteIcon />
              </IconButton>
            </Tooltip>
          </Grid>
        </div>
      </Popover>
    </div>
  );
};
