-
Notifications
You must be signed in to change notification settings - Fork 2
/
task_list.go
158 lines (144 loc) · 4.44 KB
/
task_list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package donor
import (
"net/http"
"github.com/ministryofjustice/opg-go-common/template"
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
"github.com/ministryofjustice/opg-modernising-lpa/internal/validation"
)
type taskListData struct {
App page.AppData
Errors validation.List
Donor *actor.DonorProvidedDetails
Sections []taskListSection
EvidenceReceived bool
}
type taskListItem struct {
Name string
Path string
State actor.TaskState
PaymentState actor.PaymentTask
Count int
Hidden bool
}
type taskListSection struct {
Heading string
Items []taskListItem
}
func TaskList(tmpl template.Template, evidenceReceivedStore EvidenceReceivedStore) Handler {
return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error {
signTaskPage := page.Paths.HowToConfirmYourIdentityAndSign
if donor.DonorIdentityConfirmed() {
signTaskPage = page.Paths.ReadYourLpa
}
typeSpecificStep := taskListItem{
Name: "chooseWhenTheLpaCanBeUsed",
Path: page.Paths.WhenCanTheLpaBeUsed.Format(donor.LpaID),
State: donor.Tasks.WhenCanTheLpaBeUsed,
}
if donor.Type == actor.LpaTypePersonalWelfare {
typeSpecificStep = taskListItem{
Name: "lifeSustainingTreatment",
Path: page.Paths.LifeSustainingTreatment.Format(donor.LpaID),
State: donor.Tasks.LifeSustainingTreatment,
}
}
evidenceReceived, err := evidenceReceivedStore.Get(r.Context())
if err != nil {
return err
}
var paymentPath string
switch donor.Tasks.PayForLpa {
case actor.PaymentTaskDenied:
paymentPath = page.Paths.FeeDenied.Format(donor.LpaID)
case actor.PaymentTaskMoreEvidenceRequired:
paymentPath = page.Paths.UploadEvidence.Format(donor.LpaID)
default:
paymentPath = page.Paths.AboutPayment.Format(donor.LpaID)
}
checkPath := page.Paths.CheckYourLpa
if len(donor.Under18ActorDetails()) > 0 {
checkPath = page.Paths.YouCannotSignYourLpaYet
} else if donor.CertificateProviderSharesDetails() {
checkPath = page.Paths.ConfirmYourCertificateProviderIsNotRelated
}
data := &taskListData{
App: appData,
Donor: donor,
EvidenceReceived: evidenceReceived,
Sections: []taskListSection{
{
Heading: "fillInTheLpa",
Items: []taskListItem{
{
Name: "provideYourDetails",
Path: page.Paths.YourDetails.Format(donor.LpaID),
State: donor.Tasks.YourDetails,
},
{
Name: "chooseYourAttorneys",
Path: page.Paths.ChooseAttorneysGuidance.Format(donor.LpaID),
State: donor.Tasks.ChooseAttorneys,
Count: donor.Attorneys.Len(),
},
{
Name: "chooseYourReplacementAttorneys",
Path: page.Paths.DoYouWantReplacementAttorneys.Format(donor.LpaID),
State: donor.Tasks.ChooseReplacementAttorneys,
Count: donor.ReplacementAttorneys.Len(),
},
typeSpecificStep,
{
Name: "addRestrictionsToTheLpa",
Path: page.Paths.Restrictions.Format(donor.LpaID),
State: donor.Tasks.Restrictions,
},
{
Name: "chooseYourCertificateProvider",
Path: page.Paths.WhatACertificateProviderDoes.Format(donor.LpaID),
State: donor.Tasks.CertificateProvider,
},
{
Name: "peopleToNotifyAboutYourLpa",
Path: page.Paths.DoYouWantToNotifyPeople.Format(donor.LpaID),
State: donor.Tasks.PeopleToNotify,
Count: len(donor.PeopleToNotify),
},
{
Name: "chooseYourSignatoryAndIndependentWitness",
Path: page.Paths.GettingHelpSigning.Format(donor.LpaID),
State: donor.Tasks.ChooseYourSignatory,
Hidden: !donor.Donor.CanSign.IsNo(),
},
{
Name: "checkAndSendToYourCertificateProvider",
Path: checkPath.Format(donor.LpaID),
State: donor.Tasks.CheckYourLpa,
},
},
},
{
Heading: "payForTheLpa",
Items: []taskListItem{
{
Name: "payForTheLpa",
Path: paymentPath,
PaymentState: donor.Tasks.PayForLpa,
},
},
},
{
Heading: "confirmYourIdentityAndSign",
Items: []taskListItem{
{
Name: "confirmYourIdentityAndSign",
Path: signTaskPage.Format(donor.LpaID),
State: donor.Tasks.ConfirmYourIdentityAndSign,
},
},
},
},
}
return tmpl(w, data)
}
}