From 4af174dffb593e223d485a8a521cd6c1eb0ef603 Mon Sep 17 00:00:00 2001 From: vrde Date: Mon, 13 Jul 2015 19:53:16 +0200 Subject: [PATCH] Work on signup/login --- js/components/ascribe_forms/form_login.js | 17 +++++-- js/components/ascribe_forms/form_signup.js | 13 +++++- js/components/login_container.js | 1 - js/components/password_reset_container.js | 4 +- .../prize/components/login_container.js | 27 +++++++++++ .../prize/components/signup_container.js | 45 +++++++++++++++++++ js/components/whitelabel/prize/routes.js | 8 +++- 7 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 js/components/whitelabel/prize/components/login_container.js create mode 100644 js/components/whitelabel/prize/components/signup_container.js diff --git a/js/components/ascribe_forms/form_login.js b/js/components/ascribe_forms/form_login.js index fbc2e80e..60d45f61 100644 --- a/js/components/ascribe_forms/form_login.js +++ b/js/components/ascribe_forms/form_login.js @@ -11,6 +11,7 @@ import UserActions from '../../actions/user_actions'; import Form from './form'; import Property from './property'; +import FormPropertyHeader from './form_property_header'; import apiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; @@ -19,20 +20,25 @@ import { getLangText } from '../../utils/lang_utils'; let LoginForm = React.createClass({ + propTypes: { + headerMessage: React.PropTypes.string, + submitMessage: React.PropTypes.string, redirectOnLoggedIn: React.PropTypes.bool, redirectOnLoginSuccess: React.PropTypes.bool }, + mixins: [Router.Navigation], + getDefaultProps() { return { + headerMessage: 'Enter ascribe', + submitMessage: 'Log in', redirectOnLoggedIn: true, redirectOnLoginSuccess: true }; }, - mixins: [Router.Navigation], - getInitialState() { return UserStore.getState(); }, @@ -80,6 +86,7 @@ let LoginForm = React.createClass({ render() { return (
- {getLangText('Enter')} ascribe + {getLangText(this.props.submitMessage)} } spinner={ }> + +

{getLangText(this.props.headerMessage)}

+
@@ -114,7 +124,6 @@ let LoginForm = React.createClass({ name="password" required/> -
); } diff --git a/js/components/ascribe_forms/form_signup.js b/js/components/ascribe_forms/form_signup.js index 258a3923..3477769c 100644 --- a/js/components/ascribe_forms/form_signup.js +++ b/js/components/ascribe_forms/form_signup.js @@ -21,11 +21,20 @@ import apiUrls from '../../constants/api_urls'; let SignupForm = React.createClass({ propTypes: { + headerMessage: React.PropTypes.string, + submitMessage: React.PropTypes.string, handleSuccess: React.PropTypes.func }, mixins: [Router.Navigation], + getDefaultProps() { + return { + headerMessage: 'Welcome to ascribe', + submitMessage: 'Sign up' + }; + }, + getInitialState() { return UserStore.getState(); }, @@ -72,7 +81,7 @@ let SignupForm = React.createClass({ getFormData={this.getFormData} buttons={ } spinner={ }> -

{getLangText('Welcome to ascribe')}

+

{getLangText(this.props.headerMessage)}

-
diff --git a/js/components/password_reset_container.js b/js/components/password_reset_container.js index 5ab258b0..4feba36a 100644 --- a/js/components/password_reset_container.js +++ b/js/components/password_reset_container.js @@ -39,7 +39,7 @@ let PasswordResetContainer = React.createClass({ return (
- {getLangText('Reset your ascribe password')} + {getLangText('Reset your password')}
@@ -157,4 +157,4 @@ let PasswordResetForm = React.createClass({ } }); -export default PasswordResetContainer; \ No newline at end of file +export default PasswordResetContainer; diff --git a/js/components/whitelabel/prize/components/login_container.js b/js/components/whitelabel/prize/components/login_container.js new file mode 100644 index 00000000..cab80774 --- /dev/null +++ b/js/components/whitelabel/prize/components/login_container.js @@ -0,0 +1,27 @@ +'use strict'; + +import React from 'react'; +import Router from 'react-router'; + +import LoginForm from '../../../ascribe_forms/form_login'; + +let Link = Router.Link; + + +let LoginContainer = React.createClass({ + render() { + return ( +
+ +
+ I'm not a user Sign up...
+ I forgot my password Rescue me... +
+
+ ); + } +}); + + + +export default LoginContainer; diff --git a/js/components/whitelabel/prize/components/signup_container.js b/js/components/whitelabel/prize/components/signup_container.js new file mode 100644 index 00000000..da33a9a4 --- /dev/null +++ b/js/components/whitelabel/prize/components/signup_container.js @@ -0,0 +1,45 @@ +'use strict'; + +import React from 'react'; +import SignupForm from '../../../ascribe_forms/form_signup'; + + +let SignupContainer = React.createClass({ + getInitialState() { + return { + submitted: false, + message: null + }; + }, + + handleSuccess(message){ + this.setState({ + submitted: true, + message: message + }); + }, + + render() { + if (this.state.submitted){ + return ( +
+
+
+ {this.state.message} +
+
+ ); + } + return ( +
+ +
+ ); + } +}); + + +export default SignupContainer; diff --git a/js/components/whitelabel/prize/routes.js b/js/components/whitelabel/prize/routes.js index 634fc531..372de33d 100644 --- a/js/components/whitelabel/prize/routes.js +++ b/js/components/whitelabel/prize/routes.js @@ -4,6 +4,9 @@ import React from 'react'; import Router from 'react-router'; import Landing from './components/landing'; +import LoginContainer from './components/login_container'; +import SignupContainer from './components/signup_container'; +import PasswordResetContainer from '../../../components/password_reset_container'; import App from './app'; import AppConstants from '../../../constants/application_constants'; @@ -16,8 +19,9 @@ function getRoutes(commonRoutes) { return ( - - {commonRoutes} + + + ); }