[DEV-147] Add resend user-staff invitation (#1069)
* add resend user-staff invitation * fix width issue * fix styles issues * fix code blank spaces * improve coding * improve coding
This commit is contained in:
parent
645e64532b
commit
f045c08b2e
|
@ -53,6 +53,8 @@ class StaffEditor extends React.Component {
|
|||
departments: this.getUserDepartments(),
|
||||
closedTicketsShown: false,
|
||||
sendEmailOnNewTicket: this.props.sendEmailOnNewTicket,
|
||||
loadingReInviteStaff: false,
|
||||
reInviteStaff: "",
|
||||
rawForm: {
|
||||
dateRange: statsUtils.getInitialDateRange(),
|
||||
departments: [],
|
||||
|
@ -152,6 +154,8 @@ class StaffEditor extends React.Component {
|
|||
<div className="col-md-8">
|
||||
<div className="staff-editor__activity">
|
||||
<div className="staff-editor__activity-title">{i18n('ACTIVITY')}</div>
|
||||
{myData.lastLogin ? null : this.renderReInviteStaffButton()}
|
||||
{this.renderReInviteStaffMessage()}
|
||||
{this.renderStaffStats()}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -162,6 +166,56 @@ class StaffEditor extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
renderReInviteStaffButton () {
|
||||
const inviteStaffButtonContent = <div><Icon name="user-plus" /> {i18n('INVITE_STAFF')}</div>;
|
||||
|
||||
return (
|
||||
<div className="staff-editor__staff-invitation-content">
|
||||
{i18n('USER_UNLOGGED_IN')}
|
||||
<Button onClick={this.onReInviteStaffButton.bind(this)} size="medium" type="secondary" className="staff-editor__staff-invitation-button" disabled={this.state.loadingReInviteStaff}>
|
||||
{this.state.loadingReInviteStaff ? <Loading /> : inviteStaffButtonContent}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderReInviteStaffMessage() {
|
||||
const { reInviteStaff } = this.state;
|
||||
|
||||
if (reInviteStaff) {
|
||||
return (
|
||||
<Message className="staff-editor__staff-invitation-message" type={reInviteStaff} leftAligned>
|
||||
{(reInviteStaff === "success") ? i18n('RESEND_STAFF_INVITATION_SUCCESS') : i18n('RESEND_STAFF_INVITATION_FAIL')}
|
||||
</Message>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
onReInviteStaffButton() {
|
||||
this.setState({
|
||||
loadingReInviteStaff: true
|
||||
})
|
||||
|
||||
API.call({
|
||||
path: '/staff/resend-invite-staff',
|
||||
data: {
|
||||
email: this.props.email
|
||||
}
|
||||
}).then(() => {
|
||||
this.setState({
|
||||
loadingReInviteStaff: false,
|
||||
reInviteStaff: 'success'
|
||||
})
|
||||
}).catch(() => {
|
||||
this.setState({
|
||||
loadingReInviteStaff: false,
|
||||
reInviteStaff: 'error'
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
renderMessage() {
|
||||
const { message } = this.state;
|
||||
let messageType = (message === 'FAIL') ? 'error' : 'success';
|
||||
|
@ -317,6 +371,7 @@ class StaffEditor extends React.Component {
|
|||
departmentIndexes.push(index);
|
||||
}
|
||||
});
|
||||
|
||||
return departmentIndexes;
|
||||
}
|
||||
|
||||
|
|
|
@ -213,11 +213,23 @@
|
|||
}
|
||||
|
||||
&__activity {
|
||||
|
||||
&-title {
|
||||
margin-bottom: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
&__staff {
|
||||
&-invitation-content {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
&-invitation-button {
|
||||
min-width: 180px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,6 +244,9 @@ export default {
|
|||
'RESEND_EMAIL_VERIFICATION': 'Resend e-mail verification',
|
||||
'RESEND_EMAIL_VERIFICATION_SUCCESS': 'The mail was sent successfully',
|
||||
'RESEND_EMAIL_VERIFICATION_FAIL': 'An error has occurred',
|
||||
'USER_UNLOGGED_IN': 'This user has never logged in before',
|
||||
'RESEND_STAFF_INVITATION_SUCCESS': 'The invitation was sent successfully',
|
||||
'RESEND_STAFF_INVITATION_FAIL': 'The invitation could not be sent',
|
||||
|
||||
//ACTIVITIES
|
||||
'ACTIVITY_COMMENT': 'commented ticket',
|
||||
|
|
Loading…
Reference in New Issue