@lysaab/lysa-pep 1.0.1-0 → 1.0.2-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/pages/IsPep/IsPepMessages.js +18 -26
- package/lib/pages/IsPep/IsPepPage.js +34 -14
- package/lib/pages/RelationPage/RelationMessages.js +40 -39
- package/lib/pages/RelationPage/RelationPage.js +54 -43
- package/lib/pages/RolePage/RoleMessages.js +61 -57
- package/lib/pages/RolePage/RolePage.js +74 -68
- package/lib/pages/StatusPage/StatusMessages.js +196 -4
- package/lib/pages/StatusPage/StatusPage.js +39 -19
- package/lib/utils/Possession.d.ts +1 -0
- package/lib/utils/Possession.js +18 -0
- package/package.json +2 -2
- package/src/demo/Pep.tsx +22 -22
- package/src/pages/IsPep/IsPepMessages.ts +35 -43
- package/src/pages/IsPep/IsPepPage.tsx +37 -17
- package/src/pages/RelationPage/RelationMessages.ts +40 -39
- package/src/pages/RelationPage/RelationPage.tsx +76 -46
- package/src/pages/RolePage/RoleMessages.ts +61 -57
- package/src/pages/RolePage/RolePage.tsx +90 -76
- package/src/pages/StatusPage/StatusMessages.ts +196 -4
- package/src/pages/StatusPage/StatusPage.tsx +59 -24
- package/src/utils/Possession.ts +21 -0
|
@@ -2,7 +2,7 @@ import React, {
|
|
|
2
2
|
FunctionComponent,
|
|
3
3
|
useRef,
|
|
4
4
|
useCallback,
|
|
5
|
-
useContext
|
|
5
|
+
useContext,
|
|
6
6
|
} from "react";
|
|
7
7
|
import {
|
|
8
8
|
Form,
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
RequiredValidator,
|
|
11
11
|
PrimaryButton,
|
|
12
12
|
LysaFormRef,
|
|
13
|
-
Datepicker
|
|
13
|
+
Datepicker,
|
|
14
14
|
} from "@lysaab/ui-2";
|
|
15
15
|
import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
|
|
16
|
-
import { PepContext, PepStatus } from "../PepContext";
|
|
16
|
+
import { PepContext, PepStatus, EntityType, PepType } from "../PepContext";
|
|
17
17
|
import { CountrySelect } from "../../components/CountrySelect";
|
|
18
18
|
import { useIntl, FormattedMessage, IntlShape } from "react-intl";
|
|
19
19
|
import {
|
|
@@ -22,8 +22,9 @@ import {
|
|
|
22
22
|
isLocalCountryMessages,
|
|
23
23
|
countrySelectionMessages,
|
|
24
24
|
localCountryAltMessages,
|
|
25
|
-
stateAltMessages
|
|
25
|
+
stateAltMessages,
|
|
26
26
|
} from "./StatusMessages";
|
|
27
|
+
import { formatPossessive } from "../../utils/Possession";
|
|
27
28
|
|
|
28
29
|
interface Props {
|
|
29
30
|
next: () => void;
|
|
@@ -35,6 +36,7 @@ export const StatusPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
35
36
|
const intl = useIntl();
|
|
36
37
|
const stateAlternatives = getStateAlternatives(intl);
|
|
37
38
|
const isSwedenAlternatives = getIsLocalCountryAlternatives(intl);
|
|
39
|
+
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
38
40
|
|
|
39
41
|
const nextPage = useCallback(() => {
|
|
40
42
|
if (formRef.current && formRef.current.isValid) {
|
|
@@ -74,13 +76,27 @@ export const StatusPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
74
76
|
>
|
|
75
77
|
<RadioGroup
|
|
76
78
|
alternatives={stateAlternatives}
|
|
77
|
-
header={intl.formatMessage(isOngoingMessages.header
|
|
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
|
+
})}
|
|
78
92
|
onChange={updateIsOngoing}
|
|
79
93
|
value={stateAlternatives.find(
|
|
80
|
-
alt => alt.value === pepContext.state.isOngoing
|
|
94
|
+
(alt) => alt.value === pepContext.state.isOngoing
|
|
81
95
|
)}
|
|
82
96
|
validators={[
|
|
83
|
-
RequiredValidator(
|
|
97
|
+
new RequiredValidator(
|
|
98
|
+
intl.formatMessage(isOngoingMessages.required)
|
|
99
|
+
),
|
|
84
100
|
]}
|
|
85
101
|
/>
|
|
86
102
|
|
|
@@ -89,11 +105,13 @@ export const StatusPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
89
105
|
<Datepicker
|
|
90
106
|
label={intl.formatMessage(endedMessages.header)}
|
|
91
107
|
selected={pepContext.state.ended}
|
|
92
|
-
onChange={event =>
|
|
108
|
+
onChange={(event) =>
|
|
93
109
|
pepContext.setState({ ended: event || undefined })
|
|
94
110
|
}
|
|
95
111
|
validators={[
|
|
96
|
-
RequiredValidator(
|
|
112
|
+
new RequiredValidator(
|
|
113
|
+
intl.formatMessage(isOngoingMessages.required)
|
|
114
|
+
),
|
|
97
115
|
]}
|
|
98
116
|
showMonthYearPicker
|
|
99
117
|
dateFormat="yyyy-MM"
|
|
@@ -103,30 +121,47 @@ export const StatusPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
103
121
|
|
|
104
122
|
<RadioGroup
|
|
105
123
|
alternatives={isSwedenAlternatives}
|
|
106
|
-
header={intl.formatMessage(isLocalCountryMessages.header
|
|
124
|
+
header={intl.formatMessage(isLocalCountryMessages.header, {
|
|
125
|
+
possessiveName: formatPossessive(
|
|
126
|
+
pepContext.state.ownerName,
|
|
127
|
+
intl.locale
|
|
128
|
+
),
|
|
129
|
+
})}
|
|
107
130
|
onChange={updateIsSweden}
|
|
108
131
|
value={isSwedenAlternatives.find(
|
|
109
|
-
alt => alt.value === pepContext.state.isSweden
|
|
132
|
+
(alt) => alt.value === pepContext.state.isSweden
|
|
110
133
|
)}
|
|
111
134
|
validators={[
|
|
112
|
-
RequiredValidator(
|
|
135
|
+
new RequiredValidator(
|
|
113
136
|
intl.formatMessage(isLocalCountryMessages.required)
|
|
114
|
-
)
|
|
137
|
+
),
|
|
115
138
|
]}
|
|
116
139
|
/>
|
|
117
140
|
|
|
118
141
|
{pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (
|
|
119
142
|
<CountrySelect
|
|
120
|
-
label={intl.formatMessage(countrySelectionMessages.header
|
|
121
|
-
|
|
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) =>
|
|
122
157
|
pepContext.setState({
|
|
123
|
-
country: event.value ? event.value.toString() : undefined
|
|
158
|
+
country: event.value ? event.value.toString() : undefined,
|
|
124
159
|
})
|
|
125
160
|
}
|
|
126
161
|
validators={[
|
|
127
|
-
RequiredValidator(
|
|
162
|
+
new RequiredValidator(
|
|
128
163
|
intl.formatMessage(countrySelectionMessages.required)
|
|
129
|
-
)
|
|
164
|
+
),
|
|
130
165
|
]}
|
|
131
166
|
value={pepContext.state.country}
|
|
132
167
|
omitCountries={["SE"]}
|
|
@@ -149,12 +184,12 @@ function getIsLocalCountryAlternatives(intl: IntlShape): Alternative<string>[] {
|
|
|
149
184
|
return [
|
|
150
185
|
{
|
|
151
186
|
text: intl.formatMessage(localCountryAltMessages.localCountry),
|
|
152
|
-
value: "sweden"
|
|
187
|
+
value: "sweden",
|
|
153
188
|
},
|
|
154
189
|
{
|
|
155
190
|
text: intl.formatMessage(localCountryAltMessages.otherCountry),
|
|
156
|
-
value: "other"
|
|
157
|
-
}
|
|
191
|
+
value: "other",
|
|
192
|
+
},
|
|
158
193
|
];
|
|
159
194
|
}
|
|
160
195
|
|
|
@@ -162,11 +197,11 @@ function getStateAlternatives(intl: IntlShape): Alternative<PepStatus>[] {
|
|
|
162
197
|
return [
|
|
163
198
|
{
|
|
164
199
|
text: intl.formatMessage(stateAltMessages[PepStatus.ONGOING]),
|
|
165
|
-
value: PepStatus.ONGOING
|
|
200
|
+
value: PepStatus.ONGOING,
|
|
166
201
|
},
|
|
167
202
|
{
|
|
168
203
|
text: intl.formatMessage(stateAltMessages[PepStatus.ENDED]),
|
|
169
|
-
value: PepStatus.ENDED
|
|
170
|
-
}
|
|
204
|
+
value: PepStatus.ENDED,
|
|
205
|
+
},
|
|
171
206
|
];
|
|
172
207
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function formatPossessive(text: string | undefined, locale: string) {
|
|
2
|
+
if (!text) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
const language = locale.substr(0, 2);
|
|
6
|
+
if (language === "sv") {
|
|
7
|
+
return formatSwedish(text);
|
|
8
|
+
}
|
|
9
|
+
return text;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function formatSwedish(text: string) {
|
|
13
|
+
if (
|
|
14
|
+
text[text.length - 1] !== "s" &&
|
|
15
|
+
text[text.length - 1] !== "z" &&
|
|
16
|
+
text[text.length - 1] !== "x"
|
|
17
|
+
) {
|
|
18
|
+
text += "s";
|
|
19
|
+
}
|
|
20
|
+
return text;
|
|
21
|
+
}
|