From c17034f182729dc0280923bb174de1fdb82ec026 Mon Sep 17 00:00:00 2001 From: Max Red Date: Fri, 28 Oct 2016 17:59:50 -0300 Subject: [PATCH] Max - call ticket seen from both admin and client [skip ci] --- .../panel/tickets/admin-panel-view-ticket.js | 11 +++++++- .../dashboard-ticket/dashboard-ticket-page.js | 25 ++++++++++++++++--- client/src/data/fixtures/ticket-fixtures.js | 13 +++++++++- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/client/src/app/admin/panel/tickets/admin-panel-view-ticket.js b/client/src/app/admin/panel/tickets/admin-panel-view-ticket.js index f9f34b20..f0744670 100644 --- a/client/src/app/admin/panel/tickets/admin-panel-view-ticket.js +++ b/client/src/app/admin/panel/tickets/admin-panel-view-ticket.js @@ -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() { diff --git a/client/src/app/main/dashboard/dashboard-ticket/dashboard-ticket-page.js b/client/src/app/main/dashboard/dashboard-ticket/dashboard-ticket-page.js index c6ea17bc..cfd74743 100644 --- a/client/src/app/main/dashboard/dashboard-ticket/dashboard-ticket-page.js +++ b/client/src/app/main/dashboard/dashboard-ticket/dashboard-ticket-page.js @@ -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 = ; + } return (
- + {ticketView}
); } getTicketData() { - return _.find(this.props.tickets, {ticketNumber: this.props.params.ticketNumber}); + return _.find(this.props.tickets, {ticketNumber: this.props.params.ticketNumber}) || {}; } retrieveUserData() { @@ -32,4 +51,4 @@ export default connect((store) => { return { tickets: store.session.userTickets }; -})(DashboardTicketPage); \ No newline at end of file +})(DashboardTicketPage); diff --git a/client/src/data/fixtures/ticket-fixtures.js b/client/src/data/fixtures/ticket-fixtures.js index 573ccd61..b83a8a76 100644 --- a/client/src/data/fixtures/ticket-fixtures.js +++ b/client/src/data/fixtures/ticket-fixtures.js @@ -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: { @@ -203,4 +214,4 @@ module.exports = [ }; } } -]; \ No newline at end of file +];