import { useState } from 'react'

const useModal = <TData = any>(defaultData: TData | null = null) => {
  const [open, setOpen] = useState<boolean>(false)
  const [data, setData] = useState<TData | null>(defaultData)

  const handleClose = () => setOpen(false)

  return {
    open,
    setOpen,
    data,
    setData,
    handleClose
  }
}

export default useModal
