Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADJUST1-79 Show correct last updated by name #44

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions server/model/adjustmentsHubViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ export default class AdjustmentsHubViewModel {
.reduce((sum, current) => sum + current, 0)
}

public getLastUpdatedDate(adjustmentType: AdjustmentType) {
public getLastUpdated(adjustmentType: AdjustmentType) {
return this.adjustments
.filter(it => it.adjustmentType === adjustmentType.value)
.map(a => new Date(a.lastUpdatedDate))
.reduce((a, b) => (a > b ? a : b))
.map(a => {
return { ...a, lastUpdatedDate: new Date(a.lastUpdatedDate) }
})
.reduce((a, b) => (a.lastUpdatedDate > b.lastUpdatedDate ? a : b))
}

public showDetails(adjustmentType: AdjustmentType) {
Expand Down
72 changes: 38 additions & 34 deletions server/views/macros/hubAdjustmentCard.njk
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
{% from "govuk/components/details/macro.njk" import govukDetails %}
{% macro adjustmentCard(adjustmentType, model) %}
<div class="adjustment-card">
<div class="adjustment-card_heading">
<h2 class="govuk-heading-s adj-card-heading govuk-!-margin-bottom-0">{{adjustmentType.text}}</h2>
<div class="adjustment-card">
<div class="adjustment-card_heading">
<h2 class="govuk-heading-s adj-card-heading govuk-!-margin-bottom-0">{{ adjustmentType.text }}</h2>

{% if model.displayAddLink(adjustmentType) %}
<a href="/{{model.prisonerDetail.offenderNo}}/{{adjustmentType.url}}/add" class="govuk-!-text-align-right" data-qa="add-{{adjustmentType.url}}">Add {{adjustmentType.shortText}}</a>
{% else %}
<a href="/{{model.prisonerDetail.offenderNo}}/remand" class="govuk-!-text-align-right">Review remand</a>
{% endif %}
{% if model.displayAddLink(adjustmentType) %}
<a href="/{{ model.prisonerDetail.offenderNo }}/{{ adjustmentType.url }}/add" class="govuk-!-text-align-right"
data-qa="add-{{ adjustmentType.url }}">Add {{ adjustmentType.shortText }}</a>
{% else %}
<a href="/{{ model.prisonerDetail.offenderNo }}/remand" class="govuk-!-text-align-right">Review remand</a>
{% endif %}

</div>
<div class="adjustment-card_content">
<span class="count govuk-body">{{model.getTotalDays(adjustmentType)}}</span>
<span>Days</span>
{% if model.showDetails(adjustmentType) %}
<a href="/{{model.prisonerDetail.offenderNo}}/{{adjustmentType.url}}/view" data-qa="view-{{adjustmentType.url}}">view details</a>
<p class="govuk-body govuk-!-font-size-14">Last update on {{ model.getLastUpdatedDate(adjustmentType) | date("DD MMMM YYYY") }} by {{model.remandDecision.decisionBy}}.</p>
{% endif %}
</div>
<div class="adjustment-card_content">
<span class="count govuk-body">{{ model.getTotalDays(adjustmentType) }}</span>
<span>Days</span>
{% if model.showDetails(adjustmentType) %}
<a href="/{{ model.prisonerDetail.offenderNo }}/{{ adjustmentType.url }}/view"
data-qa="view-{{ adjustmentType.url }}">view details</a>
<p class="govuk-body govuk-!-font-size-14">Last update
on {{ model.getLastUpdated(adjustmentType).lastUpdatedDate | date("DD MMMM YYYY") }}
by {{ model.getLastUpdated(adjustmentType).lastUpdatedBy }}.</p>
{% endif %}

{% if adjustmentType.value == 'REMAND' and model.remandDecision %}
<p class="govuk-body">{{model.remandDecision.days}} days of suggested remand was
{{ "accepted" if model.remandDecision.accepted else "rejected" }}
on {{model.remandDecision.decisionOn | date("DD MMMM YYYY")}}
by {{model.remandDecision.decisionBy}}.
{% if not model.remandDecision.accepted %}
<br/>
Reason for rejection: {{model.remandDecision.rejectComment}}
<br/>
<a href="{{model.prisonerDetail.offenderNo}}/remand">Re-review</a>
{% endif %}
</p>
{% endif %}
{{ govukDetails({
summaryText: "More about " + adjustmentType.shortText,
html: adjustmentType.moreAboutHtml or "More about " + adjustmentType.shortText
}) }}
</div>
{% if adjustmentType.value == 'REMAND' and model.remandDecision %}
<p class="govuk-body">{{ model.remandDecision.days }} days of suggested remand was
{{ "accepted" if model.remandDecision.accepted else "rejected" }}
on {{ model.remandDecision.decisionOn | date("DD MMMM YYYY") }}
by {{ model.remandDecision.decisionBy }}.
{% if not model.remandDecision.accepted %}
<br/>
Reason for rejection: {{ model.remandDecision.rejectComment }}
<br/>
<a href="{{ model.prisonerDetail.offenderNo }}/remand">Re-review</a>
{% endif %}
</p>
{% endif %}
{{ govukDetails({
summaryText: "More about " + adjustmentType.shortText,
html: adjustmentType.moreAboutHtml or "More about " + adjustmentType.shortText
}) }}
</div>
</div>
{% endmacro %}