Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 3dbc386 into 63e1788
Browse files Browse the repository at this point in the history
hawx authored Aug 22, 2024
2 parents 63e1788 + 3dbc386 commit 6686b73
Showing 8 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion internal/voucher/path.go
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ func (p Path) Redirect(w http.ResponseWriter, r *http.Request, appData appcontex
func (p Path) CanGoTo(provided *voucherdata.Provided) bool {
switch p {
case PathYourName:
return !provided.Tasks.ConfirmYourIdentity.IsCompleted()
return provided.Tasks.ConfirmYourIdentity.IsNotStarted()

case PathVerifyDonorDetails:
return provided.Tasks.ConfirmYourName.IsCompleted() &&
12 changes: 10 additions & 2 deletions internal/voucher/voucherpage/confirm_allowed_to_vouch.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package voucherpage
import (
"errors"
"net/http"
"strings"

"github.com/ministryofjustice/opg-go-common/template"
"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext"
@@ -20,6 +21,7 @@ type confirmAllowedToVouchData struct {
Form *form.YesNoForm
Lpa *lpadata.Lpa
SurnameMatchesDonor bool
MatchIdentity bool
}

func ConfirmAllowedToVouch(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, voucherStore VoucherStore) Handler {
@@ -33,7 +35,8 @@ func ConfirmAllowedToVouch(tmpl template.Template, lpaStoreResolvingService LpaS
App: appData,
Form: form.NewYesNoForm(form.YesNoUnknown),
Lpa: lpa,
SurnameMatchesDonor: provided.LastName == lpa.Donor.LastName,
SurnameMatchesDonor: strings.EqualFold(provided.LastName, lpa.Donor.LastName),
MatchIdentity: provided.Tasks.ConfirmYourIdentity.IsInProgress(),
}

if r.Method == http.MethodPost {
@@ -45,7 +48,12 @@ func ConfirmAllowedToVouch(tmpl template.Template, lpaStoreResolvingService LpaS
return errors.New("// TODO there should be a page here but it hasn't been built yet")
}

provided.Tasks.ConfirmYourName = task.StateCompleted
if provided.Tasks.ConfirmYourIdentity.IsInProgress() {
provided.Tasks.ConfirmYourIdentity = task.StateCompleted
} else {
provided.Tasks.ConfirmYourName = task.StateCompleted
}

if err := voucherStore.Put(r.Context(), provided); err != nil {
return err
}
4 changes: 3 additions & 1 deletion internal/voucher/voucherpage/confirm_your_name.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package voucherpage

import (
"net/http"
"strings"

"github.com/ministryofjustice/opg-go-common/template"
"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext"
@@ -45,7 +46,8 @@ func ConfirmYourName(tmpl template.Template, lpaStoreResolvingService LpaStoreRe
provided.FirstNames = firstNames
provided.LastName = lastName

if lastName == lpa.Donor.LastName || !provided.NameMatches(lpa).IsNone() {
if !provided.Tasks.ConfirmYourName.IsCompleted() &&
(strings.EqualFold(lastName, lpa.Donor.LastName) || !provided.NameMatches(lpa).IsNone()) {
redirect = voucher.PathConfirmAllowedToVouch
state = task.StateInProgress
}
13 changes: 11 additions & 2 deletions internal/voucher/voucherpage/identity_with_one_login_callback.go
Original file line number Diff line number Diff line change
@@ -45,7 +45,12 @@ func IdentityWithOneLoginCallback(oneLoginClient OneLoginClient, sessionStore Se
}

provided.IdentityUserData = userData
provided.Tasks.ConfirmYourIdentity = task.StateCompleted
if provided.NameMatches(lpa).IsNone() {
provided.Tasks.ConfirmYourIdentity = task.StateCompleted
} else {
provided.Tasks.ConfirmYourIdentity = task.StateInProgress
}

if err := voucherStore.Put(r.Context(), provided); err != nil {
return err
}
@@ -66,6 +71,10 @@ func IdentityWithOneLoginCallback(oneLoginClient OneLoginClient, sessionStore Se
return voucher.PathUnableToConfirmIdentity.Redirect(w, r, appData, appData.LpaID)
}

return voucher.PathOneLoginIdentityDetails.Redirect(w, r, appData, appData.LpaID)
if provided.Tasks.ConfirmYourIdentity.IsCompleted() {
return voucher.PathOneLoginIdentityDetails.Redirect(w, r, appData, appData.LpaID)
}

return voucher.PathConfirmAllowedToVouch.Redirect(w, r, appData, appData.LpaID)
}
}
5 changes: 4 additions & 1 deletion internal/voucher/voucherpage/task_list.go
Original file line number Diff line number Diff line change
@@ -32,7 +32,10 @@ func TaskList(tmpl template.Template, lpaStoreResolvingService LpaStoreResolving
}

confirmYourIdentityPath := voucher.PathConfirmYourIdentity
if provided.Tasks.ConfirmYourIdentity.IsCompleted() {
switch provided.Tasks.ConfirmYourIdentity {
case task.StateInProgress:
confirmYourIdentityPath = voucher.PathConfirmAllowedToVouch
case task.StateCompleted:
confirmYourIdentityPath = voucher.PathOneLoginIdentityDetails
}

3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
@@ -1280,5 +1280,6 @@
"thankYou": "Thank you",
"youHaveVouchedFor": "You have vouched for {{.DonorFullNamePossessive}} identity.",
"voucherThankYouContent": "<p class=\"govuk-body\">You do not need to do anything else.</p><p class=\"govuk-body\">{{.DonorFirstNamesPossessive}} vouching request will no longer appear on your dashboard.</p><p class=\"govuk-body\">You can print this page out for your records if you wish, or close this browsing window.</p>",
"youHaveEnteredNameWhichMatchesSomeone": "You have entered a name that matches someone named on {{.DonorFullNamePossessive}} lasting power of attorney (LPA)."
"youHaveEnteredNameWhichMatchesSomeone": "You have entered a name that matches someone named on {{.DonorFullNamePossessive}} lasting power of attorney (LPA).",
"yourConfirmedIdentityDetailsMatchSomeone": "Your confirmed identity details match someone named on {{.DonorFullNamePossessive}} lasting power of attorney (LPA)."
}
5 changes: 4 additions & 1 deletion web/template/voucher/confirm_allowed_to_vouch.gohtml
Original file line number Diff line number Diff line change
@@ -10,7 +10,10 @@
<h1 class="govuk-heading-xl">{{ tr .App "confirmThatYouAreAllowedToVouch" }}</h1>

<p class="govuk-body">
{{ if .SurnameMatchesDonor }}
{{ if .MatchIdentity }}
{{ trFormat .App "yourConfirmedIdentityDetailsMatchSomeone"
"DonorFullNamePossessive" (possessive .App .Lpa.Donor.FullName) }}
{{ else if .SurnameMatchesDonor }}
{{ trFormat .App "theDonorsLastNameMatchesYours"
"DonorFullNamePossessive" (possessive .App .Lpa.Donor.FullName) }}
{{ else }}
2 changes: 1 addition & 1 deletion web/template/voucher/confirm_your_name.gohtml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
{{ define "pageTitle" }}{{ tr .App "confirmYourName" }}{{ end }}

{{ define "main" }}
{{ $canChange := not .Tasks.ConfirmYourIdentity.IsCompleted }}
{{ $canChange := .Tasks.ConfirmYourIdentity.IsNotStarted }}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

0 comments on commit 6686b73

Please sign in to comment.