-
Notifications
You must be signed in to change notification settings - Fork 2
/
same_name_warning.go
94 lines (82 loc) · 2.18 KB
/
same_name_warning.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
package actor
import (
"fmt"
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
)
type SameNameWarning struct {
actor Type
matches Type
firstNames string
lastName string
}
func NewSameNameWarning(actor, matches Type, firstNames, lastName string) *SameNameWarning {
if actor == TypeNone || matches == TypeNone {
return nil
}
return &SameNameWarning{
actor: actor,
matches: matches,
firstNames: firstNames,
lastName: lastName,
}
}
func (w *SameNameWarning) Format(l localize.Localizer) string {
return l.Format(w.translationKey(), map[string]any{
"ArticleAndType": l.T(w.actorType()),
"FirstNames": w.firstNames,
"LastName": w.lastName,
})
}
func (w *SameNameWarning) String() string {
if w == nil {
return "<nil>"
}
return fmt.Sprintf("%d|%d|%s|%s", w.actor, w.matches, w.firstNames, w.lastName)
}
func (w *SameNameWarning) translationKey() string {
switch w.matches {
case TypeDonor:
return "donorMatchesActorWarning"
case TypeAttorney:
if w.actor == TypeAttorney {
return "attorneyMatchesAttorneyWarning"
}
return "attorneyMatchesActorWarning"
case TypeReplacementAttorney:
if w.actor == TypeReplacementAttorney {
return "replacementAttorneyMatchesReplacementAttorneyWarning"
}
return "replacementAttorneyMatchesActorWarning"
case TypeCertificateProvider:
return "certificateProviderMatchesActorWarning"
case TypePersonToNotify:
if w.actor == TypePersonToNotify {
return "personToNotifyMatchesPersonToNotifyWarning"
}
return "personToNotifyMatchesActorWarning"
case TypeAuthorisedSignatory:
return "authorisedSignatoryMatchesActorWarning"
case TypeIndependentWitness:
return "independentWitnessMatchesActorWarning"
}
return ""
}
func (w *SameNameWarning) actorType() string {
switch w.actor {
case TypeDonor:
return "theDonor"
case TypeAttorney:
return "anAttorney"
case TypeReplacementAttorney:
return "aReplacementAttorney"
case TypeCertificateProvider:
return "theCertificateProvider"
case TypePersonToNotify:
return "aPersonToNotify"
case TypeAuthorisedSignatory:
return "theAuthorisedSignatory"
case TypeIndependentWitness:
return "theIndependentWitness"
}
return ""
}