Ivan - Add create ticket for no user system [skip ci]
This commit is contained in:
parent
e20760e8bb
commit
4119509cc4
|
@ -13,6 +13,7 @@ import MainSignUpPage from 'app/main/main-signup/main-signup-page';
|
||||||
import MainVerifyTokenPage from 'app/main/main-verify-token-page';
|
import MainVerifyTokenPage from 'app/main/main-verify-token-page';
|
||||||
import MainRecoverPasswordPage from 'app/main/main-recover-password/main-recover-password-page';
|
import MainRecoverPasswordPage from 'app/main/main-recover-password/main-recover-password-page';
|
||||||
import MainMaintenancePage from 'app/main/main-maintenance-page';
|
import MainMaintenancePage from 'app/main/main-maintenance-page';
|
||||||
|
import MainCheckTicketPage from 'app/main/main-check-ticket-page';
|
||||||
|
|
||||||
import DashboardLayout from 'app/main/dashboard/dashboard-layout';
|
import DashboardLayout from 'app/main/dashboard/dashboard-layout';
|
||||||
import DashboardListTicketsPage from 'app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page';
|
import DashboardListTicketsPage from 'app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page';
|
||||||
|
@ -63,6 +64,12 @@ export default (
|
||||||
<Route path='verify-token/:email/:token' component={MainVerifyTokenPage}/>
|
<Route path='verify-token/:email/:token' component={MainVerifyTokenPage}/>
|
||||||
<Route path='recover-password' component={MainRecoverPasswordPage}/>
|
<Route path='recover-password' component={MainRecoverPasswordPage}/>
|
||||||
<Route path='maintenance' component={MainMaintenancePage}/>
|
<Route path='maintenance' component={MainMaintenancePage}/>
|
||||||
|
|
||||||
|
<Route path='create-ticket' component={DashboardCreateTicketPage}/>
|
||||||
|
<Route path='check-ticket' component={MainCheckTicketPage}/>
|
||||||
|
<Route path='ticket/:ticketNumber/:email' component={DashboardTicketPage}/>
|
||||||
|
<Route path='articles' component={DashboardListArticlesPage}/>
|
||||||
|
|
||||||
<Route path='dashboard' component={DashboardLayout}>
|
<Route path='dashboard' component={DashboardLayout}>
|
||||||
<IndexRoute component={DashboardListTicketsPage} />
|
<IndexRoute component={DashboardListTicketsPage} />
|
||||||
<Route path='articles' component={DashboardListArticlesPage}/>
|
<Route path='articles' component={DashboardListArticlesPage}/>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import SessionStore from 'lib-app/session-store';
|
||||||
import store from 'app/store';
|
import store from 'app/store';
|
||||||
import SessionActions from 'actions/session-actions';
|
import SessionActions from 'actions/session-actions';
|
||||||
import LanguageSelector from 'app-components/language-selector';
|
import LanguageSelector from 'app-components/language-selector';
|
||||||
|
import Captcha from 'app/main/captcha';
|
||||||
|
|
||||||
import Header from 'core-components/header';
|
import Header from 'core-components/header';
|
||||||
import Form from 'core-components/form';
|
import Form from 'core-components/form';
|
||||||
|
@ -34,6 +35,8 @@ class CreateTicketForm extends React.Component {
|
||||||
title: '',
|
title: '',
|
||||||
content: RichTextEditor.createEmptyValue(),
|
content: RichTextEditor.createEmptyValue(),
|
||||||
departmentIndex: 0,
|
departmentIndex: 0,
|
||||||
|
email: '',
|
||||||
|
name: '',
|
||||||
language: 'en'
|
language: 'en'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -79,7 +82,7 @@ class CreateTicketForm extends React.Component {
|
||||||
renderCaptcha() {
|
renderCaptcha() {
|
||||||
return (
|
return (
|
||||||
<div className="create-ticket-form__captcha">
|
<div className="create-ticket-form__captcha">
|
||||||
<Captcha />
|
<Captcha ref="captcha"/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -105,6 +108,11 @@ class CreateTicketForm extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit(formState) {
|
onSubmit(formState) {
|
||||||
|
let captcha = this.refs.captcha && this.refs.captcha.getWrappedInstance();
|
||||||
|
|
||||||
|
if (captcha && !captcha.getValue()) {
|
||||||
|
captcha.focus();
|
||||||
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: true
|
loading: true
|
||||||
});
|
});
|
||||||
|
@ -112,10 +120,12 @@ class CreateTicketForm extends React.Component {
|
||||||
API.call({
|
API.call({
|
||||||
path: '/ticket/create',
|
path: '/ticket/create',
|
||||||
data: _.extend({}, formState, {
|
data: _.extend({}, formState, {
|
||||||
|
captcha: captcha && captcha.getValue(),
|
||||||
departmentId: SessionStore.getDepartments()[formState.departmentIndex].id
|
departmentId: SessionStore.getDepartments()[formState.departmentIndex].id
|
||||||
})
|
})
|
||||||
}).then(this.onTicketSuccess.bind(this)).catch(this.onTicketFail.bind(this));
|
}).then(this.onTicketSuccess.bind(this)).catch(this.onTicketFail.bind(this));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onTicketSuccess() {
|
onTicketSuccess() {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -123,10 +133,11 @@ class CreateTicketForm extends React.Component {
|
||||||
message: 'success'
|
message: 'success'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(this.props.userLogged) {
|
||||||
store.dispatch(SessionActions.getUserData());
|
store.dispatch(SessionActions.getUserData());
|
||||||
|
|
||||||
setTimeout(() => {browserHistory.push('/dashboard')}, 2000);
|
setTimeout(() => {browserHistory.push('/dashboard')}, 2000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onTicketFail() {
|
onTicketFail() {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
|
@ -1,16 +1,45 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import {connect} from 'react-redux';
|
||||||
|
|
||||||
|
import Captcha from 'app/main/captcha';
|
||||||
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';
|
||||||
|
|
||||||
class DashboardCreateTicketPage extends React.Component {
|
class DashboardCreateTicketPage extends React.Component {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
userSystemEnabled: React.PropTypes.bool
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let Wrapper = 'div';
|
||||||
|
|
||||||
|
if(!this.props.userSystemEnabled) {
|
||||||
|
Wrapper = Widget;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className={this.getClass()}>
|
||||||
<CreateTicketForm />
|
<Wrapper>
|
||||||
|
<CreateTicketForm userLogged={this.props.userSystemEnabled} />
|
||||||
|
</Wrapper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getClass() {
|
||||||
|
let classes = {
|
||||||
|
'dashboard-create-ticket-page': true,
|
||||||
|
'dashboard-create-ticket-page_wrapped': (!this.props.userSystemEnabled)
|
||||||
|
};
|
||||||
|
|
||||||
|
return classNames(classes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DashboardCreateTicketPage;
|
export default connect((store) => {
|
||||||
|
return {
|
||||||
|
userSystemEnabled: store.config['user-system-enabled']
|
||||||
|
};
|
||||||
|
})(DashboardCreateTicketPage);
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
.dashboard-create-ticket-page {
|
||||||
|
|
||||||
|
&_wrapped {
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
class MainCheckTicketPage extends React.Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="main-check-ticket-page">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MainCheckTicketPage;
|
|
@ -63,7 +63,7 @@ class MainSignUpPageWidget extends React.Component {
|
||||||
return {
|
return {
|
||||||
loading: this.state.loading,
|
loading: this.state.loading,
|
||||||
className: 'signup-widget__form',
|
className: 'signup-widget__form',
|
||||||
onSubmit: this.onLoginFormSubmit.bind(this)
|
onSubmit: this.onSignupFormSubmit.bind(this)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class MainSignUpPageWidget extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoginFormSubmit(formState) {
|
onSignupFormSubmit(formState) {
|
||||||
const captcha = this.refs.captcha.getWrappedInstance();
|
const captcha = this.refs.captcha.getWrappedInstance();
|
||||||
|
|
||||||
if (!captcha.getValue()) {
|
if (!captcha.getValue()) {
|
||||||
|
|
Loading…
Reference in New Issue