Last active
July 6, 2017 06:02
-
-
Save ernestofreyreg/bdb0a06252a34e5f575febca6937de3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileUploader extends Component { | |
static propTypes = { | |
uploadingFile: PropTypes.object, | |
uploadProgress: PropTypes.object, | |
cancelled: PropTypes.bool, | |
completed: PropTypes.bool, | |
uploadFile: PropTypes.func.isRequired, | |
cancelUpload: PropTypes.func.isRequired, | |
retryUpload: PropTypes.func.isRequired | |
} | |
handleDrop = acceptedfiles => { | |
// Just upload first file | |
this.props.uploadFile(acceptedfiles[0]) | |
} | |
handleCancelUpload = () => { | |
this.props.cancelUpload() | |
} | |
handleRetry = () => { | |
this.props.retryUpload() | |
} | |
render () { | |
const { | |
uploadingFile, | |
uploadProgress, | |
cancelled, | |
completed | |
} = this.props | |
if (!uploadingFile) { | |
return <FileDrop onDrop={this.handleDrop} /> | |
} | |
return ( | |
<FileUploadProgress | |
file={uploadingFile} | |
progress={uploadProgress} | |
cancelled={cancelled} | |
completed={completed} | |
onCancel={this.handleCancelUpload} | |
onRetry={this.handleRetry} | |
/> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment