import {
  Button,
  Dialog,
  DialogTitle,
  DialogActions,
  DialogContent,
} from '@material-ui/core';

export const Modal = ({
  open,
  close,
  submit,
  title,
  children,
  hideSubmit,
}) => {
  const closeLabel = hideSubmit ? "Close" : "Cancel";

  return (
    <Dialog
      open={open}
      onClose={close}
    >
      <DialogTitle id="alert-dialog-title">
        {title}
      </DialogTitle>
      <DialogContent>
        {children}
      </DialogContent>
      <DialogActions>
        <Button
          onClick={close}
        >
          {closeLabel}
        </Button>
        {!hideSubmit && <Button
          variant="contained"
          color="secondary"
          onClick={submit}
          autoFocus
        >
          Submit
        </Button>}
      </DialogActions>
    </Dialog>
  )
}