2015-06-20 16:43:18 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import Router from 'react-router';
|
|
|
|
|
2015-06-25 12:56:43 +02:00
|
|
|
import { mergeOptions } from '../utils/general_utils';
|
2015-07-01 18:58:13 +02:00
|
|
|
import { getLangText } from '../utils/lang_utils';
|
2015-06-25 12:56:43 +02:00
|
|
|
|
|
|
|
import UserStore from '../stores/user_store';
|
2015-06-20 16:43:18 +02:00
|
|
|
|
|
|
|
import GlobalNotificationModel from '../models/global_notification_model';
|
|
|
|
import GlobalNotificationActions from '../actions/global_notification_actions';
|
|
|
|
|
|
|
|
import Form from './ascribe_forms/form';
|
|
|
|
import Property from './ascribe_forms/property';
|
|
|
|
import InputCheckbox from './ascribe_forms/input_checkbox';
|
|
|
|
|
|
|
|
import apiUrls from '../constants/api_urls';
|
|
|
|
|
|
|
|
|
2015-06-22 10:50:22 +02:00
|
|
|
let SignupContainer = React.createClass({
|
2015-06-20 16:43:18 +02:00
|
|
|
mixins: [Router.Navigation],
|
|
|
|
|
2015-06-25 12:56:43 +02:00
|
|
|
getInitialState() {
|
|
|
|
return mergeOptions({
|
2015-06-22 10:50:22 +02:00
|
|
|
submitted: false,
|
|
|
|
message: null
|
2015-06-25 12:56:43 +02:00
|
|
|
}, UserStore.getState());
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
UserStore.listen(this.onChange);
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
UserStore.unlisten(this.onChange);
|
2015-06-22 10:50:22 +02:00
|
|
|
},
|
2015-06-25 12:56:43 +02:00
|
|
|
|
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
|
|
|
|
|
|
|
// if user is already logged in, redirect him to piece list
|
|
|
|
if(this.state.currentUser && this.state.currentUser.email) {
|
|
|
|
this.transitionTo('pieces');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-06-22 10:50:22 +02:00
|
|
|
handleSuccess(message){
|
|
|
|
this.setState({
|
|
|
|
submitted: true,
|
|
|
|
message: message
|
|
|
|
});
|
|
|
|
},
|
2015-06-25 12:56:43 +02:00
|
|
|
|
2015-06-20 16:43:18 +02:00
|
|
|
render() {
|
2015-06-22 10:50:22 +02:00
|
|
|
if (this.state.submitted){
|
|
|
|
return (
|
|
|
|
<div className="ascribe-login-wrapper">
|
|
|
|
<br/>
|
|
|
|
<div className="ascribe-login-text ascribe-login-header">
|
|
|
|
{this.state.message}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2015-06-20 16:43:18 +02:00
|
|
|
return (
|
|
|
|
<div className="ascribe-login-wrapper">
|
|
|
|
<br/>
|
|
|
|
<div className="ascribe-login-text ascribe-login-header">
|
2015-07-01 18:58:13 +02:00
|
|
|
{getLangText('Welcome to')} ascribe...
|
2015-06-20 16:43:18 +02:00
|
|
|
</div>
|
2015-06-22 10:50:22 +02:00
|
|
|
<SignupForm handleSuccess={this.handleSuccess}/>
|
2015-06-20 16:43:18 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-06-22 10:50:22 +02:00
|
|
|
let SignupForm = React.createClass({
|
2015-06-20 16:43:18 +02:00
|
|
|
mixins: [Router.Navigation],
|
|
|
|
|
2015-06-22 10:50:22 +02:00
|
|
|
handleSuccess(response){
|
2015-06-20 16:43:18 +02:00
|
|
|
|
2015-07-01 18:58:13 +02:00
|
|
|
let notificationText = getLangText('Sign up successful');
|
2015-06-22 10:50:22 +02:00
|
|
|
let notification = new GlobalNotificationModel(notificationText, 'success', 50000);
|
2015-06-20 16:43:18 +02:00
|
|
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
2015-07-01 18:58:13 +02:00
|
|
|
this.props.handleSuccess(getLangText('We sent an email to your address') + ' ' + response.user.email +
|
|
|
|
', ' + getLangText('please confirm') + '.');
|
2015-06-20 16:43:18 +02:00
|
|
|
|
|
|
|
},
|
|
|
|
render() {
|
2015-07-01 18:58:13 +02:00
|
|
|
let tooltipPassword = getLangText('Your password must be at least 10 characters') + '.\n ' +
|
|
|
|
getLangText('This password is securing your digital property like a bank account') + '.\n ' +
|
|
|
|
getLangText('Store it in a safe place') + '!';
|
2015-06-20 16:43:18 +02:00
|
|
|
return (
|
|
|
|
<Form
|
2015-06-22 10:50:22 +02:00
|
|
|
ref='form'
|
|
|
|
url={apiUrls.users_signup}
|
|
|
|
handleSuccess={this.handleSuccess}
|
|
|
|
buttons={
|
|
|
|
<button type="submit" className="btn ascribe-btn ascribe-btn-login">
|
2015-07-01 18:58:13 +02:00
|
|
|
{getLangText('Sign up to ascribe')}
|
2015-06-22 10:50:22 +02:00
|
|
|
</button>}
|
|
|
|
spinner={
|
|
|
|
<button className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
|
|
|
|
<img src="https://s3-us-west-2.amazonaws.com/ascribe0/media/thumbnails/ascribe_animated_medium.gif" />
|
|
|
|
</button>
|
|
|
|
}>
|
2015-06-20 16:43:18 +02:00
|
|
|
<Property
|
|
|
|
name='email'
|
2015-07-01 18:58:13 +02:00
|
|
|
label={getLangText('Email')}>
|
2015-06-20 16:43:18 +02:00
|
|
|
<input
|
|
|
|
type="email"
|
2015-07-01 18:58:13 +02:00
|
|
|
placeholder={getLangText('Enter your email')}
|
2015-06-20 16:43:18 +02:00
|
|
|
autoComplete="on"
|
|
|
|
required/>
|
|
|
|
</Property>
|
|
|
|
<Property
|
|
|
|
name='password'
|
2015-07-01 18:58:13 +02:00
|
|
|
label={getLangText('Password')}
|
2015-06-20 16:43:18 +02:00
|
|
|
tooltip={tooltipPassword}>
|
|
|
|
<input
|
|
|
|
type="password"
|
2015-07-01 18:58:13 +02:00
|
|
|
placeholder={getLangText('Enter your password')}
|
2015-06-20 16:43:18 +02:00
|
|
|
autoComplete="on"
|
|
|
|
required/>
|
|
|
|
</Property>
|
|
|
|
<Property
|
|
|
|
name='password_confirm'
|
2015-07-01 18:58:13 +02:00
|
|
|
label={getLangText('Confirm Password')}
|
2015-06-20 16:43:18 +02:00
|
|
|
tooltip={tooltipPassword}>
|
|
|
|
<input
|
|
|
|
type="password"
|
2015-07-01 18:58:13 +02:00
|
|
|
placeholder={getLangText('Enter your password once again')}
|
2015-06-20 16:43:18 +02:00
|
|
|
autoComplete="on"
|
|
|
|
required/>
|
|
|
|
</Property>
|
|
|
|
<Property
|
|
|
|
name='promo_code'
|
2015-07-01 18:58:13 +02:00
|
|
|
label={getLangText('Promocode')}>
|
2015-06-20 16:43:18 +02:00
|
|
|
<input
|
2015-06-25 14:39:39 +02:00
|
|
|
type="text"
|
2015-07-01 18:58:13 +02:00
|
|
|
placeholder={getLangText('Enter a promocode here (Optional)')}/>
|
2015-06-20 16:43:18 +02:00
|
|
|
</Property>
|
2015-06-22 10:50:22 +02:00
|
|
|
<hr />
|
2015-06-20 16:43:18 +02:00
|
|
|
<InputCheckbox
|
2015-06-22 10:50:22 +02:00
|
|
|
name='terms'
|
2015-06-20 16:43:18 +02:00
|
|
|
required="required"
|
|
|
|
label={
|
|
|
|
<div>
|
2015-07-01 18:58:13 +02:00
|
|
|
{getLangText('I agree to the')}
|
|
|
|
<a href="/terms" target="_blank"> {getLangText('Terms of Service')}</a>
|
2015-06-20 16:43:18 +02:00
|
|
|
</div>}/>
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-06-22 10:50:22 +02:00
|
|
|
export default SignupContainer;
|