Compare commits
1 Commits
password-v
...
show-error
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
768afa475b |
@@ -33,68 +33,11 @@ import Instance from '../../../../../../../components/Connection';
|
||||
import Checkbox from 'material-ui/Checkbox';
|
||||
import Popover from 'material-ui/Popover';
|
||||
|
||||
const ADDRESS_TYPE_HOME = "home";
|
||||
|
||||
let DateTimeFormat;
|
||||
|
||||
|
||||
DateTimeFormat = global.Intl.DateTimeFormat;
|
||||
|
||||
export class ValidationErrorsInfoDialog extends React.Component {
|
||||
|
||||
state = {
|
||||
open: this.props.open,
|
||||
}
|
||||
|
||||
componentWillReceiveProps(newProps){
|
||||
this.setState({open: newProps.open});
|
||||
}
|
||||
|
||||
handleOpen = () => {
|
||||
this.setState({ open: true });
|
||||
};
|
||||
|
||||
handleClose = () => {
|
||||
this.setState({ open: false });
|
||||
this.props.onDismiss();
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
const actions = [
|
||||
<FlatButton
|
||||
label="Dismiss"
|
||||
primary={true}
|
||||
keyboardFocused={true}
|
||||
onClick={this.handleClose}
|
||||
/>,
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Dialog
|
||||
title="Erors"
|
||||
actions={actions}
|
||||
modal={false}
|
||||
open={this.state.open}
|
||||
onRequestClose={this.handleClose}
|
||||
overlayStyle={{backgroundColor: 'transparent'}}
|
||||
>
|
||||
{this.props.errorMessages.map(errorMessage => {
|
||||
return (
|
||||
<div>
|
||||
<a>{errorMessage.message}</a>
|
||||
<br/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class DialogExampleSimple extends React.Component {
|
||||
state = {
|
||||
open: true,
|
||||
@@ -455,8 +398,6 @@ class VerticalNonLinear extends React.Component {
|
||||
},
|
||||
return_time: new Date(),
|
||||
pickupTimeHide: false,
|
||||
showValidationErrors:false,
|
||||
validationErrors:[],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -471,16 +412,6 @@ class VerticalNonLinear extends React.Component {
|
||||
if (user.useruuid !== loggedUser.useruuid) {
|
||||
Instance.getRawConn().get(`/v1/nemt/users/member/${user.useruuid}`)
|
||||
.then(function (res) {
|
||||
let userHomeAddress = null;
|
||||
res.data.addresses.forEach(address => {
|
||||
if (address.address_type === ADDRESS_TYPE_HOME) {
|
||||
userHomeAddress = address;
|
||||
}
|
||||
});
|
||||
if (userHomeAddress != null) {
|
||||
userHomeAddress.name = "Home";
|
||||
state.handlePickupChanged(userHomeAddress, state);
|
||||
}
|
||||
state.setState(Object.assign(state.state, { user: res.data, showUserSelection: true, userSelectionText: `${res.data.member} - ${res.data.name}` }));
|
||||
})
|
||||
.catch(err => {
|
||||
@@ -567,15 +498,7 @@ class VerticalNonLinear extends React.Component {
|
||||
Instance.getRawConn().post('/v1/nemt/rides', requestRide).then(function (res) {
|
||||
self.handleRequestClose(self);
|
||||
window.location.href = '/#/app/page/map/' + res.data.ride_uuid;
|
||||
}).catch(error => {
|
||||
if (error.response.status === 422){
|
||||
//Unprocessable Entity (validation failed)
|
||||
self.setState(Object.assign(self.state, {
|
||||
showValidationErrors:true,
|
||||
validationErrors:error.response.data.data
|
||||
}));
|
||||
}
|
||||
});
|
||||
}).catch(console.error);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -862,12 +785,6 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
}
|
||||
|
||||
handleValidationErrosDialogDismiss(){
|
||||
this.setState(Object.assign(this.state, {
|
||||
showValidationErrors:false
|
||||
}));
|
||||
}
|
||||
|
||||
render() {
|
||||
// const { stepIndex } = this.state;
|
||||
this.getLocation();
|
||||
@@ -906,17 +823,7 @@ class VerticalNonLinear extends React.Component {
|
||||
|
||||
if (this.state.showUserSelection && this.state.users.length > 0) {
|
||||
const handleAutocomplete = (u) => {
|
||||
let userHomeAddress = null;
|
||||
u.addresses.forEach(address => {
|
||||
if (address.address_type === ADDRESS_TYPE_HOME) {
|
||||
userHomeAddress = address;
|
||||
}
|
||||
});
|
||||
if (userHomeAddress != null) {
|
||||
userHomeAddress.name = "Home";
|
||||
state.handlePickupChanged(userHomeAddress,state);
|
||||
}
|
||||
state.setState(Object.assign(state.state, { user: u, userSelectionText: u.userdata }));
|
||||
state.setState(Object.assign(state.state, { user: u, userSelectionText: u.userdata }));
|
||||
}
|
||||
const datasourceConfig = { text: 'userdata', value: 'useruuid' }
|
||||
userSelection = (
|
||||
@@ -941,8 +848,6 @@ class VerticalNonLinear extends React.Component {
|
||||
<div className="box-body padding-xs">
|
||||
|
||||
<div style={{ maxWidth: 380, margin: 'auto' }}>
|
||||
<ValidationErrorsInfoDialog open = {this.state.showValidationErrors} errorMessages = {this.state.validationErrors} onDismiss={this.handleValidationErrosDialogDismiss.bind(this)}/>
|
||||
|
||||
<Stepper
|
||||
activeStep={this.state.stepIndex}
|
||||
linear={false}
|
||||
|
||||
@@ -650,7 +650,7 @@ class Organization extends React.Component {
|
||||
open={this.state.showErrorMessage}
|
||||
onRequestClose={this.handleDialogDismiss.bind(this)}
|
||||
>
|
||||
{this.state.errorMessage}
|
||||
{this.state.message}
|
||||
</Dialog>
|
||||
<Main organization={this.state.organization}
|
||||
onAddressAdded={this.handleAddressAdded} onAddressRemoved={this.handleAddressRemoved}
|
||||
|
||||
@@ -47,9 +47,7 @@ class SignUp extends React.Component {
|
||||
"role": { name: "", key: "SP", desc: "" },
|
||||
"profiles": [],
|
||||
"types": [],
|
||||
"organizations": [],
|
||||
showValidationErrors : false,
|
||||
validationErrors: []
|
||||
"organizations": []
|
||||
}
|
||||
|
||||
this.buttonValidated = this.buttonValidated.bind(this);
|
||||
@@ -228,42 +226,12 @@ class SignUp extends React.Component {
|
||||
localStorage.removeItem('loggedUser');
|
||||
location.href = '/#/login';
|
||||
}).catch(function (err) {
|
||||
if (err.response.status === 422){
|
||||
//Unprocessable Entity (validation failed)
|
||||
state.setState(Object.assign(state.state, {
|
||||
showValidationErrors:true,
|
||||
validationErrors:err.response.data.data
|
||||
}));
|
||||
}else{
|
||||
alert('Error to log in: ' + err.message);
|
||||
}
|
||||
alert('Error to log in: ' + err.message);
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
handleDismiss(){
|
||||
this.setState(Object.assign(this.state, { showErrorMessage: 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">
|
||||
|
||||
@@ -366,10 +334,6 @@ class SignUp extends React.Component {
|
||||
<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>
|
||||
</div>
|
||||
<div className="divider" />
|
||||
<div className="form-group">
|
||||
{validationErrors}
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user