import _get from "lodash/fp/get";
import _uniqueId from "lodash/fp/uniqueId";
import React from 'react';
import PropTypes from 'prop-types';
import { NovaSolidDataTransferDataUpload1 as UploadIcon } from '@coorpacademy/nova-icons';
import Loader from '../../atom/loader';
import style from './style.css';
class BrandUploadBox extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      dragging: false
    };
    this.handleDragStart = this.handleDragStart.bind(this);
    this.handleDragStop = this.handleDragStop.bind(this);
  }
  handleDragStart() {
    this.setState({
      dragging: true
    });
  }
  handleDragStop() {
    this.setState({
      dragging: false
    });
  }
  render() {
    const idBox = _uniqueId('drop-box-');
    const {
      skin
    } = this.context;
    const {
      status
    } = this.props;
    const {
      dragging
    } = this.state;
    let content;
    const {
      description = '',
      browse = '',
      onLoad,
      name
    } = this.props;
    const brandColor = _get('common.brand', skin);
    switch (status) {
      case 'loading':
        content = /*#__PURE__*/React.createElement("div", {
          className: style.loading
        }, /*#__PURE__*/React.createElement(Loader, null));
        break;
      default:
        content = /*#__PURE__*/React.createElement("div", {
          className: style.wrapper
        }, /*#__PURE__*/React.createElement("div", {
          id: idBox,
          className: dragging ? style.dropping : style.defaultStyle
        }, /*#__PURE__*/React.createElement("div", {
          className: style.cont
        }, /*#__PURE__*/React.createElement(UploadIcon, {
          style: {
            color: brandColor
          },
          className: style.arrow
        }), /*#__PURE__*/React.createElement("div", {
          className: style.desc
        }, description), /*#__PURE__*/React.createElement("span", {
          className: style.browse
        }, browse)), /*#__PURE__*/React.createElement("input", {
          type: "file",
          name: name,
          className: style.inputFile,
          onChange: onLoad,
          onDragEnter: this.handleDragStart,
          onDrop: this.handleDragStop,
          onDragLeave: this.handleDragStop
        })));
    }
    return content;
  }
}
BrandUploadBox.propTypes = process.env.NODE_ENV !== "production" ? {
  name: PropTypes.string,
  description: PropTypes.string,
  browse: PropTypes.string,
  status: PropTypes.oneOf(['default', 'loading']),
  onLoad: PropTypes.func
} : {};
export default BrandUploadBox;
//# sourceMappingURL=index.js.map