Skip to content

Commit 145874d

Browse files
committed
create confirm details njk template
1 parent c11e0d6 commit 145874d

8 files changed

+146
-16
lines changed

server/@types/express/express-session.d.ts

-12
This file was deleted.

server/@types/express/index.d.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
import { HmppsUser } from '../../interfaces/hmppsUser'
22

33
export declare module 'express-session' {
4-
// Declare that the session will potentially contain these additional fields
54
interface SessionData {
65
returnTo: string
76
nowInMinutes: number
7+
applicationData?: ApplicationData
8+
}
9+
10+
interface ApplicationData {
11+
type: ApplicationType
12+
prisonerName: string
13+
date: Date
14+
additionalData?: AdditionalApplicationData
15+
}
16+
17+
interface ApplicationType {
18+
value: string
19+
name: string
20+
}
21+
22+
type AdditionalApplicationData = SwapVOsForPinCreditDetails
23+
24+
interface SwapVOsForPinCreditDetails {
25+
swapVOsToPinCreditDetails: string
826
}
927
}
1028

server/routes/applications/applicationTypeRoutes.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export default function applicationTypeRoutes({ auditService }: { auditService:
3838

3939
req.session.applicationData = {
4040
type: selectedAppType,
41+
prisonerName: 'Prisoner Name',
42+
date: new Date(),
4143
}
4244

4345
res.redirect(`/log/prisoner-details`)

server/routes/applications/prisonerDetailsRoutes.ts

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ export default function prisonerDetailsRoutes({ auditService }: { auditService:
2727
router.post(
2828
'/log/prisoner-details',
2929
asyncMiddleware(async (req: Request, res: Response) => {
30+
if (!req.session.applicationData) {
31+
res.status(400).send('Application data is missing')
32+
return
33+
}
34+
35+
req.session.applicationData = {
36+
...req.session.applicationData,
37+
prisonerName: req.body.prisonerName,
38+
date: req.body.date,
39+
}
40+
3041
res.redirect(`/log/swap-vos-pin-credit-details`)
3142
}),
3243
)

server/routes/applications/swapVosPinCreditDetailsRoutes.ts

+9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ export default function swapVosPinCreditDetailsRoutes({ auditService }: { auditS
3030
router.post(
3131
'/log/swap-vos-pin-credit-details',
3232
asyncMiddleware(async (req: Request, res: Response) => {
33+
req.session.applicationData = {
34+
...req.session.applicationData,
35+
additionalData: {
36+
...req.session.applicationData?.additionalData,
37+
swapVOsToPinCreditDetails: req.body.swapVosPinCreditDetails,
38+
},
39+
}
40+
3341
res.redirect(`/log/swap-vos-pin-credit-details/confirm`)
3442
}),
3543
)
@@ -51,6 +59,7 @@ export default function swapVosPinCreditDetailsRoutes({ auditService }: { auditS
5159
return res.render('pages/log/confirm-swap-vos-pin-credit-details', {
5260
title: 'Check details',
5361
appTypeTitle: 'Swap VOs for PIN credit',
62+
session: req.session,
5463
})
5564
}),
5665
)
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,115 @@
11
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
2+
{% from "govuk/components/button/macro.njk" import govukButton %}
3+
{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %}
24

35
{% extends "../../partials/layout.njk" %}
46

57
{% set pageTitle = applicationName + " - " + title %}
6-
{% set mainClasses = "app-container govuk-body applications-landing-page" %}
8+
{% set mainClasses = "app-container govuk-body applications-landing-page" %}
79

810
{% block content %}
911
<div class="govuk-body govuk-width-container">
1012
{{ govukBackLink({
1113
text: "Back",
12-
href: "/log/prisoner-details"
14+
href: "/log/swap-vos-pin-credit-details"
15+
}) }}
16+
17+
<span class="govuk-caption-xl">{{ appTypeTitle }}</span>
18+
<h1 class="govuk-heading-xl govuk-!-margin-top-0">Check details</h1>
19+
20+
{{ govukSummaryList({
21+
classes: "govuk-!-margin-bottom-9",
22+
rows: [
23+
{
24+
key: {
25+
text: "Application Type"
26+
},
27+
value: {
28+
text: "Swap VOs for pin credit"
29+
},
30+
actions: {
31+
items: [
32+
{
33+
href: "#",
34+
text: "Change",
35+
visuallyHiddenText: "application type"
36+
}
37+
]
38+
}
39+
}
40+
]
41+
}) }}
42+
43+
<h2 class="govuk-heading-m">Application details</h2>
44+
45+
{{ govukSummaryList({
46+
classes: "govuk-!-margin-bottom-9",
47+
rows: [
48+
{
49+
key: {
50+
text: "Prisoner"
51+
},
52+
value: {
53+
text: session.applicationData.prisonerName
54+
},
55+
actions: {
56+
items: [
57+
{
58+
href: "#",
59+
text: "Change",
60+
visuallyHiddenText: "prisoner"
61+
}
62+
]
63+
}
64+
},
65+
{
66+
key: {
67+
text: "Submitted on"
68+
},
69+
value: {
70+
text: session.applicationData.date
71+
},
72+
actions: {
73+
items: [
74+
{
75+
href: "#",
76+
text: "Change",
77+
visuallyHiddenText: "submitted on"
78+
}
79+
]
80+
}
81+
}
82+
]
83+
}) }}
84+
85+
<h2 class="govuk-heading-m">VOs to swap</h2>
86+
87+
{{ govukSummaryList({
88+
classes: "govuk-!-margin-bottom-9",
89+
rows: [
90+
{
91+
key: {
92+
text: "Details"
93+
},
94+
value: {
95+
text: session.applicationData.additionalData.swapVOsToPinCreditDetails
96+
},
97+
actions: {
98+
items: [
99+
{
100+
href: "#",
101+
text: "Change",
102+
visuallyHiddenText: "details"
103+
}
104+
]
105+
}
106+
}
107+
]
108+
}) }}
109+
110+
{{ govukButton({
111+
text: "Continue",
112+
classes: "govuk-button--primary"
13113
}) }}
14114
</div>
15115
{% endblock %}

server/views/pages/log/prisoner-details.njk

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
classes: "govuk-!-margin-top-0"
4141
}) }}
4242

43+
<input type="hidden" id="prisonerName" name="prisonerName" value="Patel, Taj">
44+
4345
{{ mojDatePicker({
4446
id: "date",
4547
name: "date",

server/views/pages/log/swap-vos-pin-credit-details.njk

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<input type="hidden" name="_csrf" value="{{ csrfToken }}" />
2525

2626
{{ govukCharacterCount({
27-
name: "swap-vos-pin-credit-details",
27+
name: "swapVosPinCreditDetails",
2828
id: "swap-vos-pin-credit-details",
2929
maxlength: 1000,
3030
threshold: 75,

0 commit comments

Comments
 (0)