Guillermo - add-edit-password-frontend-message [skip ci]

This commit is contained in:
AntonyAntonio 2016-09-16 20:34:04 -03:00
parent 1487df9a93
commit 132886f06b
3 changed files with 53 additions and 7 deletions

View File

@ -8,12 +8,16 @@ import FormField from 'core-components/form-field';
import SubmitButton from 'core-components/submit-button'; import SubmitButton from 'core-components/submit-button';
import ModalContainer from 'app/modal-container'; import ModalContainer from 'app/modal-container';
import AreYouSure from 'app-components/are-you-sure'; 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 { class DashboardEditProfilePage extends React.Component {
state= { state= {
loadingEmail: false, 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)}> <Form loading={this.state.loadingEmail} onSubmit={this.onSubmitEditEmail.bind(this)}>
<FormField name="newEmail" label="New Email" field="input" validation="EMAIL" fieldProps={{size:'large'}} required/> <FormField name="newEmail" label="New Email" field="input" validation="EMAIL" fieldProps={{size:'large'}} required/>
<SubmitButton>CHANGE EMAIL</SubmitButton> <SubmitButton>CHANGE EMAIL</SubmitButton>
{this.renderMessageEmail()}
</Form> </Form>
<div className="edit-profile-page__title">Edit password</div> <div className="edit-profile-page__title">Edit password</div>
<Form loading={this.state.loadingPass} onSubmit={this.onSubmitEditPassword.bind(this)}> <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="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/> <FormField name="repeatNewPassword" label="Repeat New Password" field="input" validation="REPEAT_PASSWORD" fieldProps={{password:true ,size:'large'}} required/>
<SubmitButton>CHANGE PASSWORD</SubmitButton> <SubmitButton>CHANGE PASSWORD</SubmitButton>
{this.renderMessagePass()}
</Form> </Form>
</div> </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) { onSubmitEditEmail(formState) {
ModalContainer.openModal(<AreYouSure onYes={this.callEditEmailAPI.bind(this, formState)}/>); ModalContainer.openModal(<AreYouSure onYes={this.callEditEmailAPI.bind(this, formState)}/>);
} }
@ -56,8 +82,14 @@ class DashboardEditProfilePage extends React.Component {
} }
}).then(function () { }).then(function () {
this.setState({ this.setState({
loadingEmail: false loadingEmail: false,
messageEmail: "success"
}); });
}.bind(this)).catch(function (){
this.setState({
loadingEmail: false,
messageEmail: 'fail'
})
}.bind(this)); }.bind(this));
} }
@ -73,10 +105,17 @@ class DashboardEditProfilePage extends React.Component {
} }
}).then(function () { }).then(function () {
this.setState({ this.setState({
loadingPass: false loadingPass: false,
messagePass: "success"
}); });
}.bind(this)).catch(function (){
this.setState({
loadingPass: false,
messagePass: 'fail'
})
}.bind(this)); }.bind(this));
} }
} }
export default DashboardEditProfilePage; export default DashboardEditProfilePage;

View File

@ -6,4 +6,8 @@
font-size: 20px; font-size: 20px;
text-align: left; text-align: left;
} }
&__message{
margin-top: 20px;
margin-bottom: 20px;
}
} }

View File

@ -51,6 +51,9 @@ export default {
'SIGNUP_SUCCESS': 'You have registered successfully in our support system.', 'SIGNUP_SUCCESS': 'You have registered successfully in our support system.',
'TICKET_SENT': 'Ticket has been created successfully.', 'TICKET_SENT': 'Ticket has been created successfully.',
'VALID_RECOVER': 'Password recovered successfully', 'VALID_RECOVER': 'Password recovered successfully',
'EMAIL_EXISTS': 'Email already exists, please try to log in or recover password', 'EMAIL_EXISTS': 'Email already exists',
'ARE_YOU_SURE': 'Are you sure?' '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'
}; };