Skip to content

Commit

Permalink
Update dashboard for registered LPAs
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx committed Dec 3, 2024
1 parent 04eee0e commit b46772c
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 90 deletions.
3 changes: 3 additions & 0 deletions cmd/mlpa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func run(ctx context.Context, logger *slog.Logger) error {
searchEndpoint = os.Getenv("SEARCH_ENDPOINT")
searchIndexName = cmp.Or(os.Getenv("SEARCH_INDEX_NAME"), "lpas")
searchIndexingEnabled = os.Getenv("SEARCH_INDEXING_DISABLED") != "1"
useURL = os.Getenv("USE_A_LASTING_POWER_OF_ATTORNEY_URL")
)

staticHash, err := dirhash.HashDir(webDir+"/static", webDir, dirhash.DefaultHash)
Expand Down Expand Up @@ -304,6 +305,7 @@ func run(ctx context.Context, logger *slog.Logger) error {
eventClient,
lpaStoreClient,
searchClient,
useURL,
)))

mux.Handle("/", app.App(
Expand All @@ -328,6 +330,7 @@ func run(ctx context.Context, logger *slog.Logger) error {
eventClient,
lpaStoreClient,
searchClient,
useURL,
))

var handler http.Handler = mux
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/donor/dashboard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ describe('Dashboard', () => {
cy.contains('Property and affairs');
cy.contains('Sam Smith');
cy.contains('strong', 'Registered');
cy.get('.govuk-dashboard-row a').should('have.length', 2);
cy.contains('a', 'View LPA');
cy.contains('a', 'Use');
cy.contains('a', 'Continue to Use a lasting power of attorney');
});
});

