@lysaab/lysa-pep 5.0.0 → 5.1.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/Exports.d.ts +7 -7
- package/Exports.js +7 -7
- package/README.md +44 -44
- package/components/PepAnswers.d.ts +8 -8
- package/components/PepAnswers.js +101 -103
- package/components/PepAnswers.scss +7 -7
- package/model/PepModel.d.ts +7 -7
- package/model/PepModel.js +40 -40
- package/package.json +74 -74
- package/pages/IsPep/IsPepMessages.d.ts +20 -20
- package/pages/IsPep/IsPepMessages.js +10 -10
- package/pages/IsPep/IsPepPage.d.ts +15 -15
- package/pages/IsPep/IsPepPage.js +61 -61
- package/pages/PepContext.d.ts +81 -80
- package/pages/PepContext.js +89 -88
- package/pages/RelationPage/RelationMessages.d.ts +67 -67
- package/pages/RelationPage/RelationMessages.js +69 -69
- package/pages/RelationPage/RelationPage.d.ts +6 -6
- package/pages/RelationPage/RelationPage.js +158 -158
- package/pages/RolePage/RoleMessages.d.ts +119 -119
- package/pages/RolePage/RoleMessages.js +121 -121
- package/pages/RolePage/RolePage.d.ts +13 -13
- package/pages/RolePage/RolePage.js +222 -222
- package/pages/StatusPage/StatusMessages.d.ts +51 -51
- package/pages/StatusPage/StatusMessages.js +53 -53
- package/pages/StatusPage/StatusPage.d.ts +10 -10
- package/pages/StatusPage/StatusPage.js +104 -104
- package/utils/Possession.d.ts +1 -1
- package/utils/Possession.js +27 -27
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
export declare const relationMessages: {
|
|
2
|
-
header: {
|
|
3
|
-
id: string;
|
|
4
|
-
};
|
|
5
|
-
required: {
|
|
6
|
-
id: string;
|
|
7
|
-
};
|
|
8
|
-
MARRIED_PARTNER: {
|
|
9
|
-
id: string;
|
|
10
|
-
};
|
|
11
|
-
COLIVING_PARTNER: {
|
|
12
|
-
id: string;
|
|
13
|
-
};
|
|
14
|
-
CHILD: {
|
|
15
|
-
id: string;
|
|
16
|
-
};
|
|
17
|
-
PARENT: {
|
|
18
|
-
id: string;
|
|
19
|
-
};
|
|
20
|
-
CHILD_MARRIED_PARTNER: {
|
|
21
|
-
id: string;
|
|
22
|
-
};
|
|
23
|
-
CHILD_COLIVING_PARTNER: {
|
|
24
|
-
id: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export declare const businessRelationMessages: {
|
|
28
|
-
header: {
|
|
29
|
-
id: string;
|
|
30
|
-
};
|
|
31
|
-
required: {
|
|
32
|
-
id: string;
|
|
33
|
-
};
|
|
34
|
-
CO_OWNERSHIP: {
|
|
35
|
-
id: string;
|
|
36
|
-
};
|
|
37
|
-
CLOSE_CONNECTION: {
|
|
38
|
-
id: string;
|
|
39
|
-
};
|
|
40
|
-
COMPANY_FOR_PEP: {
|
|
41
|
-
id: string;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export declare const relativeNameMessages: {
|
|
45
|
-
header: {
|
|
46
|
-
id: string;
|
|
47
|
-
};
|
|
48
|
-
required: {
|
|
49
|
-
id: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
export declare const birthdayMessages: {
|
|
53
|
-
header: {
|
|
54
|
-
id: string;
|
|
55
|
-
};
|
|
56
|
-
required: {
|
|
57
|
-
id: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export declare const colleagueNameMessages: {
|
|
61
|
-
header: {
|
|
62
|
-
id: string;
|
|
63
|
-
};
|
|
64
|
-
required: {
|
|
65
|
-
id: string;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
1
|
+
export declare const relationMessages: {
|
|
2
|
+
header: {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
required: {
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
MARRIED_PARTNER: {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
COLIVING_PARTNER: {
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
CHILD: {
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
PARENT: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
CHILD_MARRIED_PARTNER: {
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
CHILD_COLIVING_PARTNER: {
|
|
24
|
+
id: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const businessRelationMessages: {
|
|
28
|
+
header: {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
required: {
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
CO_OWNERSHIP: {
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
CLOSE_CONNECTION: {
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
COMPANY_FOR_PEP: {
|
|
41
|
+
id: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const relativeNameMessages: {
|
|
45
|
+
header: {
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
required: {
|
|
49
|
+
id: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare const birthdayMessages: {
|
|
53
|
+
header: {
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
required: {
|
|
57
|
+
id: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export declare const colleagueNameMessages: {
|
|
61
|
+
header: {
|
|
62
|
+
id: string;
|
|
63
|
+
};
|
|
64
|
+
required: {
|
|
65
|
+
id: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import { defineMessages } from "react-intl";
|
|
2
|
-
import { BusinessRelation, Relation } from "../PepContext";
|
|
3
|
-
export const relationMessages = defineMessages({
|
|
4
|
-
header: {
|
|
5
|
-
id: "pep.relation.relationship.header",
|
|
6
|
-
},
|
|
7
|
-
required: {
|
|
8
|
-
id: "pep.relation.relation.required",
|
|
9
|
-
},
|
|
10
|
-
[Relation.MARRIED_PARTNER]: {
|
|
11
|
-
id: "pep.relation.relation.MARRIED_PARTNER",
|
|
12
|
-
},
|
|
13
|
-
[Relation.COLIVING_PARTNER]: {
|
|
14
|
-
id: "pep.relation.relation.COLIVING_PARTNER",
|
|
15
|
-
},
|
|
16
|
-
[Relation.CHILD]: {
|
|
17
|
-
id: "pep.relation.relation.CHILD",
|
|
18
|
-
},
|
|
19
|
-
[Relation.PARENT]: {
|
|
20
|
-
id: "pep.relation.relation.PARENT",
|
|
21
|
-
},
|
|
22
|
-
[Relation.CHILD_MARRIED_PARTNER]: {
|
|
23
|
-
id: "pep.relation.relation.CHILD_MARRIED_PARTNER",
|
|
24
|
-
},
|
|
25
|
-
[Relation.CHILD_COLIVING_PARTNER]: {
|
|
26
|
-
id: "pep.relation.relation.CHILD_COLIVING_PARTNER",
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
export const businessRelationMessages = defineMessages({
|
|
30
|
-
header: {
|
|
31
|
-
id: "pep.relation.businessrelation.header",
|
|
32
|
-
},
|
|
33
|
-
required: {
|
|
34
|
-
id: "pep.relation.businessrelation.required",
|
|
35
|
-
},
|
|
36
|
-
[BusinessRelation.CO_OWNERSHIP]: {
|
|
37
|
-
id: "pep.relation.businessrelation.alt.CO_OWNERSHIP",
|
|
38
|
-
},
|
|
39
|
-
[BusinessRelation.CLOSE_CONNECTION]: {
|
|
40
|
-
id: "pep.relation.businessrelation.alt.CLOSE_CONNECTION",
|
|
41
|
-
},
|
|
42
|
-
[BusinessRelation.COMPANY_FOR_PEP]: {
|
|
43
|
-
id: "pep.relation.businessrelation.alt.COMPANY_FOR_PEP",
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
export const relativeNameMessages = defineMessages({
|
|
47
|
-
header: {
|
|
48
|
-
id: "pep.relation.relative.name.header",
|
|
49
|
-
},
|
|
50
|
-
required: {
|
|
51
|
-
id: "pep.relation.relative.name.required",
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
export const birthdayMessages = defineMessages({
|
|
55
|
-
header: {
|
|
56
|
-
id: "pep.relation.birthday.header",
|
|
57
|
-
},
|
|
58
|
-
required: {
|
|
59
|
-
id: "pep.relation.birthday.required",
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
export const colleagueNameMessages = defineMessages({
|
|
63
|
-
header: {
|
|
64
|
-
id: "pep.relation.colleague.name.header",
|
|
65
|
-
},
|
|
66
|
-
required: {
|
|
67
|
-
id: "pep.relation.colleague.name.required",
|
|
68
|
-
},
|
|
69
|
-
});
|
|
1
|
+
import { defineMessages } from "react-intl";
|
|
2
|
+
import { BusinessRelation, Relation } from "../PepContext";
|
|
3
|
+
export const relationMessages = defineMessages({
|
|
4
|
+
header: {
|
|
5
|
+
id: "pep.relation.relationship.header",
|
|
6
|
+
},
|
|
7
|
+
required: {
|
|
8
|
+
id: "pep.relation.relation.required",
|
|
9
|
+
},
|
|
10
|
+
[Relation.MARRIED_PARTNER]: {
|
|
11
|
+
id: "pep.relation.relation.MARRIED_PARTNER",
|
|
12
|
+
},
|
|
13
|
+
[Relation.COLIVING_PARTNER]: {
|
|
14
|
+
id: "pep.relation.relation.COLIVING_PARTNER",
|
|
15
|
+
},
|
|
16
|
+
[Relation.CHILD]: {
|
|
17
|
+
id: "pep.relation.relation.CHILD",
|
|
18
|
+
},
|
|
19
|
+
[Relation.PARENT]: {
|
|
20
|
+
id: "pep.relation.relation.PARENT",
|
|
21
|
+
},
|
|
22
|
+
[Relation.CHILD_MARRIED_PARTNER]: {
|
|
23
|
+
id: "pep.relation.relation.CHILD_MARRIED_PARTNER",
|
|
24
|
+
},
|
|
25
|
+
[Relation.CHILD_COLIVING_PARTNER]: {
|
|
26
|
+
id: "pep.relation.relation.CHILD_COLIVING_PARTNER",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export const businessRelationMessages = defineMessages({
|
|
30
|
+
header: {
|
|
31
|
+
id: "pep.relation.businessrelation.header",
|
|
32
|
+
},
|
|
33
|
+
required: {
|
|
34
|
+
id: "pep.relation.businessrelation.required",
|
|
35
|
+
},
|
|
36
|
+
[BusinessRelation.CO_OWNERSHIP]: {
|
|
37
|
+
id: "pep.relation.businessrelation.alt.CO_OWNERSHIP",
|
|
38
|
+
},
|
|
39
|
+
[BusinessRelation.CLOSE_CONNECTION]: {
|
|
40
|
+
id: "pep.relation.businessrelation.alt.CLOSE_CONNECTION",
|
|
41
|
+
},
|
|
42
|
+
[BusinessRelation.COMPANY_FOR_PEP]: {
|
|
43
|
+
id: "pep.relation.businessrelation.alt.COMPANY_FOR_PEP",
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
export const relativeNameMessages = defineMessages({
|
|
47
|
+
header: {
|
|
48
|
+
id: "pep.relation.relative.name.header",
|
|
49
|
+
},
|
|
50
|
+
required: {
|
|
51
|
+
id: "pep.relation.relative.name.required",
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
export const birthdayMessages = defineMessages({
|
|
55
|
+
header: {
|
|
56
|
+
id: "pep.relation.birthday.header",
|
|
57
|
+
},
|
|
58
|
+
required: {
|
|
59
|
+
id: "pep.relation.birthday.required",
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
export const colleagueNameMessages = defineMessages({
|
|
63
|
+
header: {
|
|
64
|
+
id: "pep.relation.colleague.name.header",
|
|
65
|
+
},
|
|
66
|
+
required: {
|
|
67
|
+
id: "pep.relation.colleague.name.required",
|
|
68
|
+
},
|
|
69
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionComponent } from "react";
|
|
2
|
-
interface Props {
|
|
3
|
-
next: () => void;
|
|
4
|
-
}
|
|
5
|
-
export declare const RelationPage: FunctionComponent<Props>;
|
|
6
|
-
export {};
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
next: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const RelationPage: FunctionComponent<Props>;
|
|
6
|
+
export {};
|
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
import React, { useContext, useRef, useCallback, } from "react";
|
|
2
|
-
import { PepContext, PepType, BusinessRelation, Relation, EntityType, } from "../PepContext";
|
|
3
|
-
import { RadioGroup, Form, RequiredValidator, TextInput, Datepicker, PrimaryButton, Card, } from "@lysaab/ui-2";
|
|
4
|
-
import { DateTime } from "luxon";
|
|
5
|
-
import { useIntl, FormattedMessage } from "react-intl";
|
|
6
|
-
import { relationMessages, businessRelationMessages, relativeNameMessages, birthdayMessages, colleagueNameMessages, } from "./RelationMessages";
|
|
7
|
-
import { formatPossessive } from "../../utils/Possession";
|
|
8
|
-
const DATEPICKER_START_DATE = DateTime.fromISO("1970-01-01").toJSDate();
|
|
9
|
-
export const RelationPage = ({ next }) => {
|
|
10
|
-
const intl = useIntl();
|
|
11
|
-
const pepContext = useContext(PepContext);
|
|
12
|
-
const formRef = useRef();
|
|
13
|
-
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
14
|
-
const type = pepContext.state.type;
|
|
15
|
-
const businessRelationAlternatives = getBusinessRelationAlternatives(intl, entityType, pepContext);
|
|
16
|
-
const relationAlternatives = getRelationAlternatives(intl, entityType, pepContext);
|
|
17
|
-
const nextPage = useCallback(() => {
|
|
18
|
-
if (formRef.current && formRef.current.isValid) {
|
|
19
|
-
next();
|
|
20
|
-
}
|
|
21
|
-
}, [formRef, next]);
|
|
22
|
-
return (React.createElement(Form, { onSubmit: () => nextPage(), lysaFormRef: formRef },
|
|
23
|
-
React.createElement(Card, null,
|
|
24
|
-
type === PepType.RELATIVE ? (React.createElement(RadioGroup, { alternatives: relationAlternatives, onChange: (alternative) => {
|
|
25
|
-
pepContext.setState({
|
|
26
|
-
relationToPEP: alternative.value,
|
|
27
|
-
});
|
|
28
|
-
}, value: relationAlternatives.find((alt) => alt.value === pepContext.state.relationToPEP), header: intl.formatMessage(relationMessages.header, {
|
|
29
|
-
entityType,
|
|
30
|
-
name: pepContext.state.ownerName,
|
|
31
|
-
possessiveName: formatPossessive(pepContext.state.ownerName, intl.locale),
|
|
32
|
-
}), validators: [
|
|
33
|
-
new RequiredValidator(intl.formatMessage(relationMessages.required)),
|
|
34
|
-
] })) : null,
|
|
35
|
-
type === PepType.COLLEAGUE ? (React.createElement(RadioGroup, { alternatives: businessRelationAlternatives, onChange: (alternative) => {
|
|
36
|
-
pepContext.setState({
|
|
37
|
-
businessRelation: alternative.value,
|
|
38
|
-
});
|
|
39
|
-
}, value: businessRelationAlternatives.find((alt) => alt.value === pepContext.state.businessRelation), header: intl.formatMessage(businessRelationMessages.header, {
|
|
40
|
-
entityType,
|
|
41
|
-
name: pepContext.state.ownerName,
|
|
42
|
-
}), validators: [
|
|
43
|
-
new RequiredValidator(intl.formatMessage(businessRelationMessages.required)),
|
|
44
|
-
] })) : null,
|
|
45
|
-
pepContext.state.relationToPEP && type === PepType.RELATIVE ? (React.createElement(React.Fragment, null,
|
|
46
|
-
React.createElement(TextInput, { label: intl.formatMessage(relativeNameMessages.header, {
|
|
47
|
-
entityType,
|
|
48
|
-
name: pepContext.state.ownerName,
|
|
49
|
-
relation: pepContext.state.type === PepType.COLLEAGUE
|
|
50
|
-
? pepContext.state.businessRelation
|
|
51
|
-
: pepContext.state.relationToPEP,
|
|
52
|
-
possessiveName: formatPossessive(pepContext.state.ownerName, intl.locale),
|
|
53
|
-
}), value: pepContext.state.nameOfPEP || "", onChange: (value) => {
|
|
54
|
-
pepContext.setState({ nameOfPEP: value });
|
|
55
|
-
}, validators: [
|
|
56
|
-
new RequiredValidator(intl.formatMessage(relativeNameMessages.required)),
|
|
57
|
-
] }),
|
|
58
|
-
React.createElement(Datepicker, { label: intl.formatMessage(birthdayMessages.header, {
|
|
59
|
-
entityType,
|
|
60
|
-
name: pepContext.state.ownerName,
|
|
61
|
-
relation: pepContext.state.type === PepType.COLLEAGUE
|
|
62
|
-
? pepContext.state.businessRelation
|
|
63
|
-
: pepContext.state.relationToPEP,
|
|
64
|
-
possessiveName: formatPossessive(pepContext.state.ownerName, intl.locale),
|
|
65
|
-
}), selected: pepContext.state.birthdayOfPEP, onChange: (event) => {
|
|
66
|
-
pepContext.setState({
|
|
67
|
-
birthdayOfPEP: event || undefined,
|
|
68
|
-
});
|
|
69
|
-
}, validators: [
|
|
70
|
-
new RequiredValidator(intl.formatMessage(birthdayMessages.required)),
|
|
71
|
-
], maxDate: new Date(), openToDate: pepContext.state.birthdayOfPEP || DATEPICKER_START_DATE }))) : null,
|
|
72
|
-
pepContext.state.businessRelation && type === PepType.COLLEAGUE ? (React.createElement(React.Fragment, null,
|
|
73
|
-
React.createElement(TextInput, { label: intl.formatMessage(colleagueNameMessages.header, {
|
|
74
|
-
entityType,
|
|
75
|
-
name: pepContext.state.ownerName,
|
|
76
|
-
relation: pepContext.state.type === PepType.COLLEAGUE
|
|
77
|
-
? pepContext.state.businessRelation
|
|
78
|
-
: pepContext.state.relationToPEP,
|
|
79
|
-
possessiveName: formatPossessive(pepContext.state.ownerName, intl.locale),
|
|
80
|
-
}), value: pepContext.state.nameOfPEP || "", onChange: (value) => {
|
|
81
|
-
pepContext.setState({ nameOfPEP: value });
|
|
82
|
-
}, validators: [
|
|
83
|
-
new RequiredValidator(intl.formatMessage(colleagueNameMessages.required)),
|
|
84
|
-
] }))) : null),
|
|
85
|
-
React.createElement(PrimaryButton, { block: true, type: "submit" },
|
|
86
|
-
React.createElement(FormattedMessage, { id: "pep.relation.next" }))));
|
|
87
|
-
};
|
|
88
|
-
function getRelationAlternatives(intl, entityType, pepContext) {
|
|
89
|
-
return [
|
|
90
|
-
{
|
|
91
|
-
text: intl.formatMessage(relationMessages[Relation.MARRIED_PARTNER], {
|
|
92
|
-
entityType,
|
|
93
|
-
name: pepContext.state.ownerName,
|
|
94
|
-
}),
|
|
95
|
-
value: Relation.MARRIED_PARTNER,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
text: intl.formatMessage(relationMessages[Relation.COLIVING_PARTNER], {
|
|
99
|
-
entityType,
|
|
100
|
-
name: pepContext.state.ownerName,
|
|
101
|
-
}),
|
|
102
|
-
value: Relation.COLIVING_PARTNER,
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
text: intl.formatMessage(relationMessages[Relation.CHILD], {
|
|
106
|
-
entityType,
|
|
107
|
-
name: pepContext.state.ownerName,
|
|
108
|
-
}),
|
|
109
|
-
value: Relation.CHILD,
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
text: intl.formatMessage(relationMessages[Relation.PARENT], {
|
|
113
|
-
entityType,
|
|
114
|
-
name: pepContext.state.ownerName,
|
|
115
|
-
}),
|
|
116
|
-
value: Relation.PARENT,
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
text: intl.formatMessage(relationMessages[Relation.CHILD_MARRIED_PARTNER], {
|
|
120
|
-
entityType,
|
|
121
|
-
name: pepContext.state.ownerName,
|
|
122
|
-
}),
|
|
123
|
-
value: Relation.CHILD_MARRIED_PARTNER,
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
text: intl.formatMessage(relationMessages[Relation.CHILD_COLIVING_PARTNER], {
|
|
127
|
-
entityType,
|
|
128
|
-
name: pepContext.state.ownerName,
|
|
129
|
-
}),
|
|
130
|
-
value: Relation.CHILD_COLIVING_PARTNER,
|
|
131
|
-
},
|
|
132
|
-
];
|
|
133
|
-
}
|
|
134
|
-
function getBusinessRelationAlternatives(intl, entityType, pepContext) {
|
|
135
|
-
return [
|
|
136
|
-
{
|
|
137
|
-
text: intl.formatMessage(businessRelationMessages[BusinessRelation.CO_OWNERSHIP], {
|
|
138
|
-
entityType,
|
|
139
|
-
name: pepContext.state.ownerName,
|
|
140
|
-
}),
|
|
141
|
-
value: BusinessRelation.CO_OWNERSHIP,
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
text: intl.formatMessage(businessRelationMessages[BusinessRelation.CLOSE_CONNECTION], {
|
|
145
|
-
entityType,
|
|
146
|
-
name: pepContext.state.ownerName,
|
|
147
|
-
}),
|
|
148
|
-
value: BusinessRelation.CLOSE_CONNECTION,
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
text: intl.formatMessage(businessRelationMessages[BusinessRelation.COMPANY_FOR_PEP], {
|
|
152
|
-
entityType,
|
|
153
|
-
name: pepContext.state.ownerName,
|
|
154
|
-
}),
|
|
155
|
-
value: BusinessRelation.COMPANY_FOR_PEP,
|
|
156
|
-
},
|
|
157
|
-
];
|
|
158
|
-
}
|
|
1
|
+
import React, { useContext, useRef, useCallback, } from "react";
|
|
2
|
+
import { PepContext, PepType, BusinessRelation, Relation, EntityType, } from "../PepContext";
|
|
3
|
+
import { RadioGroup, Form, RequiredValidator, TextInput, Datepicker, PrimaryButton, Card, } from "@lysaab/ui-2";
|
|
4
|
+
import { DateTime } from "luxon";
|
|
5
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
6
|
+
import { relationMessages, businessRelationMessages, relativeNameMessages, birthdayMessages, colleagueNameMessages, } from "./RelationMessages";
|
|
7
|
+
import { formatPossessive } from "../../utils/Possession";
|
|
8
|
+
const DATEPICKER_START_DATE = DateTime.fromISO("1970-01-01").toJSDate();
|
|
9
|
+
export const RelationPage = ({ next }) => {
|
|
10
|
+
const intl = useIntl();
|
|
11
|
+
const pepContext = useContext(PepContext);
|
|
12
|
+
const formRef = useRef();
|
|
13
|
+
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
14
|
+
const type = pepContext.state.type;
|
|
15
|
+
const businessRelationAlternatives = getBusinessRelationAlternatives(intl, entityType, pepContext);
|
|
16
|
+
const relationAlternatives = getRelationAlternatives(intl, entityType, pepContext);
|
|
17
|
+
const nextPage = useCallback(() => {
|
|
18
|
+
if (formRef.current && formRef.current.isValid) {
|
|
19
|
+
next();
|
|
20
|
+
}
|
|
21
|
+
}, [formRef, next]);
|
|
22
|
+
return (React.createElement(Form, { onSubmit: () => nextPage(), lysaFormRef: formRef },
|
|
23
|
+
React.createElement(Card, null,
|
|
24
|
+
type === PepType.RELATIVE ? (React.createElement(RadioGroup, { alternatives: relationAlternatives, onChange: (alternative) => {
|
|
25
|
+
pepContext.setState({
|
|
26
|
+
relationToPEP: alternative.value,
|
|
27
|
+
});
|
|
28
|
+
}, value: relationAlternatives.find((alt) => alt.value === pepContext.state.relationToPEP), header: intl.formatMessage(relationMessages.header, {
|
|
29
|
+
entityType,
|
|
30
|
+
name: pepContext.state.ownerName,
|
|
31
|
+
possessiveName: formatPossessive(pepContext.state.ownerName, intl.locale),
|
|
32
|
+
}), validators: [
|
|
33
|
+
new RequiredValidator(intl.formatMessage(relationMessages.required)),
|
|
34
|
+
] })) : null,
|
|
35
|
+
type === PepType.COLLEAGUE ? (React.createElement(RadioGroup, { alternatives: businessRelationAlternatives, onChange: (alternative) => {
|
|
36
|
+
pepContext.setState({
|
|
37
|
+
businessRelation: alternative.value,
|
|
38
|
+
});
|
|
39
|
+
}, value: businessRelationAlternatives.find((alt) => alt.value === pepContext.state.businessRelation), header: intl.formatMessage(businessRelationMessages.header, {
|
|
40
|
+
entityType,
|
|
41
|
+
name: pepContext.state.ownerName,
|
|
42
|
+
}), validators: [
|
|
43
|
+
new RequiredValidator(intl.formatMessage(businessRelationMessages.required)),
|
|
44
|
+
] })) : null,
|
|
45
|
+
pepContext.state.relationToPEP && type === PepType.RELATIVE ? (React.createElement(React.Fragment, null,
|
|
46
|
+
React.createElement(TextInput, { label: intl.formatMessage(relativeNameMessages.header, {
|
|
47
|
+
entityType,
|
|
48
|
+
name: pepContext.state.ownerName,
|
|
49
|
+
relation: pepContext.state.type === PepType.COLLEAGUE
|
|
50
|
+
? pepContext.state.businessRelation
|
|
51
|
+
: pepContext.state.relationToPEP,
|
|
52
|
+
possessiveName: formatPossessive(pepContext.state.ownerName, intl.locale),
|
|
53
|
+
}), value: pepContext.state.nameOfPEP || "", onChange: (value) => {
|
|
54
|
+
pepContext.setState({ nameOfPEP: value });
|
|
55
|
+
}, validators: [
|
|
56
|
+
new RequiredValidator(intl.formatMessage(relativeNameMessages.required)),
|
|
57
|
+
] }),
|
|
58
|
+
React.createElement(Datepicker, { label: intl.formatMessage(birthdayMessages.header, {
|
|
59
|
+
entityType,
|
|
60
|
+
name: pepContext.state.ownerName,
|
|
61
|
+
relation: pepContext.state.type === PepType.COLLEAGUE
|
|
62
|
+
? pepContext.state.businessRelation
|
|
63
|
+
: pepContext.state.relationToPEP,
|
|
64
|
+
possessiveName: formatPossessive(pepContext.state.ownerName, intl.locale),
|
|
65
|
+
}), selected: pepContext.state.birthdayOfPEP, onChange: (event) => {
|
|
66
|
+
pepContext.setState({
|
|
67
|
+
birthdayOfPEP: event || undefined,
|
|
68
|
+
});
|
|
69
|
+
}, validators: [
|
|
70
|
+
new RequiredValidator(intl.formatMessage(birthdayMessages.required)),
|
|
71
|
+
], maxDate: new Date(), openToDate: pepContext.state.birthdayOfPEP || DATEPICKER_START_DATE }))) : null,
|
|
72
|
+
pepContext.state.businessRelation && type === PepType.COLLEAGUE ? (React.createElement(React.Fragment, null,
|
|
73
|
+
React.createElement(TextInput, { label: intl.formatMessage(colleagueNameMessages.header, {
|
|
74
|
+
entityType,
|
|
75
|
+
name: pepContext.state.ownerName,
|
|
76
|
+
relation: pepContext.state.type === PepType.COLLEAGUE
|
|
77
|
+
? pepContext.state.businessRelation
|
|
78
|
+
: pepContext.state.relationToPEP,
|
|
79
|
+
possessiveName: formatPossessive(pepContext.state.ownerName, intl.locale),
|
|
80
|
+
}), value: pepContext.state.nameOfPEP || "", onChange: (value) => {
|
|
81
|
+
pepContext.setState({ nameOfPEP: value });
|
|
82
|
+
}, validators: [
|
|
83
|
+
new RequiredValidator(intl.formatMessage(colleagueNameMessages.required)),
|
|
84
|
+
] }))) : null),
|
|
85
|
+
React.createElement(PrimaryButton, { block: true, type: "submit" },
|
|
86
|
+
React.createElement(FormattedMessage, { id: "pep.relation.next" }))));
|
|
87
|
+
};
|
|
88
|
+
function getRelationAlternatives(intl, entityType, pepContext) {
|
|
89
|
+
return [
|
|
90
|
+
{
|
|
91
|
+
text: intl.formatMessage(relationMessages[Relation.MARRIED_PARTNER], {
|
|
92
|
+
entityType,
|
|
93
|
+
name: pepContext.state.ownerName,
|
|
94
|
+
}),
|
|
95
|
+
value: Relation.MARRIED_PARTNER,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
text: intl.formatMessage(relationMessages[Relation.COLIVING_PARTNER], {
|
|
99
|
+
entityType,
|
|
100
|
+
name: pepContext.state.ownerName,
|
|
101
|
+
}),
|
|
102
|
+
value: Relation.COLIVING_PARTNER,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
text: intl.formatMessage(relationMessages[Relation.CHILD], {
|
|
106
|
+
entityType,
|
|
107
|
+
name: pepContext.state.ownerName,
|
|
108
|
+
}),
|
|
109
|
+
value: Relation.CHILD,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
text: intl.formatMessage(relationMessages[Relation.PARENT], {
|
|
113
|
+
entityType,
|
|
114
|
+
name: pepContext.state.ownerName,
|
|
115
|
+
}),
|
|
116
|
+
value: Relation.PARENT,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
text: intl.formatMessage(relationMessages[Relation.CHILD_MARRIED_PARTNER], {
|
|
120
|
+
entityType,
|
|
121
|
+
name: pepContext.state.ownerName,
|
|
122
|
+
}),
|
|
123
|
+
value: Relation.CHILD_MARRIED_PARTNER,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
text: intl.formatMessage(relationMessages[Relation.CHILD_COLIVING_PARTNER], {
|
|
127
|
+
entityType,
|
|
128
|
+
name: pepContext.state.ownerName,
|
|
129
|
+
}),
|
|
130
|
+
value: Relation.CHILD_COLIVING_PARTNER,
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
function getBusinessRelationAlternatives(intl, entityType, pepContext) {
|
|
135
|
+
return [
|
|
136
|
+
{
|
|
137
|
+
text: intl.formatMessage(businessRelationMessages[BusinessRelation.CO_OWNERSHIP], {
|
|
138
|
+
entityType,
|
|
139
|
+
name: pepContext.state.ownerName,
|
|
140
|
+
}),
|
|
141
|
+
value: BusinessRelation.CO_OWNERSHIP,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
text: intl.formatMessage(businessRelationMessages[BusinessRelation.CLOSE_CONNECTION], {
|
|
145
|
+
entityType,
|
|
146
|
+
name: pepContext.state.ownerName,
|
|
147
|
+
}),
|
|
148
|
+
value: BusinessRelation.CLOSE_CONNECTION,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
text: intl.formatMessage(businessRelationMessages[BusinessRelation.COMPANY_FOR_PEP], {
|
|
152
|
+
entityType,
|
|
153
|
+
name: pepContext.state.ownerName,
|
|
154
|
+
}),
|
|
155
|
+
value: BusinessRelation.COMPANY_FOR_PEP,
|
|
156
|
+
},
|
|
157
|
+
];
|
|
158
|
+
}
|