Skip to content

Commit

Permalink
PI-2035: Added activity log
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcphee77 committed Mar 27, 2024
1 parent ecdcfe1 commit 55097cd
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions server/routes/activityLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ export default function activityLogRoutes(router: Router, { hmppsAuthClient }: S
get('/case/:crn/activity-log', async (req, res, _next) => {
const { crn } = req.params
const token = await hmppsAuthClient.getSystemClientToken(res.locals.user.username)
const masClient = new MasApiClient(token)

if (req.query.view === 'compact') {
res.locals.compactView = true
} else {
res.locals.defaultView = true
}

const personActivity = await masClient.getPersonActivityLog(crn)

await auditService.sendAuditMessage({
action: 'VIEW_MAS_ACTIVITY_LOG',
Expand All @@ -20,17 +29,6 @@ export default function activityLogRoutes(router: Router, { hmppsAuthClient }: S
correlationId: v4(),
service: 'hmpps-manage-a-supervision-ui',
})

const masClient = new MasApiClient(token)

const personActivity = await masClient.getPersonActivityLog(crn)

if (req.query.view === 'compact') {
res.locals.compactView = true
} else {
res.locals.defaultView = true
}

res.render('pages/activity-log', {
personActivity,
crn,
Expand Down Expand Up @@ -71,14 +69,6 @@ export default function activityLogRoutes(router: Router, { hmppsAuthClient }: S
const { crn, id } = req.params
const token = await hmppsAuthClient.getSystemClientToken(res.locals.user.username)

await auditService.sendAuditMessage({
action: 'VIEW_MAS_ACTIVITY_LOG_DETAIL',
who: res.locals.user.username,
subjectId: crn,
subjectType: 'CRN',
correlationId: v4(),
service: 'hmpps-manage-a-supervision-ui',
})
const masClient = new MasApiClient(token)
const personAppointment = await masClient.getPersonAppointment(crn, id)
const isActivityLog = true
Expand All @@ -88,6 +78,16 @@ export default function activityLogRoutes(router: Router, { hmppsAuthClient }: S
if (req.query.view) {
queryParams.push(`view=${req.query.view}`)
}

await auditService.sendAuditMessage({
action: 'VIEW_MAS_ACTIVITY_LOG_DETAIL',
who: res.locals.user.username,
subjectId: crn,
subjectType: 'CRN',
correlationId: v4(),
service: 'hmpps-manage-a-supervision-ui',
})

res.render('pages/schedule/appointment', {
category,
queryParams,
Expand Down

0 comments on commit 55097cd

Please sign in to comment.