@lysaab/lysa-pep 0.14.0 → 0.14.2
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 -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 +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 +4 -3
- 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
package/lib/pages/PepRolePage.js
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import React, { useRef, useCallback, useContext } from "react";
|
|
2
|
-
import { Form, PrimaryButton, RequiredValidator, TextInput, Select } from "@lysaab/ui-2";
|
|
3
|
-
import { PepContext, Role, MilitaryRank, EntityType, PepType, } from "./PepContext";
|
|
4
|
-
import { CountrySelect } from "../components/CountrySelect";
|
|
5
|
-
import { getGovernmentCompanyNameLabel, getGovernmentCompanyRoleLabel, getHighRankingPositionIntCorpNameLabel, getHighRankingPositionIntCorpRoleLabel, getMilitaryRankLabel, getRoleLabel, getAmbassadorLabel } from "../model/PepTexts";
|
|
6
|
-
export const roleAlternatives = [
|
|
7
|
-
{ text: "Stats eller regeringschef", value: Role.HEAD_OF_GOVERNMENT },
|
|
8
|
-
{ text: "Minister eller Vice/Biträdande minister", value: Role.MINISTER },
|
|
9
|
-
{ text: "Ledamot i parlament eller riksdag", value: Role.PARLIMENT_MEMBER },
|
|
10
|
-
{
|
|
11
|
-
text: "Ledamot i centralbanks styrande organ",
|
|
12
|
-
value: Role.CENTRAL_BANK_MEMBER
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
text: "Ledamot för styrelsen i politiskt parti representerade i riksdagen",
|
|
16
|
-
value: Role.BOARD_MEMBER_POLITICAL_PARTY
|
|
17
|
-
},
|
|
18
|
-
{ text: "Domare i högsta domstolen", value: Role.JUDGE_SUPREME_COURT },
|
|
19
|
-
{
|
|
20
|
-
text: "Domare i konstitutionell domstol eller annat rättsligt organ på hög nivå vars beslut endast undantagsvis kan överklagas",
|
|
21
|
-
value: Role.JUDGE_OTHER_HIGH_COURT
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
text: "Högre tjänsteman vid revisionsmyndighet",
|
|
25
|
-
value: Role.REVISION_INSTITUTE
|
|
26
|
-
},
|
|
27
|
-
{ text: "Ambassadör eller bestickningschef", value: Role.AMBASSADOR },
|
|
28
|
-
{ text: "Högre officer i försvarsmakt", value: Role.MILITARY_OFFICER },
|
|
29
|
-
{
|
|
30
|
-
text: "Person som ingår i statsägt företags förvaltnings-, lednings eller kontrollorgan",
|
|
31
|
-
value: Role.GOVERNMENT_COMPANY
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
text: "EU-parlamentariker",
|
|
35
|
-
value: Role.EU_HIGH_RANKING_POSITION
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
text: "Befattning på hög nivå i en internationell organisation",
|
|
39
|
-
value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP
|
|
40
|
-
}
|
|
41
|
-
];
|
|
42
|
-
export const militaryAlternatives = [
|
|
43
|
-
{
|
|
44
|
-
text: "General",
|
|
45
|
-
value: MilitaryRank.GENERAL
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
text: "Generallöjtnant",
|
|
49
|
-
value: MilitaryRank.LIEUTENANT_GENERAL
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
text: "Generalmajor",
|
|
53
|
-
value: MilitaryRank.MAJOR_GENERAL
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
text: "Amiral",
|
|
57
|
-
value: MilitaryRank.ADMIRAL
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
text: "Viceamiral",
|
|
61
|
-
value: MilitaryRank.VICE_ADMIRAL
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
text: "Konteramiral",
|
|
65
|
-
value: MilitaryRank.REAR_ADMIRAL
|
|
66
|
-
}
|
|
67
|
-
];
|
|
68
|
-
export const PepRolePage = ({ next }) => {
|
|
69
|
-
const pepContext = useContext(PepContext);
|
|
70
|
-
const formRef = useRef();
|
|
71
|
-
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
72
|
-
const type = pepContext.state.type;
|
|
73
|
-
const nextPage = useCallback(() => {
|
|
74
|
-
if (formRef.current && formRef.current.isValid) {
|
|
75
|
-
next();
|
|
76
|
-
}
|
|
77
|
-
}, [formRef, next]);
|
|
78
|
-
const resetRoleFields = useCallback(() => {
|
|
79
|
-
pepContext.setState({
|
|
80
|
-
ambassadorCountry: undefined,
|
|
81
|
-
governmentCompany: undefined,
|
|
82
|
-
governmentCompanyRole: undefined,
|
|
83
|
-
internationalOrganisation: undefined,
|
|
84
|
-
internationalOrganisationRole: undefined,
|
|
85
|
-
militaryRank: undefined
|
|
86
|
-
});
|
|
87
|
-
}, [pepContext]);
|
|
88
|
-
if (!type || type === PepType.NOT_PEP) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
return (React.createElement(Form, { onSubmit: () => nextPage(), lysaFormRef: formRef },
|
|
92
|
-
React.createElement(Select, { label: getRoleLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), placeholder: "V\u00E4lj en roll", alternatives: roleAlternatives, value: roleAlternatives.find(alt => alt.value === pepContext.state.role), onChange: event => {
|
|
93
|
-
pepContext.setState({ role: event.value });
|
|
94
|
-
resetRoleFields();
|
|
95
|
-
}, validators: [RequiredValidator("Du måste välja roll")] }),
|
|
96
|
-
pepContext.state.role && pepContext.state.role === Role.AMBASSADOR ? (React.createElement(CountrySelect, { label: getAmbassadorLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), onChange: event => pepContext.setState({
|
|
97
|
-
ambassadorCountry: event.value
|
|
98
|
-
? event.value.toString()
|
|
99
|
-
: undefined
|
|
100
|
-
}), value: pepContext.state.ambassadorCountry, validators: [RequiredValidator("Du måste välja land")] })) : null,
|
|
101
|
-
pepContext.state.role &&
|
|
102
|
-
pepContext.state.role === Role.GOVERNMENT_COMPANY ? (React.createElement(React.Fragment, null,
|
|
103
|
-
React.createElement(TextInput, { label: getGovernmentCompanyNameLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), value: pepContext.state.governmentCompany || "", onChange:
|
|
104
|
-
pepContext.setState({ governmentCompany:
|
|
105
|
-
}, validators: [RequiredValidator("Du måste ange ett namn")] }),
|
|
106
|
-
React.createElement(TextInput, { label: getGovernmentCompanyRoleLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), value: pepContext.state.governmentCompanyRole || "", onChange:
|
|
107
|
-
pepContext.setState({
|
|
108
|
-
governmentCompanyRole:
|
|
109
|
-
});
|
|
110
|
-
}, validators: [RequiredValidator("Du måste ange roll")] }))) : null,
|
|
111
|
-
pepContext.state.role &&
|
|
112
|
-
pepContext.state.role ===
|
|
113
|
-
Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP ? (React.createElement(React.Fragment, null,
|
|
114
|
-
React.createElement(TextInput, { label: getHighRankingPositionIntCorpNameLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), value: pepContext.state.internationalOrganisation || "", onChange:
|
|
115
|
-
pepContext.setState({ internationalOrganisation:
|
|
116
|
-
}, validators: [RequiredValidator("Du måste ange ett namn")] }),
|
|
117
|
-
React.createElement(TextInput, { label: getHighRankingPositionIntCorpRoleLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), value: pepContext.state.internationalOrganisationRole || "", onChange:
|
|
118
|
-
pepContext.setState({
|
|
119
|
-
internationalOrganisationRole:
|
|
120
|
-
});
|
|
121
|
-
}, validators: [RequiredValidator("Du måste ange roll")] }))) : null,
|
|
122
|
-
pepContext.state.role &&
|
|
123
|
-
pepContext.state.role === Role.MILITARY_OFFICER ? (React.createElement(Select, { label: getMilitaryRankLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), placeholder: "V\u00E4lj grad", alternatives: militaryAlternatives, value: militaryAlternatives.find(alt => alt.value === pepContext.state.militaryRank), onChange: event => {
|
|
124
|
-
pepContext.setState({ militaryRank: event.value });
|
|
125
|
-
}, validators: [RequiredValidator("Du måste ange en grad")] })) : null,
|
|
126
|
-
React.createElement(PrimaryButton, { type: "submit" }, "N\u00E4sta")));
|
|
127
|
-
};
|
|
1
|
+
import React, { useRef, useCallback, useContext, } from "react";
|
|
2
|
+
import { Form, PrimaryButton, RequiredValidator, TextInput, Select, } from "@lysaab/ui-2";
|
|
3
|
+
import { PepContext, Role, MilitaryRank, EntityType, PepType, } from "./PepContext";
|
|
4
|
+
import { CountrySelect } from "../components/CountrySelect";
|
|
5
|
+
import { getGovernmentCompanyNameLabel, getGovernmentCompanyRoleLabel, getHighRankingPositionIntCorpNameLabel, getHighRankingPositionIntCorpRoleLabel, getMilitaryRankLabel, getRoleLabel, getAmbassadorLabel, } from "../model/PepTexts";
|
|
6
|
+
export const roleAlternatives = [
|
|
7
|
+
{ text: "Stats eller regeringschef", value: Role.HEAD_OF_GOVERNMENT },
|
|
8
|
+
{ text: "Minister eller Vice/Biträdande minister", value: Role.MINISTER },
|
|
9
|
+
{ text: "Ledamot i parlament eller riksdag", value: Role.PARLIMENT_MEMBER },
|
|
10
|
+
{
|
|
11
|
+
text: "Ledamot i centralbanks styrande organ",
|
|
12
|
+
value: Role.CENTRAL_BANK_MEMBER,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
text: "Ledamot för styrelsen i politiskt parti representerade i riksdagen",
|
|
16
|
+
value: Role.BOARD_MEMBER_POLITICAL_PARTY,
|
|
17
|
+
},
|
|
18
|
+
{ text: "Domare i högsta domstolen", value: Role.JUDGE_SUPREME_COURT },
|
|
19
|
+
{
|
|
20
|
+
text: "Domare i konstitutionell domstol eller annat rättsligt organ på hög nivå vars beslut endast undantagsvis kan överklagas",
|
|
21
|
+
value: Role.JUDGE_OTHER_HIGH_COURT,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
text: "Högre tjänsteman vid revisionsmyndighet",
|
|
25
|
+
value: Role.REVISION_INSTITUTE,
|
|
26
|
+
},
|
|
27
|
+
{ text: "Ambassadör eller bestickningschef", value: Role.AMBASSADOR },
|
|
28
|
+
{ text: "Högre officer i försvarsmakt", value: Role.MILITARY_OFFICER },
|
|
29
|
+
{
|
|
30
|
+
text: "Person som ingår i statsägt företags förvaltnings-, lednings eller kontrollorgan",
|
|
31
|
+
value: Role.GOVERNMENT_COMPANY,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
text: "EU-parlamentariker",
|
|
35
|
+
value: Role.EU_HIGH_RANKING_POSITION,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
text: "Befattning på hög nivå i en internationell organisation",
|
|
39
|
+
value: Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
export const militaryAlternatives = [
|
|
43
|
+
{
|
|
44
|
+
text: "General",
|
|
45
|
+
value: MilitaryRank.GENERAL,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
text: "Generallöjtnant",
|
|
49
|
+
value: MilitaryRank.LIEUTENANT_GENERAL,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
text: "Generalmajor",
|
|
53
|
+
value: MilitaryRank.MAJOR_GENERAL,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
text: "Amiral",
|
|
57
|
+
value: MilitaryRank.ADMIRAL,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
text: "Viceamiral",
|
|
61
|
+
value: MilitaryRank.VICE_ADMIRAL,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
text: "Konteramiral",
|
|
65
|
+
value: MilitaryRank.REAR_ADMIRAL,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
export const PepRolePage = ({ next }) => {
|
|
69
|
+
const pepContext = useContext(PepContext);
|
|
70
|
+
const formRef = useRef();
|
|
71
|
+
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
72
|
+
const type = pepContext.state.type;
|
|
73
|
+
const nextPage = useCallback(() => {
|
|
74
|
+
if (formRef.current && formRef.current.isValid) {
|
|
75
|
+
next();
|
|
76
|
+
}
|
|
77
|
+
}, [formRef, next]);
|
|
78
|
+
const resetRoleFields = useCallback(() => {
|
|
79
|
+
pepContext.setState({
|
|
80
|
+
ambassadorCountry: undefined,
|
|
81
|
+
governmentCompany: undefined,
|
|
82
|
+
governmentCompanyRole: undefined,
|
|
83
|
+
internationalOrganisation: undefined,
|
|
84
|
+
internationalOrganisationRole: undefined,
|
|
85
|
+
militaryRank: undefined,
|
|
86
|
+
});
|
|
87
|
+
}, [pepContext]);
|
|
88
|
+
if (!type || type === PepType.NOT_PEP) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return (React.createElement(Form, { onSubmit: () => nextPage(), lysaFormRef: formRef },
|
|
92
|
+
React.createElement(Select, { label: getRoleLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), placeholder: "V\u00E4lj en roll", alternatives: roleAlternatives, value: roleAlternatives.find(alt => alt.value === pepContext.state.role), onChange: event => {
|
|
93
|
+
pepContext.setState({ role: event.value });
|
|
94
|
+
resetRoleFields();
|
|
95
|
+
}, validators: [RequiredValidator("Du måste välja roll")] }),
|
|
96
|
+
pepContext.state.role && pepContext.state.role === Role.AMBASSADOR ? (React.createElement(CountrySelect, { label: getAmbassadorLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), onChange: event => pepContext.setState({
|
|
97
|
+
ambassadorCountry: event.value
|
|
98
|
+
? event.value.toString()
|
|
99
|
+
: undefined,
|
|
100
|
+
}), value: pepContext.state.ambassadorCountry, validators: [RequiredValidator("Du måste välja land")] })) : null,
|
|
101
|
+
pepContext.state.role &&
|
|
102
|
+
pepContext.state.role === Role.GOVERNMENT_COMPANY ? (React.createElement(React.Fragment, null,
|
|
103
|
+
React.createElement(TextInput, { label: getGovernmentCompanyNameLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), value: pepContext.state.governmentCompany || "", onChange: value => {
|
|
104
|
+
pepContext.setState({ governmentCompany: value });
|
|
105
|
+
}, validators: [RequiredValidator("Du måste ange ett namn")] }),
|
|
106
|
+
React.createElement(TextInput, { label: getGovernmentCompanyRoleLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), value: pepContext.state.governmentCompanyRole || "", onChange: value => {
|
|
107
|
+
pepContext.setState({
|
|
108
|
+
governmentCompanyRole: value,
|
|
109
|
+
});
|
|
110
|
+
}, validators: [RequiredValidator("Du måste ange roll")] }))) : null,
|
|
111
|
+
pepContext.state.role &&
|
|
112
|
+
pepContext.state.role ===
|
|
113
|
+
Role.HIGH_RANKING_POSITION_INTERNALTIONAL_CORP ? (React.createElement(React.Fragment, null,
|
|
114
|
+
React.createElement(TextInput, { label: getHighRankingPositionIntCorpNameLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), value: pepContext.state.internationalOrganisation || "", onChange: value => {
|
|
115
|
+
pepContext.setState({ internationalOrganisation: value });
|
|
116
|
+
}, validators: [RequiredValidator("Du måste ange ett namn")] }),
|
|
117
|
+
React.createElement(TextInput, { label: getHighRankingPositionIntCorpRoleLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), value: pepContext.state.internationalOrganisationRole || "", onChange: value => {
|
|
118
|
+
pepContext.setState({
|
|
119
|
+
internationalOrganisationRole: value,
|
|
120
|
+
});
|
|
121
|
+
}, validators: [RequiredValidator("Du måste ange roll")] }))) : null,
|
|
122
|
+
pepContext.state.role &&
|
|
123
|
+
pepContext.state.role === Role.MILITARY_OFFICER ? (React.createElement(Select, { label: getMilitaryRankLabel(entityType, type, pepContext.state.relationToPEP, pepContext.state.businessRelation, pepContext.state.ownerName), placeholder: "V\u00E4lj grad", alternatives: militaryAlternatives, value: militaryAlternatives.find(alt => alt.value === pepContext.state.militaryRank), onChange: event => {
|
|
124
|
+
pepContext.setState({ militaryRank: event.value });
|
|
125
|
+
}, validators: [RequiredValidator("Du måste ange en grad")] })) : null,
|
|
126
|
+
React.createElement(PrimaryButton, { type: "submit" }, "N\u00E4sta")));
|
|
127
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionComponent } from "react";
|
|
2
|
-
interface Props {
|
|
3
|
-
next: () => void;
|
|
4
|
-
}
|
|
5
|
-
export declare const PepStatusPage: FunctionComponent<Props>;
|
|
6
|
-
export {};
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
next: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const PepStatusPage: FunctionComponent<Props>;
|
|
6
|
+
export {};
|
|
@@ -1,57 +1,51 @@
|
|
|
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
|
-
const stateAlternatives = [
|
|
6
|
-
{
|
|
7
|
-
text: "Pågående",
|
|
8
|
-
value: PepStatus.ONGOING
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
text: "Avslutad",
|
|
12
|
-
value: PepStatus.ENDED
|
|
13
|
-
}
|
|
14
|
-
];
|
|
15
|
-
const isSwedenAlternatives = [
|
|
16
|
-
{ text: "Sverige", value: "sweden" },
|
|
17
|
-
{ text: "Annat", value: "other" }
|
|
18
|
-
];
|
|
19
|
-
export const PepStatusPage = ({ next }) => {
|
|
20
|
-
const pepContext = useContext(PepContext);
|
|
21
|
-
const formRef = useRef();
|
|
22
|
-
const nextPage = useCallback(() => {
|
|
23
|
-
if (formRef.current && formRef.current.isValid) {
|
|
24
|
-
next();
|
|
25
|
-
}
|
|
26
|
-
}, [formRef, next]);
|
|
27
|
-
const updateIsSweden = useCallback((
|
|
28
|
-
pepContext.setState({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
pepContext.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
pepContext.state.isOngoing &&
|
|
53
|
-
pepContext.state.isOngoing === PepStatus.ENDED ? (React.createElement(Datepicker, { label: "N\u00E4r avslutades uppdraget?", selected: pepContext.state.ended, onChange: event => pepContext.setState({ ended: event || undefined }), validators: [RequiredValidator("Du måste ange fördelsedag")], showMonthYearPicker: true, dateFormat: "yyyy-MM", maxDate: new Date() })) : null,
|
|
54
|
-
React.createElement(RadioGroup, { alternatives: isSwedenAlternatives, header: "I vilket land \u00E4r befattningen", onChange: updateIsSweden, value: isSwedenAlternatives.find(alt => alt.value === pepContext.state.isSweden), validators: [RequiredValidator("Du måste välja ett alternativ")] }),
|
|
55
|
-
pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (React.createElement(CountrySelect, { label: "V\u00E4lj i vilket land befattningen \u00E4r", onChange: event => pepContext.setState({ country: event.value ? event.value.toString() : undefined }), validators: [RequiredValidator("Du måste välja land")], value: pepContext.state.country, removeSweden: true })) : null,
|
|
56
|
-
React.createElement(PrimaryButton, { type: "submit" }, "N\u00E4sta"))));
|
|
57
|
-
};
|
|
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
|
+
const stateAlternatives = [
|
|
6
|
+
{
|
|
7
|
+
text: "Pågående",
|
|
8
|
+
value: PepStatus.ONGOING,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
text: "Avslutad",
|
|
12
|
+
value: PepStatus.ENDED,
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
const isSwedenAlternatives = [
|
|
16
|
+
{ text: "Sverige", value: "sweden" },
|
|
17
|
+
{ text: "Annat", value: "other" },
|
|
18
|
+
];
|
|
19
|
+
export const PepStatusPage = ({ next }) => {
|
|
20
|
+
const pepContext = useContext(PepContext);
|
|
21
|
+
const formRef = useRef();
|
|
22
|
+
const nextPage = useCallback(() => {
|
|
23
|
+
if (formRef.current && formRef.current.isValid) {
|
|
24
|
+
next();
|
|
25
|
+
}
|
|
26
|
+
}, [formRef, next]);
|
|
27
|
+
const updateIsSweden = useCallback((alternative) => {
|
|
28
|
+
pepContext.setState({ isSweden: alternative.value });
|
|
29
|
+
if (alternative.value === "other") {
|
|
30
|
+
pepContext.setState({ country: undefined });
|
|
31
|
+
}
|
|
32
|
+
}, [pepContext]);
|
|
33
|
+
const updateIsOngoing = useCallback((alternative) => {
|
|
34
|
+
pepContext.setState({ isOngoing: alternative.value });
|
|
35
|
+
if (alternative.value === PepStatus.ONGOING) {
|
|
36
|
+
pepContext.setState({ ended: undefined });
|
|
37
|
+
}
|
|
38
|
+
}, [pepContext]);
|
|
39
|
+
return (React.createElement("div", null,
|
|
40
|
+
React.createElement(Form, { lysaFormRef: formRef, onSubmit: () => {
|
|
41
|
+
nextPage();
|
|
42
|
+
} },
|
|
43
|
+
React.createElement(RadioGroup, { alternatives: stateAlternatives, header: "\u00C4r befattningen p\u00E5g\u00E5ende eller avslutad?", onChange: updateIsOngoing, value: stateAlternatives.find(alt => alt.value === pepContext.state.isOngoing), validators: [RequiredValidator("Du måste välja ett alternativ")] }),
|
|
44
|
+
pepContext.state.isOngoing &&
|
|
45
|
+
pepContext.state.isOngoing === PepStatus.ENDED ? (React.createElement(Datepicker, { label: "N\u00E4r avslutades uppdraget?", selected: pepContext.state.ended, onChange: event => pepContext.setState({ ended: event || undefined }), validators: [RequiredValidator("Du måste ange fördelsedag")], showMonthYearPicker: true, dateFormat: "yyyy-MM", maxDate: new Date() })) : null,
|
|
46
|
+
React.createElement(RadioGroup, { alternatives: isSwedenAlternatives, header: "I vilket land \u00E4r befattningen", onChange: updateIsSweden, value: isSwedenAlternatives.find(alt => alt.value === pepContext.state.isSweden), validators: [RequiredValidator("Du måste välja ett alternativ")] }),
|
|
47
|
+
pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (React.createElement(CountrySelect, { label: "V\u00E4lj i vilket land befattningen \u00E4r", onChange: event => pepContext.setState({
|
|
48
|
+
country: event.value ? event.value.toString() : undefined,
|
|
49
|
+
}), validators: [RequiredValidator("Du måste välja land")], value: pepContext.state.country, removeSweden: true })) : null,
|
|
50
|
+
React.createElement(PrimaryButton, { type: "submit" }, "N\u00E4sta"))));
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lysaab/lysa-pep",
|
|
3
3
|
"author": "Lysa AB",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.2",
|
|
5
5
|
"main": "./lib/Exports.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@lysaab/ui-2": "^8.7.0",
|
|
8
7
|
"@types/luxon": "^1.15.2",
|
|
9
8
|
"luxon": "^1.21.1"
|
|
10
9
|
},
|
|
11
10
|
"devDependencies": {
|
|
12
|
-
"@lysaab/ui-2": "^8.7.0",
|
|
13
11
|
"@types/jest": "24.0.20",
|
|
14
12
|
"@types/luxon": "^1.15.2",
|
|
15
13
|
"@types/node": "12.11.7",
|
|
@@ -22,6 +20,9 @@
|
|
|
22
20
|
"react-scripts": "3.2.0",
|
|
23
21
|
"typescript": "^3.7.2"
|
|
24
22
|
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@lysaab/ui-2": "^16.3.2"
|
|
25
|
+
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"start": "react-scripts start",
|
|
27
28
|
"build": "react-scripts build",
|
|
@@ -16,7 +16,7 @@ export interface Country {
|
|
|
16
16
|
|
|
17
17
|
interface Props extends ValidationProps {
|
|
18
18
|
value?: string;
|
|
19
|
-
onChange?(value: Alternative): void;
|
|
19
|
+
onChange?(value: Alternative<string>): void;
|
|
20
20
|
label: string;
|
|
21
21
|
removeSweden?: boolean;
|
|
22
22
|
}
|
|
@@ -29,11 +29,7 @@ export const CountrySelect: FunctionComponent<Props> = ({
|
|
|
29
29
|
const [countryAlternatives] = useState(
|
|
30
30
|
countries
|
|
31
31
|
.filter(country => !(removeSweden && country.value === "SE"))
|
|
32
|
-
.map(
|
|
33
|
-
(country): Alternative => {
|
|
34
|
-
return { text: country.label, value: country.value };
|
|
35
|
-
}
|
|
36
|
-
)
|
|
32
|
+
.map(country => ({ text: country.label, value: country.value }))
|
|
37
33
|
);
|
|
38
34
|
|
|
39
35
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
.static-input {
|
|
2
|
-
margin-bottom: 8px;
|
|
3
|
-
|
|
4
|
-
.label {
|
|
5
|
-
font-weight: bold;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
.static-input {
|
|
2
|
+
margin-bottom: 8px;
|
|
3
|
+
|
|
4
|
+
.label {
|
|
5
|
+
font-weight: bold;
|
|
6
|
+
}
|
|
7
|
+
}
|