@lysaab/lysa-pep 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.development +1 -0
- package/lib/Exports.d.ts +8 -8
- package/lib/Exports.js +8 -8
- package/lib/components/CountrySelect.d.ts +22 -22
- package/lib/components/CountrySelect.js +21 -23
- package/lib/components/PepAnswers.d.ts +8 -8
- package/lib/components/PepAnswers.js +38 -38
- package/lib/components/PepAnswers.scss +7 -0
- package/lib/model/Countries.d.ts +4 -4
- package/lib/model/Countries.js +1002 -1002
- package/lib/model/PepModel.d.ts +7 -7
- package/lib/model/PepModel.js +40 -40
- package/lib/model/PepTexts.d.ts +322 -322
- package/lib/model/PepTexts.js +467 -467
- package/lib/pages/PepContext.d.ts +79 -79
- package/lib/pages/PepContext.js +67 -67
- package/lib/pages/PepIsPepPage.d.ts +6 -6
- package/lib/pages/PepIsPepPage.js +55 -57
- package/lib/pages/PepRelationPage.d.ts +6 -6
- package/lib/pages/PepRelationPage.js +79 -83
- package/lib/pages/PepRolePage.d.ts +10 -9
- package/lib/pages/PepRolePage.js +127 -127
- package/lib/pages/PepStatusPage.d.ts +6 -6
- package/lib/pages/PepStatusPage.js +51 -57
- package/package.json +5 -6
- package/src/components/CountrySelect.tsx +2 -6
- package/src/components/PepAnswers.scss +7 -7
- package/src/components/PepAnswers.tsx +122 -122
- package/src/model/PepTexts.ts +514 -514
- package/src/pages/PepIsPepPage.tsx +12 -14
- package/src/pages/PepRelationPage.tsx +24 -28
- package/src/pages/PepRolePage.tsx +38 -30
- package/src/pages/PepStatusPage.tsx +132 -143
- package/.vscode/settings.json +0 -4
|
@@ -2,14 +2,14 @@ import React, {
|
|
|
2
2
|
FunctionComponent,
|
|
3
3
|
useRef,
|
|
4
4
|
useCallback,
|
|
5
|
-
useContext
|
|
5
|
+
useContext,
|
|
6
6
|
} from "react";
|
|
7
7
|
import {
|
|
8
8
|
Form,
|
|
9
9
|
RadioGroup,
|
|
10
10
|
RequiredValidator,
|
|
11
11
|
PrimaryButton,
|
|
12
|
-
LysaFormRef
|
|
12
|
+
LysaFormRef,
|
|
13
13
|
} from "@lysaab/ui-2";
|
|
14
14
|
import { PepType, PepContext, EntityType } from "./PepContext";
|
|
15
15
|
import { LABELS } from "../model/PepTexts";
|
|
@@ -26,17 +26,17 @@ export const PepIsPepPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
26
26
|
const IsPepAlternatives = [
|
|
27
27
|
{
|
|
28
28
|
text: labels[entityType].GENERIC.IS_PEP[PepType.NOT_PEP],
|
|
29
|
-
value: PepType.NOT_PEP
|
|
29
|
+
value: PepType.NOT_PEP,
|
|
30
30
|
},
|
|
31
31
|
{ text: labels[entityType].GENERIC.IS_PEP[PepType.ME], value: PepType.ME },
|
|
32
32
|
{
|
|
33
33
|
text: labels[entityType].GENERIC.IS_PEP[PepType.RELATIVE],
|
|
34
|
-
value: PepType.RELATIVE
|
|
34
|
+
value: PepType.RELATIVE,
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
text: labels[entityType].GENERIC.IS_PEP[PepType.COLLEAGUE],
|
|
38
|
-
value: PepType.COLLEAGUE
|
|
39
|
-
}
|
|
38
|
+
value: PepType.COLLEAGUE,
|
|
39
|
+
},
|
|
40
40
|
];
|
|
41
41
|
|
|
42
42
|
const nextPage = useCallback(() => {
|
|
@@ -61,7 +61,7 @@ export const PepIsPepPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
61
61
|
militaryRank: undefined,
|
|
62
62
|
nameOfPEP: undefined,
|
|
63
63
|
relationToPEP: undefined,
|
|
64
|
-
role: undefined
|
|
64
|
+
role: undefined,
|
|
65
65
|
});
|
|
66
66
|
}, [pepContext]);
|
|
67
67
|
|
|
@@ -69,15 +69,13 @@ export const PepIsPepPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
69
69
|
<Form onSubmit={() => nextPage()} lysaFormRef={formRef}>
|
|
70
70
|
<RadioGroup
|
|
71
71
|
alternatives={IsPepAlternatives}
|
|
72
|
-
onChange={
|
|
73
|
-
pepContext.setState({
|
|
74
|
-
type: event.value ? (event.value.value as PepType) : undefined
|
|
75
|
-
});
|
|
72
|
+
onChange={alternative => {
|
|
73
|
+
pepContext.setState({ type: alternative.value });
|
|
76
74
|
resetValues();
|
|
77
75
|
}}
|
|
78
|
-
value={
|
|
79
|
-
|
|
80
|
-
}
|
|
76
|
+
value={IsPepAlternatives.find(
|
|
77
|
+
alt => alt.value === pepContext.state.type
|
|
78
|
+
)}
|
|
81
79
|
header={labels[entityType].GENERIC.IS_PEP_HEADER}
|
|
82
80
|
validators={[RequiredValidator("Du måste välja ett alternativ")]}
|
|
83
81
|
/>
|
|
@@ -2,14 +2,14 @@ import React, {
|
|
|
2
2
|
useContext,
|
|
3
3
|
useRef,
|
|
4
4
|
useCallback,
|
|
5
|
-
FunctionComponent
|
|
5
|
+
FunctionComponent,
|
|
6
6
|
} from "react";
|
|
7
7
|
import {
|
|
8
8
|
PepContext,
|
|
9
9
|
PepType,
|
|
10
10
|
BusinessRelation,
|
|
11
11
|
Relation,
|
|
12
|
-
EntityType
|
|
12
|
+
EntityType,
|
|
13
13
|
} from "./PepContext";
|
|
14
14
|
import {
|
|
15
15
|
LysaFormRef,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
RequiredValidator,
|
|
20
20
|
TextInput,
|
|
21
21
|
Datepicker,
|
|
22
|
-
PrimaryButton
|
|
22
|
+
PrimaryButton,
|
|
23
23
|
} from "@lysaab/ui-2";
|
|
24
24
|
import { LABELS } from "../model/PepTexts";
|
|
25
25
|
import { DateTime } from "luxon";
|
|
@@ -37,65 +37,65 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
37
37
|
const type = pepContext.state.type;
|
|
38
38
|
const labels = LABELS(pepContext.state.ownerName);
|
|
39
39
|
|
|
40
|
-
const businessRelationAlternatives: Alternative[] = [
|
|
40
|
+
const businessRelationAlternatives: Alternative<BusinessRelation>[] = [
|
|
41
41
|
{
|
|
42
42
|
text:
|
|
43
43
|
labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
|
|
44
44
|
BusinessRelation.CO_OWNERSHIP
|
|
45
45
|
],
|
|
46
|
-
value: BusinessRelation.CO_OWNERSHIP
|
|
46
|
+
value: BusinessRelation.CO_OWNERSHIP,
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
text:
|
|
50
50
|
labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
|
|
51
51
|
BusinessRelation.CLOSE_CONNECTION
|
|
52
52
|
],
|
|
53
|
-
value: BusinessRelation.CLOSE_CONNECTION
|
|
53
|
+
value: BusinessRelation.CLOSE_CONNECTION,
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
text:
|
|
57
57
|
labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
|
|
58
58
|
BusinessRelation.COMPANY_FOR_PEP
|
|
59
59
|
],
|
|
60
|
-
value: BusinessRelation.COMPANY_FOR_PEP
|
|
61
|
-
}
|
|
60
|
+
value: BusinessRelation.COMPANY_FOR_PEP,
|
|
61
|
+
},
|
|
62
62
|
];
|
|
63
63
|
|
|
64
|
-
const relationAlternatives: Alternative[] = [
|
|
64
|
+
const relationAlternatives: Alternative<Relation>[] = [
|
|
65
65
|
{
|
|
66
66
|
text:
|
|
67
67
|
labels[entityType][PepType.RELATIVE].RELATION[Relation.MARRIED_PARTNER],
|
|
68
|
-
value: Relation.MARRIED_PARTNER
|
|
68
|
+
value: Relation.MARRIED_PARTNER,
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
text:
|
|
72
72
|
labels[entityType][PepType.RELATIVE].RELATION[
|
|
73
73
|
Relation.COLIVING_PARTNER
|
|
74
74
|
],
|
|
75
|
-
value: Relation.COLIVING_PARTNER
|
|
75
|
+
value: Relation.COLIVING_PARTNER,
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
text: labels[entityType][PepType.RELATIVE].RELATION[Relation.CHILD],
|
|
79
|
-
value: Relation.CHILD
|
|
79
|
+
value: Relation.CHILD,
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
text: labels[entityType][PepType.RELATIVE].RELATION[Relation.PARENT],
|
|
83
|
-
value: Relation.PARENT
|
|
83
|
+
value: Relation.PARENT,
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
text:
|
|
87
87
|
labels[entityType][PepType.RELATIVE].RELATION[
|
|
88
88
|
Relation.CHILD_MARRIED_PARTNER
|
|
89
89
|
],
|
|
90
|
-
value: Relation.CHILD_MARRIED_PARTNER
|
|
90
|
+
value: Relation.CHILD_MARRIED_PARTNER,
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
text:
|
|
94
94
|
labels[entityType][PepType.RELATIVE].RELATION[
|
|
95
95
|
Relation.CHILD_COLIVING_PARTNER
|
|
96
96
|
],
|
|
97
|
-
value: Relation.CHILD_COLIVING_PARTNER
|
|
98
|
-
}
|
|
97
|
+
value: Relation.CHILD_COLIVING_PARTNER,
|
|
98
|
+
},
|
|
99
99
|
];
|
|
100
100
|
|
|
101
101
|
const nextPage = useCallback(() => {
|
|
@@ -108,11 +108,9 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
108
108
|
{type === PepType.RELATIVE ? (
|
|
109
109
|
<RadioGroup
|
|
110
110
|
alternatives={relationAlternatives}
|
|
111
|
-
onChange={
|
|
111
|
+
onChange={alternative => {
|
|
112
112
|
pepContext.setState({
|
|
113
|
-
relationToPEP:
|
|
114
|
-
? (event.value.value as Relation)
|
|
115
|
-
: undefined
|
|
113
|
+
relationToPEP: alternative.value,
|
|
116
114
|
});
|
|
117
115
|
}}
|
|
118
116
|
value={relationAlternatives.find(
|
|
@@ -125,11 +123,9 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
125
123
|
{type === PepType.COLLEAGUE ? (
|
|
126
124
|
<RadioGroup
|
|
127
125
|
alternatives={businessRelationAlternatives}
|
|
128
|
-
onChange={
|
|
126
|
+
onChange={alternative => {
|
|
129
127
|
pepContext.setState({
|
|
130
|
-
businessRelation:
|
|
131
|
-
? (event.value.value as BusinessRelation)
|
|
132
|
-
: undefined
|
|
128
|
+
businessRelation: alternative.value,
|
|
133
129
|
});
|
|
134
130
|
}}
|
|
135
131
|
value={businessRelationAlternatives.find(
|
|
@@ -148,8 +144,8 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
148
144
|
]
|
|
149
145
|
}
|
|
150
146
|
value={pepContext.state.nameOfPEP || ""}
|
|
151
|
-
onChange={
|
|
152
|
-
pepContext.setState({ nameOfPEP:
|
|
147
|
+
onChange={value => {
|
|
148
|
+
pepContext.setState({ nameOfPEP: value });
|
|
153
149
|
}}
|
|
154
150
|
validators={[RequiredValidator("Du måste ange namn")]}
|
|
155
151
|
/>
|
|
@@ -179,8 +175,8 @@ export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
179
175
|
]
|
|
180
176
|
}
|
|
181
177
|
value={pepContext.state.nameOfPEP || ""}
|
|
182
|
-
onChange={
|
|
183
|
-
pepContext.setState({ nameOfPEP:
|
|
178
|
+
onChange={value => {
|
|
179
|
+
pepContext.setState({ nameOfPEP: value });
|
|
184
180
|
}}
|
|
185
181
|
validators={[RequiredValidator("Du måste ange namn")]}
|
|
186
182
|
/>
|
|
@@ -2,7 +2,7 @@ import React, {
|
|
|
2
2
|
FunctionComponent,
|
|
3
3
|
useRef,
|
|
4
4
|
useCallback,
|
|
5
|
-
useContext
|
|
5
|
+
useContext,
|
|
6
6
|
} from "react";
|
|
7
7
|
import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
|
|
8
8
|
import {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
PrimaryButton,
|
|
12
12
|
RequiredValidator,
|
|
13
13
|
TextInput,
|
|
14
|
-
Select
|
|
14
|
+
Select,
|
|
15
15
|
} from "@lysaab/ui-2";
|
|
16
16
|
import {
|
|
17
17
|
PepContext,
|
|
@@ -21,76 +21,84 @@ import {
|
|
|
21
21
|
PepType,
|
|
22
22
|
} from "./PepContext";
|
|
23
23
|
import { CountrySelect } from "../components/CountrySelect";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
getGovernmentCompanyNameLabel,
|
|
26
|
+
getGovernmentCompanyRoleLabel,
|
|
27
|
+
getHighRankingPositionIntCorpNameLabel,
|
|
28
|
+
getHighRankingPositionIntCorpRoleLabel,
|
|
29
|
+
getMilitaryRankLabel,
|
|
30
|
+
getRoleLabel,
|
|
31
|
+
getAmbassadorLabel,
|
|
32
|
+
} from "../model/PepTexts";
|
|
25
33
|
|
|
26
34
|
interface Props {
|
|
27
35
|
next: () => void;
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
export const roleAlternatives: Alternative[] = [
|
|
38
|
+
export const roleAlternatives: Alternative<Role>[] = [
|
|
31
39
|
{ text: "Stats eller regeringschef", value: Role.HEAD_OF_GOVERNMENT },
|
|
32
40
|
{ text: "Minister eller Vice/Biträdande minister", value: Role.MINISTER },
|
|
33
41
|
{ text: "Ledamot i parlament eller riksdag", value: Role.PARLIMENT_MEMBER },
|
|
34
42
|
{
|
|
35
43
|
text: "Ledamot i centralbanks styrande organ",
|
|
36
|
-
value: Role.CENTRAL_BANK_MEMBER
|
|
44
|
+
value: Role.CENTRAL_BANK_MEMBER,
|
|
37
45
|
},
|
|
38
46
|
{
|
|
39
47
|
text: "Ledamot för styrelsen i politiskt parti representerade i riksdagen",
|
|
40
|
-
value: Role.BOARD_MEMBER_POLITICAL_PARTY
|
|
48
|
+
value: Role.BOARD_MEMBER_POLITICAL_PARTY,
|
|
41
49
|
},
|
|
42
50
|
{ text: "Domare i högsta domstolen", value: Role.JUDGE_SUPREME_COURT },
|
|
43
51
|
{
|
|
44
52
|
text:
|
|
45
53
|
"Domare i konstitutionell domstol eller annat rättsligt organ på hög nivå vars beslut endast undantagsvis kan överklagas",
|
|
46
|
-
value: Role.JUDGE_OTHER_HIGH_COURT
|
|
54
|
+
value: Role.JUDGE_OTHER_HIGH_COURT,
|
|
47
55
|
},
|
|
48
56
|
{
|
|
49
57
|
text: "Högre tjänsteman vid revisionsmyndighet",
|
|
50
|
-
value: Role.REVISION_INSTITUTE
|
|
58
|
+
value: Role.REVISION_INSTITUTE,
|
|
51
59
|
},
|
|
52
60
|
{ text: "Ambassadör eller bestickningschef", value: Role.AMBASSADOR },
|
|
53
61
|
{ text: "Högre officer i försvarsmakt", value: Role.MILITARY_OFFICER },
|
|
54
62
|
{
|
|
55
63
|
text:
|
|
56
64
|
"Person som ingår i statsägt företags förvaltnings-, lednings eller kontrollorgan",
|
|
57
|
-
value: Role.GOVERNMENT_COMPANY
|
|
65
|
+
value: Role.GOVERNMENT_COMPANY,
|
|
58
66
|
},
|
|
59
67
|
{
|
|
60
68
|
text: "EU-parlamentariker",
|
|
61
|
-
value: Role.EU_HIGH_RANKING_POSITION
|
|
69
|
+
value: Role.EU_HIGH_RANKING_POSITION,
|
|
62
70
|
},
|
|
63
71
|
{
|
|
64
72
|
text: "Befattning på hög nivå i en internationell organisation",
|
|
65
|
-
value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP
|
|
66
|
-
}
|
|
73
|
+
value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP,
|
|
74
|
+
},
|
|
67
75
|
];
|
|
68
76
|
|
|
69
|
-
export const militaryAlternatives: Alternative[] = [
|
|
77
|
+
export const militaryAlternatives: Alternative<MilitaryRank>[] = [
|
|
70
78
|
{
|
|
71
79
|
text: "General",
|
|
72
|
-
value: MilitaryRank.GENERAL
|
|
80
|
+
value: MilitaryRank.GENERAL,
|
|
73
81
|
},
|
|
74
82
|
{
|
|
75
83
|
text: "Generallöjtnant",
|
|
76
|
-
value: MilitaryRank.LIEUTENANT_GENERAL
|
|
84
|
+
value: MilitaryRank.LIEUTENANT_GENERAL,
|
|
77
85
|
},
|
|
78
86
|
{
|
|
79
87
|
text: "Generalmajor",
|
|
80
|
-
value: MilitaryRank.MAJOR_GENERAL
|
|
88
|
+
value: MilitaryRank.MAJOR_GENERAL,
|
|
81
89
|
},
|
|
82
90
|
{
|
|
83
91
|
text: "Amiral",
|
|
84
|
-
value: MilitaryRank.ADMIRAL
|
|
92
|
+
value: MilitaryRank.ADMIRAL,
|
|
85
93
|
},
|
|
86
94
|
{
|
|
87
95
|
text: "Viceamiral",
|
|
88
|
-
value: MilitaryRank.VICE_ADMIRAL
|
|
96
|
+
value: MilitaryRank.VICE_ADMIRAL,
|
|
89
97
|
},
|
|
90
98
|
{
|
|
91
99
|
text: "Konteramiral",
|
|
92
|
-
value: MilitaryRank.REAR_ADMIRAL
|
|
93
|
-
}
|
|
100
|
+
value: MilitaryRank.REAR_ADMIRAL,
|
|
101
|
+
},
|
|
94
102
|
];
|
|
95
103
|
|
|
96
104
|
export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
|
|
@@ -112,7 +120,7 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
|
|
|
112
120
|
governmentCompanyRole: undefined,
|
|
113
121
|
internationalOrganisation: undefined,
|
|
114
122
|
internationalOrganisationRole: undefined,
|
|
115
|
-
militaryRank: undefined
|
|
123
|
+
militaryRank: undefined,
|
|
116
124
|
});
|
|
117
125
|
}, [pepContext]);
|
|
118
126
|
|
|
@@ -155,7 +163,7 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
|
|
|
155
163
|
pepContext.setState({
|
|
156
164
|
ambassadorCountry: event.value
|
|
157
165
|
? event.value.toString()
|
|
158
|
-
: undefined
|
|
166
|
+
: undefined,
|
|
159
167
|
})
|
|
160
168
|
}
|
|
161
169
|
value={pepContext.state.ambassadorCountry}
|
|
@@ -175,8 +183,8 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
|
|
|
175
183
|
pepContext.state.ownerName
|
|
176
184
|
)}
|
|
177
185
|
value={pepContext.state.governmentCompany || ""}
|
|
178
|
-
onChange={
|
|
179
|
-
pepContext.setState({ governmentCompany:
|
|
186
|
+
onChange={value => {
|
|
187
|
+
pepContext.setState({ governmentCompany: value });
|
|
180
188
|
}}
|
|
181
189
|
validators={[RequiredValidator("Du måste ange ett namn")]}
|
|
182
190
|
/>
|
|
@@ -189,9 +197,9 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
|
|
|
189
197
|
pepContext.state.ownerName
|
|
190
198
|
)}
|
|
191
199
|
value={pepContext.state.governmentCompanyRole || ""}
|
|
192
|
-
onChange={
|
|
200
|
+
onChange={value => {
|
|
193
201
|
pepContext.setState({
|
|
194
|
-
governmentCompanyRole:
|
|
202
|
+
governmentCompanyRole: value,
|
|
195
203
|
});
|
|
196
204
|
}}
|
|
197
205
|
validators={[RequiredValidator("Du måste ange roll")]}
|
|
@@ -212,8 +220,8 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
|
|
|
212
220
|
pepContext.state.ownerName
|
|
213
221
|
)}
|
|
214
222
|
value={pepContext.state.internationalOrganisation || ""}
|
|
215
|
-
onChange={
|
|
216
|
-
pepContext.setState({ internationalOrganisation:
|
|
223
|
+
onChange={value => {
|
|
224
|
+
pepContext.setState({ internationalOrganisation: value });
|
|
217
225
|
}}
|
|
218
226
|
validators={[RequiredValidator("Du måste ange ett namn")]}
|
|
219
227
|
/>
|
|
@@ -226,9 +234,9 @@ export const PepRolePage: FunctionComponent<Props> = ({ next }) => {
|
|
|
226
234
|
pepContext.state.ownerName
|
|
227
235
|
)}
|
|
228
236
|
value={pepContext.state.internationalOrganisationRole || ""}
|
|
229
|
-
onChange={
|
|
237
|
+
onChange={value => {
|
|
230
238
|
pepContext.setState({
|
|
231
|
-
internationalOrganisationRole:
|
|
239
|
+
internationalOrganisationRole: value,
|
|
232
240
|
});
|
|
233
241
|
}}
|
|
234
242
|
validators={[RequiredValidator("Du måste ange roll")]}
|
|
@@ -1,143 +1,132 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
FunctionComponent,
|
|
3
|
-
useRef,
|
|
4
|
-
useCallback,
|
|
5
|
-
useContext
|
|
6
|
-
} from "react";
|
|
7
|
-
import {
|
|
8
|
-
Form,
|
|
9
|
-
RadioGroup,
|
|
10
|
-
RequiredValidator,
|
|
11
|
-
PrimaryButton,
|
|
12
|
-
LysaFormRef,
|
|
13
|
-
Datepicker
|
|
14
|
-
} from "@lysaab/ui-2";
|
|
15
|
-
import {
|
|
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
|
-
const
|
|
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
|
-
validators={[RequiredValidator("Du måste välja land")]}
|
|
134
|
-
value={pepContext.state.country}
|
|
135
|
-
removeSweden={true}
|
|
136
|
-
/>
|
|
137
|
-
) : null}
|
|
138
|
-
|
|
139
|
-
<PrimaryButton type="submit">Nästa</PrimaryButton>
|
|
140
|
-
</Form>
|
|
141
|
-
</div>
|
|
142
|
-
);
|
|
143
|
-
};
|
|
1
|
+
import React, {
|
|
2
|
+
FunctionComponent,
|
|
3
|
+
useRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
} from "react";
|
|
7
|
+
import {
|
|
8
|
+
Form,
|
|
9
|
+
RadioGroup,
|
|
10
|
+
RequiredValidator,
|
|
11
|
+
PrimaryButton,
|
|
12
|
+
LysaFormRef,
|
|
13
|
+
Datepicker,
|
|
14
|
+
} from "@lysaab/ui-2";
|
|
15
|
+
import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
|
|
16
|
+
import { PepContext, PepStatus } from "./PepContext";
|
|
17
|
+
import { CountrySelect } from "../components/CountrySelect";
|
|
18
|
+
|
|
19
|
+
const stateAlternatives: Alternative<PepStatus>[] = [
|
|
20
|
+
{
|
|
21
|
+
text: "Pågående",
|
|
22
|
+
value: PepStatus.ONGOING,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
text: "Avslutad",
|
|
26
|
+
value: PepStatus.ENDED,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const isSwedenAlternatives: Alternative<string>[] = [
|
|
31
|
+
{ text: "Sverige", value: "sweden" },
|
|
32
|
+
{ text: "Annat", value: "other" },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
interface Props {
|
|
36
|
+
next: () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const PepStatusPage: FunctionComponent<Props> = ({ next }) => {
|
|
40
|
+
const pepContext = useContext(PepContext);
|
|
41
|
+
const formRef = useRef<LysaFormRef>();
|
|
42
|
+
|
|
43
|
+
const nextPage = useCallback(() => {
|
|
44
|
+
if (formRef.current && formRef.current.isValid) {
|
|
45
|
+
next();
|
|
46
|
+
}
|
|
47
|
+
}, [formRef, next]);
|
|
48
|
+
|
|
49
|
+
const updateIsSweden = useCallback(
|
|
50
|
+
(alternative: Alternative<string>) => {
|
|
51
|
+
pepContext.setState({ isSweden: alternative.value });
|
|
52
|
+
|
|
53
|
+
if (alternative.value === "other") {
|
|
54
|
+
pepContext.setState({ country: undefined });
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
[pepContext]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const updateIsOngoing = useCallback(
|
|
61
|
+
(alternative: Alternative<PepStatus>) => {
|
|
62
|
+
pepContext.setState({ isOngoing: alternative.value });
|
|
63
|
+
|
|
64
|
+
if (alternative.value === PepStatus.ONGOING) {
|
|
65
|
+
pepContext.setState({ ended: undefined });
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
[pepContext]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div>
|
|
73
|
+
<Form
|
|
74
|
+
lysaFormRef={formRef}
|
|
75
|
+
onSubmit={() => {
|
|
76
|
+
nextPage();
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<RadioGroup
|
|
80
|
+
alternatives={stateAlternatives}
|
|
81
|
+
header="Är befattningen pågående eller avslutad?"
|
|
82
|
+
onChange={updateIsOngoing}
|
|
83
|
+
value={stateAlternatives.find(
|
|
84
|
+
alt => alt.value === pepContext.state.isOngoing
|
|
85
|
+
)}
|
|
86
|
+
validators={[RequiredValidator("Du måste välja ett alternativ")]}
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
{pepContext.state.isOngoing &&
|
|
90
|
+
pepContext.state.isOngoing === PepStatus.ENDED ? (
|
|
91
|
+
<Datepicker
|
|
92
|
+
label="När avslutades uppdraget?"
|
|
93
|
+
selected={pepContext.state.ended}
|
|
94
|
+
onChange={event =>
|
|
95
|
+
pepContext.setState({ ended: event || undefined })
|
|
96
|
+
}
|
|
97
|
+
validators={[RequiredValidator("Du måste ange fördelsedag")]}
|
|
98
|
+
showMonthYearPicker
|
|
99
|
+
dateFormat="yyyy-MM"
|
|
100
|
+
maxDate={new Date()}
|
|
101
|
+
/>
|
|
102
|
+
) : null}
|
|
103
|
+
|
|
104
|
+
<RadioGroup
|
|
105
|
+
alternatives={isSwedenAlternatives}
|
|
106
|
+
header="I vilket land är befattningen"
|
|
107
|
+
onChange={updateIsSweden}
|
|
108
|
+
value={isSwedenAlternatives.find(
|
|
109
|
+
alt => alt.value === pepContext.state.isSweden
|
|
110
|
+
)}
|
|
111
|
+
validators={[RequiredValidator("Du måste välja ett alternativ")]}
|
|
112
|
+
/>
|
|
113
|
+
|
|
114
|
+
{pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (
|
|
115
|
+
<CountrySelect
|
|
116
|
+
label="Välj i vilket land befattningen är"
|
|
117
|
+
onChange={event =>
|
|
118
|
+
pepContext.setState({
|
|
119
|
+
country: event.value ? event.value.toString() : undefined,
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
validators={[RequiredValidator("Du måste välja land")]}
|
|
123
|
+
value={pepContext.state.country}
|
|
124
|
+
removeSweden={true}
|
|
125
|
+
/>
|
|
126
|
+
) : null}
|
|
127
|
+
|
|
128
|
+
<PrimaryButton type="submit">Nästa</PrimaryButton>
|
|
129
|
+
</Form>
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
};
|