import Stack from '@mui/material/Stack';
import IconButton from '@mui/material/IconButton';
import SearchIcon from '@mui/icons-material/Search';
import { makeStyles } from '@material-ui/core'
import { useDispatch } from 'react-redux';
import { useState } from 'react';

import MenuList from './MenuList'
import DeleteModal from './DeleteModal';
import { actionRightIsOpen } from '../../../../../redux/control/action'

const useStyles = makeStyles({
  container: {
    marginLeft: 20,
    display: 'flex',
    alignContent: 'center',
    alignItems:'center'
  }, 
})

interface IButtons {
  setIsSomeSelected: React.Dispatch<React.SetStateAction<boolean>>,
}

const Buttons = ({setIsSomeSelected}:IButtons) => {
  const classes = useStyles()
  const dispatch = useDispatch()
  const [modal,setModal] = useState<boolean>(false)

  return (
    <Stack className={classes.container} direction="row">
      <IconButton onClick={() => dispatch(actionRightIsOpen('search'))} aria-label="delete" size="medium">
        <SearchIcon fontSize='medium'/>
      </IconButton>
      <MenuList setModal={setModal} setIsSomeSelected={setIsSomeSelected}/>
       {modal&&<DeleteModal setModal={setModal}/>}      
    </Stack>
  );
}

export default Buttons