mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Change SignupForm for loading UserStore from top level app
This commit is contained in:
parent
1c4ca0d152
commit
d867a3d9c1
@ -44,8 +44,10 @@ let LoginForm = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
const { headerMessage, submitMessage, location: { query: { email: emailQuery } } } = this.props;
|
||||
console.log(emailQuery);
|
||||
const {
|
||||
headerMessage,
|
||||
location: { query: { email: emailQuery } },
|
||||
submitMessage } = this.props;
|
||||
|
||||
return (
|
||||
<Form
|
||||
|
@ -3,9 +3,6 @@
|
||||
import React from 'react';
|
||||
import { History } from 'react-router';
|
||||
|
||||
import UserStore from '../../stores/user_store';
|
||||
import UserActions from '../../actions/user_actions';
|
||||
|
||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||
|
||||
@ -24,8 +21,12 @@ let SignupForm = React.createClass({
|
||||
headerMessage: React.PropTypes.string,
|
||||
submitMessage: React.PropTypes.string,
|
||||
handleSuccess: React.PropTypes.func,
|
||||
children: React.PropTypes.element,
|
||||
location: React.PropTypes.object
|
||||
location: React.PropTypes.object,
|
||||
children: React.PropTypes.oneOfType([
|
||||
React.PropTypes.arrayOf(React.PropTypes.element),
|
||||
React.PropTypes.element,
|
||||
React.PropTypes.string
|
||||
])
|
||||
},
|
||||
|
||||
mixins: [History],
|
||||
@ -37,27 +38,11 @@ let SignupForm = React.createClass({
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return UserStore.getState();
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
UserStore.listen(this.onChange);
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
UserStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
this.setState(state);
|
||||
},
|
||||
|
||||
handleSuccess(response) {
|
||||
if (response.user) {
|
||||
let notification = new GlobalNotificationModel(getLangText('Sign up successful'), 'success', 50000);
|
||||
const notification = new GlobalNotificationModel(getLangText('Sign up successful'), 'success', 50000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
||||
|
||||
// Refactor this to its own component
|
||||
this.props.handleSuccess(getLangText('We sent an email to your address') + ' ' + response.user.email + ', ' + getLangText('please confirm') + '.');
|
||||
} else {
|
||||
@ -66,18 +51,20 @@ let SignupForm = React.createClass({
|
||||
},
|
||||
|
||||
getFormData() {
|
||||
if (this.props.location.query.token){
|
||||
return {token: this.props.location.query.token};
|
||||
}
|
||||
return null;
|
||||
const { token } = this.props.location.query;
|
||||
return token ? { token } : null;
|
||||
},
|
||||
|
||||
render() {
|
||||
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') + '!';
|
||||
const {
|
||||
children,
|
||||
headerMessage,
|
||||
location: { query: { email: emailQuery } },
|
||||
submitMessage } = this.props;
|
||||
|
||||
let email = this.props.location.query.email || null;
|
||||
const 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') + '!';
|
||||
|
||||
return (
|
||||
<Form
|
||||
@ -88,15 +75,16 @@ let SignupForm = React.createClass({
|
||||
handleSuccess={this.handleSuccess}
|
||||
buttons={
|
||||
<button type="submit" className="btn btn-default btn-wide">
|
||||
{this.props.submitMessage}
|
||||
</button>}
|
||||
{submitMessage}
|
||||
</button>
|
||||
}
|
||||
spinner={
|
||||
<span className="btn btn-default btn-wide btn-spinner">
|
||||
<AscribeSpinner color="dark-blue" size="md" />
|
||||
</span>
|
||||
}>
|
||||
}>
|
||||
<div className="ascribe-form-header">
|
||||
<h3>{this.props.headerMessage}</h3>
|
||||
<h3>{headerMessage}</h3>
|
||||
</div>
|
||||
<Property
|
||||
name='email'
|
||||
@ -128,7 +116,7 @@ let SignupForm = React.createClass({
|
||||
autoComplete="on"
|
||||
required/>
|
||||
</Property>
|
||||
{this.props.children}
|
||||
{children}
|
||||
<Property
|
||||
name="terms"
|
||||
className="ascribe-property-collapsible-toggle"
|
||||
|
Loading…
Reference in New Issue
Block a user