mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-28 16:24:42 +02:00
Clear create ticket form after create a ticket with mandatory login disabled (#966)
* Clear create ticket form after create a ticket with mandatory login disabled. * WIP
This commit is contained in:
parent
55c89d58cc
commit
167d7927db
@ -17,6 +17,12 @@ import FormField from 'core-components/form-field';
|
|||||||
import SubmitButton from 'core-components/submit-button';
|
import SubmitButton from 'core-components/submit-button';
|
||||||
import Message from 'core-components/message';
|
import Message from 'core-components/message';
|
||||||
|
|
||||||
|
const DEFAULT_CREATE_TICKET_FORM_VALUE = {
|
||||||
|
title: '',
|
||||||
|
email: '',
|
||||||
|
name: ''
|
||||||
|
};
|
||||||
|
|
||||||
class CreateTicketForm extends React.Component {
|
class CreateTicketForm extends React.Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -34,23 +40,15 @@ class CreateTicketForm extends React.Component {
|
|||||||
loading: false,
|
loading: false,
|
||||||
message: null,
|
message: null,
|
||||||
form: {
|
form: {
|
||||||
title: '',
|
...DEFAULT_CREATE_TICKET_FORM_VALUE,
|
||||||
content: TextEditor.createEmpty(),
|
content: TextEditor.createEmpty(),
|
||||||
departmentIndex: getPublicDepartmentIndexFromDepartmentId(this.props.defaultDepartmentId, SessionStore.getDepartments()),
|
departmentIndex: getPublicDepartmentIndexFromDepartmentId(this.props.defaultDepartmentId, SessionStore.getDepartments()),
|
||||||
email: '',
|
|
||||||
name: '',
|
|
||||||
language: this.props.language
|
language: this.props.language
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { userLogged, isDefaultDepartmentLocked, isStaff, onlyOneSupportedLanguage, allowAttachments } = this.props;
|
||||||
userLogged,
|
|
||||||
isDefaultDepartmentLocked,
|
|
||||||
isStaff,
|
|
||||||
onlyOneSupportedLanguage,
|
|
||||||
allowAttachments
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="create-ticket-form">
|
<div className="create-ticket-form">
|
||||||
@ -118,7 +116,7 @@ class CreateTicketForm extends React.Component {
|
|||||||
renderMessage() {
|
renderMessage() {
|
||||||
switch (this.state.message) {
|
switch (this.state.message) {
|
||||||
case 'success':
|
case 'success':
|
||||||
return <Message className="create-ticket-form__message" type="success">{i18n('TICKET_SENT')}</Message>;
|
return this.props.userLogged ? <Message className="create-ticket-form__message" type="success">{i18n('TICKET_SENT')}</Message> : null;
|
||||||
case 'fail':
|
case 'fail':
|
||||||
return <Message className="create-ticket-form__message" type="error">{i18n('TICKET_SENT_ERROR')}</Message>;
|
return <Message className="create-ticket-form__message" type="error">{i18n('TICKET_SENT_ERROR')}</Message>;
|
||||||
default:
|
default:
|
||||||
@ -127,10 +125,7 @@ class CreateTicketForm extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFormProps() {
|
getFormProps() {
|
||||||
const {
|
const { loading, form } = this.state;
|
||||||
loading,
|
|
||||||
form
|
|
||||||
} = this.state;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loading,
|
loading,
|
||||||
@ -161,16 +156,26 @@ class CreateTicketForm extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onTicketSuccess(email, result) {
|
onTicketSuccess() {
|
||||||
const { onSuccess } = this.props;
|
const { onSuccess, userLogged, language } = this.props;
|
||||||
|
const { form } = this.state;
|
||||||
const message = 'success';
|
const message = 'success';
|
||||||
|
|
||||||
this.setState(
|
this.setState(
|
||||||
{
|
{
|
||||||
loading: false,
|
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) => {
|
export default connect((store) => {
|
||||||
const { language, supportedLanguages } = store.config;
|
const { language, supportedLanguages } = store.config;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
language: _.includes(supportedLanguages, language) ? language : supportedLanguages[0],
|
language: _.includes(supportedLanguages, language) ? language : supportedLanguages[0],
|
||||||
onlyOneSupportedLanguage: supportedLanguages.length == 1 ? true : false,
|
onlyOneSupportedLanguage: supportedLanguages.length == 1 ? true : false,
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import {connect} from 'react-redux';
|
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 CreateTicketForm from 'app/main/dashboard/dashboard-create-ticket/create-ticket-form';
|
||||||
|
|
||||||
import Widget from 'core-components/widget';
|
import Widget from 'core-components/widget';
|
||||||
|
import Message from 'core-components/message';
|
||||||
|
|
||||||
class DashboardCreateTicketPage extends React.Component {
|
class DashboardCreateTicketPage extends React.Component {
|
||||||
|
|
||||||
@ -23,21 +26,24 @@ class DashboardCreateTicketPage extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={this.getClass()}>
|
<div className={this.getClass()}>
|
||||||
<Wrapper>
|
<Wrapper className="dashboard-create-ticket-page__container">
|
||||||
<CreateTicketForm
|
{queryString.parse(window.location.search)["message"] ?
|
||||||
userLogged={(this.props.location.pathname !== '/create-ticket')}
|
<Message className="dashboard-create-ticket-page__message" type="success">
|
||||||
onSuccess={this.onCreateTicketSuccess.bind(this)}/>
|
{i18n('TICKET_NUMBER_SENT')}
|
||||||
|
</Message> :
|
||||||
|
null}
|
||||||
|
<div className={this.getCreateTicketFormClass()}>
|
||||||
|
<CreateTicketForm
|
||||||
|
userLogged={(this.props.location.pathname !== '/create-ticket')}
|
||||||
|
onSuccess={this.onCreateTicketSuccess.bind(this)} />
|
||||||
|
</div>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onCreateTicketSuccess(result, email, message) {
|
onCreateTicketSuccess(message) {
|
||||||
if((this.props.location.pathname !== '/create-ticket')) {
|
history.push(`${(this.props.location.pathname !== '/create-ticket') ? "/dashboard" : "/create-ticket"}?message=${message}`);
|
||||||
history.push(`/dashboard?message=${message}`);
|
|
||||||
} else {
|
|
||||||
setTimeout(() => {history.push('/check-ticket/' + result.data.ticketNumber + '/' + email)}, 1000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getClass() {
|
getClass() {
|
||||||
@ -49,6 +55,15 @@ class DashboardCreateTicketPage extends React.Component {
|
|||||||
|
|
||||||
return classNames(classes);
|
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) => {
|
export default connect((store) => {
|
||||||
|
@ -7,4 +7,14 @@
|
|||||||
float: none;
|
float: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
&__container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__create-ticket-form__hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -42,16 +42,8 @@ class DashboardListTicketsPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { userUsers } = this.props;
|
||||||
userUsers
|
const { loading, page, pages, tickets, message } = this.state;
|
||||||
} = this.props;
|
|
||||||
const {
|
|
||||||
loading,
|
|
||||||
page,
|
|
||||||
pages,
|
|
||||||
tickets,
|
|
||||||
message
|
|
||||||
} = this.state;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="dashboard-ticket-list">
|
<div className="dashboard-ticket-list">
|
||||||
|
@ -408,6 +408,7 @@ export default {
|
|||||||
'SIGNUP_SUCCESS': 'You have registered successfully in our support system.',
|
'SIGNUP_SUCCESS': 'You have registered successfully in our support system.',
|
||||||
'INVITE_USER_SUCCESS': 'You have invited a new user 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_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',
|
'VALID_RECOVER': 'Password recovered successfully',
|
||||||
'EMAIL_EXISTS': 'Email already exists',
|
'EMAIL_EXISTS': 'Email already exists',
|
||||||
'ARE_YOU_SURE': 'Confirm action',
|
'ARE_YOU_SURE': 'Confirm action',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user