import React, { PropTypes } from 'react' import { Link } from 'react-router' import linkState from 'boost/linkState' import openExternal from 'boost/openExternal' import { signup } from 'boost/api' export default class SignupContainer extends React.Component { constructor (props) { super(props) this.state = { user: {}, connectionFailed: false, emailConflicted: false, nameConflicted: false, validationFailed: false, isSending: false, error: null } this.linkState = linkState this.openExternal = openExternal } handleSubmit (e) { this.setState({ isSending: true, error: null }, function () { signup(this.state.user) .then(res => { localStorage.setItem('token', res.body.token) localStorage.setItem('currentUser', JSON.stringify(res.body.user)) this.props.history.pushState('home') }) .catch(err => { console.error(err) if (err.code === 'ECONNREFUSED') { return this.setState({ error: { name: 'CunnectionRefused', message: 'Can\'t connect to API server.' }, isSending: false }) } else if (err.status != null) { return this.setState({ error: { name: err.response.body.name, message: err.response.body.message }, isSending: false }) } else throw err }) }) e.preventDefault() } render () { return (
this.handleSubmit(e)}>
{this.state.isSending ? (

Signing up...

) : null} {this.state.error != null ?

{this.state.error.message}

: null}

会員登録することで、当サイトの利用規約及びCookieの使用を含むデータに関するポリシーに同意するものとします。

) } } SignupContainer.propTypes = { history: PropTypes.shape({ pushState: PropTypes.func }) }