@lysaab/lysa-pep 6.1.1 → 7.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/README.md +7 -0
- package/lib/README.md +51 -0
- package/lib/package.json +73 -0
- package/{pages → lib/pages}/IsPep/IsPepPage.js +2 -3
- package/{pages → lib/pages}/PepContext.d.ts +3 -3
- package/{pages → lib/pages}/RelationPage/RelationPage.js +2 -3
- package/{pages → lib/pages}/RolePage/RolePage.js +2 -3
- package/{pages → lib/pages}/StatusPage/StatusPage.js +2 -3
- package/package.json +20 -21
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +2 -0
- package/src/App.scss +5 -0
- package/src/App.test.tsx +9 -0
- package/src/App.tsx +17 -0
- package/src/Exports.ts +12 -0
- package/src/components/PepAnswers.scss +7 -0
- package/src/components/PepAnswers.tsx +218 -0
- package/src/demo/Done.tsx +21 -0
- package/src/demo/Localization.tsx +66 -0
- package/src/demo/LocalizationContext.tsx +61 -0
- package/src/demo/Pep.tsx +172 -0
- package/src/index.css +13 -0
- package/src/index.tsx +13 -0
- package/src/locales/da.json +98 -0
- package/src/locales/de.json +98 -0
- package/src/locales/defaultMessages.json +335 -0
- package/src/locales/en.json +98 -0
- package/src/locales/fi.json +98 -0
- package/src/locales/sv.json +98 -0
- package/src/locales/whitelist_da.json +2 -0
- package/src/locales/whitelist_en.json +2 -0
- package/src/locales/whitelist_fi.json +2 -0
- package/src/locales/whitelist_sv.json +2 -0
- package/src/logo.svg +1 -0
- package/src/model/PepModel.ts +54 -0
- package/src/pages/IsPep/IsPepMessages.ts +11 -0
- package/src/pages/IsPep/IsPepPage.tsx +119 -0
- package/src/pages/PepContext.tsx +150 -0
- package/src/pages/RelationPage/RelationMessages.ts +74 -0
- package/src/pages/RelationPage/RelationPage.tsx +306 -0
- package/src/pages/RolePage/RoleMessages.ts +128 -0
- package/src/pages/RolePage/RolePage.tsx +359 -0
- package/src/pages/StatusPage/StatusMessages.ts +59 -0
- package/src/pages/StatusPage/StatusPage.tsx +237 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/serviceWorker.ts +143 -0
- package/src/utils/Possession.ts +41 -0
- package/translationRunner.js +7 -0
- package/tsconfig.json +26 -0
- package/tsconfig_build.json +19 -0
- /package/{Exports.d.ts → lib/Exports.d.ts} +0 -0
- /package/{Exports.js → lib/Exports.js} +0 -0
- /package/{components → lib/components}/PepAnswers.d.ts +0 -0
- /package/{components → lib/components}/PepAnswers.js +0 -0
- /package/{components → lib/components}/PepAnswers.scss +0 -0
- /package/{messages → lib/messages}/src/components/PepAnswers.json +0 -0
- /package/{messages → lib/messages}/src/pages/IsPep/IsPepMessages.json +0 -0
- /package/{messages → lib/messages}/src/pages/IsPep/IsPepPage.json +0 -0
- /package/{messages → lib/messages}/src/pages/RelationPage/RelationMessages.json +0 -0
- /package/{messages → lib/messages}/src/pages/RelationPage/RelationPage.json +0 -0
- /package/{messages → lib/messages}/src/pages/RolePage/RoleMessages.json +0 -0
- /package/{messages → lib/messages}/src/pages/RolePage/RolePage.json +0 -0
- /package/{messages → lib/messages}/src/pages/StatusPage/StatusMessages.json +0 -0
- /package/{messages → lib/messages}/src/pages/StatusPage/StatusPage.json +0 -0
- /package/{model → lib/model}/PepModel.d.ts +0 -0
- /package/{model → lib/model}/PepModel.js +0 -0
- /package/{pages → lib/pages}/IsPep/IsPepMessages.d.ts +0 -0
- /package/{pages → lib/pages}/IsPep/IsPepMessages.js +0 -0
- /package/{pages → lib/pages}/IsPep/IsPepPage.d.ts +0 -0
- /package/{pages → lib/pages}/PepContext.js +0 -0
- /package/{pages → lib/pages}/RelationPage/RelationMessages.d.ts +0 -0
- /package/{pages → lib/pages}/RelationPage/RelationMessages.js +0 -0
- /package/{pages → lib/pages}/RelationPage/RelationPage.d.ts +0 -0
- /package/{pages → lib/pages}/RolePage/RoleMessages.d.ts +0 -0
- /package/{pages → lib/pages}/RolePage/RoleMessages.js +0 -0
- /package/{pages → lib/pages}/RolePage/RolePage.d.ts +0 -0
- /package/{pages → lib/pages}/StatusPage/StatusMessages.d.ts +0 -0
- /package/{pages → lib/pages}/StatusPage/StatusMessages.js +0 -0
- /package/{pages → lib/pages}/StatusPage/StatusPage.d.ts +0 -0
- /package/{utils → lib/utils}/Possession.d.ts +0 -0
- /package/{utils → lib/utils}/Possession.js +0 -0
|
@@ -0,0 +1,359 @@
|
|
|
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
|
+
RequiredValidator,
|
|
12
|
+
TextInput,
|
|
13
|
+
Select,
|
|
14
|
+
Card,
|
|
15
|
+
CountrySelect,
|
|
16
|
+
Language,
|
|
17
|
+
Button,
|
|
18
|
+
} from "@lysaab/ui-2";
|
|
19
|
+
import {
|
|
20
|
+
PepContext,
|
|
21
|
+
Role,
|
|
22
|
+
MilitaryRank,
|
|
23
|
+
PepType,
|
|
24
|
+
EntityType,
|
|
25
|
+
} from "../PepContext";
|
|
26
|
+
import { useIntl, IntlShape, FormattedMessage } from "react-intl";
|
|
27
|
+
import {
|
|
28
|
+
roleMessages,
|
|
29
|
+
ambassadorMessages,
|
|
30
|
+
governmentCompanyMessages,
|
|
31
|
+
intCompanyMessages,
|
|
32
|
+
militaryMessages,
|
|
33
|
+
} from "./RoleMessages";
|
|
34
|
+
import { formatPossessive } from "../../utils/Possession";
|
|
35
|
+
|
|
36
|
+
interface Props {
|
|
37
|
+
language: Language;
|
|
38
|
+
next: () => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const RolePage: FunctionComponent<Props> = ({ language, next }) => {
|
|
42
|
+
const pepContext = useContext(PepContext);
|
|
43
|
+
const formRef = useRef<LysaFormRef>();
|
|
44
|
+
const intl = useIntl();
|
|
45
|
+
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
46
|
+
const type = pepContext.state.type;
|
|
47
|
+
|
|
48
|
+
const roleAlternatives: Alternative<Role>[] = getRoleAlts(intl);
|
|
49
|
+
const militaryAlternatives: Alternative<MilitaryRank>[] =
|
|
50
|
+
getMilitaryAlts(intl);
|
|
51
|
+
|
|
52
|
+
const nextPage = useCallback(() => {
|
|
53
|
+
if (formRef.current && formRef.current.isValid) {
|
|
54
|
+
next();
|
|
55
|
+
}
|
|
56
|
+
}, [formRef, next]);
|
|
57
|
+
|
|
58
|
+
const resetRoleFields = useCallback(() => {
|
|
59
|
+
pepContext.setState({
|
|
60
|
+
ambassadorCountry: undefined,
|
|
61
|
+
governmentCompany: undefined,
|
|
62
|
+
governmentCompanyRole: undefined,
|
|
63
|
+
internationalOrganisation: undefined,
|
|
64
|
+
internationalOrganisationRole: undefined,
|
|
65
|
+
militaryRank: undefined,
|
|
66
|
+
});
|
|
67
|
+
}, [pepContext]);
|
|
68
|
+
|
|
69
|
+
if (!type || type === PepType.NOT_PEP) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Form onSubmit={() => nextPage()} lysaFormRef={formRef}>
|
|
75
|
+
<Card>
|
|
76
|
+
<Select
|
|
77
|
+
label={intl.formatMessage(roleMessages.header, {
|
|
78
|
+
entityType,
|
|
79
|
+
pepType: type,
|
|
80
|
+
relation:
|
|
81
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
82
|
+
? pepContext.state.businessRelation
|
|
83
|
+
: pepContext.state.relationToPEP,
|
|
84
|
+
name: pepContext.state.ownerName,
|
|
85
|
+
possessiveName: formatPossessive(
|
|
86
|
+
pepContext.state.ownerName,
|
|
87
|
+
intl.locale
|
|
88
|
+
),
|
|
89
|
+
})}
|
|
90
|
+
placeholder={intl.formatMessage(roleMessages.placeholder)}
|
|
91
|
+
alternatives={roleAlternatives}
|
|
92
|
+
value={roleAlternatives.find(
|
|
93
|
+
(alt) => alt.value === pepContext.state.role
|
|
94
|
+
)}
|
|
95
|
+
onChange={(event) => {
|
|
96
|
+
pepContext.setState({ role: event.value as Role });
|
|
97
|
+
resetRoleFields();
|
|
98
|
+
}}
|
|
99
|
+
validators={[
|
|
100
|
+
new RequiredValidator(intl.formatMessage(roleMessages.required)),
|
|
101
|
+
]}
|
|
102
|
+
/>
|
|
103
|
+
|
|
104
|
+
{pepContext.state.role && pepContext.state.role === Role.AMBASSADOR ? (
|
|
105
|
+
<CountrySelect
|
|
106
|
+
label={intl.formatMessage(ambassadorMessages.header, {
|
|
107
|
+
entityType,
|
|
108
|
+
pepType: type,
|
|
109
|
+
relation:
|
|
110
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
111
|
+
? pepContext.state.businessRelation
|
|
112
|
+
: pepContext.state.relationToPEP,
|
|
113
|
+
name: pepContext.state.ownerName,
|
|
114
|
+
})}
|
|
115
|
+
onChange={(event) =>
|
|
116
|
+
pepContext.setState({
|
|
117
|
+
ambassadorCountry: event.value ? event.value : undefined,
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
value={pepContext.state.ambassadorCountry}
|
|
121
|
+
validators={[
|
|
122
|
+
new RequiredValidator(
|
|
123
|
+
intl.formatMessage(ambassadorMessages.required)
|
|
124
|
+
),
|
|
125
|
+
]}
|
|
126
|
+
language={language}
|
|
127
|
+
placeholder={intl.formatMessage(ambassadorMessages.placeholder)}
|
|
128
|
+
/>
|
|
129
|
+
) : null}
|
|
130
|
+
|
|
131
|
+
{pepContext.state.role &&
|
|
132
|
+
pepContext.state.role === Role.GOVERNMENT_COMPANY ? (
|
|
133
|
+
<React.Fragment>
|
|
134
|
+
<TextInput
|
|
135
|
+
label={intl.formatMessage(governmentCompanyMessages.nameHeader, {
|
|
136
|
+
entityType,
|
|
137
|
+
pepType: type,
|
|
138
|
+
relation:
|
|
139
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
140
|
+
? pepContext.state.businessRelation
|
|
141
|
+
: pepContext.state.relationToPEP,
|
|
142
|
+
name: pepContext.state.ownerName,
|
|
143
|
+
})}
|
|
144
|
+
value={pepContext.state.governmentCompany || ""}
|
|
145
|
+
onChange={(value) => {
|
|
146
|
+
pepContext.setState({ governmentCompany: value });
|
|
147
|
+
}}
|
|
148
|
+
validators={[
|
|
149
|
+
new RequiredValidator(
|
|
150
|
+
intl.formatMessage(governmentCompanyMessages.nameRequired)
|
|
151
|
+
),
|
|
152
|
+
]}
|
|
153
|
+
/>
|
|
154
|
+
<TextInput
|
|
155
|
+
label={intl.formatMessage(governmentCompanyMessages.roleHeader, {
|
|
156
|
+
entityType,
|
|
157
|
+
pepType: type,
|
|
158
|
+
relation:
|
|
159
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
160
|
+
? pepContext.state.businessRelation
|
|
161
|
+
: pepContext.state.relationToPEP,
|
|
162
|
+
name: pepContext.state.ownerName,
|
|
163
|
+
})}
|
|
164
|
+
value={pepContext.state.governmentCompanyRole || ""}
|
|
165
|
+
onChange={(value) => {
|
|
166
|
+
pepContext.setState({
|
|
167
|
+
governmentCompanyRole: value,
|
|
168
|
+
});
|
|
169
|
+
}}
|
|
170
|
+
validators={[
|
|
171
|
+
new RequiredValidator(
|
|
172
|
+
intl.formatMessage(governmentCompanyMessages.roleRequired)
|
|
173
|
+
),
|
|
174
|
+
]}
|
|
175
|
+
/>
|
|
176
|
+
</React.Fragment>
|
|
177
|
+
) : null}
|
|
178
|
+
|
|
179
|
+
{pepContext.state.role &&
|
|
180
|
+
pepContext.state.role ===
|
|
181
|
+
Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP ? (
|
|
182
|
+
<React.Fragment>
|
|
183
|
+
<TextInput
|
|
184
|
+
label={intl.formatMessage(intCompanyMessages.nameHeader, {
|
|
185
|
+
entityType,
|
|
186
|
+
pepType: type,
|
|
187
|
+
relation:
|
|
188
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
189
|
+
? pepContext.state.businessRelation
|
|
190
|
+
: pepContext.state.relationToPEP,
|
|
191
|
+
name: pepContext.state.ownerName,
|
|
192
|
+
})}
|
|
193
|
+
value={pepContext.state.internationalOrganisation || ""}
|
|
194
|
+
onChange={(value) => {
|
|
195
|
+
pepContext.setState({ internationalOrganisation: value });
|
|
196
|
+
}}
|
|
197
|
+
validators={[
|
|
198
|
+
new RequiredValidator(
|
|
199
|
+
intl.formatMessage(intCompanyMessages.nameRequired)
|
|
200
|
+
),
|
|
201
|
+
]}
|
|
202
|
+
/>
|
|
203
|
+
<TextInput
|
|
204
|
+
label={intl.formatMessage(intCompanyMessages.roleHeader, {
|
|
205
|
+
entityType,
|
|
206
|
+
pepType: type,
|
|
207
|
+
relation:
|
|
208
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
209
|
+
? pepContext.state.businessRelation
|
|
210
|
+
: pepContext.state.relationToPEP,
|
|
211
|
+
name: pepContext.state.ownerName,
|
|
212
|
+
})}
|
|
213
|
+
value={pepContext.state.internationalOrganisationRole || ""}
|
|
214
|
+
onChange={(value) => {
|
|
215
|
+
pepContext.setState({
|
|
216
|
+
internationalOrganisationRole: value,
|
|
217
|
+
});
|
|
218
|
+
}}
|
|
219
|
+
validators={[
|
|
220
|
+
new RequiredValidator(
|
|
221
|
+
intl.formatMessage(intCompanyMessages.roleRequired)
|
|
222
|
+
),
|
|
223
|
+
]}
|
|
224
|
+
/>
|
|
225
|
+
</React.Fragment>
|
|
226
|
+
) : null}
|
|
227
|
+
|
|
228
|
+
{pepContext.state.role &&
|
|
229
|
+
pepContext.state.role === Role.MILITARY_OFFICER ? (
|
|
230
|
+
<Select
|
|
231
|
+
label={intl.formatMessage(militaryMessages.header, {
|
|
232
|
+
entityType,
|
|
233
|
+
pepType: type,
|
|
234
|
+
relation:
|
|
235
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
236
|
+
? pepContext.state.businessRelation
|
|
237
|
+
: pepContext.state.relationToPEP,
|
|
238
|
+
name: pepContext.state.ownerName,
|
|
239
|
+
possessiveName: formatPossessive(
|
|
240
|
+
pepContext.state.ownerName,
|
|
241
|
+
intl.locale
|
|
242
|
+
),
|
|
243
|
+
})}
|
|
244
|
+
placeholder={intl.formatMessage(militaryMessages.placeholder)}
|
|
245
|
+
alternatives={militaryAlternatives}
|
|
246
|
+
value={militaryAlternatives.find(
|
|
247
|
+
(alt) => alt.value === pepContext.state.militaryRank
|
|
248
|
+
)}
|
|
249
|
+
onChange={(event) => {
|
|
250
|
+
pepContext.setState({
|
|
251
|
+
militaryRank: event.value as MilitaryRank,
|
|
252
|
+
});
|
|
253
|
+
}}
|
|
254
|
+
validators={[
|
|
255
|
+
new RequiredValidator(
|
|
256
|
+
intl.formatMessage(militaryMessages.required)
|
|
257
|
+
),
|
|
258
|
+
]}
|
|
259
|
+
/>
|
|
260
|
+
) : null}
|
|
261
|
+
</Card>
|
|
262
|
+
<Button
|
|
263
|
+
block
|
|
264
|
+
type="submit"
|
|
265
|
+
label={<FormattedMessage id="pep.role.next" />}
|
|
266
|
+
/>
|
|
267
|
+
</Form>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export function getRoleAlts(intl: IntlShape): Alternative<Role>[] {
|
|
272
|
+
return [
|
|
273
|
+
{
|
|
274
|
+
text: intl.formatMessage(roleMessages[Role.HEAD_OF_GOVERNMENT]),
|
|
275
|
+
value: Role.HEAD_OF_GOVERNMENT,
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
text: intl.formatMessage(roleMessages[Role.MINISTER]),
|
|
279
|
+
value: Role.MINISTER,
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
text: intl.formatMessage(roleMessages[Role.PARLIMENT_MEMBER]),
|
|
283
|
+
value: Role.PARLIMENT_MEMBER,
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
text: intl.formatMessage(roleMessages[Role.CENTRAL_BANK_MEMBER]),
|
|
287
|
+
value: Role.CENTRAL_BANK_MEMBER,
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
text: intl.formatMessage(roleMessages[Role.BOARD_MEMBER_POLITICAL_PARTY]),
|
|
291
|
+
value: Role.BOARD_MEMBER_POLITICAL_PARTY,
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
text: intl.formatMessage(roleMessages[Role.JUDGE_SUPREME_COURT]),
|
|
295
|
+
value: Role.JUDGE_SUPREME_COURT,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
text: intl.formatMessage(roleMessages[Role.JUDGE_OTHER_HIGH_COURT]),
|
|
299
|
+
value: Role.JUDGE_OTHER_HIGH_COURT,
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
text: intl.formatMessage(roleMessages[Role.REVISION_INSTITUTE]),
|
|
303
|
+
value: Role.REVISION_INSTITUTE,
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
text: intl.formatMessage(roleMessages[Role.AMBASSADOR]),
|
|
307
|
+
value: Role.AMBASSADOR,
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
text: intl.formatMessage(roleMessages[Role.MILITARY_OFFICER]),
|
|
311
|
+
value: Role.MILITARY_OFFICER,
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
text: intl.formatMessage(roleMessages[Role.GOVERNMENT_COMPANY]),
|
|
315
|
+
value: Role.GOVERNMENT_COMPANY,
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
text: intl.formatMessage(roleMessages[Role.EU_HIGH_RANKING_POSITION]),
|
|
319
|
+
value: Role.EU_HIGH_RANKING_POSITION,
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
text: intl.formatMessage(
|
|
323
|
+
roleMessages[Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP]
|
|
324
|
+
),
|
|
325
|
+
value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP,
|
|
326
|
+
},
|
|
327
|
+
];
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export function getMilitaryAlts(intl: IntlShape): Alternative<MilitaryRank>[] {
|
|
331
|
+
return [
|
|
332
|
+
{
|
|
333
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.GENERAL]),
|
|
334
|
+
value: MilitaryRank.GENERAL,
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
text: intl.formatMessage(
|
|
338
|
+
militaryMessages[MilitaryRank.LIEUTENANT_GENERAL]
|
|
339
|
+
),
|
|
340
|
+
value: MilitaryRank.LIEUTENANT_GENERAL,
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.MAJOR_GENERAL]),
|
|
344
|
+
value: MilitaryRank.MAJOR_GENERAL,
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.ADMIRAL]),
|
|
348
|
+
value: MilitaryRank.ADMIRAL,
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.VICE_ADMIRAL]),
|
|
352
|
+
value: MilitaryRank.VICE_ADMIRAL,
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.REAR_ADMIRAL]),
|
|
356
|
+
value: MilitaryRank.REAR_ADMIRAL,
|
|
357
|
+
},
|
|
358
|
+
];
|
|
359
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
},
|
|
8
|
+
required: {
|
|
9
|
+
id: "pep.status.isongoing.required",
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const endedMessages = defineMessages({
|
|
14
|
+
header: {
|
|
15
|
+
id: "pep.status.ended.header",
|
|
16
|
+
},
|
|
17
|
+
required: {
|
|
18
|
+
id: "pep.status.ended.required",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const isLocalCountryMessages = defineMessages({
|
|
23
|
+
header: {
|
|
24
|
+
id: "pep.status.localcountry.header",
|
|
25
|
+
},
|
|
26
|
+
required: {
|
|
27
|
+
id: "pep.status.localcountry.required",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const countrySelectionMessages = defineMessages({
|
|
32
|
+
header: {
|
|
33
|
+
id: "pep.status.countryselecton.header",
|
|
34
|
+
},
|
|
35
|
+
required: {
|
|
36
|
+
id: "pep.status.countryselecton.required",
|
|
37
|
+
},
|
|
38
|
+
placeholder: {
|
|
39
|
+
id: "pep.status.countryselection.placeholder"
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const localCountryAltMessages = defineMessages({
|
|
44
|
+
localCountry: {
|
|
45
|
+
id: "pep.status.localcountryalt.local",
|
|
46
|
+
},
|
|
47
|
+
otherCountry: {
|
|
48
|
+
id: "pep.status.othercountryalt.other",
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const stateAltMessages = defineMessages({
|
|
53
|
+
[PepStatus.ONGOING]: {
|
|
54
|
+
id: "pep.status.state.ONGOING",
|
|
55
|
+
},
|
|
56
|
+
[PepStatus.ENDED]: {
|
|
57
|
+
id: "pep.status.state.ENDED",
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
FunctionComponent,
|
|
3
|
+
useRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
} from "react";
|
|
7
|
+
import {
|
|
8
|
+
Form,
|
|
9
|
+
RadioGroup,
|
|
10
|
+
RequiredValidator,
|
|
11
|
+
LysaFormRef,
|
|
12
|
+
Datepicker,
|
|
13
|
+
Card,
|
|
14
|
+
CountrySelect,
|
|
15
|
+
Language,
|
|
16
|
+
WorldCountry,
|
|
17
|
+
Button,
|
|
18
|
+
} from "@lysaab/ui-2";
|
|
19
|
+
import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
|
|
20
|
+
import { PepContext, PepStatus, EntityType, PepType } from "../PepContext";
|
|
21
|
+
import { useIntl, FormattedMessage, IntlShape } from "react-intl";
|
|
22
|
+
import {
|
|
23
|
+
isOngoingMessages,
|
|
24
|
+
endedMessages,
|
|
25
|
+
isLocalCountryMessages,
|
|
26
|
+
countrySelectionMessages,
|
|
27
|
+
localCountryAltMessages,
|
|
28
|
+
stateAltMessages,
|
|
29
|
+
} from "./StatusMessages";
|
|
30
|
+
import { formatPossessive } from "../../utils/Possession";
|
|
31
|
+
|
|
32
|
+
interface Props {
|
|
33
|
+
countryName: string;
|
|
34
|
+
countryCode: WorldCountry;
|
|
35
|
+
language: Language;
|
|
36
|
+
next: () => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const StatusPage: FunctionComponent<Props> = ({
|
|
40
|
+
countryName,
|
|
41
|
+
countryCode,
|
|
42
|
+
language,
|
|
43
|
+
next,
|
|
44
|
+
}) => {
|
|
45
|
+
const pepContext = useContext(PepContext);
|
|
46
|
+
const formRef = useRef<LysaFormRef>();
|
|
47
|
+
const intl = useIntl();
|
|
48
|
+
const stateAlternatives = getStateAlternatives(intl);
|
|
49
|
+
const isLocalCountryAlternatives = getIsLocalCountryAlternatives(
|
|
50
|
+
intl,
|
|
51
|
+
countryName
|
|
52
|
+
);
|
|
53
|
+
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
54
|
+
|
|
55
|
+
const nextPage = useCallback(() => {
|
|
56
|
+
if (formRef.current && formRef.current.isValid) {
|
|
57
|
+
next();
|
|
58
|
+
}
|
|
59
|
+
}, [formRef, next]);
|
|
60
|
+
|
|
61
|
+
const updateIsLocalCountry = useCallback(
|
|
62
|
+
(alternative: Alternative<string>) => {
|
|
63
|
+
pepContext.setState({ isLocalCountry: alternative.value });
|
|
64
|
+
|
|
65
|
+
if (alternative.value === "other") {
|
|
66
|
+
pepContext.setState({ country: undefined });
|
|
67
|
+
} else {
|
|
68
|
+
pepContext.setState({ country: countryCode });
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[pepContext, countryCode]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const updateIsOngoing = useCallback(
|
|
75
|
+
(alternative: Alternative<PepStatus>) => {
|
|
76
|
+
pepContext.setState({ isOngoing: alternative.value });
|
|
77
|
+
|
|
78
|
+
if (alternative.value === PepStatus.ONGOING) {
|
|
79
|
+
pepContext.setState({ ended: undefined });
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
[pepContext]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div>
|
|
87
|
+
<Form
|
|
88
|
+
lysaFormRef={formRef}
|
|
89
|
+
onSubmit={() => {
|
|
90
|
+
nextPage();
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<Card>
|
|
94
|
+
<RadioGroup
|
|
95
|
+
alternatives={stateAlternatives}
|
|
96
|
+
header={intl.formatMessage(isOngoingMessages.header, {
|
|
97
|
+
entityType,
|
|
98
|
+
name: pepContext.state.ownerName,
|
|
99
|
+
possessiveName: formatPossessive(
|
|
100
|
+
pepContext.state.ownerName,
|
|
101
|
+
intl.locale
|
|
102
|
+
),
|
|
103
|
+
relation:
|
|
104
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
105
|
+
? pepContext.state.businessRelation
|
|
106
|
+
: pepContext.state.relationToPEP,
|
|
107
|
+
pepType: pepContext.state.type,
|
|
108
|
+
})}
|
|
109
|
+
onChange={updateIsOngoing}
|
|
110
|
+
value={stateAlternatives.find(
|
|
111
|
+
(alt) => alt.value === pepContext.state.isOngoing
|
|
112
|
+
)}
|
|
113
|
+
validators={[
|
|
114
|
+
new RequiredValidator(
|
|
115
|
+
intl.formatMessage(isOngoingMessages.required)
|
|
116
|
+
),
|
|
117
|
+
]}
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
{pepContext.state.isOngoing &&
|
|
121
|
+
pepContext.state.isOngoing === PepStatus.ENDED ? (
|
|
122
|
+
<Datepicker
|
|
123
|
+
label={intl.formatMessage(endedMessages.header)}
|
|
124
|
+
selected={pepContext.state.ended}
|
|
125
|
+
onChange={(event) => {
|
|
126
|
+
// event has a type that says it can be [startDate, endDate]
|
|
127
|
+
// but we know that will never be the case here
|
|
128
|
+
pepContext.setState({ ended: (event as Date) || undefined });
|
|
129
|
+
}}
|
|
130
|
+
validators={[
|
|
131
|
+
new RequiredValidator(
|
|
132
|
+
intl.formatMessage(endedMessages.required)
|
|
133
|
+
),
|
|
134
|
+
]}
|
|
135
|
+
showMonthYearPicker
|
|
136
|
+
dateFormat="yyyy-MM"
|
|
137
|
+
maxDate={new Date()}
|
|
138
|
+
/>
|
|
139
|
+
) : null}
|
|
140
|
+
</Card>
|
|
141
|
+
|
|
142
|
+
<Card>
|
|
143
|
+
<RadioGroup
|
|
144
|
+
alternatives={isLocalCountryAlternatives}
|
|
145
|
+
header={intl.formatMessage(isLocalCountryMessages.header, {
|
|
146
|
+
possessiveName: formatPossessive(
|
|
147
|
+
pepContext.state.ownerName,
|
|
148
|
+
intl.locale
|
|
149
|
+
),
|
|
150
|
+
})}
|
|
151
|
+
onChange={updateIsLocalCountry}
|
|
152
|
+
value={isLocalCountryAlternatives.find(
|
|
153
|
+
(alt) => alt.value === pepContext.state.isLocalCountry
|
|
154
|
+
)}
|
|
155
|
+
validators={[
|
|
156
|
+
new RequiredValidator(
|
|
157
|
+
intl.formatMessage(isLocalCountryMessages.required)
|
|
158
|
+
),
|
|
159
|
+
]}
|
|
160
|
+
/>
|
|
161
|
+
|
|
162
|
+
{pepContext.state.isLocalCountry &&
|
|
163
|
+
pepContext.state.isLocalCountry === "other" ? (
|
|
164
|
+
<CountrySelect
|
|
165
|
+
label={intl.formatMessage(countrySelectionMessages.header, {
|
|
166
|
+
entityType,
|
|
167
|
+
name: pepContext.state.ownerName,
|
|
168
|
+
possessiveName: formatPossessive(
|
|
169
|
+
pepContext.state.ownerName,
|
|
170
|
+
intl.locale
|
|
171
|
+
),
|
|
172
|
+
relation:
|
|
173
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
174
|
+
? pepContext.state.businessRelation
|
|
175
|
+
: pepContext.state.relationToPEP,
|
|
176
|
+
pepType: pepContext.state.type,
|
|
177
|
+
})}
|
|
178
|
+
onChange={(event) =>
|
|
179
|
+
pepContext.setState({
|
|
180
|
+
country: event.value ? event.value : undefined,
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
validators={[
|
|
184
|
+
new RequiredValidator(
|
|
185
|
+
intl.formatMessage(countrySelectionMessages.required)
|
|
186
|
+
),
|
|
187
|
+
]}
|
|
188
|
+
value={pepContext.state.country}
|
|
189
|
+
omitList={[countryCode]}
|
|
190
|
+
language={language}
|
|
191
|
+
placeholder={intl.formatMessage(
|
|
192
|
+
countrySelectionMessages.placeholder
|
|
193
|
+
)}
|
|
194
|
+
/>
|
|
195
|
+
) : null}
|
|
196
|
+
</Card>
|
|
197
|
+
|
|
198
|
+
<Button
|
|
199
|
+
label={<FormattedMessage id="pep.status.next" />}
|
|
200
|
+
block
|
|
201
|
+
type="submit"
|
|
202
|
+
/>
|
|
203
|
+
</Form>
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
function getIsLocalCountryAlternatives(
|
|
209
|
+
intl: IntlShape,
|
|
210
|
+
countryName: string
|
|
211
|
+
): Alternative<string>[] {
|
|
212
|
+
return [
|
|
213
|
+
{
|
|
214
|
+
text: intl.formatMessage(localCountryAltMessages.localCountry, {
|
|
215
|
+
countryName,
|
|
216
|
+
}),
|
|
217
|
+
value: "local",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
text: intl.formatMessage(localCountryAltMessages.otherCountry),
|
|
221
|
+
value: "other",
|
|
222
|
+
},
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function getStateAlternatives(intl: IntlShape): Alternative<PepStatus>[] {
|
|
227
|
+
return [
|
|
228
|
+
{
|
|
229
|
+
text: intl.formatMessage(stateAltMessages[PepStatus.ONGOING]),
|
|
230
|
+
value: PepStatus.ONGOING,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
text: intl.formatMessage(stateAltMessages[PepStatus.ENDED]),
|
|
234
|
+
value: PepStatus.ENDED,
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|