Skip to content

Commit

Permalink
Merge 671500e into 6c8e023
Browse files Browse the repository at this point in the history
  • Loading branch information
acsauk authored Mar 21, 2024
2 parents 6c8e023 + 671500e commit 0f71afe
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 6 deletions.
3 changes: 2 additions & 1 deletion internal/actor/donor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package actor

import (
"fmt"
"strings"

"github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid"
"github.com/ministryofjustice/opg-modernising-lpa/internal/date"
Expand Down Expand Up @@ -32,7 +33,7 @@ type Donor struct {
}

func (d Donor) FullName() string {
return fmt.Sprintf("%s %s", d.FirstNames, d.LastName)
return strings.Trim(fmt.Sprintf("%s %s", d.FirstNames, d.LastName), " ")
}

// AuthorisedSignatory contains details of the person who will sign the LPA on the donor's behalf
Expand Down
3 changes: 3 additions & 0 deletions internal/page/app_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type AppData struct {
LoginSessionEmail string
Permission actor.Permission
LoggedInSupporterID string
IsDonorPage bool
LpaType actor.LpaType
DonorFullName string
}

func (d AppData) Redirect(w http.ResponseWriter, r *http.Request, url string) error {
Expand Down
11 changes: 8 additions & 3 deletions internal/page/donor/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,6 @@ func makeLpaHandle(mux *http.ServeMux, store SessionStore, errorHandler page.Err
}

if loginSession.OrganisationID != "" {
appData.IsSupporter = true
appData.OrganisationName = loginSession.OrganisationName

sessionData.OrganisationID = loginSession.OrganisationID
sessionData.Email = loginSession.Email
}
Expand All @@ -458,6 +455,14 @@ func makeLpaHandle(mux *http.ServeMux, store SessionStore, errorHandler page.Err
return
}

if loginSession.OrganisationID != "" {
appData.IsSupporter = true
appData.OrganisationName = loginSession.OrganisationName
appData.IsDonorPage = true
appData.LpaType = lpa.Type
appData.DonorFullName = lpa.Donor.FullName()
}

if err := h(appData, w, r.WithContext(page.ContextWithAppData(ctx, appData)), lpa); err != nil {
errorHandler(w, r, err)
}
Expand Down
4 changes: 3 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1159,5 +1159,7 @@
"accessRemoved": "Welsh",
"youRemovedAccessToThisLPAFor": "Welsh <span class=\"govuk-!-font-weight-bold\">{{.Email}}</span>.",
"lpaTaskList": "Welsh",
"donorsTypeLpa": "{{.DonorFullNamePossessive}} {{.LpaType}} Welsh"
"donorsTypeLpa": "{{.DonorFullNamePossessive}} {{.LpaType}} Welsh",
"supporterLPAContextPrimer": "<p class=\"app-supporter-lpa-context-banner__content govuk-!-font-weight-bold\">Welsh</p> <p class=\"app-supporter-lpa-context-banner__content\">Welsh</p>",
"youAreDrafting": "Welsh"
}
4 changes: 3 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1091,5 +1091,7 @@
"accessRemoved": "Access removed",
"youRemovedAccessToThisLPAFor": "You removed access to this LPA for <span class=\"govuk-!-font-weight-bold\">{{.Email}}</span>.",
"lpaTaskList": "LPA task list",
"donorsTypeLpa": "{{.DonorFullNamePossessive}} {{.LpaType}} LPA"
"donorsTypeLpa": "{{.DonorFullNamePossessive}} {{.LpaType}} LPA",
"supporterLPAContextPrimer": "<p class=\"app-supporter-lpa-context-banner__content govuk-!-font-weight-bold\">As a supporter drafting an LPA, you’ll need to enter information about the donor.</p> <p class=\"app-supporter-lpa-context-banner__content\">The language in this service addresses the donor. For example: ‘Your details’ requires you to enter the details of the donor.</p>",
"youAreDrafting": "You are drafting"
}
1 change: 1 addition & 0 deletions web/assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import "patterns/trans_switch";
@import "patterns/data_loss_warning";
@import "patterns/loading_spinner";
@import "patterns/supporter-lpa-context";

.app-float-right {
float: right;
Expand Down
13 changes: 13 additions & 0 deletions web/assets/scss/patterns/_supporter-lpa-context.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import "node_modules/govuk-frontend/dist/govuk/base";
@import "node_modules/govuk-frontend/dist/govuk/objects/grid";

.app-supporter-lpa-context-banner{
border-bottom: 2px solid #000000;
margin-bottom: govuk-spacing(8);
padding-left: govuk-spacing(3);
background-color: #cce2d8;

.app-supporter-lpa-context-banner__content{
@include govuk-font($size: 19);
}
}
1 change: 1 addition & 0 deletions web/template/layout/page.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@

<main class="govuk-main-wrapper app-main-class" id="main-content" role="main">
{{ template "error-summary" . }}
{{ template "supporter-lpa-context" . }}
{{ template "main" . }}
</main>
</div>
Expand Down
18 changes: 18 additions & 0 deletions web/template/layout/supporter-lpa-context.gohtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ define "supporter-lpa-context" }}
{{ if and .App.IsSupporter .App.IsDonorPage }}
<div class="app-supporter-lpa-context-banner">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{ if and (not .App.DonorFullName) .App.LpaType.Empty }}
{{ trHtml .App "supporterLPAContextPrimer" }}
{{ else }}
<p class="app-supporter-lpa-context-banner__content">
{{ $donorNamePossessive := .App.Localizer.Possessive .App.DonorFullName }}
{{ tr .App "youAreDrafting" }} <span class="govuk-!-font-weight-bold">{{ $donorNamePossessive }} {{ if not .App.LpaType.Empty }} {{ lowerFirst (tr .App .App.LpaType.String) }} {{ end }}</span>{{ tr .App "lpa" }}
</p>
{{ end }}
</div>
</div>
</div>
{{ end }}
{{ end }}

0 comments on commit 0f71afe

Please sign in to comment.