diff --git a/client/src/app/Routes.js b/client/src/app/Routes.js index 2a137332..59b5f961 100644 --- a/client/src/app/Routes.js +++ b/client/src/app/Routes.js @@ -13,6 +13,7 @@ import MainSignUpPage from 'app/main/main-signup/main-signup-page'; import MainVerifyTokenPage from 'app/main/main-verify-token-page'; import MainRecoverPasswordPage from 'app/main/main-recover-password/main-recover-password-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 DashboardListTicketsPage from 'app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page'; @@ -63,6 +64,12 @@ export default ( + + + + + + 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 f8898b8f..a4c17908 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 @@ -10,6 +10,7 @@ import SessionStore from 'lib-app/session-store'; import store from 'app/store'; import SessionActions from 'actions/session-actions'; import LanguageSelector from 'app-components/language-selector'; +import Captcha from 'app/main/captcha'; import Header from 'core-components/header'; import Form from 'core-components/form'; @@ -34,6 +35,8 @@ class CreateTicketForm extends React.Component { title: '', content: RichTextEditor.createEmptyValue(), departmentIndex: 0, + email: '', + name: '', language: 'en' } }; @@ -79,7 +82,7 @@ class CreateTicketForm extends React.Component { renderCaptcha() { return (
- +
); } @@ -105,16 +108,23 @@ class CreateTicketForm extends React.Component { } onSubmit(formState) { - this.setState({ - loading: true - }); + let captcha = this.refs.captcha && this.refs.captcha.getWrappedInstance(); - API.call({ - path: '/ticket/create', - data: _.extend({}, formState, { - departmentId: SessionStore.getDepartments()[formState.departmentIndex].id - }) - }).then(this.onTicketSuccess.bind(this)).catch(this.onTicketFail.bind(this)); + if (captcha && !captcha.getValue()) { + captcha.focus(); + } else { + this.setState({ + loading: true + }); + + API.call({ + path: '/ticket/create', + data: _.extend({}, formState, { + captcha: captcha && captcha.getValue(), + departmentId: SessionStore.getDepartments()[formState.departmentIndex].id + }) + }).then(this.onTicketSuccess.bind(this)).catch(this.onTicketFail.bind(this)); + } } onTicketSuccess() { @@ -123,9 +133,10 @@ class CreateTicketForm extends React.Component { message: 'success' }); - store.dispatch(SessionActions.getUserData()); - - setTimeout(() => {browserHistory.push('/dashboard')}, 2000); + if(this.props.userLogged) { + store.dispatch(SessionActions.getUserData()); + setTimeout(() => {browserHistory.push('/dashboard')}, 2000); + } } onTicketFail() { 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 596cc4a9..cc7ad75f 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,16 +1,45 @@ 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 Widget from 'core-components/widget'; class DashboardCreateTicketPage extends React.Component { + static propTypes = { + userSystemEnabled: React.PropTypes.bool + }; + render() { + let Wrapper = 'div'; + + if(!this.props.userSystemEnabled) { + Wrapper = Widget; + } + return ( -
- +
+ + +
); } + + 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); 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 new file mode 100644 index 00000000..cba5b276 --- /dev/null +++ b/client/src/app/main/dashboard/dashboard-create-ticket/dashboard-create-ticket-page.scss @@ -0,0 +1,6 @@ +.dashboard-create-ticket-page { + + &_wrapped { + padding: 0 10px; + } +} \ No newline at end of file diff --git a/client/src/app/main/main-check-ticket-page.js b/client/src/app/main/main-check-ticket-page.js new file mode 100644 index 00000000..25ebb95a --- /dev/null +++ b/client/src/app/main/main-check-ticket-page.js @@ -0,0 +1,13 @@ +import React from 'react'; + +class MainCheckTicketPage extends React.Component { + render() { + return ( +
+ +
+ ) + } +} + +export default MainCheckTicketPage; \ No newline at end of file diff --git a/client/src/app/main/main-check-ticket-page.scss b/client/src/app/main/main-check-ticket-page.scss new file mode 100644 index 00000000..e69de29b diff --git a/client/src/app/main/main-signup/main-signup-page.js b/client/src/app/main/main-signup/main-signup-page.js index fa14d8f9..e5baab65 100644 --- a/client/src/app/main/main-signup/main-signup-page.js +++ b/client/src/app/main/main-signup/main-signup-page.js @@ -63,7 +63,7 @@ class MainSignUpPageWidget extends React.Component { return { loading: this.state.loading, 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(); if (!captcha.getValue()) {