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-452 DR Edit remand #189

Merged
merged 2 commits into from
Mar 1, 2024
Merged

ADJUST1-452 DR Edit remand #189

merged 2 commits into from
Mar 1, 2024

Conversation

pavilionsahota
Copy link
Contributor

No description provided.

@pavilionsahota pavilionsahota requested a review from a team as a code owner February 29, 2024 14:33
@@ -18,4 +19,31 @@ export default class RemandChangeModel {
public remandRelatedValidationSummary() {
return remandRelatedValidationSummary(this.calculatedUnusedDeductions?.validationMessages)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we try and use more functional programming techniques in modern typescript, e.g. moving away from using traditional for loops and mutable variables.. something like this.

public isModified(): boolean {
  if (!this.dbAdjustment) {
    return false;
  }

  const sessionCharges = this.adjustment.remand.chargeId.sort((a, b) => a - b);
  const dbCharges = this.dbAdjustment.remand.chargeId.sort((a, b) => a - b);

  const chargeIdModified = !sessionCharges.every((chargeId, index) => chargeId === dbCharges[index]);

  const dateModified = this.adjustment.toDate !== this.dbAdjustment.toDate || 
                       this.adjustment.fromDate !== this.dbAdjustment.fromDate;

  return chargeIdModified || dateModified;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've adjusted this as you've suggested

{% if model.showUnusedMessage %}
<p class="govuk-body">The updates will change the amount of unused deductions. Check the unused remand alert on NOMIS.</p>
{% endif %}

<form method="post">
<input type="hidden" name="_csrf" value="{{ csrfToken }}"/>
<div class="govuk-button-group">
{% if not model.remandRelatedValidationSummary().errorList.length %}
{% if not model.remandRelatedValidationSummary().errorList.length and model.isModified() %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth adding a unit test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've written 2 unit tests for this

Copy link
Contributor

@yasinmustafa yasinmustafa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@yasinmustafa yasinmustafa merged commit 4bfc20e into main Mar 1, 2024
4 checks passed
@yasinmustafa yasinmustafa deleted the ADJUST1-452-DR-Edit-remand branch March 1, 2024 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants