import { cancelProAccount, cancelProAccountFailure, cancelProAccountSuccess } from '../actions/settingsMembershipActions'; import {Field, formValueSelector, reduxForm} from 'redux-form'; import React, {Component} from 'react'; import { connect } from 'react-redux'; import fetch from 'isomorphic-fetch'; import FormField from '../components/FormField'; import LoadingSpinner from '../components/LoadingSpinner'; import PropTypes from 'prop-types'; class SettingsMembershipCancelPro extends Component { constructor(props) { super(props); this.state = { isFetching: false, mustBlock: false, showForm: false } this.handleDisablePro = this.handleDisablePro.bind(this); this.handleShowForm = this.handleShowForm.bind(this); } handleShowForm() { this.setState({ showForm: !this.state.showForm }) } handleDisablePro() { const { dispatch, onCancel } = this.props; const { mustBlock } = this.state; const csrf = window._CONFIG_.csrf; this.setState({ isFetching: true, mustBlock: true, }) dispatch(cancelProAccount('Please wait while the info is updated...')); fetch('/api/v1/pro', { method: 'DELETE', credentials: 'same-origin', headers: { 'x-busk-csrf': csrf === "" ? null : csrf } }) .then(response => response.json()) .then(json => { if (!json.error) { this.setState({ isFetching: false, // mustBlock: false, }) setTimeout(() => onCancel('no'), 1000); dispatch(cancelProAccountSuccess(json.message)); } else { setTimeout(() => this.setState({ mustBlock: false, }), 1000) dispatch(cancelProAccountFailure(json.message || json.error.message || json.datas.msg)); } }) .catch(error => { this.setState({ isFetching: false, mustBlock: false, }) dispatch(cancelProAccountFailure(`Fetch Failure >>> error: ${error}`)); }) } render() { const { endDate, onCancel } = this.props; const { isFetching, mustBlock, showForm } = this.state; return(
Are you suuuure?
(You will keep your pro features until {endDate})