Skip to content

Commit d445d0b

Browse files
committed
fix(profile): view all notifications display
1 parent 950ade6 commit d445d0b

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/client/containers/Modals/ViewAllNotificationsModal.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import BaseModal from 'containers/Modals/BaseModal'
2828
import Button from 'components/Button'
2929

3030
import helpers from 'lib/helpers'
31+
import history from 'lib/lib-history'
3132

3233
@observer
3334
class ViewAllNotificationsModal extends React.Component {
@@ -41,7 +42,7 @@ class ViewAllNotificationsModal extends React.Component {
4142
componentDidMount () {
4243
helpers.hideAllpDropDowns()
4344
axios
44-
.get('/api/v1/users/notifications')
45+
.get('/api/v2/accounts/profile/notifications')
4546
.then(res => {
4647
this.notifications = res.data.notifications
4748
})
@@ -57,7 +58,7 @@ class ViewAllNotificationsModal extends React.Component {
5758

5859
this.props.hideModal()
5960
this.props.socket.emit(NOTIFICATIONS_MARK_READ, notification._id)
60-
History.pushState(null, null, `/tickets/${notification.data.ticket.uid}`)
61+
history.push(`/tickets/${notification.data.ticket.uid}`)
6162
}
6263

6364
render () {

src/controllers/api/v2/accounts.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const Group = require('../../../models').GroupModel
2222
const Team = require('../../../models').TeamModel
2323
const Department = require('../../../models').DepartmentModel
2424
const passwordComplexity = require('../../../settings/passwordComplexity')
25-
const { RoleModel, RoleOrderModel } = require('../../../models')
25+
const { RoleModel, RoleOrderModel, NotificationModel } = require('../../../models')
2626

2727
const accountsApi = {}
2828

@@ -472,6 +472,16 @@ accountsApi.updatePassword = async (req, res) => {
472472
}
473473
}
474474

475+
accountsApi.userNotifications = async (req, res) => {
476+
try {
477+
const notifications = await NotificationModel.findAllForUser(req.user._id)
478+
479+
return apiUtil.sendApiSuccess(res, { notifications })
480+
} catch (err) {
481+
return apiUtil.sendApiError(res, 500, err)
482+
}
483+
}
484+
475485
accountsApi.getRoles = async (req, res) => {
476486
try {
477487
const roles = await RoleModel.find({})

src/controllers/api/v2/routes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = function (middleware, router, controllers) {
3939
router.post('/api/v2/accounts/profile/mfa/verify', apiv2Auth, csrfCheck, apiv2.accounts.verifyMFA)
4040
router.post('/api/v2/accounts/profile/mfa/disable', apiv2Auth, csrfCheck, apiv2.accounts.disableMFA)
4141
router.post('/api/v2/accounts/profile/update-password', apiv2Auth, csrfCheck, apiv2.accounts.updatePassword)
42+
router.get('/api/v2/accounts/profile/notifications', apiv2Auth, apiv2.accounts.userNotifications)
4243
router.put('/api/v2/accounts/:username', apiv2Auth, canUser('accounts:update'), apiv2.accounts.update)
4344

4445
// Account Roles

0 commit comments

Comments
 (0)