@lysaab/lysa-pep 7.0.0 → 7.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/{src/Exports.ts → Exports.d.ts} +2 -7
- package/{lib/Exports.js → Exports.js} +2 -2
- package/{lib/components → components}/PepAnswers.d.ts +6 -0
- package/components/PepAnswers.js +182 -0
- package/package.json +8 -8
- package/{lib/pages → pages}/IsPep/IsPepPage.d.ts +2 -0
- package/{lib/pages → pages}/IsPep/IsPepPage.js +7 -4
- package/lib/Exports.d.ts +0 -7
- package/lib/README.md +0 -51
- package/lib/components/PepAnswers.js +0 -101
- package/lib/package.json +0 -73
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -2
- package/src/App.scss +0 -5
- package/src/App.test.tsx +0 -9
- package/src/App.tsx +0 -17
- package/src/components/PepAnswers.scss +0 -7
- package/src/components/PepAnswers.tsx +0 -218
- package/src/demo/Done.tsx +0 -21
- package/src/demo/Localization.tsx +0 -66
- package/src/demo/LocalizationContext.tsx +0 -61
- package/src/demo/Pep.tsx +0 -172
- package/src/index.css +0 -13
- package/src/index.tsx +0 -13
- package/src/locales/da.json +0 -98
- package/src/locales/de.json +0 -98
- package/src/locales/defaultMessages.json +0 -335
- package/src/locales/en.json +0 -98
- package/src/locales/fi.json +0 -98
- package/src/locales/sv.json +0 -98
- package/src/locales/whitelist_da.json +0 -2
- package/src/locales/whitelist_en.json +0 -2
- package/src/locales/whitelist_fi.json +0 -2
- package/src/locales/whitelist_sv.json +0 -2
- package/src/logo.svg +0 -1
- package/src/model/PepModel.ts +0 -54
- package/src/pages/IsPep/IsPepMessages.ts +0 -11
- package/src/pages/IsPep/IsPepPage.tsx +0 -119
- package/src/pages/PepContext.tsx +0 -150
- package/src/pages/RelationPage/RelationMessages.ts +0 -74
- package/src/pages/RelationPage/RelationPage.tsx +0 -306
- package/src/pages/RolePage/RoleMessages.ts +0 -128
- package/src/pages/RolePage/RolePage.tsx +0 -359
- package/src/pages/StatusPage/StatusMessages.ts +0 -59
- package/src/pages/StatusPage/StatusPage.tsx +0 -237
- package/src/react-app-env.d.ts +0 -1
- package/src/serviceWorker.ts +0 -143
- package/src/utils/Possession.ts +0 -41
- package/translationRunner.js +0 -7
- package/tsconfig.json +0 -26
- package/tsconfig_build.json +0 -19
- /package/{lib/components → components}/PepAnswers.scss +0 -0
- /package/{lib/messages → messages}/src/components/PepAnswers.json +0 -0
- /package/{lib/messages → messages}/src/pages/IsPep/IsPepMessages.json +0 -0
- /package/{lib/messages → messages}/src/pages/IsPep/IsPepPage.json +0 -0
- /package/{lib/messages → messages}/src/pages/RelationPage/RelationMessages.json +0 -0
- /package/{lib/messages → messages}/src/pages/RelationPage/RelationPage.json +0 -0
- /package/{lib/messages → messages}/src/pages/RolePage/RoleMessages.json +0 -0
- /package/{lib/messages → messages}/src/pages/RolePage/RolePage.json +0 -0
- /package/{lib/messages → messages}/src/pages/StatusPage/StatusMessages.json +0 -0
- /package/{lib/messages → messages}/src/pages/StatusPage/StatusPage.json +0 -0
- /package/{lib/model → model}/PepModel.d.ts +0 -0
- /package/{lib/model → model}/PepModel.js +0 -0
- /package/{lib/pages → pages}/IsPep/IsPepMessages.d.ts +0 -0
- /package/{lib/pages → pages}/IsPep/IsPepMessages.js +0 -0
- /package/{lib/pages → pages}/PepContext.d.ts +0 -0
- /package/{lib/pages → pages}/PepContext.js +0 -0
- /package/{lib/pages → pages}/RelationPage/RelationMessages.d.ts +0 -0
- /package/{lib/pages → pages}/RelationPage/RelationMessages.js +0 -0
- /package/{lib/pages → pages}/RelationPage/RelationPage.d.ts +0 -0
- /package/{lib/pages → pages}/RelationPage/RelationPage.js +0 -0
- /package/{lib/pages → pages}/RolePage/RoleMessages.d.ts +0 -0
- /package/{lib/pages → pages}/RolePage/RoleMessages.js +0 -0
- /package/{lib/pages → pages}/RolePage/RolePage.d.ts +0 -0
- /package/{lib/pages → pages}/RolePage/RolePage.js +0 -0
- /package/{lib/pages → pages}/StatusPage/StatusMessages.d.ts +0 -0
- /package/{lib/pages → pages}/StatusPage/StatusMessages.js +0 -0
- /package/{lib/pages → pages}/StatusPage/StatusPage.d.ts +0 -0
- /package/{lib/pages → pages}/StatusPage/StatusPage.js +0 -0
- /package/{lib/utils → utils}/Possession.d.ts +0 -0
- /package/{lib/utils → utils}/Possession.js +0 -0
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
FunctionComponent,
|
|
3
|
-
useRef,
|
|
4
|
-
useCallback,
|
|
5
|
-
useContext,
|
|
6
|
-
} from "react";
|
|
7
|
-
import {
|
|
8
|
-
Form,
|
|
9
|
-
RadioGroup,
|
|
10
|
-
RequiredValidator,
|
|
11
|
-
Button,
|
|
12
|
-
LysaFormRef,
|
|
13
|
-
Card,
|
|
14
|
-
} from "@lysaab/ui-2";
|
|
15
|
-
import { PepType, PepContext, EntityType } from "../PepContext";
|
|
16
|
-
import { useIntl, FormattedMessage } from "react-intl";
|
|
17
|
-
import { messages } from "./IsPepMessages";
|
|
18
|
-
|
|
19
|
-
export interface QuestionsProps {
|
|
20
|
-
ownerName?: string;
|
|
21
|
-
entityType?: EntityType;
|
|
22
|
-
type?: PepType;
|
|
23
|
-
onChange: (type: PepType) => void;
|
|
24
|
-
resetValues?: () => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const IsPepQuestion: React.FC<QuestionsProps> = ({
|
|
28
|
-
ownerName,
|
|
29
|
-
entityType,
|
|
30
|
-
type,
|
|
31
|
-
onChange,
|
|
32
|
-
resetValues,
|
|
33
|
-
}) => {
|
|
34
|
-
const intl = useIntl();
|
|
35
|
-
|
|
36
|
-
const IsPepAlternatives = [
|
|
37
|
-
{
|
|
38
|
-
text: intl.formatMessage(messages[PepType.NOT_PEP], {
|
|
39
|
-
entityType,
|
|
40
|
-
name: ownerName,
|
|
41
|
-
}),
|
|
42
|
-
value: PepType.NOT_PEP,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
text: intl.formatMessage(messages[PepType.ME], {
|
|
46
|
-
entityType,
|
|
47
|
-
name: ownerName,
|
|
48
|
-
}),
|
|
49
|
-
value: PepType.ME,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
text: intl.formatMessage(messages[PepType.RELATIVE], {
|
|
53
|
-
entityType,
|
|
54
|
-
name: ownerName,
|
|
55
|
-
}),
|
|
56
|
-
value: PepType.RELATIVE,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
text: intl.formatMessage(messages[PepType.COLLEAGUE], {
|
|
60
|
-
entityType,
|
|
61
|
-
name: ownerName,
|
|
62
|
-
}),
|
|
63
|
-
value: PepType.COLLEAGUE,
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<RadioGroup
|
|
69
|
-
alternatives={IsPepAlternatives}
|
|
70
|
-
onChange={(alternative) => {
|
|
71
|
-
onChange(alternative.value);
|
|
72
|
-
resetValues?.();
|
|
73
|
-
}}
|
|
74
|
-
value={IsPepAlternatives.find((alt) => alt.value === type)}
|
|
75
|
-
header={intl.formatMessage(messages.header, {
|
|
76
|
-
entityType,
|
|
77
|
-
name: ownerName,
|
|
78
|
-
})}
|
|
79
|
-
validators={[
|
|
80
|
-
new RequiredValidator(intl.formatMessage(messages.required)),
|
|
81
|
-
]}
|
|
82
|
-
data-test-id="pep-ispep"
|
|
83
|
-
/>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
interface Props {
|
|
88
|
-
next: () => void;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export const IsPepPage: FunctionComponent<Props> = ({ next }) => {
|
|
92
|
-
const pepContext = useContext(PepContext);
|
|
93
|
-
const formRef = useRef<LysaFormRef>();
|
|
94
|
-
|
|
95
|
-
const nextPage = useCallback(() => {
|
|
96
|
-
if (formRef.current && formRef.current.isValid) {
|
|
97
|
-
next();
|
|
98
|
-
}
|
|
99
|
-
}, [formRef, next]);
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<Form onSubmit={nextPage} lysaFormRef={formRef}>
|
|
103
|
-
<Card>
|
|
104
|
-
<IsPepQuestion
|
|
105
|
-
ownerName={pepContext.state.ownerName}
|
|
106
|
-
entityType={pepContext.state.legalEntityType || EntityType.PERSON}
|
|
107
|
-
type={pepContext.state.type}
|
|
108
|
-
onChange={(type) => pepContext.setState({ type })}
|
|
109
|
-
/>
|
|
110
|
-
</Card>
|
|
111
|
-
|
|
112
|
-
<Button
|
|
113
|
-
label={<FormattedMessage id="pep.ispep.next" />}
|
|
114
|
-
block
|
|
115
|
-
type="submit"
|
|
116
|
-
/>
|
|
117
|
-
</Form>
|
|
118
|
-
);
|
|
119
|
-
};
|
package/src/pages/PepContext.tsx
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { WorldCountry } from "@lysaab/ui-2";
|
|
2
|
-
import React, { useReducer } from "react";
|
|
3
|
-
|
|
4
|
-
export enum EntityType {
|
|
5
|
-
PERSON = "PERSON",
|
|
6
|
-
CORPORATION = "CORPORATION",
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export enum PepType {
|
|
10
|
-
NOT_PEP = "NOT_PEP",
|
|
11
|
-
ME = "ME",
|
|
12
|
-
RELATIVE = "RELATIVE",
|
|
13
|
-
COLLEAGUE = "COLLEAGUE",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export enum PepStatus {
|
|
17
|
-
ONGOING = "ONGOING",
|
|
18
|
-
ENDED = "ENDED",
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export enum Role {
|
|
22
|
-
HEAD_OF_GOVERNMENT = "HEAD_OF_GOVERNMENT",
|
|
23
|
-
MINISTER = "MINISTER",
|
|
24
|
-
PARLIMENT_MEMBER = "PARLIMENT_MEMBER",
|
|
25
|
-
CENTRAL_BANK_MEMBER = "CENTRAL_BANK_MEMBER",
|
|
26
|
-
BOARD_MEMBER_POLITICAL_PARTY = "BOARD_MEMBER_POLITICAL_PARTY",
|
|
27
|
-
JUDGE_SUPREME_COURT = "JUDGE_SUPREME_COURT",
|
|
28
|
-
JUDGE_OTHER_HIGH_COURT = "JUDGE_OTHER_HIGH_COURT",
|
|
29
|
-
REVISION_INSTITUTE = "REVISION_INSTITUTE",
|
|
30
|
-
AMBASSADOR = "AMBASSADOR",
|
|
31
|
-
MILITARY_OFFICER = "MILITARY_OFFICER",
|
|
32
|
-
GOVERNMENT_COMPANY = "GOVERNMENT_COMPANY",
|
|
33
|
-
EU_HIGH_RANKING_POSITION = "EU_HIGH_RANKING_POSITION",
|
|
34
|
-
HIGH_RANKING_POSITION_INTERNALTIONAL_CORP = "HIGH_RANKING_POSITION_INTERNALTIONAL_CORP",
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export enum Relation {
|
|
38
|
-
MARRIED_PARTNER = "MARRIED_PARTNER",
|
|
39
|
-
COLIVING_PARTNER = "COLIVING_PARTNER",
|
|
40
|
-
CHILD = "CHILD",
|
|
41
|
-
PARENT = "PARENT",
|
|
42
|
-
CHILD_MARRIED_PARTNER = "CHILD_MARRIED_PARTNER",
|
|
43
|
-
CHILD_COLIVING_PARTNER = "CHILD_COLIVING_PARTNER",
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export enum BusinessRelation {
|
|
47
|
-
CO_OWNERSHIP = "CO_OWNERSHIP",
|
|
48
|
-
CLOSE_CONNECTION = "CLOSE_CONNECTION",
|
|
49
|
-
COMPANY_FOR_PEP = "COMPANY_FOR_PEP",
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export enum MilitaryRank {
|
|
53
|
-
GENERAL = "GENERAL",
|
|
54
|
-
LIEUTENANT_GENERAL = "LIEUTENANT_GENERAL",
|
|
55
|
-
MAJOR_GENERAL = "MAJOR_GENERAL",
|
|
56
|
-
ADMIRAL = "ADMIRAL",
|
|
57
|
-
VICE_ADMIRAL = "VICE_ADMIRAL",
|
|
58
|
-
REAR_ADMIRAL = "REAR_ADMIRAL",
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Types for the state
|
|
62
|
-
export interface PepState {
|
|
63
|
-
legalEntityType?: EntityType;
|
|
64
|
-
type?: PepType;
|
|
65
|
-
role?: Role;
|
|
66
|
-
country?: WorldCountry;
|
|
67
|
-
ended?: Date;
|
|
68
|
-
ambassadorCountry?: WorldCountry;
|
|
69
|
-
militaryRank?: MilitaryRank;
|
|
70
|
-
governmentCompany?: string;
|
|
71
|
-
governmentCompanyRole?: string;
|
|
72
|
-
internationalOrganisation?: string;
|
|
73
|
-
internationalOrganisationRole?: string;
|
|
74
|
-
relationToPEP?: Relation;
|
|
75
|
-
nameOfPEP?: string;
|
|
76
|
-
birthdayOfPEP?: Date;
|
|
77
|
-
tin?: string;
|
|
78
|
-
businessRelation?: BusinessRelation;
|
|
79
|
-
locked?: boolean;
|
|
80
|
-
|
|
81
|
-
isOngoing?: PepStatus;
|
|
82
|
-
isLocalCountry?: string;
|
|
83
|
-
ownerName?: string;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const EMPTY_PEP_STATE: PepState = {
|
|
87
|
-
legalEntityType: undefined,
|
|
88
|
-
type: undefined,
|
|
89
|
-
role: undefined,
|
|
90
|
-
country: undefined,
|
|
91
|
-
ended: undefined,
|
|
92
|
-
ambassadorCountry: undefined,
|
|
93
|
-
militaryRank: undefined,
|
|
94
|
-
governmentCompany: undefined,
|
|
95
|
-
governmentCompanyRole: undefined,
|
|
96
|
-
internationalOrganisation: undefined,
|
|
97
|
-
internationalOrganisationRole: undefined,
|
|
98
|
-
relationToPEP: undefined,
|
|
99
|
-
nameOfPEP: undefined,
|
|
100
|
-
birthdayOfPEP: undefined,
|
|
101
|
-
tin: undefined,
|
|
102
|
-
businessRelation: undefined,
|
|
103
|
-
locked: undefined,
|
|
104
|
-
|
|
105
|
-
isOngoing: undefined,
|
|
106
|
-
isLocalCountry: undefined,
|
|
107
|
-
ownerName: undefined,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// All types for the context. This includes setter methods
|
|
111
|
-
export interface PepContextProps {
|
|
112
|
-
state: PepState;
|
|
113
|
-
setState: (newState: Partial<PepState>) => void;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Create the context. (This will just create a template)
|
|
117
|
-
export const PepContext = React.createContext<PepContextProps>(
|
|
118
|
-
{} as PepContextProps
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* A Higher Order Component. This is used to wrap classes so that the context is injected
|
|
123
|
-
* There is quite a bit TS magic here. This is so that the internal props off the component
|
|
124
|
-
* will be stripped of the context props so that the external props will only show the relevant
|
|
125
|
-
* props
|
|
126
|
-
*/
|
|
127
|
-
export const withPep =
|
|
128
|
-
<P extends object>(
|
|
129
|
-
Component: React.ComponentType<React.PropsWithChildren<P>>
|
|
130
|
-
): React.FC<React.PropsWithChildren<Omit<P, keyof PepContextProps>>> =>
|
|
131
|
-
(props) =>
|
|
132
|
-
(
|
|
133
|
-
<PepContext.Consumer>
|
|
134
|
-
{(contextProps) => <Component {...(props as P)} {...contextProps} />}
|
|
135
|
-
</PepContext.Consumer>
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
function stateReducer(state: PepState, newState: Partial<PepState>) {
|
|
139
|
-
return { ...state, ...newState };
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export const PepContextProvider: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
|
|
143
|
-
const [pep, setPep] = useReducer(stateReducer, {});
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<PepContext.Provider value={{ state: pep, setState: setPep }}>
|
|
147
|
-
{children}
|
|
148
|
-
</PepContext.Provider>
|
|
149
|
-
);
|
|
150
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { defineMessages } from "react-intl";
|
|
2
|
-
import { BusinessRelation, Relation } from "../PepContext";
|
|
3
|
-
|
|
4
|
-
export const relationMessages = defineMessages({
|
|
5
|
-
header: {
|
|
6
|
-
id: "pep.relation.relationship.header",
|
|
7
|
-
},
|
|
8
|
-
required: {
|
|
9
|
-
id: "pep.relation.relation.required",
|
|
10
|
-
},
|
|
11
|
-
[Relation.MARRIED_PARTNER]: {
|
|
12
|
-
id: "pep.relation.relation.MARRIED_PARTNER",
|
|
13
|
-
},
|
|
14
|
-
[Relation.COLIVING_PARTNER]: {
|
|
15
|
-
id: "pep.relation.relation.COLIVING_PARTNER",
|
|
16
|
-
},
|
|
17
|
-
[Relation.CHILD]: {
|
|
18
|
-
id: "pep.relation.relation.CHILD",
|
|
19
|
-
},
|
|
20
|
-
[Relation.PARENT]: {
|
|
21
|
-
id: "pep.relation.relation.PARENT",
|
|
22
|
-
},
|
|
23
|
-
[Relation.CHILD_MARRIED_PARTNER]: {
|
|
24
|
-
id: "pep.relation.relation.CHILD_MARRIED_PARTNER",
|
|
25
|
-
},
|
|
26
|
-
[Relation.CHILD_COLIVING_PARTNER]: {
|
|
27
|
-
id: "pep.relation.relation.CHILD_COLIVING_PARTNER",
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export const businessRelationMessages = defineMessages({
|
|
32
|
-
header: {
|
|
33
|
-
id: "pep.relation.businessrelation.header",
|
|
34
|
-
},
|
|
35
|
-
required: {
|
|
36
|
-
id: "pep.relation.businessrelation.required",
|
|
37
|
-
},
|
|
38
|
-
[BusinessRelation.CO_OWNERSHIP]: {
|
|
39
|
-
id: "pep.relation.businessrelation.alt.CO_OWNERSHIP",
|
|
40
|
-
},
|
|
41
|
-
[BusinessRelation.CLOSE_CONNECTION]: {
|
|
42
|
-
id: "pep.relation.businessrelation.alt.CLOSE_CONNECTION",
|
|
43
|
-
},
|
|
44
|
-
[BusinessRelation.COMPANY_FOR_PEP]: {
|
|
45
|
-
id: "pep.relation.businessrelation.alt.COMPANY_FOR_PEP",
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const relativeNameMessages = defineMessages({
|
|
50
|
-
header: {
|
|
51
|
-
id: "pep.relation.relative.name.header",
|
|
52
|
-
},
|
|
53
|
-
required: {
|
|
54
|
-
id: "pep.relation.relative.name.required",
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
export const birthdayMessages = defineMessages({
|
|
59
|
-
header: {
|
|
60
|
-
id: "pep.relation.birthday.header",
|
|
61
|
-
},
|
|
62
|
-
required: {
|
|
63
|
-
id: "pep.relation.birthday.required",
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
export const colleagueNameMessages = defineMessages({
|
|
68
|
-
header: {
|
|
69
|
-
id: "pep.relation.colleague.name.header",
|
|
70
|
-
},
|
|
71
|
-
required: {
|
|
72
|
-
id: "pep.relation.colleague.name.required",
|
|
73
|
-
},
|
|
74
|
-
});
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useContext,
|
|
3
|
-
useRef,
|
|
4
|
-
useCallback,
|
|
5
|
-
FunctionComponent,
|
|
6
|
-
} from "react";
|
|
7
|
-
import {
|
|
8
|
-
PepContext,
|
|
9
|
-
PepType,
|
|
10
|
-
BusinessRelation,
|
|
11
|
-
Relation,
|
|
12
|
-
EntityType,
|
|
13
|
-
PepContextProps,
|
|
14
|
-
} from "../PepContext";
|
|
15
|
-
import {
|
|
16
|
-
LysaFormRef,
|
|
17
|
-
RadioGroup,
|
|
18
|
-
Form,
|
|
19
|
-
Alternative,
|
|
20
|
-
RequiredValidator,
|
|
21
|
-
TextInput,
|
|
22
|
-
Datepicker,
|
|
23
|
-
Button,
|
|
24
|
-
Card,
|
|
25
|
-
} from "@lysaab/ui-2";
|
|
26
|
-
import { DateTime } from "luxon";
|
|
27
|
-
import { useIntl, IntlShape, FormattedMessage } from "react-intl";
|
|
28
|
-
import {
|
|
29
|
-
relationMessages,
|
|
30
|
-
businessRelationMessages,
|
|
31
|
-
relativeNameMessages,
|
|
32
|
-
birthdayMessages,
|
|
33
|
-
colleagueNameMessages,
|
|
34
|
-
} from "./RelationMessages";
|
|
35
|
-
import { formatPossessive } from "../../utils/Possession";
|
|
36
|
-
|
|
37
|
-
const DATEPICKER_START_DATE = DateTime.fromISO("1970-01-01").toJSDate();
|
|
38
|
-
|
|
39
|
-
interface Props {
|
|
40
|
-
next: () => void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const RelationPage: FunctionComponent<Props> = ({ next }) => {
|
|
44
|
-
const intl = useIntl();
|
|
45
|
-
const pepContext = useContext(PepContext);
|
|
46
|
-
const formRef = useRef<LysaFormRef>();
|
|
47
|
-
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
48
|
-
const type = pepContext.state.type;
|
|
49
|
-
|
|
50
|
-
const businessRelationAlternatives = getBusinessRelationAlternatives(
|
|
51
|
-
intl,
|
|
52
|
-
entityType,
|
|
53
|
-
pepContext
|
|
54
|
-
);
|
|
55
|
-
const relationAlternatives = getRelationAlternatives(
|
|
56
|
-
intl,
|
|
57
|
-
entityType,
|
|
58
|
-
pepContext
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const nextPage = useCallback(() => {
|
|
62
|
-
if (formRef.current && formRef.current.isValid) {
|
|
63
|
-
next();
|
|
64
|
-
}
|
|
65
|
-
}, [formRef, next]);
|
|
66
|
-
return (
|
|
67
|
-
<Form onSubmit={() => nextPage()} lysaFormRef={formRef}>
|
|
68
|
-
<Card>
|
|
69
|
-
{type === PepType.RELATIVE ? (
|
|
70
|
-
<RadioGroup
|
|
71
|
-
alternatives={relationAlternatives}
|
|
72
|
-
onChange={(alternative) => {
|
|
73
|
-
pepContext.setState({
|
|
74
|
-
relationToPEP: alternative.value,
|
|
75
|
-
});
|
|
76
|
-
}}
|
|
77
|
-
value={relationAlternatives.find(
|
|
78
|
-
(alt) => alt.value === pepContext.state.relationToPEP
|
|
79
|
-
)}
|
|
80
|
-
header={intl.formatMessage(relationMessages.header, {
|
|
81
|
-
entityType,
|
|
82
|
-
name: pepContext.state.ownerName,
|
|
83
|
-
possessiveName: formatPossessive(
|
|
84
|
-
pepContext.state.ownerName,
|
|
85
|
-
intl.locale
|
|
86
|
-
),
|
|
87
|
-
})}
|
|
88
|
-
validators={[
|
|
89
|
-
new RequiredValidator(
|
|
90
|
-
intl.formatMessage(relationMessages.required)
|
|
91
|
-
),
|
|
92
|
-
]}
|
|
93
|
-
/>
|
|
94
|
-
) : null}
|
|
95
|
-
{type === PepType.COLLEAGUE ? (
|
|
96
|
-
<RadioGroup
|
|
97
|
-
alternatives={businessRelationAlternatives}
|
|
98
|
-
onChange={(alternative) => {
|
|
99
|
-
pepContext.setState({
|
|
100
|
-
businessRelation: alternative.value,
|
|
101
|
-
});
|
|
102
|
-
}}
|
|
103
|
-
value={businessRelationAlternatives.find(
|
|
104
|
-
(alt) => alt.value === pepContext.state.businessRelation
|
|
105
|
-
)}
|
|
106
|
-
header={intl.formatMessage(businessRelationMessages.header, {
|
|
107
|
-
entityType,
|
|
108
|
-
name: pepContext.state.ownerName,
|
|
109
|
-
})}
|
|
110
|
-
validators={[
|
|
111
|
-
new RequiredValidator(
|
|
112
|
-
intl.formatMessage(businessRelationMessages.required)
|
|
113
|
-
),
|
|
114
|
-
]}
|
|
115
|
-
/>
|
|
116
|
-
) : null}
|
|
117
|
-
{pepContext.state.relationToPEP && type === PepType.RELATIVE ? (
|
|
118
|
-
<React.Fragment>
|
|
119
|
-
<TextInput
|
|
120
|
-
label={intl.formatMessage(relativeNameMessages.header, {
|
|
121
|
-
entityType,
|
|
122
|
-
name: pepContext.state.ownerName,
|
|
123
|
-
relation:
|
|
124
|
-
pepContext.state.type === PepType.COLLEAGUE
|
|
125
|
-
? pepContext.state.businessRelation
|
|
126
|
-
: pepContext.state.relationToPEP,
|
|
127
|
-
possessiveName: formatPossessive(
|
|
128
|
-
pepContext.state.ownerName,
|
|
129
|
-
intl.locale
|
|
130
|
-
),
|
|
131
|
-
})}
|
|
132
|
-
value={pepContext.state.nameOfPEP || ""}
|
|
133
|
-
onChange={(value) => {
|
|
134
|
-
pepContext.setState({ nameOfPEP: value });
|
|
135
|
-
}}
|
|
136
|
-
validators={[
|
|
137
|
-
new RequiredValidator(
|
|
138
|
-
intl.formatMessage(relativeNameMessages.required)
|
|
139
|
-
),
|
|
140
|
-
]}
|
|
141
|
-
/>
|
|
142
|
-
<Datepicker
|
|
143
|
-
label={intl.formatMessage(birthdayMessages.header, {
|
|
144
|
-
entityType,
|
|
145
|
-
name: pepContext.state.ownerName,
|
|
146
|
-
relation:
|
|
147
|
-
pepContext.state.type === PepType.COLLEAGUE
|
|
148
|
-
? pepContext.state.businessRelation
|
|
149
|
-
: pepContext.state.relationToPEP,
|
|
150
|
-
possessiveName: formatPossessive(
|
|
151
|
-
pepContext.state.ownerName,
|
|
152
|
-
intl.locale
|
|
153
|
-
),
|
|
154
|
-
})}
|
|
155
|
-
selected={pepContext.state.birthdayOfPEP}
|
|
156
|
-
onChange={(event) => {
|
|
157
|
-
// event has a type that says it can be [startDate, endDate]
|
|
158
|
-
// but we know that will never be the case here
|
|
159
|
-
pepContext.setState({
|
|
160
|
-
birthdayOfPEP: (event as Date) || undefined,
|
|
161
|
-
});
|
|
162
|
-
}}
|
|
163
|
-
validators={[
|
|
164
|
-
new RequiredValidator(
|
|
165
|
-
intl.formatMessage(birthdayMessages.required)
|
|
166
|
-
),
|
|
167
|
-
]}
|
|
168
|
-
maxDate={new Date()}
|
|
169
|
-
openToDate={
|
|
170
|
-
pepContext.state.birthdayOfPEP || DATEPICKER_START_DATE
|
|
171
|
-
}
|
|
172
|
-
/>
|
|
173
|
-
</React.Fragment>
|
|
174
|
-
) : null}
|
|
175
|
-
|
|
176
|
-
{pepContext.state.businessRelation && type === PepType.COLLEAGUE ? (
|
|
177
|
-
<React.Fragment>
|
|
178
|
-
<TextInput
|
|
179
|
-
label={intl.formatMessage(colleagueNameMessages.header, {
|
|
180
|
-
entityType,
|
|
181
|
-
name: pepContext.state.ownerName,
|
|
182
|
-
relation:
|
|
183
|
-
pepContext.state.type === PepType.COLLEAGUE
|
|
184
|
-
? pepContext.state.businessRelation
|
|
185
|
-
: pepContext.state.relationToPEP,
|
|
186
|
-
possessiveName: formatPossessive(
|
|
187
|
-
pepContext.state.ownerName,
|
|
188
|
-
intl.locale
|
|
189
|
-
),
|
|
190
|
-
})}
|
|
191
|
-
value={pepContext.state.nameOfPEP || ""}
|
|
192
|
-
onChange={(value) => {
|
|
193
|
-
pepContext.setState({ nameOfPEP: value });
|
|
194
|
-
}}
|
|
195
|
-
validators={[
|
|
196
|
-
new RequiredValidator(
|
|
197
|
-
intl.formatMessage(colleagueNameMessages.required)
|
|
198
|
-
),
|
|
199
|
-
]}
|
|
200
|
-
/>
|
|
201
|
-
</React.Fragment>
|
|
202
|
-
) : null}
|
|
203
|
-
</Card>
|
|
204
|
-
<Button
|
|
205
|
-
block
|
|
206
|
-
type="submit"
|
|
207
|
-
label={<FormattedMessage id="pep.relation.next" />}
|
|
208
|
-
/>
|
|
209
|
-
</Form>
|
|
210
|
-
);
|
|
211
|
-
};
|
|
212
|
-
function getRelationAlternatives(
|
|
213
|
-
intl: IntlShape,
|
|
214
|
-
entityType: EntityType,
|
|
215
|
-
pepContext: PepContextProps
|
|
216
|
-
): Alternative<Relation>[] {
|
|
217
|
-
return [
|
|
218
|
-
{
|
|
219
|
-
text: intl.formatMessage(relationMessages[Relation.MARRIED_PARTNER], {
|
|
220
|
-
entityType,
|
|
221
|
-
name: pepContext.state.ownerName,
|
|
222
|
-
}),
|
|
223
|
-
value: Relation.MARRIED_PARTNER,
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
text: intl.formatMessage(relationMessages[Relation.COLIVING_PARTNER], {
|
|
227
|
-
entityType,
|
|
228
|
-
name: pepContext.state.ownerName,
|
|
229
|
-
}),
|
|
230
|
-
value: Relation.COLIVING_PARTNER,
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
text: intl.formatMessage(relationMessages[Relation.CHILD], {
|
|
234
|
-
entityType,
|
|
235
|
-
name: pepContext.state.ownerName,
|
|
236
|
-
}),
|
|
237
|
-
value: Relation.CHILD,
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
text: intl.formatMessage(relationMessages[Relation.PARENT], {
|
|
241
|
-
entityType,
|
|
242
|
-
name: pepContext.state.ownerName,
|
|
243
|
-
}),
|
|
244
|
-
value: Relation.PARENT,
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
text: intl.formatMessage(
|
|
248
|
-
relationMessages[Relation.CHILD_MARRIED_PARTNER],
|
|
249
|
-
{
|
|
250
|
-
entityType,
|
|
251
|
-
name: pepContext.state.ownerName,
|
|
252
|
-
}
|
|
253
|
-
),
|
|
254
|
-
value: Relation.CHILD_MARRIED_PARTNER,
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
text: intl.formatMessage(
|
|
258
|
-
relationMessages[Relation.CHILD_COLIVING_PARTNER],
|
|
259
|
-
{
|
|
260
|
-
entityType,
|
|
261
|
-
name: pepContext.state.ownerName,
|
|
262
|
-
}
|
|
263
|
-
),
|
|
264
|
-
value: Relation.CHILD_COLIVING_PARTNER,
|
|
265
|
-
},
|
|
266
|
-
];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function getBusinessRelationAlternatives(
|
|
270
|
-
intl: IntlShape,
|
|
271
|
-
entityType: EntityType,
|
|
272
|
-
pepContext: PepContextProps
|
|
273
|
-
): Alternative<BusinessRelation>[] {
|
|
274
|
-
return [
|
|
275
|
-
{
|
|
276
|
-
text: intl.formatMessage(
|
|
277
|
-
businessRelationMessages[BusinessRelation.CO_OWNERSHIP],
|
|
278
|
-
{
|
|
279
|
-
entityType,
|
|
280
|
-
name: pepContext.state.ownerName,
|
|
281
|
-
}
|
|
282
|
-
),
|
|
283
|
-
value: BusinessRelation.CO_OWNERSHIP,
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
text: intl.formatMessage(
|
|
287
|
-
businessRelationMessages[BusinessRelation.CLOSE_CONNECTION],
|
|
288
|
-
{
|
|
289
|
-
entityType,
|
|
290
|
-
name: pepContext.state.ownerName,
|
|
291
|
-
}
|
|
292
|
-
),
|
|
293
|
-
value: BusinessRelation.CLOSE_CONNECTION,
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
text: intl.formatMessage(
|
|
297
|
-
businessRelationMessages[BusinessRelation.COMPANY_FOR_PEP],
|
|
298
|
-
{
|
|
299
|
-
entityType,
|
|
300
|
-
name: pepContext.state.ownerName,
|
|
301
|
-
}
|
|
302
|
-
),
|
|
303
|
-
value: BusinessRelation.COMPANY_FOR_PEP,
|
|
304
|
-
},
|
|
305
|
-
];
|
|
306
|
-
}
|