Skip to content

Commit

Permalink
MAN-309 - add card elements
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj committed Jan 29, 2025
1 parent e1a6615 commit 623630c
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 32 deletions.
1 change: 1 addition & 0 deletions server/data/model/previousOrderDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { Sentence } from './sentenceDetails'

export interface PreviousOrderDetail {
name: Name
title: string
sentence: Sentence
}
1 change: 1 addition & 0 deletions server/data/model/sentenceDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface Sentence {
unpaidWorkProgress: string
licenceConditions: LicenceCondition[]
}

export interface OffenceDetails {
eventNumber: string
offence: Offence
Expand Down
2 changes: 1 addition & 1 deletion server/routes/sentence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function sentenceRoutes(router: Router, { hmppsAuthClient }: Serv

const previousOrderDetail = await masClient.getSentencePreviousOrder(crn, eventNumber)

res.render('pages/sentence/previous-order', {
res.render('pages/sentence/previous-orders/previous-order', {
previousOrderDetail,
crn,
})
Expand Down
62 changes: 62 additions & 0 deletions server/views/pages/sentence/_conviction.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{% set hasAdditionalSentences = sentence.conviction.additionalSentences and sentence.conviction.additionalSentences.length > 0 %}
{% set additionalSentences %}
{% for additionalSentence in sentence.conviction.additionalSentences %}
{% set detailsHtml %}
{{ govukSummaryList({
rows: [
{
key: { text: 'Sentence' },
value: { text: additionalSentence.description }
},
{
key: { text: 'Value' },
value: { text: additionalSentence.value }
} if additionalSentence.value,
{
key: { text: 'Length' },
value: { text: additionalSentence.length }
} if additionalSentence.length,
{
key: { text: 'Notes' },
value: { html: additionalSentence.notes | nl2br if additionalSentence.notes else 'No notes' }
}
]
}) }}
{% endset %}
{{ govukDetails({
classes: 'govuk-!-margin-bottom-1',
summaryText: additionalSentence.description,
html: detailsHtml
}) }}
{% endfor %}
{% endset %}

{% set conviction %}
{{ govukSummaryList({
rows: [
{
key: { text: "Sentencing court" },
value: { html: sentence.conviction.sentencingCourt | nl2br if sentence.conviction.sentencingCourt else 'No court details' }
},
{
key: { text: "Responsible court" },
value: { html: sentence.conviction.responsibleCourt | nl2br if sentence.conviction.responsibleCourt else 'No court details' }
},
{
key: { text: "Conviction date" },
value: { html: sentence.conviction.convictionDate | dateWithYear | nl2br if sentence.conviction.convictionDate else 'No conviction date' }
},
{
key: { text: "Additional sentences" },
value: { html: additionalSentences if hasAdditionalSentences else 'No additional sentences' }
}
]
}) }}
{% endset %}

{{ appSummaryCard({
attributes: {'data-qa': 'convictionCard'},
titleText: 'Conviction',
classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title',
html: conviction
}) }}
42 changes: 42 additions & 0 deletions server/views/pages/sentence/_sentence-offence.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% set hasAdditionalOffences = sentence.offenceDetails.additionalOffences and sentence.offenceDetails.additionalOffences.length > 0 %}
{% set additionalOffences %}
{% if hasAdditionalOffences %}
<ol class="govuk-list{% if sentence.offenceDetails.additionalOffences > 1 %} govuk-list--number{% endif %}">
{% for additionalOffence in sentence.offenceDetails.additionalOffences %}
<li>{{ additionalOffence.description }} ({{ additionalOffence.count }} count)</li>
{% endfor %}
</ol>

<a href="/case/{{ crn }}/sentence/offences/{{ sentence.offenceDetails.eventNumber }}">View additional offence details</a>
{% endif %}
{% endset %}

{% set offence %}
{{ govukSummaryList({
rows: [
{
key: { text: "Main offence" },
value: { html: sentence.offenceDetails.offence.description + ' (' + sentence.offenceDetails.offence.count + ' count)' }
},
{
key: { text: "Offence date" },
value: { html: sentence.offenceDetails.dateOfOffence | dateWithYear }
},
{
key: { text: "Notes" },
value: { html: sentence.offenceDetails.notes | nl2br if sentence.offenceDetails.notes else 'No notes' }
},
{
key: { text: "Additional offences" },
value: { html: additionalOffences if hasAdditionalOffences else 'No additional offences' }
}
]
}) }}
{% endset %}

{{ appSummaryCard({
attributes: {'data-qa': 'offenceCard'},
titleText: 'Offence',
classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title',
html: offence
}) }}
55 changes: 55 additions & 0 deletions server/views/pages/sentence/_sentence.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{% set hasCourtDocuments = sentence.courtDocuments and sentence.courtDocuments.length > 0 %}
{% set courtDocuments %}
<ul class="govuk-list govuk-!-margin-top-0">
{% for doc in sentence.courtDocuments %}
<li>
<a href="personal-details/documents/{{ doc.id }}/download" download="{{ doc.documentName }}">{{ doc.documentName }}</a><br>
<span class="govuk-!-font-size-16">
{% if doc.lastSaved %}
Last updated {{ doc.lastSaved | dateWithYearShortMonth }}
{% else %}
Unavailable
{% endif %}
</span>
</li>
{% endfor %}
</ul>
{% endset %}

{% set sentence %}
{{ govukSummaryList({
rows: [
{
key: { text: "Order" },
value: { html: sentence.order.description | nl2br if sentence.order.description else 'No order details' }
},
{
key: { text: "Sentence start date" },
value: { html: sentence.order.startDate | dateWithYear | nl2br if sentence.order.startDate else 'No start date details' }
},
{
key: { text: "Sentence end date" },
value: { html: sentence.order.releaseDate | dateWithYear | nl2br if sentence.order.releaseDate else 'No release date details' }
},
{
key: { text: "Terminated date" },
value: { html: sentence.order.endDate | dateWithYear | nl2br if sentence.order.endDate else 'No end date details' }
},
{
key: { text: "Termination reason" },
value: { html: sentence.order.startDate | monthsOrDaysElapsed + ' elasped (of ' + sentence.order.length + ' months)' | nl2br if sentence.order.startDate else 'No details' }
},
{
key: { text: "Court documents" },
value: { html: '<span data-qa="courtDocumentsValue">' + courtDocuments if hasCourtDocuments else 'No court documents' + '</span>' }
}
]
}) }}
{% endset %}

{{ appSummaryCard({
attributes: {'data-qa': 'sentenceCard'},
titleText: 'Sentence',
classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title',
html: sentence
}) }}
4 changes: 2 additions & 2 deletions server/views/pages/sentence/offences.njk
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

{% set offence = offences.mainOffence %}
{% set mainOffence = true %}
{% include './_offence.njk' %}
{% include './_sentence-offence.njk' %}

{% set mainOffence = false %}
{% if offences.additionalOffences and offences.additionalOffences.length > 0 %}
<h2 class="govuk-heading-l govuk-!-margin-top-8">Additional offences</h2>
{% for offence in offences.additionalOffences %}
{% include './_offence.njk' %}
{% include './_sentence-offence.njk' %}
{% endfor %}
{% endif %}
{% endblock %}
26 changes: 0 additions & 26 deletions server/views/pages/sentence/previous-order.njk

This file was deleted.

41 changes: 41 additions & 0 deletions server/views/pages/sentence/previous-orders/previous-order.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% extends "../../../partials/layout.njk" %}
{% set headerPersonName = previousOrderDetail.name.forename + ' ' + previousOrderDetail.name.surname %}

{% block beforeContent %}
{{ govukBreadcrumbs({
items: [
{
text: "My cases",
href: "/case"
},
{
text: headerPersonName,
href: "/case/" + crn,
attributes: { "data-ai-id": "breadcrumbPersonNameLink" }
},
{
text: "Sentence",
href: "/case/" + crn + "/sentence"
},
{
text: "Previous Orders",
href: "/case/" + crn + "/sentence/previous-orders"
}
]
}) }}
{% endblock %}
{% block content %}
<div class="govuk-!-margin-bottom-0">
<h2 class="govuk-caption-l">Previous orders</h2>
</div>

{% set sentence = previousOrderDetail.sentence %}
{% if sentence %}
<h2 class="govuk-heading-m govuk-!-margin-bottom-4" data-qa="pageHeading">
{{ previousOrderDetail.title }}
</h2>
{% include '../_sentence-offence.njk' %}
{% include '../_conviction.njk' %}
{% include '../_sentence.njk' %}
{% endif %}
{% endblock %}
47 changes: 45 additions & 2 deletions wiremock/mappings/X000001-offence.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,52 @@
"status": 200,
"jsonBody": {
"name": {
"forename": "Eula",
"forename": "Caroline",
"middleName": "",
"surname": "Schmeler"
"surname": "Wolff"
},
"mainOffence": {
"description": "Possessing etc firearm or ammunition without firearm certificate (Group 1) - 08103",
"category": "Firearms offences",
"code": "08103",
"date": "2024-04-23",
"count": 1,
"notes": "overview"
},
"additionalOffences": [
{
"description": "Endangering railway passengers - 00600",
"category": "Endangering railway passengers",
"code": "00600",
"date": "2024-03-22",
"count": 1
},
{
"description": "Contravene court remedy order (S.42) - 08505",
"category": "Health and Safety at Work etc Act 1974",
"code": "08505",
"date": "2024-02-21",
"count": 3
}
]
},
"headers": {
"Content-Type": "application/json"
}
}
},
{
"request": {
"urlPattern": "/mas/sentence/X000001/offences/1",
"method": "GET"
},
"response": {
"status": 200,
"jsonBody": {
"name": {
"forename": "Caroline",
"middleName": "",
"surname": "Wolff"
},
"mainOffence": {
"description": "Possessing etc firearm or ammunition without firearm certificate (Group 1) - 08103",
Expand Down
Loading

0 comments on commit 623630c

Please sign in to comment.