Skip to content

Commit

Permalink
Go to check and send after updating details to match confirmed
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx committed Jan 31, 2025
1 parent 6c002b1 commit e0fdd1b
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 41 deletions.
25 changes: 10 additions & 15 deletions internal/donor/donorpage/identity_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package donorpage

import (
"net/http"
"net/url"
"strings"

"github.com/ministryofjustice/opg-go-common/template"
Expand All @@ -22,7 +21,6 @@ type identityDetailsData struct {
LastNameMatch bool
DateOfBirthMatch bool
AddressMatch bool
DetailsUpdated bool
Form *form.YesNoForm
}

Expand All @@ -36,7 +34,6 @@ func IdentityDetails(tmpl template.Template, donorStore DonorStore) Handler {
App: appData,
Form: form.NewYesNoForm(form.YesNoUnknown),
Provided: provided,
DetailsUpdated: r.FormValue("detailsUpdated") == "1",
FirstNamesMatch: strings.EqualFold(provided.Donor.FirstNames, provided.IdentityUserData.FirstNames),
LastNameMatch: strings.EqualFold(provided.Donor.LastName, provided.IdentityUserData.LastName),
DateOfBirthMatch: provided.Donor.DateOfBirth == provided.IdentityUserData.DateOfBirth,
Expand All @@ -48,31 +45,29 @@ func IdentityDetails(tmpl template.Template, donorStore DonorStore) Handler {
data.Errors = f.Validate()

if data.Errors.None() {
var redirect donor.Path

if f.YesNo.IsYes() {
provided.Donor.FirstNames = provided.IdentityUserData.FirstNames
provided.Donor.LastName = provided.IdentityUserData.LastName
provided.Donor.DateOfBirth = provided.IdentityUserData.DateOfBirth
provided.Donor.Address = provided.IdentityUserData.CurrentAddress
provided.Tasks.CheckYourLpa = task.StateInProgress
provided.Tasks.ConfirmYourIdentity = task.IdentityStateCompleted
if err := provided.UpdateCheckedHash(); err != nil {
return err
}

if err := donorStore.Put(r.Context(), provided); err != nil {
return err
}

return donor.PathIdentityDetails.RedirectQuery(w, r, appData, provided, url.Values{"detailsUpdated": {"1"}})
redirect = donor.PathIdentityDetailsUpdated
} else {
provided.ContinueWithMismatchedIdentity = true
provided.Tasks.ConfirmYourIdentity = task.IdentityStatePending

if err := donorStore.Put(r.Context(), provided); err != nil {
return err
}
redirect = donor.PathIdentityDetails
}

return donor.PathIdentityDetails.Redirect(w, r, appData, provided)
if err := donorStore.Put(r.Context(), provided); err != nil {
return err
}

return redirect.Redirect(w, r, appData, provided)
}
}

Expand Down
30 changes: 10 additions & 20 deletions internal/donor/donorpage/identity_details_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestGetIdentityDetails(t *testing.T) {
expectedLastNameMatch bool
expectedDateOfBirthMatch bool
expectedAddressMatch bool
expectedDetailsUpdated bool
url string
}{
"details match": {
Expand All @@ -60,14 +59,6 @@ func TestGetIdentityDetails(t *testing.T) {
},
url: "/",
},
"details updated": {
donorProvided: &donordata.Provided{
Donor: donordata.Donor{FirstNames: "a", LastName: "b", DateOfBirth: dob, Address: testAddress},
IdentityUserData: identity.UserData{FirstNames: "b"},
},
url: "/?detailsUpdated=1",
expectedDetailsUpdated: true,
},
}

for name, tc := range testcases {
Expand All @@ -81,7 +72,6 @@ func TestGetIdentityDetails(t *testing.T) {
App: testAppData,
Form: form.NewYesNoForm(form.YesNoUnknown),
Provided: tc.donorProvided,
DetailsUpdated: tc.expectedDetailsUpdated,
FirstNamesMatch: tc.expectedFirstNamesMatch,
LastNameMatch: tc.expectedLastNameMatch,
DateOfBirthMatch: tc.expectedDateOfBirthMatch,
Expand All @@ -102,21 +92,21 @@ func TestPostIdentityDetails(t *testing.T) {
existingDob := date.New("1", "2", "3")
identityDob := date.New("4", "5", "6")

updated := &donordata.Provided{
LpaID: "lpa-id",
Donor: donordata.Donor{FirstNames: "B", LastName: "B", DateOfBirth: identityDob, Address: place.Address{Line1: "a"}},
IdentityUserData: identity.UserData{FirstNames: "B", LastName: "B", DateOfBirth: identityDob, CurrentAddress: place.Address{Line1: "a"}},
Tasks: donordata.Tasks{ConfirmYourIdentity: task.IdentityStateCompleted},
}
updated.UpdateCheckedHash()

testcases := map[form.YesNo]struct {
provided *donordata.Provided
redirect string
}{
form.Yes: {
provided: updated,
redirect: donor.PathIdentityDetails.Format("lpa-id") + "?detailsUpdated=1",
provided: &donordata.Provided{
LpaID: "lpa-id",
Donor: donordata.Donor{FirstNames: "B", LastName: "B", DateOfBirth: identityDob, Address: place.Address{Line1: "a"}},
IdentityUserData: identity.UserData{FirstNames: "B", LastName: "B", DateOfBirth: identityDob, CurrentAddress: place.Address{Line1: "a"}},
Tasks: donordata.Tasks{
CheckYourLpa: task.StateInProgress,
ConfirmYourIdentity: task.IdentityStateCompleted,
},
},
redirect: donor.PathIdentityDetailsUpdated.Format("lpa-id"),
},
form.No: {
provided: &donordata.Provided{
Expand Down
4 changes: 3 additions & 1 deletion internal/donor/donorpage/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@ func Register(
IdentityWithOneLogin(oneLoginClient, sessionStore, random.String))
handleWithDonor(donor.PathIdentityWithOneLoginCallback, page.CanGoBack,
IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore, scheduledStore, eventClient))
handleWithDonor(donor.PathIdentityDetails, page.CanGoBack,
handleWithDonor(donor.PathIdentityDetails, page.None,
IdentityDetails(tmpls.Get("identity_details.gohtml"), donorStore))
handleWithDonor(donor.PathIdentityDetailsUpdated, page.None,
Guidance(tmpls.Get("identity_details_updated.gohtml")))
handleWithDonor(donor.PathRegisterWithCourtOfProtection, page.None,
RegisterWithCourtOfProtection(tmpls.Get("register_with_court_of_protection.gohtml"), donorStore))

Expand Down
1 change: 1 addition & 0 deletions internal/donor/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const (
PathHowWouldCertificateProviderPreferToCarryOutTheirRole = Path("/how-would-certificate-provider-prefer-to-carry-out-their-role")
PathHowWouldYouLikeToSendEvidence = Path("/how-would-you-like-to-send-evidence")
PathIdentityDetails = Path("/identity-details")
PathIdentityDetailsUpdated = Path("/identity-details-updated")
PathIdentityWithOneLogin = Path("/id/one-login")
PathIdentityWithOneLoginCallback = Path("/id/one-login/callback")
PathLifeSustainingTreatment = Path("/life-sustaining-treatment")
Expand Down
16 changes: 16 additions & 0 deletions internal/templatefn/fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package templatefn
import (
"fmt"
"html/template"
"net/url"
"reflect"
"slices"
"strings"
Expand Down Expand Up @@ -90,6 +91,7 @@ func All(globals *Globals) map[string]any {
"legend": legend,
"legendHeading": legendHeading,
"fieldset": fieldset,
"query": query,
}
}

Expand Down Expand Up @@ -563,3 +565,17 @@ func fieldset(top any, name string, value any, legend legendData, is ...any) fie
Items: items(top, name, value, is...),
}
}

func query(args ...string) url.Values {
q := url.Values{}

if len(args)%2 != 0 {
panic("must have even number of args")

Check warning on line 573 in internal/templatefn/fn.go

View check run for this annotation

Codecov / codecov/patch

internal/templatefn/fn.go#L569-L573

Added lines #L569 - L573 were not covered by tests
}

for i := 0; i < len(args); i += 2 {
q.Add(args[i], args[i+1])
}

Check warning on line 578 in internal/templatefn/fn.go

View check run for this annotation

Codecov / codecov/patch

internal/templatefn/fn.go#L576-L578

Added lines #L576 - L578 were not covered by tests

return q

Check warning on line 580 in internal/templatefn/fn.go

View check run for this annotation

Codecov / codecov/patch

internal/templatefn/fn.go#L580

Added line #L580 was not covered by tests
}
4 changes: 3 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1557,5 +1557,7 @@
"someOfTheDetailsDoNotMatchYouAskedOpgToCheck": "<p class=\"govuk-body\">Welsh</p>",
"confirmationOfIdentityPending": "Welsh",
"whyCantEditMyLpa": "Welsh",
"whyCantEditMyLpaContent": "<p class=\"govuk-body\">Welsh</p><p class=\"govuk-body\"><a href=\"{{.Link}}\" class=\"govuk-link\">Welsh</a></p>"
"whyCantEditMyLpaContent": "<p class=\"govuk-body\">Welsh</p><p class=\"govuk-body\"><a href=\"{{.Link}}\" class=\"govuk-link\">Welsh</a></p>",
"yourCertificateProviderMustBeNotifiedDetailsUpdated": "<p class=\"govuk-body\">Welsh</p>",
"yourLpaDetailsHaveBeenUpdatedToMatchIdentityMustBeNotified": "<div class=\"govuk-notification-banner__content\"><h3 class=\"govuk-notification-banner__heading\">Welsh</h3><p class=\"govuk-body\">Welsh</p></div>"
}
4 changes: 3 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1453,5 +1453,7 @@
"someOfTheDetailsDoNotMatchYouAskedOpgToCheck": "<p class=\"govuk-body\">Some of the details on your LPA do not match your confirmed identity details. You have asked OPG to check this mismatch.</p><p class=\"govuk-body\">We will contact you if you need to take further action.</p>",
"confirmationOfIdentityPending": "Confirmation of identity pending",
"whyCantEditMyLpa": "Why can’t I edit my LPA?",
"whyCantEditMyLpaContent": "<p class=\"govuk-body\">You have signed your LPA, so you cannot change the decisions you made when you filled it in.</p><p class=\"govuk-body\"><a href=\"{{.Link}}\" class=\"govuk-link\">View LPA</a></p>"
"whyCantEditMyLpaContent": "<p class=\"govuk-body\">You have signed your LPA, so you cannot change the decisions you made when you filled it in.</p><p class=\"govuk-body\"><a href=\"{{.Link}}\" class=\"govuk-link\">View LPA</a></p>",
"yourCertificateProviderMustBeNotifiedDetailsUpdated": "<p class=\"govuk-body\">Your certificate provider must be notified of any updates to your LPA.</p><p class=\"govuk-body\">When you select ‘Continue’ you will be able to check your LPA and send a notification to your certificate provider that your LPA has been updated.</p>",
"yourLpaDetailsHaveBeenUpdatedToMatchIdentityMustBeNotified": "<div class=\"govuk-notification-banner__content\"><h3 class=\"govuk-notification-banner__heading\">Your LPA details have been updated to match your confirmed identity</h3><p class=\"govuk-body\">Your certificate provider must be notified of any updates to your LPA.</p></div>"
}
4 changes: 4 additions & 0 deletions web/template/donor/check_your_lpa.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{ if eq (.App.Query.Get "identityUpdated") "1" }}
{{ template "notification-banner" (notificationBanner .App "important" (trFormatHtml .App "yourLpaDetailsHaveBeenUpdatedToMatchIdentityMustBeNotified") "contents") }}
{{ end }}

<h1 class="govuk-heading-xl">
{{ tr .App "checkYourLpa" }}
</h1>
Expand Down
4 changes: 1 addition & 3 deletions web/template/donor/identity_details.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<div class="govuk-grid-column-two-thirds">
{{ if .Provided.ContinueWithMismatchedIdentity }}
{{ template "notification-banner" (notificationBanner .App "important" (trHtml .App "theOpgIsCheckingYourMismatchedIdentityDetails") "heading") }}
{{ else if .DetailsUpdated }}
{{ template "notification-banner" (notificationBanner .App "success" (trHtml .App "yourLPADetailsHaveBeenUpdatedToMatchIdentitySuccess") "success" "heading") }}
{{ else if .DetailsMatch }}
{{ if .Provided.WantVoucher.IsYes }}
{{ template "notification-banner" (notificationBanner .App "success" (trFormatHtml .App "voucherHasSuccessfullyConfirmedYourIdentity" "VoucherFullName" .Provided.Voucher.FullName) "success" "contents" ) }}
Expand All @@ -23,7 +21,7 @@
{{ template "notification-banner" (notificationBanner .App "important" (trHtml .App "theDetailsOnYourLpaDoNotMatch") "heading") }}
{{ end}}

{{ if or .DetailsUpdated (not .DetailsMatch) }}
{{ if not .DetailsMatch }}
<h1 class="govuk-heading-m">{{ tr .App "theDetailsOnYourLPA" }}</h1>

<dl class="govuk-summary-list govuk-!-margin-bottom-9">
Expand Down
30 changes: 30 additions & 0 deletions web/template/donor/identity_details_updated.gohtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{ template "page" . }}

{{ define "pageTitle" }}
{{ tr .App "yourConfirmedIdentityDetails" }}
{{ end }}

{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{ template "notification-banner" (notificationBanner .App "success" (trHtml .App "yourLPADetailsHaveBeenUpdatedToMatchIdentitySuccess") "success" "heading") }}

<h1 class="govuk-heading-m">{{ tr .App "theDetailsOnYourLPA" }}</h1>

<dl class="govuk-summary-list govuk-!-margin-bottom-9">
{{ template "summary-row" (staticSummaryRow .App "firstNames" .Donor.Donor.FirstNames) }}
{{ template "summary-row" (staticSummaryRow .App "lastName" .Donor.Donor.LastName) }}
{{ template "summary-row" (staticSummaryRow .App "dateOfBirth" (formatDate .App .Donor.Donor.DateOfBirth)) }}
{{ template "address-summary-row" (staticSummaryRow .App "address" .Donor.Donor.Address) }}
</dl>

{{ template "identity-details" (card .App .Donor.IdentityUserData) }}

<div class="govuk-inset-text">
{{ trHtml .App "yourCertificateProviderMustBeNotifiedDetailsUpdated" }}
</div>

{{ template "button" (button .App "continue" "link" (global.Paths.CheckYourLpa.FormatQuery .Donor.LpaID (query "identityUpdated" "1"))) }}
</div>
</div>
{{ end }}

0 comments on commit e0fdd1b

Please sign in to comment.