Max - call ticket seen from both admin and client [skip ci]

This commit is contained in:
Max Red 2016-10-28 17:59:50 -03:00
parent 5ade2f51d8
commit c17034f182
3 changed files with 44 additions and 5 deletions

View File

@ -71,7 +71,7 @@ class AdminPanelViewTicket extends React.Component {
retrieveTicket() {
API.call({
path: '/ticket/get',
date: {
data: {
ticketNumber: this.props.params.ticketNumber
}
}).then(this.onRetrieveSuccess.bind(this)).catch(this.onRetrieveFail.bind(this))
@ -82,6 +82,15 @@ class AdminPanelViewTicket extends React.Component {
loading: false,
ticket: result.data
});
if(result.data.unreadStaff){
API.call({
path: '/ticket/seen',
data: {
ticketNumber: this.props.params.ticketNumber
}
})
}
}
onRetrieveFail() {

View File

@ -2,6 +2,9 @@ import React from 'react';
import _ from 'lodash';
import {connect} from 'react-redux';
import i18n from 'lib-app/i18n';
import API from 'lib-app/api-call';
import SessionActions from 'actions/session-actions';
import TicketViewer from 'app-components/ticket-viewer';
@ -11,16 +14,32 @@ class DashboardTicketPage extends React.Component {
tickets: React.PropTypes.array
};
componentDidMount() {
let ticket = this.getTicketData();
if(ticket.unread) {
API.call({
path: '/ticket/seen',
data: {
ticketNumber: ticket.ticketNumber
}
})
}
}
render() {
let ticketView = i18n('NO_PERMISSION');
if(!_.isEmpty(this.getTicketData())) {
ticketView = <TicketViewer ticket={this.getTicketData()} onChange={this.retrieveUserData.bind(this)}/>;
}
return (
<div className="dashboard-ticket-page">
<TicketViewer ticket={this.getTicketData()} onChange={this.retrieveUserData.bind(this)}/>
{ticketView}
</div>
);
}
getTicketData() {
return _.find(this.props.tickets, {ticketNumber: this.props.params.ticketNumber});
return _.find(this.props.tickets, {ticketNumber: this.props.params.ticketNumber}) || {};
}
retrieveUserData() {

View File

@ -78,6 +78,16 @@ module.exports = [
};
}
},
{
path: '/ticket/seen',
time: 200,
response: function () {
return {
status: 'success',
data: {}
};
}
},
{
path: '/ticket/get',
time: 1000,
@ -96,6 +106,7 @@ module.exports = [
file: 'http://www.opensupports.com/some_file.zip',
language: 'en',
unread: false,
unreadStaff: true,
closed: false,
priority: 'medium',
author: {