Merged in FRONT-35-edit--profile-form (pull request #50)
FRONT-35 edit profile form
This commit is contained in:
commit
98e9c65890
client/src
app/main/dashboard
dashboard-edit-profile
dashboard-list-tickets
data
|
@ -1,14 +1,121 @@
|
|||
import React from 'react';
|
||||
|
||||
import API from 'lib-app/api-call';
|
||||
|
||||
import Header from 'core-components/header';
|
||||
import Form from 'core-components/form';
|
||||
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,
|
||||
messageEmail:'',
|
||||
messagePass:''
|
||||
};
|
||||
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
DASHBOARD EDIT PROFILE
|
||||
<div className="edit-profile-page">
|
||||
<Header title="Edit Profile" description="what ever" />
|
||||
<div className="edit-profile-page__title">Edit Email</div>
|
||||
<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)}>
|
||||
<FormField name="oldPassword" label="Old 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/>
|
||||
<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)}/>);
|
||||
}
|
||||
|
||||
onSubmitEditPassword(formState) {
|
||||
ModalContainer.openModal(<AreYouSure onYes={this.callEditPassAPI.bind(this, formState)}/>);
|
||||
}
|
||||
|
||||
callEditEmailAPI(formState){
|
||||
this.setState({
|
||||
loadingEmail: true
|
||||
});
|
||||
API.call({
|
||||
path: "/user/edit-email",
|
||||
data: {
|
||||
newEmail: formState.newEmail
|
||||
}
|
||||
}).then(function () {
|
||||
this.setState({
|
||||
loadingEmail: false,
|
||||
messageEmail: "success"
|
||||
});
|
||||
}.bind(this)).catch(function (){
|
||||
this.setState({
|
||||
loadingEmail: false,
|
||||
messageEmail: 'fail'
|
||||
})
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
callEditPassAPI(formState){
|
||||
this.setState({
|
||||
loadingPass: true
|
||||
});
|
||||
API.call({
|
||||
path: "/user/edit-password",
|
||||
data: {
|
||||
oldPassword: formState.oldPassword,
|
||||
newPassword: formState.password
|
||||
}
|
||||
}).then(function () {
|
||||
this.setState({
|
||||
loadingPass: false,
|
||||
messagePass: "success"
|
||||
});
|
||||
}.bind(this)).catch(function (){
|
||||
this.setState({
|
||||
loadingPass: false,
|
||||
messagePass: 'fail'
|
||||
})
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default DashboardEditProfilePage;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
@import '../../../../scss/vars';
|
||||
|
||||
.edit-profile-page {
|
||||
&__title {
|
||||
color: $dark-grey;
|
||||
font-size: 20px;
|
||||
text-align: left;
|
||||
}
|
||||
&__message{
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import i18n from 'lib-app/i18n';
|
|||
import Header from 'core-components/header';
|
||||
import Table from 'core-components/table';
|
||||
import Button from 'core-components/button';
|
||||
import Tooltip from 'core-components/tooltip';
|
||||
|
||||
class DashboardListTicketsPage extends React.Component {
|
||||
static propTypes = {
|
||||
|
@ -58,7 +59,11 @@ class DashboardListTicketsPage extends React.Component {
|
|||
let titleText = (ticket.unread) ? ticket.title + ' (1)' : ticket.title;
|
||||
|
||||
return {
|
||||
number: '#' + ticket.ticketNumber,
|
||||
number: (
|
||||
<Tooltip content="hola">
|
||||
{'#' + ticket.ticketNumber}
|
||||
</Tooltip>
|
||||
),
|
||||
title: (
|
||||
<Button className="dashboard-ticket-list__title-link" type="clean" route={{to: '/dashboard/ticket/' + ticket.ticketNumber}}>
|
||||
{titleText}
|
||||
|
|
|
@ -104,6 +104,26 @@ module.exports = [
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/edit-email',
|
||||
time: 1000,
|
||||
response: function () {
|
||||
return {
|
||||
status: 'success',
|
||||
data: {}
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/edit-password',
|
||||
time: 1000,
|
||||
response: function () {
|
||||
return {
|
||||
status: 'success',
|
||||
data: {}
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/get',
|
||||
time: 100,
|
||||
|
|
|
@ -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