Upstream sync

This commit is contained in:
Senad Uka
2018-05-29 17:02:50 +02:00
parent 3969863cbf
commit 8e52651172
24 changed files with 657 additions and 252 deletions

View File

@@ -17,6 +17,10 @@ import Toggle from 'material-ui/Toggle';
import Snackbar from 'material-ui/Snackbar';
import Instance from '../../../components/Connection';
import Checkbox from 'material-ui/Checkbox';
import ValidationErrorsInfoDialog from '../../../components/Shared/ValidationErrorsInfoDialog';
class SignUp extends React.Component {
constructor(props) {
super(props);
@@ -39,7 +43,8 @@ class SignUp extends React.Component {
"passConfirmation": "",
"organizationType": { name: "", key: "provider", desc: "" },
showValidationErrors: false,
validationErrors: []
validationErrors: [],
agreedTerms:false,
}
this.buttonValidated = this.buttonValidated.bind(this);
@@ -65,7 +70,7 @@ class SignUp extends React.Component {
if (!this.state.first || this.state.first === null || this.state.first === "") validated = false;
if (!this.state.last || this.state.last === null || this.state.last === "") validated = false;
if (!this.state.password_validated || !this.state.pass || this.state.pass === null || this.state.pass === "") validated = false;
if (!this.state.agreedTerms) validated = false;
this.setState(Object.assign(this.state, { validated: validated }));
}
@@ -109,6 +114,11 @@ class SignUp extends React.Component {
this.setState(Object.assign(this.state, { password_validated: this.state.pass === this.state.passConfirmation }));
};
handleChecked = (event, checked) => {
this.setState(Object.assign(this.state, { agreedTerms: checked }));
this.buttonValidated();
};
clickEvent = (event) => {
event.preventDefault();
const state = this;
@@ -144,29 +154,13 @@ class SignUp extends React.Component {
});
}
handleDismiss() {
this.setState(Object.assign(this.state, { showErrorMessage: false }));
handleValidationErrosDialogDismiss() {
this.setState(Object.assign(this.state, {
showValidationErrors: false
}));
}
render() {
let validationErrors = null;
if (this.state.showValidationErrors) {
validationErrors = (
<ul>
{this.state.validationErrors.map(errorMessage => {
const oneValidationMessage = (<li>{errorMessage.message}</li>);
const oneValidationMessageWithTab = (<span><li style={{ marginLeft: 2 + "em" }}>{errorMessage.message}</li></span>);
if (errorMessage.field_name === "password-tab") {
return oneValidationMessageWithTab;
} else {
return oneValidationMessage;
}
})}
</ul>
);
}
return (
<div className="body-inner">
@@ -243,17 +237,21 @@ class SignUp extends React.Component {
</div>
<div className="divider" />
<div className="form-group">
<p className="text-small">By clicking on sign up, you agree to <a href="javascript:;"><i>terms</i></a> and <a href="javascript:;"><i>privacy policy</i></a></p>
<Checkbox
label="Member has consented to terms of use"
checked={this.state.agreedTerms}
onCheck={this.handleChecked}
/>
</div>
<div className="divider" />
<div className="form-group">
{validationErrors}
<p className="text-small">By clicking on sign up, you agree to <a href="javascript:;"><i>terms</i></a> and <a href="javascript:;"><i>privacy policy</i></a></p>
</div>
<ValidationErrorsInfoDialog open={this.state.showValidationErrors} errorMessages={this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)} />
</fieldset>
</form>
</div>
<div className="card-action no-border text-right">
<a href="#/login" className="color-gray-light">Login</a>
<RaisedButton
label="Sign up"
primary={true}