@lysaab/lysa-pep 1.0.2-0 → 1.0.3-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 +7 -7
- package/lib/Exports.js +7 -7
- package/lib/components/CountrySelect.d.ts +15 -15
- package/lib/components/CountrySelect.js +30 -30
- package/lib/components/PepAnswers.d.ts +8 -8
- package/lib/components/PepAnswers.js +131 -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/IsPep/IsPepMessages.d.ts +32 -32
- package/lib/pages/IsPep/IsPepMessages.js +66 -66
- package/lib/pages/IsPep/IsPepPage.d.ts +14 -14
- package/lib/pages/IsPep/IsPepPage.js +59 -59
- 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/lib/pages/RelationPage/RelationMessages.d.ts +105 -105
- package/lib/pages/RelationPage/RelationMessages.js +283 -283
- package/lib/pages/RelationPage/RelationPage.d.ts +6 -6
- package/lib/pages/RelationPage/RelationPage.js +153 -153
- package/lib/pages/RolePage/RoleMessages.d.ts +185 -185
- package/lib/pages/RolePage/RoleMessages.js +385 -385
- package/lib/pages/RolePage/RolePage.d.ts +11 -11
- package/lib/pages/RolePage/RolePage.js +220 -220
- package/lib/pages/StatusPage/StatusMessages.d.ts +72 -72
- package/lib/pages/StatusPage/StatusMessages.js +266 -266
- package/lib/pages/StatusPage/StatusPage.d.ts +6 -6
- package/lib/pages/StatusPage/StatusPage.js +95 -95
- package/lib/utils/Possession.d.ts +1 -1
- package/lib/utils/Possession.js +18 -18
- package/package.json +57 -57
- package/src/Exports.ts +12 -12
- package/src/components/CountrySelect.tsx +47 -47
- package/src/components/PepAnswers.scss +7 -7
- package/src/components/PepAnswers.tsx +252 -252
- package/src/demo/Done.tsx +16 -16
- package/src/demo/Pep.tsx +112 -112
- package/src/model/PepModel.ts +52 -52
- package/src/pages/IsPep/IsPepMessages.ts +67 -67
- package/src/pages/IsPep/IsPepPage.tsx +115 -114
- package/src/pages/PepContext.tsx +144 -144
- package/src/pages/RelationPage/RelationMessages.ts +288 -288
- package/src/pages/RelationPage/RelationPage.tsx +299 -299
- package/src/pages/RolePage/RoleMessages.ts +393 -393
- package/src/pages/RolePage/RolePage.tsx +356 -356
- package/src/pages/StatusPage/StatusMessages.ts +272 -272
- package/src/pages/StatusPage/StatusPage.tsx +207 -207
- package/.vscode/settings.json +0 -4
|
@@ -1,207 +1,207 @@
|
|
|
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, EntityType, PepType } 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
|
-
import { formatPossessive } from "../../utils/Possession";
|
|
28
|
-
|
|
29
|
-
interface Props {
|
|
30
|
-
next: () => void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const StatusPage: FunctionComponent<Props> = ({ next }) => {
|
|
34
|
-
const pepContext = useContext(PepContext);
|
|
35
|
-
const formRef = useRef<LysaFormRef>();
|
|
36
|
-
const intl = useIntl();
|
|
37
|
-
const stateAlternatives = getStateAlternatives(intl);
|
|
38
|
-
const isSwedenAlternatives = getIsLocalCountryAlternatives(intl);
|
|
39
|
-
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
40
|
-
|
|
41
|
-
const nextPage = useCallback(() => {
|
|
42
|
-
if (formRef.current && formRef.current.isValid) {
|
|
43
|
-
next();
|
|
44
|
-
}
|
|
45
|
-
}, [formRef, next]);
|
|
46
|
-
|
|
47
|
-
const updateIsSweden = useCallback(
|
|
48
|
-
(alternative: Alternative<string>) => {
|
|
49
|
-
pepContext.setState({ isSweden: alternative.value });
|
|
50
|
-
|
|
51
|
-
if (alternative.value === "other") {
|
|
52
|
-
pepContext.setState({ country: undefined });
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
[pepContext]
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const updateIsOngoing = useCallback(
|
|
59
|
-
(alternative: Alternative<PepStatus>) => {
|
|
60
|
-
pepContext.setState({ isOngoing: alternative.value });
|
|
61
|
-
|
|
62
|
-
if (alternative.value === PepStatus.ONGOING) {
|
|
63
|
-
pepContext.setState({ ended: undefined });
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
[pepContext]
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<div>
|
|
71
|
-
<Form
|
|
72
|
-
lysaFormRef={formRef}
|
|
73
|
-
onSubmit={() => {
|
|
74
|
-
nextPage();
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<RadioGroup
|
|
78
|
-
alternatives={stateAlternatives}
|
|
79
|
-
header={intl.formatMessage(isOngoingMessages.header, {
|
|
80
|
-
entityType,
|
|
81
|
-
name: pepContext.state.ownerName,
|
|
82
|
-
possessiveName: formatPossessive(
|
|
83
|
-
pepContext.state.ownerName,
|
|
84
|
-
intl.locale
|
|
85
|
-
),
|
|
86
|
-
relation:
|
|
87
|
-
pepContext.state.type === PepType.COLLEAGUE
|
|
88
|
-
? pepContext.state.businessRelation
|
|
89
|
-
: pepContext.state.relationToPEP,
|
|
90
|
-
pepType: pepContext.state.type,
|
|
91
|
-
})}
|
|
92
|
-
onChange={updateIsOngoing}
|
|
93
|
-
value={stateAlternatives.find(
|
|
94
|
-
(alt) => alt.value === pepContext.state.isOngoing
|
|
95
|
-
)}
|
|
96
|
-
validators={[
|
|
97
|
-
new RequiredValidator(
|
|
98
|
-
intl.formatMessage(isOngoingMessages.required)
|
|
99
|
-
),
|
|
100
|
-
]}
|
|
101
|
-
/>
|
|
102
|
-
|
|
103
|
-
{pepContext.state.isOngoing &&
|
|
104
|
-
pepContext.state.isOngoing === PepStatus.ENDED ? (
|
|
105
|
-
<Datepicker
|
|
106
|
-
label={intl.formatMessage(endedMessages.header)}
|
|
107
|
-
selected={pepContext.state.ended}
|
|
108
|
-
onChange={(event) =>
|
|
109
|
-
pepContext.setState({ ended: event || undefined })
|
|
110
|
-
}
|
|
111
|
-
validators={[
|
|
112
|
-
new RequiredValidator(
|
|
113
|
-
intl.formatMessage(isOngoingMessages.required)
|
|
114
|
-
),
|
|
115
|
-
]}
|
|
116
|
-
showMonthYearPicker
|
|
117
|
-
dateFormat="yyyy-MM"
|
|
118
|
-
maxDate={new Date()}
|
|
119
|
-
/>
|
|
120
|
-
) : null}
|
|
121
|
-
|
|
122
|
-
<RadioGroup
|
|
123
|
-
alternatives={isSwedenAlternatives}
|
|
124
|
-
header={intl.formatMessage(isLocalCountryMessages.header, {
|
|
125
|
-
possessiveName: formatPossessive(
|
|
126
|
-
pepContext.state.ownerName,
|
|
127
|
-
intl.locale
|
|
128
|
-
),
|
|
129
|
-
})}
|
|
130
|
-
onChange={updateIsSweden}
|
|
131
|
-
value={isSwedenAlternatives.find(
|
|
132
|
-
(alt) => alt.value === pepContext.state.isSweden
|
|
133
|
-
)}
|
|
134
|
-
validators={[
|
|
135
|
-
new RequiredValidator(
|
|
136
|
-
intl.formatMessage(isLocalCountryMessages.required)
|
|
137
|
-
),
|
|
138
|
-
]}
|
|
139
|
-
/>
|
|
140
|
-
|
|
141
|
-
{pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (
|
|
142
|
-
<CountrySelect
|
|
143
|
-
label={intl.formatMessage(countrySelectionMessages.header, {
|
|
144
|
-
entityType,
|
|
145
|
-
name: pepContext.state.ownerName,
|
|
146
|
-
possessiveName: formatPossessive(
|
|
147
|
-
pepContext.state.ownerName,
|
|
148
|
-
intl.locale
|
|
149
|
-
),
|
|
150
|
-
relation:
|
|
151
|
-
pepContext.state.type === PepType.COLLEAGUE
|
|
152
|
-
? pepContext.state.businessRelation
|
|
153
|
-
: pepContext.state.relationToPEP,
|
|
154
|
-
pepType: pepContext.state.type,
|
|
155
|
-
})}
|
|
156
|
-
onChange={(event) =>
|
|
157
|
-
pepContext.setState({
|
|
158
|
-
country: event.value ? event.value.toString() : undefined,
|
|
159
|
-
})
|
|
160
|
-
}
|
|
161
|
-
validators={[
|
|
162
|
-
new RequiredValidator(
|
|
163
|
-
intl.formatMessage(countrySelectionMessages.required)
|
|
164
|
-
),
|
|
165
|
-
]}
|
|
166
|
-
value={pepContext.state.country}
|
|
167
|
-
omitCountries={["SE"]}
|
|
168
|
-
/>
|
|
169
|
-
) : null}
|
|
170
|
-
|
|
171
|
-
<PrimaryButton type="submit">
|
|
172
|
-
<FormattedMessage
|
|
173
|
-
id="pep.status.next"
|
|
174
|
-
description="Next button"
|
|
175
|
-
defaultMessage="Gå vidare"
|
|
176
|
-
/>
|
|
177
|
-
</PrimaryButton>
|
|
178
|
-
</Form>
|
|
179
|
-
</div>
|
|
180
|
-
);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
function getIsLocalCountryAlternatives(intl: IntlShape): Alternative<string>[] {
|
|
184
|
-
return [
|
|
185
|
-
{
|
|
186
|
-
text: intl.formatMessage(localCountryAltMessages.localCountry),
|
|
187
|
-
value: "sweden",
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
text: intl.formatMessage(localCountryAltMessages.otherCountry),
|
|
191
|
-
value: "other",
|
|
192
|
-
},
|
|
193
|
-
];
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function getStateAlternatives(intl: IntlShape): Alternative<PepStatus>[] {
|
|
197
|
-
return [
|
|
198
|
-
{
|
|
199
|
-
text: intl.formatMessage(stateAltMessages[PepStatus.ONGOING]),
|
|
200
|
-
value: PepStatus.ONGOING,
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
text: intl.formatMessage(stateAltMessages[PepStatus.ENDED]),
|
|
204
|
-
value: PepStatus.ENDED,
|
|
205
|
-
},
|
|
206
|
-
];
|
|
207
|
-
}
|
|
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, EntityType, PepType } 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
|
+
import { formatPossessive } from "../../utils/Possession";
|
|
28
|
+
|
|
29
|
+
interface Props {
|
|
30
|
+
next: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const StatusPage: FunctionComponent<Props> = ({ next }) => {
|
|
34
|
+
const pepContext = useContext(PepContext);
|
|
35
|
+
const formRef = useRef<LysaFormRef>();
|
|
36
|
+
const intl = useIntl();
|
|
37
|
+
const stateAlternatives = getStateAlternatives(intl);
|
|
38
|
+
const isSwedenAlternatives = getIsLocalCountryAlternatives(intl);
|
|
39
|
+
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
40
|
+
|
|
41
|
+
const nextPage = useCallback(() => {
|
|
42
|
+
if (formRef.current && formRef.current.isValid) {
|
|
43
|
+
next();
|
|
44
|
+
}
|
|
45
|
+
}, [formRef, next]);
|
|
46
|
+
|
|
47
|
+
const updateIsSweden = useCallback(
|
|
48
|
+
(alternative: Alternative<string>) => {
|
|
49
|
+
pepContext.setState({ isSweden: alternative.value });
|
|
50
|
+
|
|
51
|
+
if (alternative.value === "other") {
|
|
52
|
+
pepContext.setState({ country: undefined });
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
[pepContext]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const updateIsOngoing = useCallback(
|
|
59
|
+
(alternative: Alternative<PepStatus>) => {
|
|
60
|
+
pepContext.setState({ isOngoing: alternative.value });
|
|
61
|
+
|
|
62
|
+
if (alternative.value === PepStatus.ONGOING) {
|
|
63
|
+
pepContext.setState({ ended: undefined });
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
[pepContext]
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div>
|
|
71
|
+
<Form
|
|
72
|
+
lysaFormRef={formRef}
|
|
73
|
+
onSubmit={() => {
|
|
74
|
+
nextPage();
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<RadioGroup
|
|
78
|
+
alternatives={stateAlternatives}
|
|
79
|
+
header={intl.formatMessage(isOngoingMessages.header, {
|
|
80
|
+
entityType,
|
|
81
|
+
name: pepContext.state.ownerName,
|
|
82
|
+
possessiveName: formatPossessive(
|
|
83
|
+
pepContext.state.ownerName,
|
|
84
|
+
intl.locale
|
|
85
|
+
),
|
|
86
|
+
relation:
|
|
87
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
88
|
+
? pepContext.state.businessRelation
|
|
89
|
+
: pepContext.state.relationToPEP,
|
|
90
|
+
pepType: pepContext.state.type,
|
|
91
|
+
})}
|
|
92
|
+
onChange={updateIsOngoing}
|
|
93
|
+
value={stateAlternatives.find(
|
|
94
|
+
(alt) => alt.value === pepContext.state.isOngoing
|
|
95
|
+
)}
|
|
96
|
+
validators={[
|
|
97
|
+
new RequiredValidator(
|
|
98
|
+
intl.formatMessage(isOngoingMessages.required)
|
|
99
|
+
),
|
|
100
|
+
]}
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
{pepContext.state.isOngoing &&
|
|
104
|
+
pepContext.state.isOngoing === PepStatus.ENDED ? (
|
|
105
|
+
<Datepicker
|
|
106
|
+
label={intl.formatMessage(endedMessages.header)}
|
|
107
|
+
selected={pepContext.state.ended}
|
|
108
|
+
onChange={(event) =>
|
|
109
|
+
pepContext.setState({ ended: event || undefined })
|
|
110
|
+
}
|
|
111
|
+
validators={[
|
|
112
|
+
new RequiredValidator(
|
|
113
|
+
intl.formatMessage(isOngoingMessages.required)
|
|
114
|
+
),
|
|
115
|
+
]}
|
|
116
|
+
showMonthYearPicker
|
|
117
|
+
dateFormat="yyyy-MM"
|
|
118
|
+
maxDate={new Date()}
|
|
119
|
+
/>
|
|
120
|
+
) : null}
|
|
121
|
+
|
|
122
|
+
<RadioGroup
|
|
123
|
+
alternatives={isSwedenAlternatives}
|
|
124
|
+
header={intl.formatMessage(isLocalCountryMessages.header, {
|
|
125
|
+
possessiveName: formatPossessive(
|
|
126
|
+
pepContext.state.ownerName,
|
|
127
|
+
intl.locale
|
|
128
|
+
),
|
|
129
|
+
})}
|
|
130
|
+
onChange={updateIsSweden}
|
|
131
|
+
value={isSwedenAlternatives.find(
|
|
132
|
+
(alt) => alt.value === pepContext.state.isSweden
|
|
133
|
+
)}
|
|
134
|
+
validators={[
|
|
135
|
+
new RequiredValidator(
|
|
136
|
+
intl.formatMessage(isLocalCountryMessages.required)
|
|
137
|
+
),
|
|
138
|
+
]}
|
|
139
|
+
/>
|
|
140
|
+
|
|
141
|
+
{pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (
|
|
142
|
+
<CountrySelect
|
|
143
|
+
label={intl.formatMessage(countrySelectionMessages.header, {
|
|
144
|
+
entityType,
|
|
145
|
+
name: pepContext.state.ownerName,
|
|
146
|
+
possessiveName: formatPossessive(
|
|
147
|
+
pepContext.state.ownerName,
|
|
148
|
+
intl.locale
|
|
149
|
+
),
|
|
150
|
+
relation:
|
|
151
|
+
pepContext.state.type === PepType.COLLEAGUE
|
|
152
|
+
? pepContext.state.businessRelation
|
|
153
|
+
: pepContext.state.relationToPEP,
|
|
154
|
+
pepType: pepContext.state.type,
|
|
155
|
+
})}
|
|
156
|
+
onChange={(event) =>
|
|
157
|
+
pepContext.setState({
|
|
158
|
+
country: event.value ? event.value.toString() : undefined,
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
validators={[
|
|
162
|
+
new RequiredValidator(
|
|
163
|
+
intl.formatMessage(countrySelectionMessages.required)
|
|
164
|
+
),
|
|
165
|
+
]}
|
|
166
|
+
value={pepContext.state.country}
|
|
167
|
+
omitCountries={["SE"]}
|
|
168
|
+
/>
|
|
169
|
+
) : null}
|
|
170
|
+
|
|
171
|
+
<PrimaryButton type="submit">
|
|
172
|
+
<FormattedMessage
|
|
173
|
+
id="pep.status.next"
|
|
174
|
+
description="Next button"
|
|
175
|
+
defaultMessage="Gå vidare"
|
|
176
|
+
/>
|
|
177
|
+
</PrimaryButton>
|
|
178
|
+
</Form>
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
function getIsLocalCountryAlternatives(intl: IntlShape): Alternative<string>[] {
|
|
184
|
+
return [
|
|
185
|
+
{
|
|
186
|
+
text: intl.formatMessage(localCountryAltMessages.localCountry),
|
|
187
|
+
value: "sweden",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
text: intl.formatMessage(localCountryAltMessages.otherCountry),
|
|
191
|
+
value: "other",
|
|
192
|
+
},
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function getStateAlternatives(intl: IntlShape): Alternative<PepStatus>[] {
|
|
197
|
+
return [
|
|
198
|
+
{
|
|
199
|
+
text: intl.formatMessage(stateAltMessages[PepStatus.ONGOING]),
|
|
200
|
+
value: PepStatus.ONGOING,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
text: intl.formatMessage(stateAltMessages[PepStatus.ENDED]),
|
|
204
|
+
value: PepStatus.ENDED,
|
|
205
|
+
},
|
|
206
|
+
];
|
|
207
|
+
}
|
package/.vscode/settings.json
DELETED