From 132886f06b05153cfb446e9737ce123483c3a50f Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Fri, 16 Sep 2016 20:34:04 -0300 Subject: [PATCH] Guillermo - add-edit-password-frontend-message [skip ci] --- .../dashboard-edit-profile-page.js | 49 +++++++++++++++++-- .../dashboard-edit-profile-page.scss | 4 ++ client/src/data/languages/en.js | 7 ++- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.js b/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.js index f0586460..10c85f55 100644 --- a/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.js +++ b/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.js @@ -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 {
CHANGE EMAIL + {this.renderMessageEmail()}
Edit password
@@ -32,11 +37,32 @@ class DashboardEditProfilePage extends React.Component { CHANGE PASSWORD + {this.renderMessagePass()} ); } - + renderMessageEmail() { + switch (this.state.messageEmail) { + case 'success': + return {i18n('EMAIL_CHANGED')}; + case 'fail': + return {i18n('EMAIL_EXISTS')}; + default: + return null; + } + + } + renderMessagePass() { + switch (this.state.messagePass) { + case 'success': + return {i18n('PASSWORD_CHANGED')}; + case 'fail': + return {i18n('OLD_PASSWORD_INCORRECT')}; + default: + return null; + } + } onSubmitEditEmail(formState) { ModalContainer.openModal(); } @@ -44,7 +70,7 @@ class DashboardEditProfilePage extends React.Component { onSubmitEditPassword(formState) { ModalContainer.openModal(); } - + callEditEmailAPI(formState){ this.setState({ loadingEmail: true @@ -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; diff --git a/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.scss b/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.scss index 872bab3c..d42e3ec5 100644 --- a/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.scss +++ b/client/src/app/main/dashboard/dashboard-edit-profile/dashboard-edit-profile-page.scss @@ -6,4 +6,8 @@ font-size: 20px; text-align: left; } + &__message{ + margin-top: 20px; + margin-bottom: 20px; + } } \ No newline at end of file diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index c4da923d..9523ca03 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -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' }; \ No newline at end of file