From 6e6e6c2034a6d64e1a706f3799b8a13406c9f143 Mon Sep 17 00:00:00 2001 From: carloveo-moj <144013256+carloveo-moj@users.noreply.github.com> Date: Thu, 28 Mar 2024 10:17:40 +0000 Subject: [PATCH] CMG-107 align error page with CCARD (#267) --- server/app.ts | 2 +- server/middleware/populateCurrentPrisoner.ts | 5 ++-- server/views/pages/error.njk | 28 +++++++++----------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/server/app.ts b/server/app.ts index 11141398..f55ed649 100755 --- a/server/app.ts +++ b/server/app.ts @@ -39,8 +39,8 @@ export default function createApp(services: Services): express.Application { app.use(authorisationMiddleware()) app.use(setUpCsrf()) app.use(setUpCurrentUser(services)) - app.use('/:nomsId', populateCurrentPrisoner(services.prisonerSearchService)) app.get('*', getFrontendComponents(services)) + app.use('/:nomsId', populateCurrentPrisoner(services.prisonerSearchService)) app.use(routes(services)) diff --git a/server/middleware/populateCurrentPrisoner.ts b/server/middleware/populateCurrentPrisoner.ts index 10b2c804..a1bf464f 100644 --- a/server/middleware/populateCurrentPrisoner.ts +++ b/server/middleware/populateCurrentPrisoner.ts @@ -11,9 +11,8 @@ export default function populateCurrentPrisoner(prisonerSearchService: PrisonerS if (username && nomsId) { try { const prisoner = await prisonerSearchService.getPrisonerDetails(nomsId, caseloads, username) - if (caseloads.includes(prisoner.prisonId)) { - res.locals.prisoner = prisoner - } else { + res.locals.prisoner = prisoner + if (!caseloads.includes(prisoner.prisonId)) { throw FullPageError.notInCaseLoadError() } } catch (error) { diff --git a/server/views/pages/error.njk b/server/views/pages/error.njk index fea3deba..4c4dd45b 100755 --- a/server/views/pages/error.njk +++ b/server/views/pages/error.njk @@ -7,31 +7,29 @@
-

- {% if status === 404 and not errorKey %} +

+ {% if errorKey === 'NOT_IN_CASELOAD' %} + The details for this person cannot be found + {% elif status === 404 and not errorKey %} Page not found {% else %} There is a problem {% endif %}

- +
+
+
+
{% if errorKey %} {% if errorKey === 'NOT_IN_CASELOAD' %} -

The details for this person cannot be found.

-

This could be because this person:

+

This could be because this person:

- -

- Check the details in NOMIS and then try again. -

+

Check the details in NOMIS and then try again.

{% elif errorKey === 'NO_SENTENCES' %}

There are no active sentences recorded.