import Stack from '@mui/material/Stack';
import IconButton from '@mui/material/IconButton';
import SearchIcon from '@mui/icons-material/Search';
import PhoneIcon from '@mui/icons-material/Phone';
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>>,
  handleStartCall: () => void
}

const Buttons = ({setIsSomeSelected,handleStartCall}:IButtons) => {
  const classes = useStyles()
  const dispatch = useDispatch()
  const [modalDelete, setModalDelete] = useState<boolean>(false)
  const handleOpenSearch = (e: any) => {
    e.stopPropagation()
    dispatch(actionRightIsOpen('search'))
  }

  return (
    <Stack className={classes.container} direction="row">
      <IconButton onClick={handleOpenSearch} aria-label="delete" size="medium">
        <SearchIcon fontSize='medium'/>
      </IconButton>
      <IconButton onClick={handleStartCall} aria-label="delete" size="medium">
        <PhoneIcon fontSize='medium'/>
      </IconButton>      
      <MenuList setModalDelete={setModalDelete} setIsSomeSelected={setIsSomeSelected}/>
      {modalDelete && <DeleteModal setModalDelete={setModalDelete} />}
    </Stack>
  );
}

export default Buttons