From e5bf1a2a1573f9911ba17d89b792c858fd11e228 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Tue, 2 Apr 2024 12:21:46 +0100 Subject: [PATCH] PI-1998 - add sentence card --- server/data/model/sentenceDetails.ts | 21 +++++++++++++ server/views/pages/sentence.njk | 39 ++++++++++++++++++++++++- wiremock/mappings/X000001-sentence.json | 24 +++++++++++++-- 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/server/data/model/sentenceDetails.ts b/server/data/model/sentenceDetails.ts index 2e1ec669..43d0d5b2 100644 --- a/server/data/model/sentenceDetails.ts +++ b/server/data/model/sentenceDetails.ts @@ -3,6 +3,8 @@ export interface SentenceDetails { crn: string sentences: Sentence[] + order: Order + requirements: Requirement[] } export interface Sentence { @@ -28,3 +30,22 @@ export interface Offence { code: string description: string } + +export interface Order { + description: string + length: string + startDate: string +} + +export interface Requirement { + description: string + codeDescription: string + length: string + rar: Rar +} + +export interface Rar { + completed: string + scheduled: string + totalDays: string +} diff --git a/server/views/pages/sentence.njk b/server/views/pages/sentence.njk index cefe60de..793bdbec 100644 --- a/server/views/pages/sentence.njk +++ b/server/views/pages/sentence.njk @@ -69,6 +69,12 @@ {% endfor %} {% endset %} + {% set hasRequirements = sentence.requirements and sentence.requirements.length > 0 %} + {% set requirements %} + {% for requirement in sentence.requirements %} + {% endfor %} + {% endset %} + {% set offence %} {{ govukSummaryList({ rows: [ @@ -105,7 +111,7 @@ }, { key: { text: "Conviction date" }, - value: { html: '' + sentence.conviction.convictionDate | nl2br if sentence.conviction.responsibleCourt | dateWithYear else 'No conviction date' + ''} + value: { html: '' + sentence.conviction.convictionDate | dateWithYear | nl2br if sentence.conviction.convictionDate else 'No conviction date' + ''} }, { key: { text: "Additional sentences" }, @@ -115,6 +121,30 @@ }) }} {% endset %} + {% set sentence %} + {{ govukSummaryList({ + rows: [ + { + key: { text: "Order" }, + value: { html: '' + sentence.order.description | nl2br if sentence.order.description else 'No order details' + '' } + }, + { + key: { text: "Start date" }, + value: { html: '' + sentence.order.startDate | dateWithYear | nl2br if sentence.order.startDate else 'No start date details' + '' } + }, + { + key: { text: "End date" }, + value: { html: '' + sentence.order.endDate | dateWithYear | nl2br if sentence.order.endDate else 'No end date details' + '' } + }, + { + key: { text: "Time elapsed" }, + value: { html: '' + sentence.order.startDate | monthsOrDaysElapsed + ' (of ' + sentence.order.length + ' months)' | nl2br if sentence.order.startDate else 'No details' + '' } + } + ] + }) }} + {% endset %} + + {{ appSummaryCard({ attributes: {'data-qa': 'offenceCard'}, titleText: 'Offence', @@ -128,6 +158,13 @@ classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title', html: conviction }) }} + + {{ appSummaryCard({ + attributes: {'data-qa': 'sentenceCard'}, + titleText: 'Sentence', + classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title', + html: sentence + }) }} {%- endfor %} {% endblock %} diff --git a/wiremock/mappings/X000001-sentence.json b/wiremock/mappings/X000001-sentence.json index b2774854..32ec4379 100644 --- a/wiremock/mappings/X000001-sentence.json +++ b/wiremock/mappings/X000001-sentence.json @@ -44,7 +44,26 @@ "description": "Disqualified from Driving" } ] - } + }, + "order": { + "description": "Default Sentence Type", + "length": 12, + "endDate": "2025-03-19", + "startDate": "2024-03-19" + }, + "requirements": [ + { + "description": "Main", + "codeDescription": "High Intensity", + "length": 12, + "notes": "my notes", + "rar": { + "completed": 1, + "scheduled": 0, + "totalDays": 1 + } + } + ] }, { "offenceDetails": { @@ -59,7 +78,8 @@ }, "conviction": { "additionalSentences": [] - } + }, + "requirements": [] } ] },