import React from 'react';
import { Modal } from 'antd';
import PropTypes from 'prop-types';
import style from '../modal.module.scss';

const { confirm } = Modal;
const DEFAULT_SIMPLE = {
  title: '',
  content: '',
  onOk: () => {
  },
  onCancel: () => {
  },
  okText: 'Да',
  cancelText: 'Нет',
  okButtonProps: {
    type: 'default',
    ghost: true,
  },
  cancelButtonProps: {
    type: 'danger',
  },
};

const Confirm = ({
  title,
  content,
  onOk,
  onCancel,
  okText,
  cancelText,
  okButtonProps,
}) => (
  <div style={{ width: '600px' }}>
    {confirm({
      title: title || DEFAULT_SIMPLE.title,
      content: content || DEFAULT_SIMPLE.content,
      onOk: onOk || null,
      onCancel: onCancel || null,
      okText: okText || DEFAULT_SIMPLE.okText,
      cancelText: cancelText || DEFAULT_SIMPLE.cancelText,
      className: style.modal__container_simple,
      okButtonProps: okButtonProps || DEFAULT_SIMPLE.okButtonProps,
      cancelButtonProps: DEFAULT_SIMPLE.cancelButtonProps,
      icon: null,
    })}
  </div>
);

Confirm.propTypes = {
  title: PropTypes.string,
  content: PropTypes.string,
  onOk: PropTypes.func,
  onCancel: PropTypes.func,
  okText: PropTypes.string,
  cancelText: PropTypes.string,
  okButtonProps: PropTypes.objectOf(PropTypes.node),
};

Confirm.defaultProps = {
  title: '',
  content: '',
  onOk: () => {},
  onCancel: () => {},
  okText: '',
  cancelText: '',
  okButtonProps: {},
};

export default Confirm;