Expand Down
3 changes: 2 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func App(
eventClient *event.Client,
lpaStoreClient *lpastore.Client,
searchClient *search.Client,
useURL string,
) http.Handler {
documentStore := document.NewStore(lpaDynamoClient, s3Client, eventClient)

Expand Down Expand Up @@ -154,7 +155,7 @@ func App(
handleRoot(page.PathVoucherStart, None,
page.Guidance(tmpls.Get("voucher_start.gohtml")))
handleRoot(page.PathDashboard, RequireSession,
page.Dashboard(tmpls.Get("dashboard.gohtml"), donorStore, dashboardStore))
page.Dashboard(tmpls.Get("dashboard.gohtml"), donorStore, dashboardStore, useURL))
handleRoot(page.PathLpaDeleted, RequireSession,
page.Guidance(tmpls.Get("lpa_deleted.gohtml")))
handleRoot(page.PathLpaWithdrawn, RequireSession,
Expand Down
2 changes: 1 addition & 1 deletion internal/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (m *mockDynamoClient) ExpectOneByPK(ctx, pk, data interface{}, err error) {
}

func TestApp(t *testing.T) {
app := App(true, &slog.Logger{}, &localize.Localizer{}, localize.En, template.Templates{}, template.Templates{}, template.Templates{}, template.Templates{}, template.Templates{}, template.Templates{}, nil, nil, "http://public.url", &pay.Client{}, &notify.Client{}, &place.Client{}, &onelogin.Client{}, nil, nil, nil, &search.Client{})
app := App(true, &slog.Logger{}, &localize.Localizer{}, localize.En, template.Templates{}, template.Templates{}, template.Templates{}, template.Templates{}, template.Templates{}, template.Templates{}, nil, nil, "http://public.url", &pay.Client{}, &notify.Client{}, &place.Client{}, &onelogin.Client{}, nil, nil, nil, &search.Client{}, "http://use.url")

assert.Implements(t, (*http.Handler)(nil), app)
}
Expand Down
39 changes: 26 additions & 13 deletions internal/page/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ type dashboardForm struct {
type dashboardData struct {
App appcontext.Data
Errors validation.List
UseTabs bool
NeedsTabs bool
DonorLpas []dashboarddata.Actor
RegisteredDonorLpas []dashboarddata.Actor
CertificateProviderLpas []dashboarddata.Actor
AttorneyLpas []dashboarddata.Actor
RegisteredAttorneyLpas []dashboarddata.Actor
VoucherLpas []dashboarddata.Actor
UseURL string
}

func Dashboard(tmpl template.Template, donorStore DonorStore, dashboardStore DashboardStore) Handler {
func Dashboard(tmpl template.Template, donorStore DonorStore, dashboardStore DashboardStore, useURL string) Handler {
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request) error {
if r.Method == http.MethodPost {
form := readDashboardForm(r)
Expand All @@ -54,24 +57,34 @@ func Dashboard(tmpl template.Template, donorStore DonorStore, dashboardStore Das
return err
}

tabCount := 1
if len(results.CertificateProvider) > 0 {
tabCount++
}
if len(results.Attorney) > 0 {
tabCount++
var donorLpas, registeredDonorLpas []dashboarddata.Actor
for _, lpa := range results.Donor {
if lpa.Lpa.RegisteredAt.IsZero() {
donorLpas = append(donorLpas, lpa)
} else {
registeredDonorLpas = append(registeredDonorLpas, lpa)
}
}
if len(results.Voucher) > 0 {
tabCount++

var attorneyLpas, registeredAttorneyLpas []dashboarddata.Actor
for _, lpa := range results.Attorney {
if lpa.Lpa.RegisteredAt.IsZero() {
attorneyLpas = append(attorneyLpas, lpa)
} else {
registeredAttorneyLpas = append(registeredAttorneyLpas, lpa)
}
}

data := &dashboardData{
App: appData,
UseTabs: tabCount > 1,
DonorLpas: results.Donor,
NeedsTabs: len(results.CertificateProvider) > 0 || len(results.Attorney) > 0 || len(results.Voucher) > 0,
DonorLpas: donorLpas,
RegisteredDonorLpas: registeredDonorLpas,
CertificateProviderLpas: results.CertificateProvider,
AttorneyLpas: results.Attorney,
AttorneyLpas: attorneyLpas,
RegisteredAttorneyLpas: registeredAttorneyLpas,
VoucherLpas: results.Voucher,
UseURL: useURL,
}

return tmpl(w, data)
Expand Down
32 changes: 19 additions & 13 deletions internal/page/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"strings"
"testing"
"time"

"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dashboard/dashboarddata"
Expand All @@ -20,16 +21,19 @@ func TestGetDashboard(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/", nil)

donorLpas := []dashboarddata.Actor{
{Lpa: &lpadata.Lpa{LpaID: "123"}},
{Lpa: &lpadata.Lpa{LpaID: "456"}},
}

donorLpas := []dashboarddata.Actor{{Lpa: &lpadata.Lpa{LpaID: "123"}}}
registeredDonorLpas := []dashboarddata.Actor{{Lpa: &lpadata.Lpa{LpaID: "456", RegisteredAt: time.Now()}}}
certificateProviderLpas := []dashboarddata.Actor{{Lpa: &lpadata.Lpa{LpaID: "abc"}}}
attorneyLpas := []dashboarddata.Actor{{Lpa: &lpadata.Lpa{LpaID: "def"}}}
registeredAttorneyLpas := []dashboarddata.Actor{{Lpa: &lpadata.Lpa{LpaID: "xyz", RegisteredAt: time.Now()}}}
voucherLpas := []dashboarddata.Actor{{Lpa: &lpadata.Lpa{LpaID: "def"}}}

results := dashboarddata.Results{Donor: donorLpas, CertificateProvider: certificateProviderLpas, Attorney: attorneyLpas, Voucher: voucherLpas}
results := dashboarddata.Results{
Donor: append(donorLpas, registeredDonorLpas...),
CertificateProvider: certificateProviderLpas,
Attorney: append(attorneyLpas, registeredAttorneyLpas...),
Voucher: voucherLpas,
}

dashboardStore := newMockDashboardStore(t)
dashboardStore.EXPECT().
Expand All @@ -40,15 +44,17 @@ func TestGetDashboard(t *testing.T) {
template.EXPECT().
Execute(w, &dashboardData{
App: appcontext.Data{},
UseTabs: true,
NeedsTabs: true,
DonorLpas: donorLpas,
RegisteredDonorLpas: registeredDonorLpas,
AttorneyLpas: attorneyLpas,
RegisteredAttorneyLpas: registeredAttorneyLpas,
CertificateProviderLpas: certificateProviderLpas,
VoucherLpas: voucherLpas,
}).
Return(nil)

err := Dashboard(template.Execute, nil, dashboardStore)(appcontext.Data{}, w, r)
err := Dashboard(template.Execute, nil, dashboardStore, "")(appcontext.Data{}, w, r)
resp := w.Result()

assert.Nil(t, err)
Expand Down Expand Up @@ -77,7 +83,7 @@ func TestGetDashboardOnlyDonor(t *testing.T) {
}).
Return(nil)

err := Dashboard(template.Execute, nil, dashboardStore)(appcontext.Data{}, w, r)
err := Dashboard(template.Execute, nil, dashboardStore, "")(appcontext.Data{}, w, r)
resp := w.Result()

assert.Nil(t, err)
Expand All @@ -93,7 +99,7 @@ func TestGetDashboardWhenDashboardStoreErrors(t *testing.T) {
GetAll(r.Context()).
Return(dashboarddata.Results{}, expectedError)

err := Dashboard(nil, nil, dashboardStore)(appcontext.Data{}, w, r)
err := Dashboard(nil, nil, dashboardStore, "")(appcontext.Data{}, w, r)
resp := w.Result()

assert.Equal(t, expectedError, err)
Expand All @@ -114,7 +120,7 @@ func TestGetDashboardWhenTemplateErrors(t *testing.T) {
Execute(w, mock.Anything).
Return(expectedError)

err := Dashboard(template.Execute, nil, dashboardStore)(appcontext.Data{}, w, r)
err := Dashboard(template.Execute, nil, dashboardStore, "")(appcontext.Data{}, w, r)
assert.Equal(t, expectedError, err)
}

Expand Down Expand Up @@ -143,7 +149,7 @@ func TestPostDashboard(t *testing.T) {
Create(r.Context()).
Return(&donordata.Provided{LpaID: "lpa-id"}, nil)

err := Dashboard(nil, donorStore, nil)(appcontext.Data{}, w, r)
err := Dashboard(nil, donorStore, nil, "")(appcontext.Data{}, w, r)
resp := w.Result()

assert.Nil(t, err)
Expand All @@ -162,7 +168,7 @@ func TestPostDashboardWhenDonorStoreError(t *testing.T) {
Create(r.Context()).
Return(&donordata.Provided{LpaID: "123"}, expectedError)

err := Dashboard(nil, donorStore, nil)(appcontext.Data{}, w, r)
err := Dashboard(nil, donorStore, nil, "")(appcontext.Data{}, w, r)
resp := w.Result()

assert.Equal(t, expectedError, err)
Expand Down
3 changes: 3 additions & 0 deletions internal/page/fixtures/attorney.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ func Attorney(
}

if registered {
if err := lpaStoreClient.SendStatutoryWaitingPeriod(donorCtx, donorDetails.LpaUID); err != nil {
return fmt.Errorf("problem sending register: %w", err)
}
if err := lpaStoreClient.SendRegister(donorCtx, donorDetails.LpaUID); err != nil {
return fmt.Errorf("problem sending register: %w", err)
}
Expand Down
11 changes: 6 additions & 5 deletions lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -942,11 +942,9 @@
"youMustReviewTheInformationYouHaveEntered": "Rhaid i chi adolygu’r wybodaeth rydych wedi’i rhoi.",
"viewSignedLpa": "Gweld yr LPA a lofnodwyd",
"useThisLpa": "Defnyddio’r LPA hon (mae’r gwasanaeth hwn yn agor mewn tab newydd)",
"registeredLpas": "Atwrniaethau Arhosol a gofrestrwyd",
"viewAndUseYourRegisteredLpas": "Welsh",
"viewAndUseRegisteredLpasAsAttorney": "Welsh",
"registeredLpasContent": "<p class=\"govuk-body\">Gallwch weld eich LPA yn ei chyfanrwydd isod, fel yr oedd pan gafodd ei llofnodi.</p><p class=\"govuk-body\">Gallwch hefyd fynd at y gwasanaeth ‘Defnyddio LPA’ lle gallwch reoli pa sefydliadau sy’n gallu defnyddio’ch LPA.</p>",
"registeredLpasContentAttorney": "<p class=\"govuk-body\"> Gallwch weld yr LPA yn ei chyfanrwydd isod, fel yr oedd pan gafodd ei llofnodi.</p><p class=\"govuk-body\"> Gallwch hefyd fynd at y gwasanaeth ‘Defnyddio LPA’ lle gallwch reoli pa sefydliadau sy’n gallu defnyddio’r LPA.</p>",
"whatIsTheUseService": "Beth yw’r gwasanaeth ‘Defnyddio LPA’?",
"whatIsTheUseServiceDetails": "<p class=\"govuk-body\">Unwaith y bydd LPA wedi’i chofrestru, gellir ei rhannu â sefydliadau drwy’r gwasanaeth ‘Defnyddio LPA’.</p><p class=\"govuk-body\">Efallai y bydd yn rhaid i chi greu cyfrif ar gyfer y gwasanaeth hwn os nad ydych wedi’i ddefnyddio o’r blaen. Os oes cyfrif gennych, bydd angen i chi fewngofnodi eto.</p><p class=\"govuk-body\">Yn y gwasanaeth ‘Defnyddio LPA’ byddwch yn gallu:</p><ul class=\"govuk-list govuk-list--bullet\"><li>rhoi hawl i sefydliadau weld crynodeb ar-lein o’r LPA, yn cynnwys unrhyw gyfyngiadau neu amodau</li><li>cadw golwg ar ba sefydliadau sydd â hawl i’w gweld</li><li>gweld y fersiwn ddiweddaraf o’r crynodeb o’r LPA, yn cynnwys unrhyw newidiadau a wnaed ers ei llofnodi </li><li>gofyn am allwedd cadarnhau cyfrif os nad ydych wedi cael un neu os ydyw wedi dod i ben</li></ul>",
"deleteThisLpa": "Dileu’r LPA hon",
"donorName": "Enw’r rhoddwr",
"lpaType": "Math o LPA",
Expand Down Expand Up @@ -1536,5 +1534,8 @@
"whatHappensNextRepeatApplicationNoFeeContent": "<h3 class=\"govuk-heading-m\">Welsh</h3>",
"theDetailsOnYourLpaDoNotMatch": "Welsh",
"theDetailsOnYourLpaCannotBeUpdatedAsSigned": "<p class=\"govuk-body\">Welsh</p>",
"ifYouDoNotWantRegisteredWithConfirmedDetailsWarning": "Welsh"
"ifYouDoNotWantRegisteredWithConfirmedDetailsWarning": "Welsh",
"continueToUse": "Welsh",
"yourLpasHaveBeenSuccessfullyRegistered": "Welsh",
"theLpasNamedAsAttorneyHaveSuccessfullyRegistered": "Welsh"
}
13 changes: 7 additions & 6 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,9 @@
"youMustReviewTheInformationYouHaveEntered": "You must review the information you have entered.",
"viewSignedLpa": "View signed LPA",
"useThisLpa": "Use this LPA (this service opens in a new tab)",
"registeredLpas": "Registered LPAs",
"registeredLpasContent": "<p class=\"govuk-body\">You can view your LPA in full below, as it was when it was signed.</p><p class=\"govuk-body\">You can also go to the ‘Use a lasting power of attorney’ service where you can manage which organisations can use your LPA.</p>",
"registeredLpasContentAttorney": "<p class=\"govuk-body\">You can view the LPA in full below, as it was when it was signed.</p><p class=\"govuk-body\">You can also go to the ‘Use a lasting power of attorney’ service where you can manage which organisations can use the LPA.</p>",
"whatIsTheUseService": "What is the ‘Use a lasting power of attorney’ service?",
"whatIsTheUseServiceDetails": "<p class=\"govuk-body\">Once an LPA is registered, it can be shared with organisations on the ‘Use a lasting power of attorney’ service.</p><p class=\"govuk-body\">You may have to create an account for this service if you’ve not used it before. If you have an account, you will need to sign in again.</p><p class=\"govuk-body\">On the ‘Use a lasting power of attorney’ service you can:</p><ul class=\"govuk-list govuk-list--bullet\"><li>give organisations access to an online summary of the LPA, including any restrictions or conditions</li><li>keep track of the organisations that have access</li><li>view the most up to date version of the LPA summary, including any changes since it was signed</li><li>ask for an activation key if you have not been given one or it has expired</li></ul>",
"viewAndUseYourRegisteredLpas": "View and use your registered LPAs",
"viewAndUseRegisteredLpasAsAttorney": "View and use registered LPAs where you are named as an attorney",
"registeredLpasContent": "<p class=\"govuk-body\">Registered LPAs can be viewed and used in the ‘Use a lasting power of attorney’ service. This allows:</p><ul class=\"govuk-list govuk-list--bullet\"><li>donors to view LPAs they have completed and registered with the Office of the Public Guardian (OPG)</li><li>attorneys to view LPAs completed and registered with OPG</li><li>attorneys to give banks and other organisations access to the LPA</li></ul>",
"deleteThisLpa": "Delete this LPA",
"donorName": "Donor name",
"lpaType": "LPA type",
Expand Down Expand Up @@ -1428,5 +1426,8 @@
"whatHappensNextRepeatApplicationNoFeeContent": "<h3 class=\"govuk-heading-m\">Sign your LPA</h3><p class=\"govuk-body\">You can still sign your LPA while we’re reviewing your application. Your certificate provider must be there as a witness when you sign it. However, we will not contact your certificate provider to provide their certificate until your repeat application has been approved.</p><h3 class=\"govuk-heading-m\">If your application is successful</h3><p class=\"govuk-body\">Once we have approved your repeat application, we will contact your certificate provider to provide their certificate.</p><h3 class=\"govuk-heading-m\">If your application is not successful</h3><p class=\"govuk-body\">We will contact you if we need more information or if your application is unsuccessful.</p>",
"theDetailsOnYourLpaDoNotMatch": "The details on your LPA do not match the identity details you have confirmed using GOV.UK One Login.",
"theDetailsOnYourLpaCannotBeUpdatedAsSigned": "<p class=\"govuk-body\">The details on your LPA cannot be updated to match the identity details you confirmed using GOV.UK One Login. This is because you have already signed the LPA.</p><p class=\"govuk-body\">The Office of the Public Guardian (OPG) will compare your details, and may contact you for more information.</p><p class=\"govuk-body\">OPG will then decide if we can register your LPA. We will let you know if there is anything else you need to do.</p><div class=\"govuk-inset-text\"><p class=\"govuk-body\">If OPG decides we can register your LPA, it will be updated with your confirmed identity details.</p></div>",
"ifYouDoNotWantRegisteredWithConfirmedDetailsWarning": "If you do not want your LPA to be registered with your confirmed identity details, you must withdraw your LPA. You will lose any fees you have paid for this LPA."
"ifYouDoNotWantRegisteredWithConfirmedDetailsWarning": "If you do not want your LPA to be registered with your confirmed identity details, you must withdraw your LPA. You will lose any fees you have paid for this LPA.",
"continueToUse": "Continue to Use a lasting power of attorney",
"yourLpasHaveBeenSuccessfullyRegistered": "Your LPAs have been successfully registered.",
"theLpasNamedAsAttorneyHaveSuccessfullyRegistered": "The LPAs where you are named as an attorney have been successfully registered."
}
5 changes: 5 additions & 0 deletions terraform/environment/region/modules/app/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ locals {
name = "LPA_STORE_SECRET_ARN",
value = data.aws_secretsmanager_secret.lpa_store_jwt_key.arn
},
{
name = "USE_A_LASTING_POWER_OF_ATTORNEY_URL",
// TODO: change this to be per env when we actually integrate
value = "https://use-lasting-power-of-attorney.service.gov.uk/lpa/dashboard"
},
]
}
)
Expand Down
Loading

0 comments on commit b46772c

Please sign in to comment.