import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; import { Field } from 'mobx-react-form'; // import Loader from 'react-loader'; import classnames from 'classnames'; import Dropzone from 'react-dropzone'; @observer export default class ImageUpload extends Component { static propTypes = { field: PropTypes.instanceOf(Field).isRequired, className: PropTypes.string, multiple: PropTypes.bool, textDelete: PropTypes.string.isRequired, textUpload: PropTypes.string.isRequired, }; static defaultProps = { className: null, multiple: false, }; state = { path: null, } onDrop(acceptedFiles) { acceptedFiles.forEach((file) => { this.setState({ path: file.path, }); this.props.field.onDrop(file); }); } dropzoneRef = null; render() { const { field, className, multiple, textDelete, textUpload, } = this.props; const cssClasses = classnames({ 'image-upload__dropzone': true, [`${className}`]: className, }); return (
{textUpload}