@lysaab/lysa-pep 1.0.0-1 → 1.0.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 +8 -7
- package/lib/Exports.js +8 -7
- package/lib/components/CountrySelect.d.ts +22 -15
- package/lib/components/CountrySelect.js +21 -30
- package/lib/components/PepAnswers.d.ts +8 -8
- package/lib/components/PepAnswers.js +39 -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/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/package.json +53 -56
- package/src/Exports.ts +13 -12
- package/src/components/CountrySelect.tsx +43 -47
- package/src/components/PepAnswers.scss +7 -7
- package/src/components/PepAnswers.tsx +120 -252
- package/src/demo/Done.tsx +20 -16
- package/src/demo/Pep.tsx +106 -112
- package/src/model/PepModel.ts +52 -52
- package/src/model/PepTexts.ts +607 -0
- package/src/pages/PepContext.tsx +144 -144
- package/src/pages/PepIsPepPage.tsx +107 -0
- package/src/pages/PepRelationPage.tsx +188 -0
- package/src/pages/PepRolePage.tsx +272 -0
- package/src/pages/PepStatusPage.tsx +157 -0
- package/.vscode/settings.json +0 -4
- package/lib/pages/IsPep/IsPepMessages.d.ts +0 -32
- package/lib/pages/IsPep/IsPepMessages.js +0 -74
- package/lib/pages/IsPep/IsPepPage.d.ts +0 -14
- package/lib/pages/IsPep/IsPepPage.js +0 -39
- package/lib/pages/RelationPage/RelationMessages.d.ts +0 -105
- package/lib/pages/RelationPage/RelationMessages.js +0 -282
- package/lib/pages/RelationPage/RelationPage.d.ts +0 -6
- package/lib/pages/RelationPage/RelationPage.js +0 -142
- package/lib/pages/RolePage/RoleMessages.d.ts +0 -185
- package/lib/pages/RolePage/RoleMessages.js +0 -381
- package/lib/pages/RolePage/RolePage.d.ts +0 -11
- package/lib/pages/RolePage/RolePage.js +0 -214
- package/lib/pages/StatusPage/StatusMessages.d.ts +0 -72
- package/lib/pages/StatusPage/StatusMessages.js +0 -74
- package/lib/pages/StatusPage/StatusPage.d.ts +0 -6
- package/lib/pages/StatusPage/StatusPage.js +0 -75
- package/src/pages/IsPep/IsPepMessages.ts +0 -75
- package/src/pages/IsPep/IsPepPage.tsx +0 -94
- package/src/pages/RelationPage/RelationMessages.ts +0 -287
- package/src/pages/RelationPage/RelationPage.tsx +0 -269
- package/src/pages/RolePage/RoleMessages.ts +0 -389
- package/src/pages/RolePage/RolePage.tsx +0 -342
- package/src/pages/StatusPage/StatusMessages.ts +0 -80
- package/src/pages/StatusPage/StatusPage.tsx +0 -172
package/src/pages/PepContext.tsx
CHANGED
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
import React, { useReducer } from "react";
|
|
2
|
-
|
|
3
|
-
export enum EntityType {
|
|
4
|
-
PERSON = "PERSON",
|
|
5
|
-
CORPORATION = "CORPORATION",
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export enum PepType {
|
|
9
|
-
NOT_PEP = "NOT_PEP",
|
|
10
|
-
ME = "ME",
|
|
11
|
-
RELATIVE = "RELATIVE",
|
|
12
|
-
COLLEAGUE = "COLLEAGUE",
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export enum PepStatus {
|
|
16
|
-
ONGOING = "ONGOING",
|
|
17
|
-
ENDED = "ENDED",
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export enum Role {
|
|
21
|
-
HEAD_OF_GOVERNMENT = "HEAD_OF_GOVERNMENT",
|
|
22
|
-
MINISTER = "MINISTER",
|
|
23
|
-
PARLIMENT_MEMBER = "PARLIMENT_MEMBER",
|
|
24
|
-
CENTRAL_BANK_MEMBER = "CENTRAL_BANK_MEMBER",
|
|
25
|
-
BOARD_MEMBER_POLITICAL_PARTY = "BOARD_MEMBER_POLITICAL_PARTY",
|
|
26
|
-
JUDGE_SUPREME_COURT = "JUDGE_SUPREME_COURT",
|
|
27
|
-
JUDGE_OTHER_HIGH_COURT = "JUDGE_OTHER_HIGH_COURT",
|
|
28
|
-
REVISION_INSTITUTE = "REVISION_INSTITUTE",
|
|
29
|
-
AMBASSADOR = "AMBASSADOR",
|
|
30
|
-
MILITARY_OFFICER = "MILITARY_OFFICER",
|
|
31
|
-
GOVERNMENT_COMPANY = "GOVERNMENT_COMPANY",
|
|
32
|
-
EU_HIGH_RANKING_POSITION = "EU_HIGH_RANKING_POSITION",
|
|
33
|
-
HIGH_RANKING_POSITION_INTERNALTIONAL_CORP = "HIGH_RANKING_POSITION_INTERNALTIONAL_CORP",
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export enum Relation {
|
|
37
|
-
MARRIED_PARTNER = "MARRIED_PARTNER",
|
|
38
|
-
COLIVING_PARTNER = "COLIVING_PARTNER",
|
|
39
|
-
CHILD = "CHILD",
|
|
40
|
-
PARENT = "PARENT",
|
|
41
|
-
CHILD_MARRIED_PARTNER = "CHILD_MARRIED_PARTNER",
|
|
42
|
-
CHILD_COLIVING_PARTNER = "CHILD_COLIVING_PARTNER",
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export enum BusinessRelation {
|
|
46
|
-
CO_OWNERSHIP = "CO_OWNERSHIP",
|
|
47
|
-
CLOSE_CONNECTION = "CLOSE_CONNECTION",
|
|
48
|
-
COMPANY_FOR_PEP = "COMPANY_FOR_PEP",
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export enum MilitaryRank {
|
|
52
|
-
GENERAL = "GENERAL",
|
|
53
|
-
LIEUTENANT_GENERAL = "LIEUTENANT_GENERAL",
|
|
54
|
-
MAJOR_GENERAL = "MAJOR_GENERAL",
|
|
55
|
-
ADMIRAL = "ADMIRAL",
|
|
56
|
-
VICE_ADMIRAL = "VICE_ADMIRAL",
|
|
57
|
-
REAR_ADMIRAL = "REAR_ADMIRAL",
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Types for the state
|
|
61
|
-
export interface PepState {
|
|
62
|
-
legalEntityType?: EntityType;
|
|
63
|
-
type?: PepType;
|
|
64
|
-
role?: Role;
|
|
65
|
-
country?: string;
|
|
66
|
-
ended?: Date;
|
|
67
|
-
ambassadorCountry?: string;
|
|
68
|
-
militaryRank?: MilitaryRank;
|
|
69
|
-
governmentCompany?: string;
|
|
70
|
-
governmentCompanyRole?: string;
|
|
71
|
-
internationalOrganisation?: string;
|
|
72
|
-
internationalOrganisationRole?: string;
|
|
73
|
-
relationToPEP?: Relation;
|
|
74
|
-
nameOfPEP?: string;
|
|
75
|
-
birthdayOfPEP?: Date;
|
|
76
|
-
tin?: string;
|
|
77
|
-
businessRelation?: BusinessRelation;
|
|
78
|
-
|
|
79
|
-
isOngoing?: PepStatus;
|
|
80
|
-
isSweden?: string;
|
|
81
|
-
ownerName?: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const EMPTY_PEP_STATE: PepState = {
|
|
85
|
-
legalEntityType: undefined,
|
|
86
|
-
type: undefined,
|
|
87
|
-
role: undefined,
|
|
88
|
-
country: undefined,
|
|
89
|
-
ended: undefined,
|
|
90
|
-
ambassadorCountry: undefined,
|
|
91
|
-
militaryRank: undefined,
|
|
92
|
-
governmentCompany: undefined,
|
|
93
|
-
governmentCompanyRole: undefined,
|
|
94
|
-
internationalOrganisation: undefined,
|
|
95
|
-
internationalOrganisationRole: undefined,
|
|
96
|
-
relationToPEP: undefined,
|
|
97
|
-
nameOfPEP: undefined,
|
|
98
|
-
birthdayOfPEP: undefined,
|
|
99
|
-
tin: undefined,
|
|
100
|
-
businessRelation: undefined,
|
|
101
|
-
|
|
102
|
-
isOngoing: undefined,
|
|
103
|
-
isSweden: undefined,
|
|
104
|
-
ownerName: undefined,
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// All types for the context. This includes setter methods
|
|
108
|
-
export interface PepContextProps {
|
|
109
|
-
state: PepState;
|
|
110
|
-
setState: (newState: Partial<PepState>) => void;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Create the context. (This will just create a template)
|
|
114
|
-
export const PepContext = React.createContext<PepContextProps>(
|
|
115
|
-
{} as PepContextProps
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* A Higher Order Component. This is used to wrap classes so that the context is injected
|
|
120
|
-
* There is quite a bit TS magic here. This is so that the internal props off the component
|
|
121
|
-
* will be stripped of the context props so that the external props will only show the relevant
|
|
122
|
-
* props
|
|
123
|
-
*/
|
|
124
|
-
export const withPep = <P extends object>(
|
|
125
|
-
Component: React.ComponentType<P>
|
|
126
|
-
): React.FC<Omit<P, keyof PepContextProps>> => props => (
|
|
127
|
-
<PepContext.Consumer>
|
|
128
|
-
{contextProps => <Component {...(props as P)} {...contextProps} />}
|
|
129
|
-
</PepContext.Consumer>
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
function stateReducer(state: PepState, newState: Partial<PepState>) {
|
|
133
|
-
return { ...state, ...newState };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export const PepContextProvider: React.FC = ({ children }) => {
|
|
137
|
-
const [pep, setPep] = useReducer(stateReducer, {});
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<PepContext.Provider value={{ state: pep, setState: setPep }}>
|
|
141
|
-
{children}
|
|
142
|
-
</PepContext.Provider>
|
|
143
|
-
);
|
|
144
|
-
};
|
|
1
|
+
import React, { useReducer } from "react";
|
|
2
|
+
|
|
3
|
+
export enum EntityType {
|
|
4
|
+
PERSON = "PERSON",
|
|
5
|
+
CORPORATION = "CORPORATION",
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export enum PepType {
|
|
9
|
+
NOT_PEP = "NOT_PEP",
|
|
10
|
+
ME = "ME",
|
|
11
|
+
RELATIVE = "RELATIVE",
|
|
12
|
+
COLLEAGUE = "COLLEAGUE",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum PepStatus {
|
|
16
|
+
ONGOING = "ONGOING",
|
|
17
|
+
ENDED = "ENDED",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export enum Role {
|
|
21
|
+
HEAD_OF_GOVERNMENT = "HEAD_OF_GOVERNMENT",
|
|
22
|
+
MINISTER = "MINISTER",
|
|
23
|
+
PARLIMENT_MEMBER = "PARLIMENT_MEMBER",
|
|
24
|
+
CENTRAL_BANK_MEMBER = "CENTRAL_BANK_MEMBER",
|
|
25
|
+
BOARD_MEMBER_POLITICAL_PARTY = "BOARD_MEMBER_POLITICAL_PARTY",
|
|
26
|
+
JUDGE_SUPREME_COURT = "JUDGE_SUPREME_COURT",
|
|
27
|
+
JUDGE_OTHER_HIGH_COURT = "JUDGE_OTHER_HIGH_COURT",
|
|
28
|
+
REVISION_INSTITUTE = "REVISION_INSTITUTE",
|
|
29
|
+
AMBASSADOR = "AMBASSADOR",
|
|
30
|
+
MILITARY_OFFICER = "MILITARY_OFFICER",
|
|
31
|
+
GOVERNMENT_COMPANY = "GOVERNMENT_COMPANY",
|
|
32
|
+
EU_HIGH_RANKING_POSITION = "EU_HIGH_RANKING_POSITION",
|
|
33
|
+
HIGH_RANKING_POSITION_INTERNALTIONAL_CORP = "HIGH_RANKING_POSITION_INTERNALTIONAL_CORP",
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export enum Relation {
|
|
37
|
+
MARRIED_PARTNER = "MARRIED_PARTNER",
|
|
38
|
+
COLIVING_PARTNER = "COLIVING_PARTNER",
|
|
39
|
+
CHILD = "CHILD",
|
|
40
|
+
PARENT = "PARENT",
|
|
41
|
+
CHILD_MARRIED_PARTNER = "CHILD_MARRIED_PARTNER",
|
|
42
|
+
CHILD_COLIVING_PARTNER = "CHILD_COLIVING_PARTNER",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export enum BusinessRelation {
|
|
46
|
+
CO_OWNERSHIP = "CO_OWNERSHIP",
|
|
47
|
+
CLOSE_CONNECTION = "CLOSE_CONNECTION",
|
|
48
|
+
COMPANY_FOR_PEP = "COMPANY_FOR_PEP",
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export enum MilitaryRank {
|
|
52
|
+
GENERAL = "GENERAL",
|
|
53
|
+
LIEUTENANT_GENERAL = "LIEUTENANT_GENERAL",
|
|
54
|
+
MAJOR_GENERAL = "MAJOR_GENERAL",
|
|
55
|
+
ADMIRAL = "ADMIRAL",
|
|
56
|
+
VICE_ADMIRAL = "VICE_ADMIRAL",
|
|
57
|
+
REAR_ADMIRAL = "REAR_ADMIRAL",
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Types for the state
|
|
61
|
+
export interface PepState {
|
|
62
|
+
legalEntityType?: EntityType;
|
|
63
|
+
type?: PepType;
|
|
64
|
+
role?: Role;
|
|
65
|
+
country?: string;
|
|
66
|
+
ended?: Date;
|
|
67
|
+
ambassadorCountry?: string;
|
|
68
|
+
militaryRank?: MilitaryRank;
|
|
69
|
+
governmentCompany?: string;
|
|
70
|
+
governmentCompanyRole?: string;
|
|
71
|
+
internationalOrganisation?: string;
|
|
72
|
+
internationalOrganisationRole?: string;
|
|
73
|
+
relationToPEP?: Relation;
|
|
74
|
+
nameOfPEP?: string;
|
|
75
|
+
birthdayOfPEP?: Date;
|
|
76
|
+
tin?: string;
|
|
77
|
+
businessRelation?: BusinessRelation;
|
|
78
|
+
|
|
79
|
+
isOngoing?: PepStatus;
|
|
80
|
+
isSweden?: string;
|
|
81
|
+
ownerName?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const EMPTY_PEP_STATE: PepState = {
|
|
85
|
+
legalEntityType: undefined,
|
|
86
|
+
type: undefined,
|
|
87
|
+
role: undefined,
|
|
88
|
+
country: undefined,
|
|
89
|
+
ended: undefined,
|
|
90
|
+
ambassadorCountry: undefined,
|
|
91
|
+
militaryRank: undefined,
|
|
92
|
+
governmentCompany: undefined,
|
|
93
|
+
governmentCompanyRole: undefined,
|
|
94
|
+
internationalOrganisation: undefined,
|
|
95
|
+
internationalOrganisationRole: undefined,
|
|
96
|
+
relationToPEP: undefined,
|
|
97
|
+
nameOfPEP: undefined,
|
|
98
|
+
birthdayOfPEP: undefined,
|
|
99
|
+
tin: undefined,
|
|
100
|
+
businessRelation: undefined,
|
|
101
|
+
|
|
102
|
+
isOngoing: undefined,
|
|
103
|
+
isSweden: undefined,
|
|
104
|
+
ownerName: undefined,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// All types for the context. This includes setter methods
|
|
108
|
+
export interface PepContextProps {
|
|
109
|
+
state: PepState;
|
|
110
|
+
setState: (newState: Partial<PepState>) => void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Create the context. (This will just create a template)
|
|
114
|
+
export const PepContext = React.createContext<PepContextProps>(
|
|
115
|
+
{} as PepContextProps
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* A Higher Order Component. This is used to wrap classes so that the context is injected
|
|
120
|
+
* There is quite a bit TS magic here. This is so that the internal props off the component
|
|
121
|
+
* will be stripped of the context props so that the external props will only show the relevant
|
|
122
|
+
* props
|
|
123
|
+
*/
|
|
124
|
+
export const withPep = <P extends object>(
|
|
125
|
+
Component: React.ComponentType<P>
|
|
126
|
+
): React.FC<Omit<P, keyof PepContextProps>> => props => (
|
|
127
|
+
<PepContext.Consumer>
|
|
128
|
+
{contextProps => <Component {...(props as P)} {...contextProps} />}
|
|
129
|
+
</PepContext.Consumer>
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
function stateReducer(state: PepState, newState: Partial<PepState>) {
|
|
133
|
+
return { ...state, ...newState };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export const PepContextProvider: React.FC = ({ children }) => {
|
|
137
|
+
const [pep, setPep] = useReducer(stateReducer, {});
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<PepContext.Provider value={{ state: pep, setState: setPep }}>
|
|
141
|
+
{children}
|
|
142
|
+
</PepContext.Provider>
|
|
143
|
+
);
|
|
144
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useRef, useCallback, useContext } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Form,
|
|
4
|
+
RadioGroup,
|
|
5
|
+
RequiredValidator,
|
|
6
|
+
PrimaryButton,
|
|
7
|
+
LysaFormRef,
|
|
8
|
+
} from "@lysaab/ui-2";
|
|
9
|
+
import { PepType, PepContext, EntityType } from "./PepContext";
|
|
10
|
+
import { LABELS } from "../model/PepTexts";
|
|
11
|
+
|
|
12
|
+
interface QuestionsProps {
|
|
13
|
+
ownerName?: string;
|
|
14
|
+
legalEntityType?: EntityType;
|
|
15
|
+
type?: PepType;
|
|
16
|
+
onChange: (type: PepType) => void;
|
|
17
|
+
resetValues?: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const PepIsPepQuestions: React.FC<QuestionsProps> = ({
|
|
21
|
+
ownerName,
|
|
22
|
+
legalEntityType,
|
|
23
|
+
type,
|
|
24
|
+
onChange,
|
|
25
|
+
resetValues,
|
|
26
|
+
}) => {
|
|
27
|
+
const labels = LABELS(ownerName);
|
|
28
|
+
const entityType = legalEntityType || EntityType.PERSON;
|
|
29
|
+
|
|
30
|
+
const IsPepAlternatives = [
|
|
31
|
+
{
|
|
32
|
+
text: labels[entityType].GENERIC.IS_PEP[PepType.NOT_PEP],
|
|
33
|
+
value: PepType.NOT_PEP,
|
|
34
|
+
},
|
|
35
|
+
{ text: labels[entityType].GENERIC.IS_PEP[PepType.ME], value: PepType.ME },
|
|
36
|
+
{
|
|
37
|
+
text: labels[entityType].GENERIC.IS_PEP[PepType.RELATIVE],
|
|
38
|
+
value: PepType.RELATIVE,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
text: labels[entityType].GENERIC.IS_PEP[PepType.COLLEAGUE],
|
|
42
|
+
value: PepType.COLLEAGUE,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<RadioGroup
|
|
48
|
+
alternatives={IsPepAlternatives}
|
|
49
|
+
onChange={(alternative) => {
|
|
50
|
+
onChange(alternative.value);
|
|
51
|
+
resetValues?.();
|
|
52
|
+
}}
|
|
53
|
+
value={IsPepAlternatives.find((alt) => alt.value === type)}
|
|
54
|
+
header={labels[entityType].GENERIC.IS_PEP_HEADER}
|
|
55
|
+
validators={[new RequiredValidator("Du måste välja ett alternativ")]}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
interface Props {
|
|
61
|
+
next: () => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const PepIsPepPage: React.FC<Props> = ({ next }) => {
|
|
65
|
+
const pepContext = useContext(PepContext);
|
|
66
|
+
const formRef = useRef<LysaFormRef>();
|
|
67
|
+
|
|
68
|
+
const nextPage = useCallback(() => {
|
|
69
|
+
if (formRef.current && formRef.current.isValid) {
|
|
70
|
+
next();
|
|
71
|
+
}
|
|
72
|
+
}, [formRef, next]);
|
|
73
|
+
|
|
74
|
+
const resetValues = useCallback(() => {
|
|
75
|
+
pepContext.setState({
|
|
76
|
+
ambassadorCountry: undefined,
|
|
77
|
+
birthdayOfPEP: undefined,
|
|
78
|
+
businessRelation: undefined,
|
|
79
|
+
country: undefined,
|
|
80
|
+
ended: undefined,
|
|
81
|
+
governmentCompany: undefined,
|
|
82
|
+
governmentCompanyRole: undefined,
|
|
83
|
+
internationalOrganisation: undefined,
|
|
84
|
+
internationalOrganisationRole: undefined,
|
|
85
|
+
isOngoing: undefined,
|
|
86
|
+
isSweden: undefined,
|
|
87
|
+
militaryRank: undefined,
|
|
88
|
+
nameOfPEP: undefined,
|
|
89
|
+
relationToPEP: undefined,
|
|
90
|
+
role: undefined,
|
|
91
|
+
});
|
|
92
|
+
}, [pepContext]);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Form onSubmit={nextPage} lysaFormRef={formRef}>
|
|
96
|
+
<PepIsPepQuestions
|
|
97
|
+
ownerName={pepContext.state.ownerName}
|
|
98
|
+
legalEntityType={pepContext.state.legalEntityType}
|
|
99
|
+
type={pepContext.state.type}
|
|
100
|
+
onChange={(type) => pepContext.setState({ type })}
|
|
101
|
+
resetValues={resetValues}
|
|
102
|
+
/>
|
|
103
|
+
|
|
104
|
+
<PrimaryButton type="submit">Nästa</PrimaryButton>
|
|
105
|
+
</Form>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
} from "./PepContext";
|
|
14
|
+
import {
|
|
15
|
+
LysaFormRef,
|
|
16
|
+
RadioGroup,
|
|
17
|
+
Form,
|
|
18
|
+
Alternative,
|
|
19
|
+
RequiredValidator,
|
|
20
|
+
TextInput,
|
|
21
|
+
Datepicker,
|
|
22
|
+
PrimaryButton,
|
|
23
|
+
} from "@lysaab/ui-2";
|
|
24
|
+
import { LABELS } from "../model/PepTexts";
|
|
25
|
+
import { DateTime } from "luxon";
|
|
26
|
+
|
|
27
|
+
const DATEPICKER_START_DATE = DateTime.fromISO("1970-01-01").toJSDate();
|
|
28
|
+
|
|
29
|
+
interface Props {
|
|
30
|
+
next: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const PepRelationPage: FunctionComponent<Props> = ({ next }) => {
|
|
34
|
+
const pepContext = useContext(PepContext);
|
|
35
|
+
const formRef = useRef<LysaFormRef>();
|
|
36
|
+
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
37
|
+
const type = pepContext.state.type;
|
|
38
|
+
const labels = LABELS(pepContext.state.ownerName);
|
|
39
|
+
|
|
40
|
+
const businessRelationAlternatives: Alternative<BusinessRelation>[] = [
|
|
41
|
+
{
|
|
42
|
+
text:
|
|
43
|
+
labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
|
|
44
|
+
BusinessRelation.CO_OWNERSHIP
|
|
45
|
+
],
|
|
46
|
+
value: BusinessRelation.CO_OWNERSHIP,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
text:
|
|
50
|
+
labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
|
|
51
|
+
BusinessRelation.CLOSE_CONNECTION
|
|
52
|
+
],
|
|
53
|
+
value: BusinessRelation.CLOSE_CONNECTION,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
text:
|
|
57
|
+
labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
|
|
58
|
+
BusinessRelation.COMPANY_FOR_PEP
|
|
59
|
+
],
|
|
60
|
+
value: BusinessRelation.COMPANY_FOR_PEP,
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
const relationAlternatives: Alternative<Relation>[] = [
|
|
65
|
+
{
|
|
66
|
+
text:
|
|
67
|
+
labels[entityType][PepType.RELATIVE].RELATION[Relation.MARRIED_PARTNER],
|
|
68
|
+
value: Relation.MARRIED_PARTNER,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
text:
|
|
72
|
+
labels[entityType][PepType.RELATIVE].RELATION[
|
|
73
|
+
Relation.COLIVING_PARTNER
|
|
74
|
+
],
|
|
75
|
+
value: Relation.COLIVING_PARTNER,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
text: labels[entityType][PepType.RELATIVE].RELATION[Relation.CHILD],
|
|
79
|
+
value: Relation.CHILD,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
text: labels[entityType][PepType.RELATIVE].RELATION[Relation.PARENT],
|
|
83
|
+
value: Relation.PARENT,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
text:
|
|
87
|
+
labels[entityType][PepType.RELATIVE].RELATION[
|
|
88
|
+
Relation.CHILD_MARRIED_PARTNER
|
|
89
|
+
],
|
|
90
|
+
value: Relation.CHILD_MARRIED_PARTNER,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
text:
|
|
94
|
+
labels[entityType][PepType.RELATIVE].RELATION[
|
|
95
|
+
Relation.CHILD_COLIVING_PARTNER
|
|
96
|
+
],
|
|
97
|
+
value: Relation.CHILD_COLIVING_PARTNER,
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
const nextPage = useCallback(() => {
|
|
102
|
+
if (formRef.current && formRef.current.isValid) {
|
|
103
|
+
next();
|
|
104
|
+
}
|
|
105
|
+
}, [formRef, next]);
|
|
106
|
+
return (
|
|
107
|
+
<Form onSubmit={() => nextPage()} lysaFormRef={formRef}>
|
|
108
|
+
{type === PepType.RELATIVE ? (
|
|
109
|
+
<RadioGroup
|
|
110
|
+
alternatives={relationAlternatives}
|
|
111
|
+
onChange={alternative => {
|
|
112
|
+
pepContext.setState({
|
|
113
|
+
relationToPEP: alternative.value,
|
|
114
|
+
});
|
|
115
|
+
}}
|
|
116
|
+
value={relationAlternatives.find(
|
|
117
|
+
alt => alt.value === pepContext.state.relationToPEP
|
|
118
|
+
)}
|
|
119
|
+
header={labels[entityType][PepType.RELATIVE].RELATION_LABEL}
|
|
120
|
+
validators={[new RequiredValidator("Du måste välja ett alternativ")]}
|
|
121
|
+
/>
|
|
122
|
+
) : null}
|
|
123
|
+
{type === PepType.COLLEAGUE ? (
|
|
124
|
+
<RadioGroup
|
|
125
|
+
alternatives={businessRelationAlternatives}
|
|
126
|
+
onChange={alternative => {
|
|
127
|
+
pepContext.setState({
|
|
128
|
+
businessRelation: alternative.value,
|
|
129
|
+
});
|
|
130
|
+
}}
|
|
131
|
+
value={businessRelationAlternatives.find(
|
|
132
|
+
alt => alt.value === pepContext.state.businessRelation
|
|
133
|
+
)}
|
|
134
|
+
header={labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION_LABEL}
|
|
135
|
+
validators={[new RequiredValidator("Du måste välja ett alternativ")]}
|
|
136
|
+
/>
|
|
137
|
+
) : null}
|
|
138
|
+
{pepContext.state.relationToPEP && type === PepType.RELATIVE ? (
|
|
139
|
+
<React.Fragment>
|
|
140
|
+
<TextInput
|
|
141
|
+
label={
|
|
142
|
+
labels[entityType][type].NAME_LABEL[
|
|
143
|
+
pepContext.state.relationToPEP
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
value={pepContext.state.nameOfPEP || ""}
|
|
147
|
+
onChange={value => {
|
|
148
|
+
pepContext.setState({ nameOfPEP: value });
|
|
149
|
+
}}
|
|
150
|
+
validators={[new RequiredValidator("Du måste ange namn")]}
|
|
151
|
+
/>
|
|
152
|
+
<Datepicker
|
|
153
|
+
label={
|
|
154
|
+
labels[entityType][type].BIRTH_LABEL[
|
|
155
|
+
pepContext.state.relationToPEP
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
selected={pepContext.state.birthdayOfPEP}
|
|
159
|
+
onChange={event =>
|
|
160
|
+
pepContext.setState({ birthdayOfPEP: event || undefined })
|
|
161
|
+
}
|
|
162
|
+
validators={[new RequiredValidator("Ange datum")]}
|
|
163
|
+
maxDate={new Date()}
|
|
164
|
+
openToDate={pepContext.state.birthdayOfPEP || DATEPICKER_START_DATE}
|
|
165
|
+
/>
|
|
166
|
+
</React.Fragment>
|
|
167
|
+
) : null}
|
|
168
|
+
|
|
169
|
+
{pepContext.state.businessRelation && type === PepType.COLLEAGUE ? (
|
|
170
|
+
<React.Fragment>
|
|
171
|
+
<TextInput
|
|
172
|
+
label={
|
|
173
|
+
labels[entityType][type].NAME_LABEL[
|
|
174
|
+
pepContext.state.businessRelation
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
value={pepContext.state.nameOfPEP || ""}
|
|
178
|
+
onChange={value => {
|
|
179
|
+
pepContext.setState({ nameOfPEP: value });
|
|
180
|
+
}}
|
|
181
|
+
validators={[new RequiredValidator("Du måste ange namn")]}
|
|
182
|
+
/>
|
|
183
|
+
</React.Fragment>
|
|
184
|
+
) : null}
|
|
185
|
+
<PrimaryButton type="submit">Nästa</PrimaryButton>
|
|
186
|
+
</Form>
|
|
187
|
+
);
|
|
188
|
+
};
|