@lysaab/lysa-pep 1.0.0-1 → 1.0.0
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/lib/Exports.d.ts +8 -7
- package/lib/Exports.js +8 -7
- package/lib/components/CountrySelect.d.ts +22 -15
- package/lib/components/CountrySelect.js +21 -30
- package/lib/components/PepAnswers.d.ts +8 -8
- package/lib/components/PepAnswers.js +39 -131
- package/lib/components/PepAnswers.scss +7 -7
- 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 +380 -322
- package/lib/model/PepTexts.js +552 -467
- package/lib/pages/PepContext.d.ts +80 -80
- package/lib/pages/PepContext.js +88 -88
- package/lib/pages/PepIsPepPage.d.ts +15 -6
- package/lib/pages/PepIsPepPage.js +59 -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 +58 -57
- package/package.json +53 -56
- package/src/Exports.ts +13 -12
- package/src/components/CountrySelect.tsx +43 -47
- package/src/components/PepAnswers.scss +7 -7
- package/src/components/PepAnswers.tsx +120 -252
- package/src/demo/Done.tsx +20 -16
- package/src/demo/Pep.tsx +106 -112
- package/src/model/PepModel.ts +52 -52
- package/src/model/PepTexts.ts +607 -0
- package/src/pages/PepContext.tsx +144 -144
- package/src/pages/PepIsPepPage.tsx +107 -0
- package/src/pages/PepRelationPage.tsx +188 -0
- package/src/pages/PepRolePage.tsx +272 -0
- package/src/pages/PepStatusPage.tsx +157 -0
- package/.vscode/settings.json +0 -4
- package/lib/pages/IsPep/IsPepMessages.d.ts +0 -32
- package/lib/pages/IsPep/IsPepMessages.js +0 -74
- package/lib/pages/IsPep/IsPepPage.d.ts +0 -14
- package/lib/pages/IsPep/IsPepPage.js +0 -39
- package/lib/pages/RelationPage/RelationMessages.d.ts +0 -105
- package/lib/pages/RelationPage/RelationMessages.js +0 -282
- package/lib/pages/RelationPage/RelationPage.d.ts +0 -6
- package/lib/pages/RelationPage/RelationPage.js +0 -142
- package/lib/pages/RolePage/RoleMessages.d.ts +0 -185
- package/lib/pages/RolePage/RoleMessages.js +0 -381
- package/lib/pages/RolePage/RolePage.d.ts +0 -11
- package/lib/pages/RolePage/RolePage.js +0 -214
- package/lib/pages/StatusPage/StatusMessages.d.ts +0 -72
- package/lib/pages/StatusPage/StatusMessages.js +0 -74
- package/lib/pages/StatusPage/StatusPage.d.ts +0 -6
- package/lib/pages/StatusPage/StatusPage.js +0 -75
- package/src/pages/IsPep/IsPepMessages.ts +0 -75
- package/src/pages/IsPep/IsPepPage.tsx +0 -94
- package/src/pages/RelationPage/RelationMessages.ts +0 -287
- package/src/pages/RelationPage/RelationPage.tsx +0 -269
- package/src/pages/RolePage/RoleMessages.ts +0 -389
- package/src/pages/RolePage/RolePage.tsx +0 -342
- package/src/pages/StatusPage/StatusMessages.ts +0 -80
- package/src/pages/StatusPage/StatusPage.tsx +0 -172
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
FunctionComponent,
|
|
3
|
-
useRef,
|
|
4
|
-
useCallback,
|
|
5
|
-
useContext
|
|
6
|
-
} from "react";
|
|
7
|
-
import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
|
|
8
|
-
import {
|
|
9
|
-
LysaFormRef,
|
|
10
|
-
Form,
|
|
11
|
-
PrimaryButton,
|
|
12
|
-
RequiredValidator,
|
|
13
|
-
TextInput,
|
|
14
|
-
Select
|
|
15
|
-
} from "@lysaab/ui-2";
|
|
16
|
-
import {
|
|
17
|
-
PepContext,
|
|
18
|
-
Role,
|
|
19
|
-
MilitaryRank,
|
|
20
|
-
PepType,
|
|
21
|
-
EntityType
|
|
22
|
-
} from "../PepContext";
|
|
23
|
-
import { CountrySelect } from "../../components/CountrySelect";
|
|
24
|
-
import { useIntl, IntlShape, FormattedMessage } from "react-intl";
|
|
25
|
-
import {
|
|
26
|
-
roleMessages,
|
|
27
|
-
ambassadorMessages,
|
|
28
|
-
governmentCompanyMessages,
|
|
29
|
-
intCompanyMessages,
|
|
30
|
-
militaryMessages
|
|
31
|
-
} from "./RoleMessages";
|
|
32
|
-
|
|
33
|
-
interface Props {
|
|
34
|
-
next: () => void;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const RolePage: FunctionComponent<Props> = ({ next }) => {
|
|
38
|
-
const pepContext = useContext(PepContext);
|
|
39
|
-
const formRef = useRef<LysaFormRef>();
|
|
40
|
-
const intl = useIntl();
|
|
41
|
-
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
42
|
-
const type = pepContext.state.type;
|
|
43
|
-
|
|
44
|
-
const roleAlternatives: Alternative<Role>[] = getRoleAlts(intl);
|
|
45
|
-
const militaryAlternatives: Alternative<MilitaryRank>[] = getMilitaryAlts(
|
|
46
|
-
intl
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const nextPage = useCallback(() => {
|
|
50
|
-
if (formRef.current && formRef.current.isValid) {
|
|
51
|
-
next();
|
|
52
|
-
}
|
|
53
|
-
}, [formRef, next]);
|
|
54
|
-
|
|
55
|
-
const resetRoleFields = useCallback(() => {
|
|
56
|
-
pepContext.setState({
|
|
57
|
-
ambassadorCountry: undefined,
|
|
58
|
-
governmentCompany: undefined,
|
|
59
|
-
governmentCompanyRole: undefined,
|
|
60
|
-
internationalOrganisation: undefined,
|
|
61
|
-
internationalOrganisationRole: undefined,
|
|
62
|
-
militaryRank: undefined
|
|
63
|
-
});
|
|
64
|
-
}, [pepContext]);
|
|
65
|
-
|
|
66
|
-
if (!type || type === PepType.NOT_PEP) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
console.log({
|
|
71
|
-
entityType,
|
|
72
|
-
pepType: type,
|
|
73
|
-
relation:
|
|
74
|
-
pepContext.state.relationToPEP || pepContext.state.businessRelation
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Form onSubmit={() => nextPage()} lysaFormRef={formRef}>
|
|
79
|
-
<Select
|
|
80
|
-
label={intl.formatMessage(roleMessages.header, {
|
|
81
|
-
entityType,
|
|
82
|
-
pepType: type,
|
|
83
|
-
relation:
|
|
84
|
-
pepContext.state.relationToPEP || pepContext.state.businessRelation,
|
|
85
|
-
name: pepContext.state.ownerName
|
|
86
|
-
})}
|
|
87
|
-
placeholder={intl.formatMessage(roleMessages.placeholder)}
|
|
88
|
-
alternatives={roleAlternatives}
|
|
89
|
-
value={roleAlternatives.find(
|
|
90
|
-
alt => alt.value === pepContext.state.role
|
|
91
|
-
)}
|
|
92
|
-
onChange={event => {
|
|
93
|
-
pepContext.setState({ role: event.value as Role });
|
|
94
|
-
resetRoleFields();
|
|
95
|
-
}}
|
|
96
|
-
validators={[
|
|
97
|
-
RequiredValidator(intl.formatMessage(roleMessages.required))
|
|
98
|
-
]}
|
|
99
|
-
/>
|
|
100
|
-
|
|
101
|
-
{pepContext.state.role && pepContext.state.role === Role.AMBASSADOR ? (
|
|
102
|
-
<CountrySelect
|
|
103
|
-
label={intl.formatMessage(ambassadorMessages.header, {
|
|
104
|
-
entityType,
|
|
105
|
-
pepType: type,
|
|
106
|
-
relation:
|
|
107
|
-
pepContext.state.relationToPEP ||
|
|
108
|
-
pepContext.state.businessRelation,
|
|
109
|
-
name: pepContext.state.ownerName
|
|
110
|
-
})}
|
|
111
|
-
onChange={event =>
|
|
112
|
-
pepContext.setState({
|
|
113
|
-
ambassadorCountry: event.value
|
|
114
|
-
? event.value.toString()
|
|
115
|
-
: undefined
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
value={pepContext.state.ambassadorCountry}
|
|
119
|
-
validators={[
|
|
120
|
-
RequiredValidator(intl.formatMessage(ambassadorMessages.required))
|
|
121
|
-
]}
|
|
122
|
-
/>
|
|
123
|
-
) : null}
|
|
124
|
-
|
|
125
|
-
{pepContext.state.role &&
|
|
126
|
-
pepContext.state.role === Role.GOVERNMENT_COMPANY ? (
|
|
127
|
-
<React.Fragment>
|
|
128
|
-
<TextInput
|
|
129
|
-
label={intl.formatMessage(governmentCompanyMessages.nameHeader, {
|
|
130
|
-
entityType,
|
|
131
|
-
pepType: type,
|
|
132
|
-
relation:
|
|
133
|
-
pepContext.state.relationToPEP ||
|
|
134
|
-
pepContext.state.businessRelation,
|
|
135
|
-
name: pepContext.state.ownerName
|
|
136
|
-
})}
|
|
137
|
-
value={pepContext.state.governmentCompany || ""}
|
|
138
|
-
onChange={value => {
|
|
139
|
-
pepContext.setState({ governmentCompany: value });
|
|
140
|
-
}}
|
|
141
|
-
validators={[
|
|
142
|
-
RequiredValidator(
|
|
143
|
-
intl.formatMessage(governmentCompanyMessages.nameRequired)
|
|
144
|
-
)
|
|
145
|
-
]}
|
|
146
|
-
/>
|
|
147
|
-
<TextInput
|
|
148
|
-
label={intl.formatMessage(governmentCompanyMessages.roleHeader, {
|
|
149
|
-
entityType,
|
|
150
|
-
pepType: type,
|
|
151
|
-
relation:
|
|
152
|
-
pepContext.state.relationToPEP ||
|
|
153
|
-
pepContext.state.businessRelation,
|
|
154
|
-
name: pepContext.state.ownerName
|
|
155
|
-
})}
|
|
156
|
-
value={pepContext.state.governmentCompanyRole || ""}
|
|
157
|
-
onChange={value => {
|
|
158
|
-
pepContext.setState({
|
|
159
|
-
governmentCompanyRole: value
|
|
160
|
-
});
|
|
161
|
-
}}
|
|
162
|
-
validators={[
|
|
163
|
-
RequiredValidator(
|
|
164
|
-
intl.formatMessage(governmentCompanyMessages.roleRequired)
|
|
165
|
-
)
|
|
166
|
-
]}
|
|
167
|
-
/>
|
|
168
|
-
</React.Fragment>
|
|
169
|
-
) : null}
|
|
170
|
-
|
|
171
|
-
{pepContext.state.role &&
|
|
172
|
-
pepContext.state.role ===
|
|
173
|
-
Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP ? (
|
|
174
|
-
<React.Fragment>
|
|
175
|
-
<TextInput
|
|
176
|
-
label={intl.formatMessage(intCompanyMessages.nameHeader, {
|
|
177
|
-
entityType,
|
|
178
|
-
pepType: type,
|
|
179
|
-
relation:
|
|
180
|
-
pepContext.state.relationToPEP ||
|
|
181
|
-
pepContext.state.businessRelation,
|
|
182
|
-
name: pepContext.state.ownerName
|
|
183
|
-
})}
|
|
184
|
-
value={pepContext.state.internationalOrganisation || ""}
|
|
185
|
-
onChange={value => {
|
|
186
|
-
pepContext.setState({ internationalOrganisation: value });
|
|
187
|
-
}}
|
|
188
|
-
validators={[
|
|
189
|
-
RequiredValidator(
|
|
190
|
-
intl.formatMessage(intCompanyMessages.nameRequired)
|
|
191
|
-
)
|
|
192
|
-
]}
|
|
193
|
-
/>
|
|
194
|
-
<TextInput
|
|
195
|
-
label={intl.formatMessage(intCompanyMessages.roleHeader, {
|
|
196
|
-
entityType,
|
|
197
|
-
pepType: type,
|
|
198
|
-
relation:
|
|
199
|
-
pepContext.state.relationToPEP ||
|
|
200
|
-
pepContext.state.businessRelation,
|
|
201
|
-
name: pepContext.state.ownerName
|
|
202
|
-
})}
|
|
203
|
-
value={pepContext.state.internationalOrganisationRole || ""}
|
|
204
|
-
onChange={value => {
|
|
205
|
-
pepContext.setState({
|
|
206
|
-
internationalOrganisationRole: value
|
|
207
|
-
});
|
|
208
|
-
}}
|
|
209
|
-
validators={[
|
|
210
|
-
RequiredValidator(
|
|
211
|
-
intl.formatMessage(intCompanyMessages.roleRequired)
|
|
212
|
-
)
|
|
213
|
-
]}
|
|
214
|
-
/>
|
|
215
|
-
</React.Fragment>
|
|
216
|
-
) : null}
|
|
217
|
-
|
|
218
|
-
{pepContext.state.role &&
|
|
219
|
-
pepContext.state.role === Role.MILITARY_OFFICER ? (
|
|
220
|
-
<Select
|
|
221
|
-
label={intl.formatMessage(militaryMessages.header, {
|
|
222
|
-
entityType,
|
|
223
|
-
pepType: type,
|
|
224
|
-
relation:
|
|
225
|
-
pepContext.state.relationToPEP ||
|
|
226
|
-
pepContext.state.businessRelation,
|
|
227
|
-
name: pepContext.state.ownerName
|
|
228
|
-
})}
|
|
229
|
-
placeholder={intl.formatMessage(militaryMessages.placeholder)}
|
|
230
|
-
alternatives={militaryAlternatives}
|
|
231
|
-
value={militaryAlternatives.find(
|
|
232
|
-
alt => alt.value === pepContext.state.militaryRank
|
|
233
|
-
)}
|
|
234
|
-
onChange={event => {
|
|
235
|
-
pepContext.setState({ militaryRank: event.value as MilitaryRank });
|
|
236
|
-
}}
|
|
237
|
-
validators={[
|
|
238
|
-
RequiredValidator(intl.formatMessage(militaryMessages.required))
|
|
239
|
-
]}
|
|
240
|
-
/>
|
|
241
|
-
) : null}
|
|
242
|
-
|
|
243
|
-
<PrimaryButton type="submit">
|
|
244
|
-
<FormattedMessage
|
|
245
|
-
id="pep.role.next"
|
|
246
|
-
description="Next button"
|
|
247
|
-
defaultMessage="Gå vidare"
|
|
248
|
-
/>
|
|
249
|
-
</PrimaryButton>
|
|
250
|
-
</Form>
|
|
251
|
-
);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export function getRoleAlts(intl: IntlShape): Alternative<Role>[] {
|
|
255
|
-
return [
|
|
256
|
-
{
|
|
257
|
-
text: intl.formatMessage(roleMessages[Role.HEAD_OF_GOVERNMENT]),
|
|
258
|
-
value: Role.HEAD_OF_GOVERNMENT
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
text: intl.formatMessage(roleMessages[Role.MINISTER]),
|
|
262
|
-
value: Role.MINISTER
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
text: intl.formatMessage(roleMessages[Role.PARLIMENT_MEMBER]),
|
|
266
|
-
value: Role.PARLIMENT_MEMBER
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
text: intl.formatMessage(roleMessages[Role.CENTRAL_BANK_MEMBER]),
|
|
270
|
-
value: Role.CENTRAL_BANK_MEMBER
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
text: intl.formatMessage(roleMessages[Role.BOARD_MEMBER_POLITICAL_PARTY]),
|
|
274
|
-
value: Role.BOARD_MEMBER_POLITICAL_PARTY
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
text: intl.formatMessage(roleMessages[Role.JUDGE_SUPREME_COURT]),
|
|
278
|
-
value: Role.JUDGE_SUPREME_COURT
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
text: intl.formatMessage(roleMessages[Role.JUDGE_OTHER_HIGH_COURT]),
|
|
282
|
-
value: Role.JUDGE_OTHER_HIGH_COURT
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
text: intl.formatMessage(roleMessages[Role.REVISION_INSTITUTE]),
|
|
286
|
-
value: Role.REVISION_INSTITUTE
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
text: intl.formatMessage(roleMessages[Role.AMBASSADOR]),
|
|
290
|
-
value: Role.AMBASSADOR
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
text: intl.formatMessage(roleMessages[Role.MILITARY_OFFICER]),
|
|
294
|
-
value: Role.MILITARY_OFFICER
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
text: intl.formatMessage(roleMessages[Role.GOVERNMENT_COMPANY]),
|
|
298
|
-
value: Role.GOVERNMENT_COMPANY
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
text: intl.formatMessage(roleMessages[Role.EU_HIGH_RANKING_POSITION]),
|
|
302
|
-
value: Role.EU_HIGH_RANKING_POSITION
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
text: intl.formatMessage(
|
|
306
|
-
roleMessages[Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP]
|
|
307
|
-
),
|
|
308
|
-
value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP
|
|
309
|
-
}
|
|
310
|
-
];
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export function getMilitaryAlts(intl: IntlShape): Alternative<MilitaryRank>[] {
|
|
314
|
-
return [
|
|
315
|
-
{
|
|
316
|
-
text: intl.formatMessage(militaryMessages[MilitaryRank.GENERAL]),
|
|
317
|
-
value: MilitaryRank.GENERAL
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
text: intl.formatMessage(
|
|
321
|
-
militaryMessages[MilitaryRank.LIEUTENANT_GENERAL]
|
|
322
|
-
),
|
|
323
|
-
value: MilitaryRank.LIEUTENANT_GENERAL
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
text: intl.formatMessage(militaryMessages[MilitaryRank.MAJOR_GENERAL]),
|
|
327
|
-
value: MilitaryRank.MAJOR_GENERAL
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
text: intl.formatMessage(militaryMessages[MilitaryRank.ADMIRAL]),
|
|
331
|
-
value: MilitaryRank.ADMIRAL
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
text: intl.formatMessage(militaryMessages[MilitaryRank.VICE_ADMIRAL]),
|
|
335
|
-
value: MilitaryRank.VICE_ADMIRAL
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
text: intl.formatMessage(militaryMessages[MilitaryRank.REAR_ADMIRAL]),
|
|
339
|
-
value: MilitaryRank.REAR_ADMIRAL
|
|
340
|
-
}
|
|
341
|
-
];
|
|
342
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { defineMessages } from "react-intl";
|
|
2
|
-
import { PepStatus } from "../PepContext";
|
|
3
|
-
|
|
4
|
-
export const isOngoingMessages = defineMessages({
|
|
5
|
-
header: {
|
|
6
|
-
id: "pep.status.isongoing.header",
|
|
7
|
-
description: "Is ongoing header",
|
|
8
|
-
defaultMessage: "Är befattningen pågående eller avslutad?",
|
|
9
|
-
},
|
|
10
|
-
required: {
|
|
11
|
-
id: "pep.status.isongoing.required",
|
|
12
|
-
description: "Is ongoing required error",
|
|
13
|
-
defaultMessage: "Du måste välja ett alternativ",
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export const endedMessages = defineMessages({
|
|
18
|
-
header: {
|
|
19
|
-
id: "pep.status.ended.header",
|
|
20
|
-
description: "When did it end header",
|
|
21
|
-
defaultMessage: "När avslutades uppdraget?",
|
|
22
|
-
},
|
|
23
|
-
required: {
|
|
24
|
-
id: "pep.status.ended.required",
|
|
25
|
-
description: "When did it end required error",
|
|
26
|
-
defaultMessage: "Du måste ange ett slutdatum",
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export const isLocalCountryMessages = defineMessages({
|
|
31
|
-
header: {
|
|
32
|
-
id: "pep.status.localcountry.sweden.header",
|
|
33
|
-
description: "Is local country header",
|
|
34
|
-
defaultMessage: "I vilket land är befattningen?",
|
|
35
|
-
},
|
|
36
|
-
required: {
|
|
37
|
-
id: "pep.status.localcountry.required",
|
|
38
|
-
description: "Is local country required error",
|
|
39
|
-
defaultMessage: "Du måste välja ett alternativ",
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export const countrySelectionMessages = defineMessages({
|
|
44
|
-
header: {
|
|
45
|
-
id: "pep.status.countryselecton.header",
|
|
46
|
-
description: "Country selection header",
|
|
47
|
-
defaultMessage: "Välj i vilket land befattningen är",
|
|
48
|
-
},
|
|
49
|
-
required: {
|
|
50
|
-
id: "pep.status.countryselecton.required",
|
|
51
|
-
description: "Country selection required error",
|
|
52
|
-
defaultMessage: "Du måste välja land",
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const localCountryAltMessages = defineMessages({
|
|
57
|
-
localCountry: {
|
|
58
|
-
id: "pep.status.localcountryalt.required",
|
|
59
|
-
description: "Local country name",
|
|
60
|
-
defaultMessage: "Sverige",
|
|
61
|
-
},
|
|
62
|
-
otherCountry: {
|
|
63
|
-
id: "pep.status.othercountryalt.required",
|
|
64
|
-
description: "Other country",
|
|
65
|
-
defaultMessage: "Annat",
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
export const stateAltMessages = defineMessages({
|
|
70
|
-
[PepStatus.ONGOING]: {
|
|
71
|
-
id: "pep.status.state.ONGOING",
|
|
72
|
-
description: "Ongoing alt",
|
|
73
|
-
defaultMessage: "Pågående",
|
|
74
|
-
},
|
|
75
|
-
[PepStatus.ENDED]: {
|
|
76
|
-
id: "pep.status.state.ENDED",
|
|
77
|
-
description: "Ended alt",
|
|
78
|
-
defaultMessage: "Avslutad",
|
|
79
|
-
},
|
|
80
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
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
|
-
import { useIntl, FormattedMessage, IntlShape } from "react-intl";
|
|
19
|
-
import {
|
|
20
|
-
isOngoingMessages,
|
|
21
|
-
endedMessages,
|
|
22
|
-
isLocalCountryMessages,
|
|
23
|
-
countrySelectionMessages,
|
|
24
|
-
localCountryAltMessages,
|
|
25
|
-
stateAltMessages
|
|
26
|
-
} from "./StatusMessages";
|
|
27
|
-
|
|
28
|
-
interface Props {
|
|
29
|
-
next: () => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const StatusPage: FunctionComponent<Props> = ({ next }) => {
|
|
33
|
-
const pepContext = useContext(PepContext);
|
|
34
|
-
const formRef = useRef<LysaFormRef>();
|
|
35
|
-
const intl = useIntl();
|
|
36
|
-
const stateAlternatives = getStateAlternatives(intl);
|
|
37
|
-
const isSwedenAlternatives = getIsLocalCountryAlternatives(intl);
|
|
38
|
-
|
|
39
|
-
const nextPage = useCallback(() => {
|
|
40
|
-
if (formRef.current && formRef.current.isValid) {
|
|
41
|
-
next();
|
|
42
|
-
}
|
|
43
|
-
}, [formRef, next]);
|
|
44
|
-
|
|
45
|
-
const updateIsSweden = useCallback(
|
|
46
|
-
(alternative: Alternative<string>) => {
|
|
47
|
-
pepContext.setState({ isSweden: alternative.value });
|
|
48
|
-
|
|
49
|
-
if (alternative.value === "other") {
|
|
50
|
-
pepContext.setState({ country: undefined });
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
[pepContext]
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const updateIsOngoing = useCallback(
|
|
57
|
-
(alternative: Alternative<PepStatus>) => {
|
|
58
|
-
pepContext.setState({ isOngoing: alternative.value });
|
|
59
|
-
|
|
60
|
-
if (alternative.value === PepStatus.ONGOING) {
|
|
61
|
-
pepContext.setState({ ended: undefined });
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
[pepContext]
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<div>
|
|
69
|
-
<Form
|
|
70
|
-
lysaFormRef={formRef}
|
|
71
|
-
onSubmit={() => {
|
|
72
|
-
nextPage();
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
<RadioGroup
|
|
76
|
-
alternatives={stateAlternatives}
|
|
77
|
-
header={intl.formatMessage(isOngoingMessages.header)}
|
|
78
|
-
onChange={updateIsOngoing}
|
|
79
|
-
value={stateAlternatives.find(
|
|
80
|
-
alt => alt.value === pepContext.state.isOngoing
|
|
81
|
-
)}
|
|
82
|
-
validators={[
|
|
83
|
-
RequiredValidator(intl.formatMessage(isOngoingMessages.required))
|
|
84
|
-
]}
|
|
85
|
-
/>
|
|
86
|
-
|
|
87
|
-
{pepContext.state.isOngoing &&
|
|
88
|
-
pepContext.state.isOngoing === PepStatus.ENDED ? (
|
|
89
|
-
<Datepicker
|
|
90
|
-
label={intl.formatMessage(endedMessages.header)}
|
|
91
|
-
selected={pepContext.state.ended}
|
|
92
|
-
onChange={event =>
|
|
93
|
-
pepContext.setState({ ended: event || undefined })
|
|
94
|
-
}
|
|
95
|
-
validators={[
|
|
96
|
-
RequiredValidator(intl.formatMessage(isOngoingMessages.required))
|
|
97
|
-
]}
|
|
98
|
-
showMonthYearPicker
|
|
99
|
-
dateFormat="yyyy-MM"
|
|
100
|
-
maxDate={new Date()}
|
|
101
|
-
/>
|
|
102
|
-
) : null}
|
|
103
|
-
|
|
104
|
-
<RadioGroup
|
|
105
|
-
alternatives={isSwedenAlternatives}
|
|
106
|
-
header={intl.formatMessage(isLocalCountryMessages.header)}
|
|
107
|
-
onChange={updateIsSweden}
|
|
108
|
-
value={isSwedenAlternatives.find(
|
|
109
|
-
alt => alt.value === pepContext.state.isSweden
|
|
110
|
-
)}
|
|
111
|
-
validators={[
|
|
112
|
-
RequiredValidator(
|
|
113
|
-
intl.formatMessage(isLocalCountryMessages.required)
|
|
114
|
-
)
|
|
115
|
-
]}
|
|
116
|
-
/>
|
|
117
|
-
|
|
118
|
-
{pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (
|
|
119
|
-
<CountrySelect
|
|
120
|
-
label={intl.formatMessage(countrySelectionMessages.header)}
|
|
121
|
-
onChange={event =>
|
|
122
|
-
pepContext.setState({
|
|
123
|
-
country: event.value ? event.value.toString() : undefined
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
validators={[
|
|
127
|
-
RequiredValidator(
|
|
128
|
-
intl.formatMessage(countrySelectionMessages.required)
|
|
129
|
-
)
|
|
130
|
-
]}
|
|
131
|
-
value={pepContext.state.country}
|
|
132
|
-
omitCountries={["SE"]}
|
|
133
|
-
/>
|
|
134
|
-
) : null}
|
|
135
|
-
|
|
136
|
-
<PrimaryButton type="submit">
|
|
137
|
-
<FormattedMessage
|
|
138
|
-
id="pep.status.next"
|
|
139
|
-
description="Next button"
|
|
140
|
-
defaultMessage="Gå vidare"
|
|
141
|
-
/>
|
|
142
|
-
</PrimaryButton>
|
|
143
|
-
</Form>
|
|
144
|
-
</div>
|
|
145
|
-
);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
function getIsLocalCountryAlternatives(intl: IntlShape): Alternative<string>[] {
|
|
149
|
-
return [
|
|
150
|
-
{
|
|
151
|
-
text: intl.formatMessage(localCountryAltMessages.localCountry),
|
|
152
|
-
value: "sweden"
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
text: intl.formatMessage(localCountryAltMessages.otherCountry),
|
|
156
|
-
value: "other"
|
|
157
|
-
}
|
|
158
|
-
];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function getStateAlternatives(intl: IntlShape): Alternative<PepStatus>[] {
|
|
162
|
-
return [
|
|
163
|
-
{
|
|
164
|
-
text: intl.formatMessage(stateAltMessages[PepStatus.ONGOING]),
|
|
165
|
-
value: PepStatus.ONGOING
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
text: intl.formatMessage(stateAltMessages[PepStatus.ENDED]),
|
|
169
|
-
value: PepStatus.ENDED
|
|
170
|
-
}
|
|
171
|
-
];
|
|
172
|
-
}
|