import React from 'react'; import {observer, inject} from 'mobx-react'; import { Layout, Content, Row, Col, Card, message, Button, Spin, Icon, notification } from 'antd'; import css from 'reactcss'; import RegisterForm from './Form'; import {Link} from 'react-router-dom'; import {LINKS} from '../../routes'; import QueueAnim from 'rc-queue-anim'; import './style.scss'; @inject('appstate') @observer export default class ComponentName extends React.Component { constructor(props) { super(props); this.props = props; this.state = { isSuccess: false, isLoading: false, registerFailedMessage: "" }; this.defaultState = Object.assign({}, this.state); this.style = css({ default: { container: { minHeight: '100vh' }, loginForm: { paddingTop: '15%' } } }) this.authStore = props.appstate.auth; this.query = this .props .location .search .substr(1) .split('&') .reduce((q, value) => { const [k, v] = value.split('='); q[k] = v; return q; }, {}); } componentDidMount() {} submitFormAction(formInstance, value) { console.log(value); this.setState({isLoading: true}) setTimeout(() => { this .authStore .register(value) .then(res => { // notification.open({ // message: 'Register Success', // description: 'Please check your email to continue' // }); this.props.history.push({ pathname:LINKS.VOUCHERS }); this.setState({isLoading: false, isSuccess: true}) // this }) .catch(err => { if (err && err.errors && err.errors[0] && err.errors[0].message) { message.error(err.errors[0].message.charAt(0).toUpperCase() + err.errors[0].message.slice(1)); } else { message.error(err.message.charAt(0).toUpperCase() + err.errors[0].message.slice(1)); } this.setState({isLoading: false, isSuccess: false, registerFailedMessage: err.message}) }); }, 1000); } render() { const RegisterFormObject = (
logo

Register Now

`${k}=${this.query[k]}`).join('&')}> Back to Login } onSubmit={this.submitFormAction.bind(this)}/>
) const RegisterSuccessObject = (

Register Success

We have sent an email to your address, please confirm it to continue

`${k}=${this.query[k]}`).join('&')}>

Back to Login

) const RegisterFailedObject = (

Register Failed

{this.state.registerFailedMessage}

Back to Register

) return (
{this.state.isSuccess && !this.state.registerFailedMessage ? (RegisterSuccessObject) : ("")} {this.state.isSuccess && this.state.registerFailedMessage ? (RegisterFailedObject) : ("")} {!this.state.isSuccess ? (RegisterFormObject) : ("")}
) } }