import _defineProperty from "@babel/runtime/helpers/defineProperty";

/**
 * Web DatePicker Component
 *
 */
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types'; // import classnames from 'classnames'

import Button from '../button/Button';
export const propTypes = {
  onSubmit: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
  onCancel: PropTypes.oneOfType([PropTypes.bool, PropTypes.func])
};
export const defaultProps = {
  // events
  onSubmit: null,
  onCancel: null
};

var _ref =
/*#__PURE__*/
React.createElement("span", null);

var _ref2 =
/*#__PURE__*/
React.createElement("span", null);

export default class DatePickerFooter extends PureComponent {
  constructor() {
    super(...arguments);

    _defineProperty(this, "onSubmitHandler", () => {
      const {
        onSubmit
      } = this.props;

      if (onSubmit) {
        onSubmit();
      }
    });

    _defineProperty(this, "onCancelHandler", () => {
      const {
        onCancel
      } = this.props;

      if (onCancel) {
        onCancel();
      }
    });
  }

  render() {
    const {
      onSubmit,
      onCancel
    } = this.props;

    if (!onSubmit && !onCancel) {
      return React.createElement(React.Fragment, null);
    }

    return React.createElement("div", {
      className: "dnb-date-picker__footer"
    }, onSubmit && React.createElement(Button, {
      text: "Ok",
      variant: "secondary",
      onClick: this.onSubmitHandler
    }) || _ref, onCancel && React.createElement(Button, {
      text: "Cancel",
      icon: "close",
      icon_position: "left",
      variant: "tertiary",
      onClick: this.onCancelHandler
    }) || _ref2);
  }

}

_defineProperty(DatePickerFooter, "defaultProps", defaultProps);

DatePickerFooter.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};