Guillermo - add-edit-password-frontend-message [skip ci]
This commit is contained in:
parent
1487df9a93
commit
132886f06b
|
@ -8,12 +8,16 @@ import FormField from 'core-components/form-field';
|
|||
import SubmitButton from 'core-components/submit-button';
|
||||
import ModalContainer from 'app/modal-container';
|
||||
import AreYouSure from 'app-components/are-you-sure';
|
||||
import Message from 'core-components/message';
|
||||
import i18n from 'lib-app/i18n';
|
||||
|
||||
class DashboardEditProfilePage extends React.Component {
|
||||
|
||||
state= {
|
||||
loadingEmail: false,
|
||||
loadingPass: false
|
||||
loadingPass: false,
|
||||
messageEmail:'',
|
||||
messagePass:''
|
||||
};
|
||||
|
||||
|
||||
|
@ -25,6 +29,7 @@ class DashboardEditProfilePage extends React.Component {
|
|||
<Form loading={this.state.loadingEmail} onSubmit={this.onSubmitEditEmail.bind(this)}>
|
||||
<FormField name="newEmail" label="New Email" field="input" validation="EMAIL" fieldProps={{size:'large'}} required/>
|
||||
<SubmitButton>CHANGE EMAIL</SubmitButton>
|
||||
{this.renderMessageEmail()}
|
||||
</Form>
|
||||
<div className="edit-profile-page__title">Edit password</div>
|
||||
<Form loading={this.state.loadingPass} onSubmit={this.onSubmitEditPassword.bind(this)}>
|
||||
|
@ -32,11 +37,32 @@ class DashboardEditProfilePage extends React.Component {
|
|||
<FormField name="password" label="New Password" field="input" validation="PASSWORD" fieldProps={{password:true ,size:'large'}} required/>
|
||||
<FormField name="repeatNewPassword" label="Repeat New Password" field="input" validation="REPEAT_PASSWORD" fieldProps={{password:true ,size:'large'}} required/>
|
||||
<SubmitButton>CHANGE PASSWORD</SubmitButton>
|
||||
{this.renderMessagePass()}
|
||||
</Form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
renderMessageEmail() {
|
||||
switch (this.state.messageEmail) {
|
||||
case 'success':
|
||||
return <Message className="edit-profile-page__message" type="success">{i18n('EMAIL_CHANGED')}</Message>;
|
||||
case 'fail':
|
||||
return <Message className="edit-profile-page__message" type="error">{i18n('EMAIL_EXISTS')}</Message>;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
renderMessagePass() {
|
||||
switch (this.state.messagePass) {
|
||||
case 'success':
|
||||
return <Message className="edit-profile-page__message" type="success">{i18n('PASSWORD_CHANGED')}</Message>;
|
||||
case 'fail':
|
||||
return <Message className="edit-profile-page__message" type="error">{i18n('OLD_PASSWORD_INCORRECT')}</Message>;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
onSubmitEditEmail(formState) {
|
||||
ModalContainer.openModal(<AreYouSure onYes={this.callEditEmailAPI.bind(this, formState)}/>);
|
||||
}
|
||||
|
@ -56,8 +82,14 @@ class DashboardEditProfilePage extends React.Component {
|
|||
}
|
||||
}).then(function () {
|
||||
this.setState({
|
||||
loadingEmail: false
|
||||
loadingEmail: false,
|
||||
messageEmail: "success"
|
||||
});
|
||||
}.bind(this)).catch(function (){
|
||||
this.setState({
|
||||
loadingEmail: false,
|
||||
messageEmail: 'fail'
|
||||
})
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
|
@ -73,10 +105,17 @@ class DashboardEditProfilePage extends React.Component {
|
|||
}
|
||||
}).then(function () {
|
||||
this.setState({
|
||||
loadingPass: false
|
||||
loadingPass: false,
|
||||
messagePass: "success"
|
||||
});
|
||||
}.bind(this)).catch(function (){
|
||||
this.setState({
|
||||
loadingPass: false,
|
||||
messagePass: 'fail'
|
||||
})
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default DashboardEditProfilePage;
|
||||
|
|
|
@ -6,4 +6,8 @@
|
|||
font-size: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
&__message{
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
|
@ -51,6 +51,9 @@ export default {
|
|||
'SIGNUP_SUCCESS': 'You have registered successfully in our support system.',
|
||||
'TICKET_SENT': 'Ticket has been created successfully.',
|
||||
'VALID_RECOVER': 'Password recovered successfully',
|
||||
'EMAIL_EXISTS': 'Email already exists, please try to log in or recover password',
|
||||
'ARE_YOU_SURE': 'Are you sure?'
|
||||
'EMAIL_EXISTS': 'Email already exists',
|
||||
'ARE_YOU_SURE': 'Are you sure?',
|
||||
'EMAIL_CHANGED': 'Email has been changed successfully',
|
||||
'PASSWORD_CHANGED': 'Password has been changed successfully',
|
||||
'OLD_PASSWORD_INCORRECT': 'Old password is incorrect'
|
||||
};
|
Loading…
Reference in New Issue