@lysaab/lysa-pep 0.17.4 → 1.0.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/.vscode/settings.json +3 -0
- package/README.md +0 -0
- package/lib/Exports.d.ts +7 -8
- package/lib/Exports.js +7 -8
- package/lib/components/CountrySelect.d.ts +15 -22
- package/lib/components/CountrySelect.js +30 -21
- package/lib/components/PepAnswers.d.ts +8 -8
- package/lib/components/PepAnswers.js +131 -39
- package/lib/components/PepAnswers.scss +0 -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/pages/IsPep/IsPepMessages.d.ts +32 -0
- package/lib/pages/IsPep/IsPepMessages.js +74 -0
- package/lib/pages/IsPep/IsPepPage.d.ts +14 -0
- package/lib/pages/IsPep/IsPepPage.js +39 -0
- package/lib/pages/PepContext.d.ts +80 -80
- package/lib/pages/PepContext.js +88 -88
- package/lib/pages/RelationPage/RelationMessages.d.ts +105 -0
- package/lib/pages/RelationPage/RelationMessages.js +282 -0
- package/lib/pages/{PepStatusPage.d.ts → RelationPage/RelationPage.d.ts} +6 -6
- package/lib/pages/RelationPage/RelationPage.js +142 -0
- package/lib/pages/RolePage/RoleMessages.d.ts +185 -0
- package/lib/pages/RolePage/RoleMessages.js +381 -0
- package/lib/pages/RolePage/RolePage.d.ts +11 -0
- package/lib/pages/RolePage/RolePage.js +214 -0
- package/lib/pages/StatusPage/StatusMessages.d.ts +72 -0
- package/lib/pages/StatusPage/StatusMessages.js +74 -0
- package/lib/pages/{PepRelationPage.d.ts → StatusPage/StatusPage.d.ts} +6 -6
- package/lib/pages/StatusPage/StatusPage.js +75 -0
- package/package.json +12 -9
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -0
- package/public/robots.txt +0 -0
- package/src/App.css +0 -0
- package/src/App.test.tsx +0 -0
- package/src/App.tsx +0 -0
- package/src/Exports.ts +7 -8
- package/src/components/CountrySelect.tsx +14 -10
- package/src/components/PepAnswers.scss +0 -0
- package/src/components/PepAnswers.tsx +167 -35
- package/src/demo/Done.tsx +2 -6
- package/src/demo/Pep.tsx +86 -80
- package/src/index.css +0 -0
- package/src/index.tsx +0 -0
- package/src/logo.svg +0 -0
- package/src/model/Countries.ts +0 -0
- package/src/model/PepModel.ts +0 -0
- package/src/pages/IsPep/IsPepMessages.ts +75 -0
- package/src/pages/IsPep/IsPepPage.tsx +94 -0
- package/src/pages/PepContext.tsx +0 -0
- package/src/pages/RelationPage/RelationMessages.ts +287 -0
- package/src/pages/RelationPage/RelationPage.tsx +269 -0
- package/src/pages/RolePage/RoleMessages.ts +389 -0
- package/src/pages/RolePage/RolePage.tsx +342 -0
- package/src/pages/StatusPage/StatusMessages.ts +80 -0
- package/src/pages/{PepStatusPage.tsx → StatusPage/StatusPage.tsx} +72 -36
- package/src/react-app-env.d.ts +0 -0
- package/src/serviceWorker.ts +0 -0
- package/tsconfig.json +0 -0
- package/tsconfig_build.json +0 -0
- package/lib/model/PepTexts.d.ts +0 -326
- package/lib/model/PepTexts.js +0 -472
- package/lib/pages/PepIsPepPage.d.ts +0 -15
- package/lib/pages/PepIsPepPage.js +0 -59
- package/lib/pages/PepRelationPage.js +0 -79
- package/lib/pages/PepRolePage.d.ts +0 -10
- package/lib/pages/PepRolePage.js +0 -127
- package/lib/pages/PepStatusPage.js +0 -54
- package/src/model/PepTexts.ts +0 -519
- package/src/pages/PepIsPepPage.tsx +0 -107
- package/src/pages/PepRelationPage.tsx +0 -188
- package/src/pages/PepRolePage.tsx +0 -272
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import React, { useRef, useCallback, useContext } from "react";
|
|
2
|
+
import { Form, PrimaryButton, RequiredValidator, TextInput, Select } from "@lysaab/ui-2";
|
|
3
|
+
import { PepContext, Role, MilitaryRank, PepType, EntityType } from "../PepContext";
|
|
4
|
+
import { CountrySelect } from "../../components/CountrySelect";
|
|
5
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
6
|
+
import { roleMessages, ambassadorMessages, governmentCompanyMessages, intCompanyMessages, militaryMessages } from "./RoleMessages";
|
|
7
|
+
export const RolePage = ({ next }) => {
|
|
8
|
+
const pepContext = useContext(PepContext);
|
|
9
|
+
const formRef = useRef();
|
|
10
|
+
const intl = useIntl();
|
|
11
|
+
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
12
|
+
const type = pepContext.state.type;
|
|
13
|
+
const roleAlternatives = getRoleAlts(intl);
|
|
14
|
+
const militaryAlternatives = getMilitaryAlts(intl);
|
|
15
|
+
const nextPage = useCallback(() => {
|
|
16
|
+
if (formRef.current && formRef.current.isValid) {
|
|
17
|
+
next();
|
|
18
|
+
}
|
|
19
|
+
}, [formRef, next]);
|
|
20
|
+
const resetRoleFields = useCallback(() => {
|
|
21
|
+
pepContext.setState({
|
|
22
|
+
ambassadorCountry: undefined,
|
|
23
|
+
governmentCompany: undefined,
|
|
24
|
+
governmentCompanyRole: undefined,
|
|
25
|
+
internationalOrganisation: undefined,
|
|
26
|
+
internationalOrganisationRole: undefined,
|
|
27
|
+
militaryRank: undefined
|
|
28
|
+
});
|
|
29
|
+
}, [pepContext]);
|
|
30
|
+
if (!type || type === PepType.NOT_PEP) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
console.log({
|
|
34
|
+
entityType,
|
|
35
|
+
pepType: type,
|
|
36
|
+
relation: pepContext.state.relationToPEP || pepContext.state.businessRelation
|
|
37
|
+
});
|
|
38
|
+
return (React.createElement(Form, { onSubmit: () => nextPage(), lysaFormRef: formRef },
|
|
39
|
+
React.createElement(Select, { label: intl.formatMessage(roleMessages.header, {
|
|
40
|
+
entityType,
|
|
41
|
+
pepType: type,
|
|
42
|
+
relation: pepContext.state.relationToPEP || pepContext.state.businessRelation,
|
|
43
|
+
name: pepContext.state.ownerName
|
|
44
|
+
}), placeholder: intl.formatMessage(roleMessages.placeholder), alternatives: roleAlternatives, value: roleAlternatives.find(alt => alt.value === pepContext.state.role), onChange: event => {
|
|
45
|
+
pepContext.setState({ role: event.value });
|
|
46
|
+
resetRoleFields();
|
|
47
|
+
}, validators: [
|
|
48
|
+
RequiredValidator(intl.formatMessage(roleMessages.required))
|
|
49
|
+
] }),
|
|
50
|
+
pepContext.state.role && pepContext.state.role === Role.AMBASSADOR ? (React.createElement(CountrySelect, { label: intl.formatMessage(ambassadorMessages.header, {
|
|
51
|
+
entityType,
|
|
52
|
+
pepType: type,
|
|
53
|
+
relation: pepContext.state.relationToPEP ||
|
|
54
|
+
pepContext.state.businessRelation,
|
|
55
|
+
name: pepContext.state.ownerName
|
|
56
|
+
}), onChange: event => pepContext.setState({
|
|
57
|
+
ambassadorCountry: event.value
|
|
58
|
+
? event.value.toString()
|
|
59
|
+
: undefined
|
|
60
|
+
}), value: pepContext.state.ambassadorCountry, validators: [
|
|
61
|
+
RequiredValidator(intl.formatMessage(ambassadorMessages.required))
|
|
62
|
+
] })) : null,
|
|
63
|
+
pepContext.state.role &&
|
|
64
|
+
pepContext.state.role === Role.GOVERNMENT_COMPANY ? (React.createElement(React.Fragment, null,
|
|
65
|
+
React.createElement(TextInput, { label: intl.formatMessage(governmentCompanyMessages.nameHeader, {
|
|
66
|
+
entityType,
|
|
67
|
+
pepType: type,
|
|
68
|
+
relation: pepContext.state.relationToPEP ||
|
|
69
|
+
pepContext.state.businessRelation,
|
|
70
|
+
name: pepContext.state.ownerName
|
|
71
|
+
}), value: pepContext.state.governmentCompany || "", onChange: value => {
|
|
72
|
+
pepContext.setState({ governmentCompany: value });
|
|
73
|
+
}, validators: [
|
|
74
|
+
RequiredValidator(intl.formatMessage(governmentCompanyMessages.nameRequired))
|
|
75
|
+
] }),
|
|
76
|
+
React.createElement(TextInput, { label: intl.formatMessage(governmentCompanyMessages.roleHeader, {
|
|
77
|
+
entityType,
|
|
78
|
+
pepType: type,
|
|
79
|
+
relation: pepContext.state.relationToPEP ||
|
|
80
|
+
pepContext.state.businessRelation,
|
|
81
|
+
name: pepContext.state.ownerName
|
|
82
|
+
}), value: pepContext.state.governmentCompanyRole || "", onChange: value => {
|
|
83
|
+
pepContext.setState({
|
|
84
|
+
governmentCompanyRole: value
|
|
85
|
+
});
|
|
86
|
+
}, validators: [
|
|
87
|
+
RequiredValidator(intl.formatMessage(governmentCompanyMessages.roleRequired))
|
|
88
|
+
] }))) : null,
|
|
89
|
+
pepContext.state.role &&
|
|
90
|
+
pepContext.state.role ===
|
|
91
|
+
Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP ? (React.createElement(React.Fragment, null,
|
|
92
|
+
React.createElement(TextInput, { label: intl.formatMessage(intCompanyMessages.nameHeader, {
|
|
93
|
+
entityType,
|
|
94
|
+
pepType: type,
|
|
95
|
+
relation: pepContext.state.relationToPEP ||
|
|
96
|
+
pepContext.state.businessRelation,
|
|
97
|
+
name: pepContext.state.ownerName
|
|
98
|
+
}), value: pepContext.state.internationalOrganisation || "", onChange: value => {
|
|
99
|
+
pepContext.setState({ internationalOrganisation: value });
|
|
100
|
+
}, validators: [
|
|
101
|
+
RequiredValidator(intl.formatMessage(intCompanyMessages.nameRequired))
|
|
102
|
+
] }),
|
|
103
|
+
React.createElement(TextInput, { label: intl.formatMessage(intCompanyMessages.roleHeader, {
|
|
104
|
+
entityType,
|
|
105
|
+
pepType: type,
|
|
106
|
+
relation: pepContext.state.relationToPEP ||
|
|
107
|
+
pepContext.state.businessRelation,
|
|
108
|
+
name: pepContext.state.ownerName
|
|
109
|
+
}), value: pepContext.state.internationalOrganisationRole || "", onChange: value => {
|
|
110
|
+
pepContext.setState({
|
|
111
|
+
internationalOrganisationRole: value
|
|
112
|
+
});
|
|
113
|
+
}, validators: [
|
|
114
|
+
RequiredValidator(intl.formatMessage(intCompanyMessages.roleRequired))
|
|
115
|
+
] }))) : null,
|
|
116
|
+
pepContext.state.role &&
|
|
117
|
+
pepContext.state.role === Role.MILITARY_OFFICER ? (React.createElement(Select, { label: intl.formatMessage(militaryMessages.header, {
|
|
118
|
+
entityType,
|
|
119
|
+
pepType: type,
|
|
120
|
+
relation: pepContext.state.relationToPEP ||
|
|
121
|
+
pepContext.state.businessRelation,
|
|
122
|
+
name: pepContext.state.ownerName
|
|
123
|
+
}), placeholder: intl.formatMessage(militaryMessages.placeholder), alternatives: militaryAlternatives, value: militaryAlternatives.find(alt => alt.value === pepContext.state.militaryRank), onChange: event => {
|
|
124
|
+
pepContext.setState({ militaryRank: event.value });
|
|
125
|
+
}, validators: [
|
|
126
|
+
RequiredValidator(intl.formatMessage(militaryMessages.required))
|
|
127
|
+
] })) : null,
|
|
128
|
+
React.createElement(PrimaryButton, { type: "submit" },
|
|
129
|
+
React.createElement(FormattedMessage, { id: "pep.role.next", description: "Next button", defaultMessage: "G\u00E5 vidare" }))));
|
|
130
|
+
};
|
|
131
|
+
export function getRoleAlts(intl) {
|
|
132
|
+
return [
|
|
133
|
+
{
|
|
134
|
+
text: intl.formatMessage(roleMessages[Role.HEAD_OF_GOVERNMENT]),
|
|
135
|
+
value: Role.HEAD_OF_GOVERNMENT
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
text: intl.formatMessage(roleMessages[Role.MINISTER]),
|
|
139
|
+
value: Role.MINISTER
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
text: intl.formatMessage(roleMessages[Role.PARLIMENT_MEMBER]),
|
|
143
|
+
value: Role.PARLIMENT_MEMBER
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
text: intl.formatMessage(roleMessages[Role.CENTRAL_BANK_MEMBER]),
|
|
147
|
+
value: Role.CENTRAL_BANK_MEMBER
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
text: intl.formatMessage(roleMessages[Role.BOARD_MEMBER_POLITICAL_PARTY]),
|
|
151
|
+
value: Role.BOARD_MEMBER_POLITICAL_PARTY
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
text: intl.formatMessage(roleMessages[Role.JUDGE_SUPREME_COURT]),
|
|
155
|
+
value: Role.JUDGE_SUPREME_COURT
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
text: intl.formatMessage(roleMessages[Role.JUDGE_OTHER_HIGH_COURT]),
|
|
159
|
+
value: Role.JUDGE_OTHER_HIGH_COURT
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
text: intl.formatMessage(roleMessages[Role.REVISION_INSTITUTE]),
|
|
163
|
+
value: Role.REVISION_INSTITUTE
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
text: intl.formatMessage(roleMessages[Role.AMBASSADOR]),
|
|
167
|
+
value: Role.AMBASSADOR
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
text: intl.formatMessage(roleMessages[Role.MILITARY_OFFICER]),
|
|
171
|
+
value: Role.MILITARY_OFFICER
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
text: intl.formatMessage(roleMessages[Role.GOVERNMENT_COMPANY]),
|
|
175
|
+
value: Role.GOVERNMENT_COMPANY
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
text: intl.formatMessage(roleMessages[Role.EU_HIGH_RANKING_POSITION]),
|
|
179
|
+
value: Role.EU_HIGH_RANKING_POSITION
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
text: intl.formatMessage(roleMessages[Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP]),
|
|
183
|
+
value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
export function getMilitaryAlts(intl) {
|
|
188
|
+
return [
|
|
189
|
+
{
|
|
190
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.GENERAL]),
|
|
191
|
+
value: MilitaryRank.GENERAL
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.LIEUTENANT_GENERAL]),
|
|
195
|
+
value: MilitaryRank.LIEUTENANT_GENERAL
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.MAJOR_GENERAL]),
|
|
199
|
+
value: MilitaryRank.MAJOR_GENERAL
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.ADMIRAL]),
|
|
203
|
+
value: MilitaryRank.ADMIRAL
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.VICE_ADMIRAL]),
|
|
207
|
+
value: MilitaryRank.VICE_ADMIRAL
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
text: intl.formatMessage(militaryMessages[MilitaryRank.REAR_ADMIRAL]),
|
|
211
|
+
value: MilitaryRank.REAR_ADMIRAL
|
|
212
|
+
}
|
|
213
|
+
];
|
|
214
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare const isOngoingMessages: {
|
|
2
|
+
header: {
|
|
3
|
+
id: string;
|
|
4
|
+
description: string;
|
|
5
|
+
defaultMessage: string;
|
|
6
|
+
};
|
|
7
|
+
required: {
|
|
8
|
+
id: string;
|
|
9
|
+
description: string;
|
|
10
|
+
defaultMessage: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const endedMessages: {
|
|
14
|
+
header: {
|
|
15
|
+
id: string;
|
|
16
|
+
description: string;
|
|
17
|
+
defaultMessage: string;
|
|
18
|
+
};
|
|
19
|
+
required: {
|
|
20
|
+
id: string;
|
|
21
|
+
description: string;
|
|
22
|
+
defaultMessage: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const isLocalCountryMessages: {
|
|
26
|
+
header: {
|
|
27
|
+
id: string;
|
|
28
|
+
description: string;
|
|
29
|
+
defaultMessage: string;
|
|
30
|
+
};
|
|
31
|
+
required: {
|
|
32
|
+
id: string;
|
|
33
|
+
description: string;
|
|
34
|
+
defaultMessage: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare const countrySelectionMessages: {
|
|
38
|
+
header: {
|
|
39
|
+
id: string;
|
|
40
|
+
description: string;
|
|
41
|
+
defaultMessage: string;
|
|
42
|
+
};
|
|
43
|
+
required: {
|
|
44
|
+
id: string;
|
|
45
|
+
description: string;
|
|
46
|
+
defaultMessage: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare const localCountryAltMessages: {
|
|
50
|
+
localCountry: {
|
|
51
|
+
id: string;
|
|
52
|
+
description: string;
|
|
53
|
+
defaultMessage: string;
|
|
54
|
+
};
|
|
55
|
+
otherCountry: {
|
|
56
|
+
id: string;
|
|
57
|
+
description: string;
|
|
58
|
+
defaultMessage: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare const stateAltMessages: {
|
|
62
|
+
ONGOING: {
|
|
63
|
+
id: string;
|
|
64
|
+
description: string;
|
|
65
|
+
defaultMessage: string;
|
|
66
|
+
};
|
|
67
|
+
ENDED: {
|
|
68
|
+
id: string;
|
|
69
|
+
description: string;
|
|
70
|
+
defaultMessage: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
import { PepStatus } from "../PepContext";
|
|
3
|
+
export const isOngoingMessages = defineMessages({
|
|
4
|
+
header: {
|
|
5
|
+
id: "pep.status.isongoing.header",
|
|
6
|
+
description: "Is ongoing header",
|
|
7
|
+
defaultMessage: "Är befattningen pågående eller avslutad?"
|
|
8
|
+
},
|
|
9
|
+
required: {
|
|
10
|
+
id: "pep.status.isongoing.required",
|
|
11
|
+
description: "Is ongoing required error",
|
|
12
|
+
defaultMessage: "Du måste välja ett alternativ"
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export const endedMessages = defineMessages({
|
|
16
|
+
header: {
|
|
17
|
+
id: "pep.status.ended.header",
|
|
18
|
+
description: "When did it end header",
|
|
19
|
+
defaultMessage: "När avslutades uppdraget?"
|
|
20
|
+
},
|
|
21
|
+
required: {
|
|
22
|
+
id: "pep.status.ended.required",
|
|
23
|
+
description: "When did it end required error",
|
|
24
|
+
defaultMessage: "Du måste ange ett slutdatum"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export const isLocalCountryMessages = defineMessages({
|
|
28
|
+
header: {
|
|
29
|
+
id: "pep.status.localcountry.sweden.header",
|
|
30
|
+
description: "Is local country header",
|
|
31
|
+
defaultMessage: "I vilket land är befattningen?"
|
|
32
|
+
},
|
|
33
|
+
required: {
|
|
34
|
+
id: "pep.status.localcountry.required",
|
|
35
|
+
description: "Is local country required error",
|
|
36
|
+
defaultMessage: "Du måste välja ett alternativ"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export const countrySelectionMessages = defineMessages({
|
|
40
|
+
header: {
|
|
41
|
+
id: "pep.status.countryselecton.header",
|
|
42
|
+
description: "Country selection header",
|
|
43
|
+
defaultMessage: "Välj i vilket land befattningen är"
|
|
44
|
+
},
|
|
45
|
+
required: {
|
|
46
|
+
id: "pep.status.countryselecton.required",
|
|
47
|
+
description: "Country selection required error",
|
|
48
|
+
defaultMessage: "Du måste välja land"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export const localCountryAltMessages = defineMessages({
|
|
52
|
+
localCountry: {
|
|
53
|
+
id: "pep.status.localcountryalt.required",
|
|
54
|
+
description: "Local country name",
|
|
55
|
+
defaultMessage: "Sverige"
|
|
56
|
+
},
|
|
57
|
+
otherCountry: {
|
|
58
|
+
id: "pep.status.localcountryalt.required",
|
|
59
|
+
description: "Other country",
|
|
60
|
+
defaultMessage: "Annat"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
export const stateAltMessages = defineMessages({
|
|
64
|
+
[PepStatus.ONGOING]: {
|
|
65
|
+
id: "pep.status.state.ONGOING",
|
|
66
|
+
description: "Ongoing alt",
|
|
67
|
+
defaultMessage: "Pågående"
|
|
68
|
+
},
|
|
69
|
+
[PepStatus.ENDED]: {
|
|
70
|
+
id: "pep.status.state.ENDED",
|
|
71
|
+
description: "Ended alt",
|
|
72
|
+
defaultMessage: "Avslutad"
|
|
73
|
+
}
|
|
74
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionComponent } from "react";
|
|
2
|
-
interface Props {
|
|
3
|
-
next: () => void;
|
|
4
|
-
}
|
|
5
|
-
export declare const
|
|
6
|
-
export {};
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
next: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const StatusPage: FunctionComponent<Props>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useRef, useCallback, useContext } from "react";
|
|
2
|
+
import { Form, RadioGroup, RequiredValidator, PrimaryButton, Datepicker } from "@lysaab/ui-2";
|
|
3
|
+
import { PepContext, PepStatus } from "../PepContext";
|
|
4
|
+
import { CountrySelect } from "../../components/CountrySelect";
|
|
5
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
6
|
+
import { isOngoingMessages, endedMessages, isLocalCountryMessages, countrySelectionMessages, localCountryAltMessages, stateAltMessages } from "./StatusMessages";
|
|
7
|
+
export const StatusPage = ({ next }) => {
|
|
8
|
+
const pepContext = useContext(PepContext);
|
|
9
|
+
const formRef = useRef();
|
|
10
|
+
const intl = useIntl();
|
|
11
|
+
const stateAlternatives = getStateAlternatives(intl);
|
|
12
|
+
const isSwedenAlternatives = getIsLocalCountryAlternatives(intl);
|
|
13
|
+
const nextPage = useCallback(() => {
|
|
14
|
+
if (formRef.current && formRef.current.isValid) {
|
|
15
|
+
next();
|
|
16
|
+
}
|
|
17
|
+
}, [formRef, next]);
|
|
18
|
+
const updateIsSweden = useCallback((alternative) => {
|
|
19
|
+
pepContext.setState({ isSweden: alternative.value });
|
|
20
|
+
if (alternative.value === "other") {
|
|
21
|
+
pepContext.setState({ country: undefined });
|
|
22
|
+
}
|
|
23
|
+
}, [pepContext]);
|
|
24
|
+
const updateIsOngoing = useCallback((alternative) => {
|
|
25
|
+
pepContext.setState({ isOngoing: alternative.value });
|
|
26
|
+
if (alternative.value === PepStatus.ONGOING) {
|
|
27
|
+
pepContext.setState({ ended: undefined });
|
|
28
|
+
}
|
|
29
|
+
}, [pepContext]);
|
|
30
|
+
return (React.createElement("div", null,
|
|
31
|
+
React.createElement(Form, { lysaFormRef: formRef, onSubmit: () => {
|
|
32
|
+
nextPage();
|
|
33
|
+
} },
|
|
34
|
+
React.createElement(RadioGroup, { alternatives: stateAlternatives, header: intl.formatMessage(isOngoingMessages.header), onChange: updateIsOngoing, value: stateAlternatives.find(alt => alt.value === pepContext.state.isOngoing), validators: [
|
|
35
|
+
RequiredValidator(intl.formatMessage(isOngoingMessages.required))
|
|
36
|
+
] }),
|
|
37
|
+
pepContext.state.isOngoing &&
|
|
38
|
+
pepContext.state.isOngoing === PepStatus.ENDED ? (React.createElement(Datepicker, { label: intl.formatMessage(endedMessages.header), selected: pepContext.state.ended, onChange: event => pepContext.setState({ ended: event || undefined }), validators: [
|
|
39
|
+
RequiredValidator(intl.formatMessage(isOngoingMessages.required))
|
|
40
|
+
], showMonthYearPicker: true, dateFormat: "yyyy-MM", maxDate: new Date() })) : null,
|
|
41
|
+
React.createElement(RadioGroup, { alternatives: isSwedenAlternatives, header: intl.formatMessage(isLocalCountryMessages.header), onChange: updateIsSweden, value: isSwedenAlternatives.find(alt => alt.value === pepContext.state.isSweden), validators: [
|
|
42
|
+
RequiredValidator(intl.formatMessage(isLocalCountryMessages.required))
|
|
43
|
+
] }),
|
|
44
|
+
pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (React.createElement(CountrySelect, { label: intl.formatMessage(countrySelectionMessages.header), onChange: event => pepContext.setState({
|
|
45
|
+
country: event.value ? event.value.toString() : undefined
|
|
46
|
+
}), validators: [
|
|
47
|
+
RequiredValidator(intl.formatMessage(countrySelectionMessages.required))
|
|
48
|
+
], value: pepContext.state.country, omitCountries: ["SE"] })) : null,
|
|
49
|
+
React.createElement(PrimaryButton, { type: "submit" },
|
|
50
|
+
React.createElement(FormattedMessage, { id: "pep.status.next", description: "Next button", defaultMessage: "G\u00E5 vidare" })))));
|
|
51
|
+
};
|
|
52
|
+
function getIsLocalCountryAlternatives(intl) {
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
text: intl.formatMessage(localCountryAltMessages.localCountry),
|
|
56
|
+
value: "sweden"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
text: intl.formatMessage(localCountryAltMessages.otherCountry),
|
|
60
|
+
value: "other"
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
function getStateAlternatives(intl) {
|
|
65
|
+
return [
|
|
66
|
+
{
|
|
67
|
+
text: intl.formatMessage(stateAltMessages[PepStatus.ONGOING]),
|
|
68
|
+
value: PepStatus.ONGOING
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
text: intl.formatMessage(stateAltMessages[PepStatus.ENDED]),
|
|
72
|
+
value: PepStatus.ENDED
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lysaab/lysa-pep",
|
|
3
3
|
"author": "Lysa AB",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0-0",
|
|
5
5
|
"main": "./lib/Exports.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@types/luxon": "^1.15.2",
|
|
8
|
-
"
|
|
8
|
+
"@types/react-intl": "^3.0.0",
|
|
9
|
+
"luxon": "^1.21.1",
|
|
10
|
+
"react-intl": "^4.1.1"
|
|
9
11
|
},
|
|
10
12
|
"devDependencies": {
|
|
11
|
-
"@lysaab/ui-2": "^16.
|
|
13
|
+
"@lysaab/ui-2": "^16.11.1",
|
|
12
14
|
"@types/jest": "24.0.20",
|
|
13
15
|
"@types/luxon": "^1.15.2",
|
|
14
16
|
"@types/node": "12.11.7",
|
|
15
|
-
"@types/react": "16.9.
|
|
16
|
-
"@types/react-dom": "16.9.
|
|
17
|
+
"@types/react": "^16.9.23",
|
|
18
|
+
"@types/react-dom": "^16.9.5",
|
|
17
19
|
"copyfiles": "^2.1.1",
|
|
18
20
|
"luxon": "^1.21.1",
|
|
19
|
-
"react": "^16.
|
|
20
|
-
"react-dom": "^16.
|
|
21
|
-
"react-scripts": "^3.4.
|
|
21
|
+
"react": "^16.13.0",
|
|
22
|
+
"react-dom": "^16.13.0",
|
|
23
|
+
"react-scripts": "^3.4.0",
|
|
22
24
|
"typescript": "^3.7.2"
|
|
23
25
|
},
|
|
24
26
|
"peerDependencies": {
|
|
@@ -33,7 +35,8 @@
|
|
|
33
35
|
"copyscss": "copyfiles -u 1 \"src/components/**/*.scss\" lib/",
|
|
34
36
|
"release:patch": "npm run build:lib && npm run copyscss && npm version patch && npm publish",
|
|
35
37
|
"release:minor": "npm run build:lib && npm run copyscss && npm version minor && npm publish",
|
|
36
|
-
"release:major": "npm run build:lib && npm run copyscss && npm version major && npm publish"
|
|
38
|
+
"release:major": "npm run build:lib && npm run copyscss && npm version major && npm publish",
|
|
39
|
+
"release:premajor": "npm run build:lib && npm run copyscss && npm version premajor && npm publish"
|
|
37
40
|
},
|
|
38
41
|
"eslintConfig": {
|
|
39
42
|
"extends": "react-app"
|
package/public/favicon.ico
CHANGED
|
File without changes
|
package/public/index.html
CHANGED
|
File without changes
|
package/public/logo192.png
CHANGED
|
File without changes
|
package/public/logo512.png
CHANGED
|
File without changes
|
package/public/manifest.json
CHANGED
|
File without changes
|
package/public/robots.txt
CHANGED
|
File without changes
|
package/src/App.css
CHANGED
|
File without changes
|
package/src/App.test.tsx
CHANGED
|
File without changes
|
package/src/App.tsx
CHANGED
|
File without changes
|
package/src/Exports.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export * from "./pages/PepContext";
|
|
2
2
|
export * from "./model/PepModel";
|
|
3
|
-
export * from "./
|
|
4
|
-
export
|
|
5
|
-
export { PepRelationPage } from "./pages/PepRelationPage";
|
|
3
|
+
export * from "./pages/IsPep/IsPepPage";
|
|
4
|
+
export { RelationPage } from "./pages/RelationPage/RelationPage";
|
|
6
5
|
export {
|
|
7
|
-
PepRolePage,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./pages/
|
|
11
|
-
export { PepStatusPage } from "./pages/
|
|
6
|
+
RolePage as PepRolePage,
|
|
7
|
+
getMilitaryAlts,
|
|
8
|
+
getRoleAlts
|
|
9
|
+
} from "./pages/RolePage/RolePage";
|
|
10
|
+
export { StatusPage as PepStatusPage } from "./pages/StatusPage/StatusPage";
|
|
12
11
|
|
|
13
12
|
export { PepAnswers } from "./components/PepAnswers";
|
|
@@ -2,12 +2,7 @@ import React, { useState, FunctionComponent } from "react";
|
|
|
2
2
|
import { Alternative, Select } from "@lysaab/ui-2";
|
|
3
3
|
import { ValidationProps } from "@lysaab/ui-2/hooks/useValidation";
|
|
4
4
|
import { countries } from "../model/Countries";
|
|
5
|
-
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
lysa: { contentPath: string };
|
|
9
|
-
}
|
|
10
|
-
}
|
|
5
|
+
import { defineMessages, useIntl } from "react-intl";
|
|
11
6
|
|
|
12
7
|
export interface Country {
|
|
13
8
|
label: string;
|
|
@@ -18,24 +13,33 @@ interface Props extends ValidationProps {
|
|
|
18
13
|
value?: string;
|
|
19
14
|
onChange?(value: Alternative<string>): void;
|
|
20
15
|
label: string;
|
|
21
|
-
|
|
16
|
+
omitCountries?: string[];
|
|
22
17
|
}
|
|
23
18
|
|
|
19
|
+
const messages = defineMessages({
|
|
20
|
+
placeholder: {
|
|
21
|
+
id: 'component.select.country',
|
|
22
|
+
description: 'Select a country placeholder',
|
|
23
|
+
defaultMessage: 'Välj ett land'
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
24
27
|
export const CountrySelect: FunctionComponent<Props> = ({
|
|
25
28
|
value,
|
|
26
|
-
|
|
29
|
+
omitCountries = [],
|
|
27
30
|
...props
|
|
28
31
|
}) => {
|
|
32
|
+
const intl = useIntl();
|
|
29
33
|
const [countryAlternatives] = useState(
|
|
30
34
|
countries
|
|
31
|
-
.filter(country => !(
|
|
35
|
+
.filter(country => !omitCountries.includes(country.value))
|
|
32
36
|
.map(country => ({ text: country.label, value: country.value }))
|
|
33
37
|
);
|
|
34
38
|
|
|
35
39
|
return (
|
|
36
40
|
<Select
|
|
37
41
|
alternatives={countryAlternatives}
|
|
38
|
-
placeholder={
|
|
42
|
+
placeholder={intl.formatMessage(messages.placeholder)}
|
|
39
43
|
value={countryAlternatives.find(country => country.value === value)}
|
|
40
44
|
{...props}
|
|
41
45
|
/>
|
|
File without changes
|