Skip to content

Commit

Permalink
PI-1998 - add sentence card
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj committed Apr 2, 2024
1 parent cc19d2f commit e5bf1a2
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 3 deletions.
21 changes: 21 additions & 0 deletions server/data/model/sentenceDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
export interface SentenceDetails {
crn: string
sentences: Sentence[]
order: Order
requirements: Requirement[]
}

export interface Sentence {
Expand All @@ -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
}
39 changes: 38 additions & 1 deletion server/views/pages/sentence.njk
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -105,7 +111,7 @@
},
{
key: { text: "Conviction date" },
value: { html: '<span data-qa="convictionDateValue">' + sentence.conviction.convictionDate | nl2br if sentence.conviction.responsibleCourt | dateWithYear else 'No conviction date' + '</span>'}
value: { html: '<span data-qa="convictionDateValue">' + sentence.conviction.convictionDate | dateWithYear | nl2br if sentence.conviction.convictionDate else 'No conviction date' + '</span>'}
},
{
key: { text: "Additional sentences" },
Expand All @@ -115,6 +121,30 @@
}) }}
{% endset %}

{% set sentence %}
{{ govukSummaryList({
rows: [
{
key: { text: "Order" },
value: { html: '<span data-qa="orderDescriptionValue">' + sentence.order.description | nl2br if sentence.order.description else 'No order details' + '</span>' }
},
{
key: { text: "Start date" },
value: { html: '<span data-qa="orderStartDateValue">' + sentence.order.startDate | dateWithYear | nl2br if sentence.order.startDate else 'No start date details' + '</span>' }
},
{
key: { text: "End date" },
value: { html: '<span data-qa="orderEndDateValue">' + sentence.order.endDate | dateWithYear | nl2br if sentence.order.endDate else 'No end date details' + '</span>' }
},
{
key: { text: "Time elapsed" },
value: { html: '<span data-qa="orderTimeElapsedValue">' + sentence.order.startDate | monthsOrDaysElapsed + ' (of ' + sentence.order.length + ' months)' | nl2br if sentence.order.startDate else 'No details' + '</span>' }
}
]
}) }}
{% endset %}


{{ appSummaryCard({
attributes: {'data-qa': 'offenceCard'},
titleText: 'Offence',
Expand All @@ -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 %}

Expand Down
24 changes: 22 additions & 2 deletions wiremock/mappings/X000001-sentence.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -59,7 +78,8 @@
},
"conviction": {
"additionalSentences": []
}
},
"requirements": []
}
]
},
Expand Down

0 comments on commit e5bf1a2

Please sign in to comment.