2015-06-20 16:43:18 +02:00
|
|
|
import React from 'react';
|
2016-06-06 14:54:29 +02:00
|
|
|
import Link from 'react-router/es6/Link';
|
2015-09-18 15:40:06 +02:00
|
|
|
|
2015-07-13 16:57:25 +02:00
|
|
|
import SignupForm from './ascribe_forms/form_signup';
|
2015-06-20 16:43:18 +02:00
|
|
|
|
2016-06-08 13:11:16 +02:00
|
|
|
import withContext from './context/with_context';
|
2016-06-07 14:53:48 +02:00
|
|
|
import { whitelabelShape } from './prop_types';
|
|
|
|
|
2016-06-13 14:35:02 +02:00
|
|
|
import { setDocumentTitle } from '../utils/dom';
|
|
|
|
import { getLangText } from '../utils/lang';
|
2015-09-16 23:27:38 +02:00
|
|
|
|
2015-06-20 16:43:18 +02:00
|
|
|
|
2015-06-22 10:50:22 +02:00
|
|
|
let SignupContainer = React.createClass({
|
2015-10-01 11:16:38 +02:00
|
|
|
propTypes: {
|
2016-06-07 14:53:48 +02:00
|
|
|
// Injected through HOCs
|
2016-06-08 14:54:05 +02:00
|
|
|
whitelabel: whitelabelShape.isRequired
|
2015-10-01 11:16:38 +02:00
|
|
|
},
|
|
|
|
|
2015-06-25 12:56:43 +02:00
|
|
|
getInitialState() {
|
2015-07-13 16:57:25 +02:00
|
|
|
return {
|
2015-06-22 10:50:22 +02:00
|
|
|
submitted: false,
|
|
|
|
message: null
|
2015-07-13 16:57:25 +02:00
|
|
|
};
|
2015-06-25 12:56:43 +02:00
|
|
|
},
|
|
|
|
|
2016-01-11 15:14:54 +01:00
|
|
|
handleSuccess(message) {
|
2015-06-22 10:50:22 +02:00
|
|
|
this.setState({
|
|
|
|
submitted: true,
|
|
|
|
message: message
|
|
|
|
});
|
|
|
|
},
|
2015-06-25 12:56:43 +02:00
|
|
|
|
2015-06-20 16:43:18 +02:00
|
|
|
render() {
|
2016-06-08 14:54:05 +02:00
|
|
|
const { whitelabel: { name: whitelabelName } } = this.props;
|
2016-01-11 15:14:54 +01:00
|
|
|
const { message, submitted } = this.state;
|
|
|
|
|
2015-10-13 16:42:40 +02:00
|
|
|
setDocumentTitle(getLangText('Sign up'));
|
|
|
|
|
2016-01-11 15:14:54 +01:00
|
|
|
if (submitted) {
|
2015-06-22 10:50:22 +02:00
|
|
|
return (
|
|
|
|
<div className="ascribe-login-wrapper">
|
|
|
|
<br/>
|
|
|
|
<div className="ascribe-login-text ascribe-login-header">
|
2016-01-11 15:14:54 +01:00
|
|
|
{message}
|
2015-06-22 10:50:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2015-06-20 16:43:18 +02:00
|
|
|
return (
|
|
|
|
<div className="ascribe-login-wrapper">
|
2015-10-01 11:16:38 +02:00
|
|
|
<SignupForm
|
|
|
|
handleSuccess={this.handleSuccess}
|
2016-06-08 14:54:05 +02:00
|
|
|
whitelabelName={whitelabelName} />
|
2015-09-16 23:27:38 +02:00
|
|
|
<div className="ascribe-login-text">
|
2016-03-07 14:04:34 +01:00
|
|
|
{getLangText(`Already a ${whitelabelName || 'ascribe'} user`)}? <Link to="/login">{getLangText('Log in')}...</Link><br/>
|
2015-09-16 23:27:38 +02:00
|
|
|
</div>
|
2015-06-20 16:43:18 +02:00
|
|
|
</div>
|
2015-09-16 23:27:38 +02:00
|
|
|
|
2015-06-20 16:43:18 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-06-08 13:11:16 +02:00
|
|
|
export default withContext(SignupContainer, 'whitelabel');
|