diff --git a/client/src/app/main/dashboard/dashboard-create-ticket/create-ticket-form.js b/client/src/app/main/dashboard/dashboard-create-ticket/create-ticket-form.js
index 827fc161..643879ec 100644
--- a/client/src/app/main/dashboard/dashboard-create-ticket/create-ticket-form.js
+++ b/client/src/app/main/dashboard/dashboard-create-ticket/create-ticket-form.js
@@ -17,6 +17,12 @@ import FormField from 'core-components/form-field';
import SubmitButton from 'core-components/submit-button';
import Message from 'core-components/message';
+const DEFAULT_CREATE_TICKET_FORM_VALUE = {
+ title: '',
+ email: '',
+ name: ''
+};
+
class CreateTicketForm extends React.Component {
static propTypes = {
@@ -34,23 +40,15 @@ class CreateTicketForm extends React.Component {
loading: false,
message: null,
form: {
- title: '',
+ ...DEFAULT_CREATE_TICKET_FORM_VALUE,
content: TextEditor.createEmpty(),
departmentIndex: getPublicDepartmentIndexFromDepartmentId(this.props.defaultDepartmentId, SessionStore.getDepartments()),
- email: '',
- name: '',
language: this.props.language
}
};
render() {
- const {
- userLogged,
- isDefaultDepartmentLocked,
- isStaff,
- onlyOneSupportedLanguage,
- allowAttachments
- } = this.props;
+ const { userLogged, isDefaultDepartmentLocked, isStaff, onlyOneSupportedLanguage, allowAttachments } = this.props;
return (
@@ -118,7 +116,7 @@ class CreateTicketForm extends React.Component {
renderMessage() {
switch (this.state.message) {
case 'success':
- return
{i18n('TICKET_SENT')};
+ return this.props.userLogged ?
{i18n('TICKET_SENT')} : null;
case 'fail':
return
{i18n('TICKET_SENT_ERROR')};
default:
@@ -127,10 +125,7 @@ class CreateTicketForm extends React.Component {
}
getFormProps() {
- const {
- loading,
- form
- } = this.state;
+ const { loading, form } = this.state;
return {
loading,
@@ -161,16 +156,26 @@ class CreateTicketForm extends React.Component {
}
}
- onTicketSuccess(email, result) {
- const { onSuccess } = this.props;
+ onTicketSuccess() {
+ const { onSuccess, userLogged, language } = this.props;
+ const { form } = this.state;
const message = 'success';
this.setState(
{
loading: false,
- message
+ message,
+ form: !userLogged ?
+ {
+ ...form,
+ ...DEFAULT_CREATE_TICKET_FORM_VALUE,
+ content: TextEditor.createEmpty(),
+ departmentIndex: getPublicDepartmentIndexFromDepartmentId(this.props.defaultDepartmentId, SessionStore.getDepartments()),
+ language
+ } :
+ form
},
- () => {onSuccess && onSuccess(result, email, message);}
+ () => {onSuccess && onSuccess(message);}
);
}
@@ -184,6 +189,7 @@ class CreateTicketForm extends React.Component {
export default connect((store) => {
const { language, supportedLanguages } = store.config;
+
return {
language: _.includes(supportedLanguages, language) ? language : supportedLanguages[0],
onlyOneSupportedLanguage: supportedLanguages.length == 1 ? true : false,
diff --git a/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.js b/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.js
index 47f05ba6..b62d7176 100644
--- a/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.js
+++ b/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.js
@@ -1,12 +1,15 @@
import React from 'react';
import classNames from 'classnames';
import {connect} from 'react-redux';
-import history from 'lib-app/history';
+import queryString from 'query-string';
+
+import history from 'lib-app/history';
+import i18n from 'lib-app/i18n';
-import SessionActions from 'actions/session-actions';
import CreateTicketForm from 'app/main/dashboard/dashboard-create-ticket/create-ticket-form';
import Widget from 'core-components/widget';
+import Message from 'core-components/message';
class DashboardCreateTicketPage extends React.Component {
@@ -23,21 +26,24 @@ class DashboardCreateTicketPage extends React.Component {
return (
-
-
+
+ {queryString.parse(window.location.search)["message"] ?
+
+ {i18n('TICKET_NUMBER_SENT')}
+ :
+ null}
+
+
+
);
}
- onCreateTicketSuccess(result, email, message) {
- if((this.props.location.pathname !== '/create-ticket')) {
- history.push(`/dashboard?message=${message}`);
- } else {
- setTimeout(() => {history.push('/check-ticket/' + result.data.ticketNumber + '/' + email)}, 1000);
- }
+ onCreateTicketSuccess(message) {
+ history.push(`${(this.props.location.pathname !== '/create-ticket') ? "/dashboard" : "/create-ticket"}?message=${message}`);
}
getClass() {
@@ -49,6 +55,15 @@ class DashboardCreateTicketPage extends React.Component {
return classNames(classes);
}
+
+ getCreateTicketFormClass() {
+ let classes = {
+ 'dashboard-create-ticket-page__create-ticket-form': true,
+ 'dashboard-create-ticket-page__create-ticket-form__hidden': !!queryString.parse(window.location.search)["message"]
+ };
+
+ return classNames(classes);
+ }
}
export default connect((store) => {
diff --git a/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.scss b/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.scss
index b7de33f8..3686272a 100644
--- a/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.scss
+++ b/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.scss
@@ -7,4 +7,14 @@
float: none;
}
}
-}
\ No newline at end of file
+
+ &__container {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ }
+
+ &__create-ticket-form__hidden {
+ display: none;
+ }
+}
diff --git a/client/src/app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page.js b/client/src/app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page.js
index e44d567b..bcce1957 100644
--- a/client/src/app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page.js
+++ b/client/src/app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page.js
@@ -42,16 +42,8 @@ class DashboardListTicketsPage extends React.Component {
}
render() {
- const {
- userUsers
- } = this.props;
- const {
- loading,
- page,
- pages,
- tickets,
- message
- } = this.state;
+ const { userUsers } = this.props;
+ const { loading, page, pages, tickets, message } = this.state;
return (
diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js
index 278cb4ce..259dc7f4 100644
--- a/client/src/data/languages/en.js
+++ b/client/src/data/languages/en.js
@@ -408,6 +408,7 @@ export default {
'SIGNUP_SUCCESS': 'You have registered successfully in our support system.',
'INVITE_USER_SUCCESS': 'You have invited a new user successfully in our support system',
'TICKET_SENT': 'Ticket has been created successfully.',
+ 'TICKET_NUMBER_SENT': 'Ticket has been created successfully and an email with the ticket number has been sent.',
'VALID_RECOVER': 'Password recovered successfully',
'EMAIL_EXISTS': 'Email already exists',
'ARE_YOU_SURE': 'Confirm action',