import { createVideo, UPLOAD_VIDEO, UPLOAD_VIDEO_FAILURE } from '../actions/settings'; import { Field, reduxForm } from 'redux-form'; import React, {Component} from 'react'; import FormField from '../components/FormField.js'; import PropTypes from 'prop-types'; class SettingsVideoForm extends Component { constructor(props) { super(props); this.state = { mustBlock: false } this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit (values) { const {dispatch, reset} = this.props; this.setState({ mustBlock: true }) dispatch(createVideo({ url: values.video_url })).then(res => { if (res.type === UPLOAD_VIDEO || res.type === UPLOAD_VIDEO_FAILURE && res.error === "Sorry mate! You have already uploaded this video.") { reset(); } this.setState({ mustBlock: false }) }) } render () { const { pristine, submitting } = this.props; const { mustBlock } = this.state; return (
) } } SettingsVideoForm.propTypes = { dispatch: PropTypes.func, handleSubmit: PropTypes.func, pristine: PropTypes.bool, reset: PropTypes.func, submitting: PropTypes.bool, } export default reduxForm({ form: 'videoForm' })(SettingsVideoForm)