1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00
onion/js/components/signup_container.js

135 lines
4.4 KiB
JavaScript
Raw Normal View History

2015-06-20 16:43:18 +02:00
'use strict';
import React from 'react';
import Router from 'react-router';
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-22 10:50:22 +02:00
getInitialState(){
return ({
submitted: false,
message: null
});
},
handleSuccess(message){
this.setState({
submitted: true,
message: message
});
},
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">
Welcome to ascribe...
</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-06-22 10:50:22 +02:00
let notificationText = 'Sign up successful';
let notification = new GlobalNotificationModel(notificationText, 'success', 50000);
2015-06-20 16:43:18 +02:00
GlobalNotificationActions.appendGlobalNotification(notification);
2015-06-22 10:50:22 +02:00
this.props.handleSuccess('We sent an email to your address ' + response.user.email + ', please confirm.');
2015-06-20 16:43:18 +02:00
},
render() {
let tooltipPassword = 'Your password must be at least 10 characters.\n ' +
'This password is securing your digital property like a bank account.\n ' +
'Store it in a safe place!';
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">
Sign up to ascribe
</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'
label="Email">
<input
type="email"
placeholder="Enter your email"
autoComplete="on"
required/>
</Property>
<Property
name='password'
label="Password"
tooltip={tooltipPassword}>
<input
type="password"
placeholder="Enter your password"
autoComplete="on"
required/>
</Property>
<Property
name='password_confirm'
label="Confirm Password"
tooltip={tooltipPassword}>
<input
type="password"
placeholder="Enter your password once again"
autoComplete="on"
required/>
</Property>
<Property
name='promo_code'
2015-06-22 10:50:22 +02:00
label="Promocode">
2015-06-20 16:43:18 +02:00
<input
type="password"
2015-06-22 10:50:22 +02:00
placeholder="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>
I agree to the&nbsp;
<a href="/terms" target="_blank"> Terms of Service</a>
</div>}/>
</Form>
);
}
});
2015-06-22 10:50:22 +02:00
export default SignupContainer;