@lysaab/lysa-pep 0.14.2 → 0.15.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 +1 -1
- package/lib/Exports.js +1 -1
- package/lib/pages/PepContext.d.ts +3 -2
- package/lib/pages/PepContext.js +21 -0
- package/lib/pages/PepIsPepPage.d.ts +9 -1
- package/lib/pages/PepIsPepPage.js +15 -9
- package/package.json +1 -1
- package/src/Exports.ts +1 -2
- package/src/model/PepModel.ts +2 -2
- package/src/pages/PepContext.tsx +32 -9
- package/src/pages/PepIsPepPage.tsx +24 -10
package/lib/Exports.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./pages/PepContext";
|
|
2
2
|
export * from "./model/PepModel";
|
|
3
3
|
export * from "./model/PepTexts";
|
|
4
|
-
export
|
|
4
|
+
export * from "./pages/PepIsPepPage";
|
|
5
5
|
export { PepRelationPage } from "./pages/PepRelationPage";
|
|
6
6
|
export { PepRolePage, militaryAlternatives, roleAlternatives } from "./pages/PepRolePage";
|
|
7
7
|
export { PepStatusPage } from "./pages/PepStatusPage";
|
package/lib/Exports.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./pages/PepContext";
|
|
2
2
|
export * from "./model/PepModel";
|
|
3
3
|
export * from "./model/PepTexts";
|
|
4
|
-
export
|
|
4
|
+
export * from "./pages/PepIsPepPage";
|
|
5
5
|
export { PepRelationPage } from "./pages/PepRelationPage";
|
|
6
6
|
export { PepRolePage, militaryAlternatives, roleAlternatives } from "./pages/PepRolePage";
|
|
7
7
|
export { PepStatusPage } from "./pages/PepStatusPage";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
export declare enum EntityType {
|
|
3
3
|
PERSON = "PERSON",
|
|
4
4
|
CORPORATION = "CORPORATION"
|
|
@@ -70,10 +70,11 @@ export interface PepState {
|
|
|
70
70
|
isSweden?: string;
|
|
71
71
|
ownerName?: string;
|
|
72
72
|
}
|
|
73
|
+
export declare const EMPTY_PEP_STATE: PepState;
|
|
73
74
|
export interface PepContextProps {
|
|
74
75
|
state: PepState;
|
|
75
76
|
setState: (newState: Partial<PepState>) => void;
|
|
76
77
|
}
|
|
77
78
|
export declare const PepContext: React.Context<PepContextProps>;
|
|
78
79
|
export declare const withPep: <P extends object>(Component: React.ComponentType<P>) => React.FC<Pick<P, Exclude<keyof P, "state" | "setState">>>;
|
|
79
|
-
export declare const PepContextProvider:
|
|
80
|
+
export declare const PepContextProvider: React.FC;
|
package/lib/pages/PepContext.js
CHANGED
|
@@ -56,6 +56,27 @@ export var MilitaryRank;
|
|
|
56
56
|
MilitaryRank["VICE_ADMIRAL"] = "VICE_ADMIRAL";
|
|
57
57
|
MilitaryRank["REAR_ADMIRAL"] = "REAR_ADMIRAL";
|
|
58
58
|
})(MilitaryRank || (MilitaryRank = {}));
|
|
59
|
+
export const EMPTY_PEP_STATE = {
|
|
60
|
+
legalEntityType: undefined,
|
|
61
|
+
type: undefined,
|
|
62
|
+
role: undefined,
|
|
63
|
+
country: undefined,
|
|
64
|
+
ended: undefined,
|
|
65
|
+
ambassadorCountry: undefined,
|
|
66
|
+
militaryRank: undefined,
|
|
67
|
+
governmentCompany: undefined,
|
|
68
|
+
governmentCompanyRole: undefined,
|
|
69
|
+
internationalOrganisation: undefined,
|
|
70
|
+
internationalOrganisationRole: undefined,
|
|
71
|
+
relationToPEP: undefined,
|
|
72
|
+
nameOfPEP: undefined,
|
|
73
|
+
birthdayOfPEP: undefined,
|
|
74
|
+
tin: undefined,
|
|
75
|
+
businessRelation: undefined,
|
|
76
|
+
isOngoing: undefined,
|
|
77
|
+
isSweden: undefined,
|
|
78
|
+
ownerName: undefined,
|
|
79
|
+
};
|
|
59
80
|
export const PepContext = React.createContext({});
|
|
60
81
|
export const withPep = (Component) => props => (React.createElement(PepContext.Consumer, null, contextProps => React.createElement(Component, Object.assign({}, props, contextProps))));
|
|
61
82
|
function stateReducer(state, newState) {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { FunctionComponent } from "react";
|
|
2
|
+
import { PepType, EntityType } from "./PepContext";
|
|
3
|
+
export interface ExternalIsPepState {
|
|
4
|
+
ownerName: string;
|
|
5
|
+
entityType: EntityType;
|
|
6
|
+
type?: PepType;
|
|
7
|
+
onChange: (type: PepType) => void;
|
|
8
|
+
}
|
|
2
9
|
interface Props {
|
|
3
|
-
next
|
|
10
|
+
next?: () => void;
|
|
11
|
+
external?: ExternalIsPepState;
|
|
4
12
|
}
|
|
5
13
|
export declare const PepIsPepPage: FunctionComponent<Props>;
|
|
6
14
|
export {};
|
|
@@ -2,11 +2,12 @@ import React, { useRef, useCallback, useContext, } from "react";
|
|
|
2
2
|
import { Form, RadioGroup, RequiredValidator, PrimaryButton, } from "@lysaab/ui-2";
|
|
3
3
|
import { PepType, PepContext, EntityType } from "./PepContext";
|
|
4
4
|
import { LABELS } from "../model/PepTexts";
|
|
5
|
-
export const PepIsPepPage = ({ next }) => {
|
|
5
|
+
export const PepIsPepPage = ({ next, external }) => {
|
|
6
|
+
var _a, _b;
|
|
6
7
|
const pepContext = useContext(PepContext);
|
|
7
8
|
const formRef = useRef();
|
|
8
|
-
const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
|
|
9
|
-
const labels = LABELS(pepContext.state.ownerName);
|
|
9
|
+
const entityType = ((_a = external) === null || _a === void 0 ? void 0 : _a.entityType) || pepContext.state.legalEntityType || EntityType.PERSON;
|
|
10
|
+
const labels = LABELS(((_b = external) === null || _b === void 0 ? void 0 : _b.ownerName) || pepContext.state.ownerName);
|
|
10
11
|
const IsPepAlternatives = [
|
|
11
12
|
{
|
|
12
13
|
text: labels[entityType].GENERIC.IS_PEP[PepType.NOT_PEP],
|
|
@@ -23,7 +24,7 @@ export const PepIsPepPage = ({ next }) => {
|
|
|
23
24
|
},
|
|
24
25
|
];
|
|
25
26
|
const nextPage = useCallback(() => {
|
|
26
|
-
if (formRef.current && formRef.current.isValid) {
|
|
27
|
+
if (formRef.current && formRef.current.isValid && next) {
|
|
27
28
|
next();
|
|
28
29
|
}
|
|
29
30
|
}, [formRef, next]);
|
|
@@ -46,10 +47,15 @@ export const PepIsPepPage = ({ next }) => {
|
|
|
46
47
|
role: undefined,
|
|
47
48
|
});
|
|
48
49
|
}, [pepContext]);
|
|
49
|
-
return (React.createElement(Form, { onSubmit:
|
|
50
|
+
return (React.createElement(Form, { onSubmit: nextPage, lysaFormRef: formRef },
|
|
50
51
|
React.createElement(RadioGroup, { alternatives: IsPepAlternatives, onChange: alternative => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (external) {
|
|
53
|
+
external.onChange(alternative.value);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
pepContext.setState({ type: alternative.value });
|
|
57
|
+
resetValues();
|
|
58
|
+
}
|
|
59
|
+
}, value: IsPepAlternatives.find(alt => { var _a; return alt.value === (((_a = external) === null || _a === void 0 ? void 0 : _a.type) || pepContext.state.type); }), header: labels[entityType].GENERIC.IS_PEP_HEADER, validators: [RequiredValidator("Du måste välja ett alternativ")] }),
|
|
60
|
+
next && React.createElement(PrimaryButton, { type: "submit" }, "N\u00E4sta")));
|
|
55
61
|
};
|
package/package.json
CHANGED
package/src/Exports.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from "./pages/PepContext";
|
|
2
2
|
export * from "./model/PepModel";
|
|
3
3
|
export * from "./model/PepTexts";
|
|
4
|
-
|
|
5
|
-
export { PepIsPepPage } from "./pages/PepIsPepPage";
|
|
4
|
+
export * from "./pages/PepIsPepPage";
|
|
6
5
|
export { PepRelationPage } from "./pages/PepRelationPage";
|
|
7
6
|
export {
|
|
8
7
|
PepRolePage,
|
package/src/model/PepModel.ts
CHANGED
|
@@ -8,8 +8,8 @@ export interface PepRequest
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Do some minor preprocessing before we are ready to send everything to the
|
|
12
|
+
* server
|
|
13
13
|
*/
|
|
14
14
|
export function stateToRequest(pepData: PepState): PepRequest {
|
|
15
15
|
const data = { ...pepData };
|
package/src/pages/PepContext.tsx
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useReducer } from "react";
|
|
2
2
|
|
|
3
3
|
export enum EntityType {
|
|
4
4
|
PERSON = "PERSON",
|
|
5
|
-
CORPORATION = "CORPORATION"
|
|
5
|
+
CORPORATION = "CORPORATION",
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export enum PepType {
|
|
9
9
|
NOT_PEP = "NOT_PEP",
|
|
10
10
|
ME = "ME",
|
|
11
11
|
RELATIVE = "RELATIVE",
|
|
12
|
-
COLLEAGUE = "COLLEAGUE"
|
|
12
|
+
COLLEAGUE = "COLLEAGUE",
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export enum PepStatus {
|
|
16
16
|
ONGOING = "ONGOING",
|
|
17
|
-
ENDED = "ENDED"
|
|
17
|
+
ENDED = "ENDED",
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export enum Role {
|
|
@@ -30,7 +30,7 @@ export enum Role {
|
|
|
30
30
|
MILITARY_OFFICER = "MILITARY_OFFICER",
|
|
31
31
|
GOVERNMENT_COMPANY = "GOVERNMENT_COMPANY",
|
|
32
32
|
EU_HIGH_RANKING_POSITION = "EU_HIGH_RANKING_POSITION",
|
|
33
|
-
HIGH_RANKING_POSITION_INTERNALTIONAL_CORP = "HIGH_RANKING_POSITION_INTERNALTIONAL_CORP"
|
|
33
|
+
HIGH_RANKING_POSITION_INTERNALTIONAL_CORP = "HIGH_RANKING_POSITION_INTERNALTIONAL_CORP",
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export enum Relation {
|
|
@@ -39,13 +39,13 @@ export enum Relation {
|
|
|
39
39
|
CHILD = "CHILD",
|
|
40
40
|
PARENT = "PARENT",
|
|
41
41
|
CHILD_MARRIED_PARTNER = "CHILD_MARRIED_PARTNER",
|
|
42
|
-
CHILD_COLIVING_PARTNER = "CHILD_COLIVING_PARTNER"
|
|
42
|
+
CHILD_COLIVING_PARTNER = "CHILD_COLIVING_PARTNER",
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export enum BusinessRelation {
|
|
46
46
|
CO_OWNERSHIP = "CO_OWNERSHIP",
|
|
47
47
|
CLOSE_CONNECTION = "CLOSE_CONNECTION",
|
|
48
|
-
COMPANY_FOR_PEP = "COMPANY_FOR_PEP"
|
|
48
|
+
COMPANY_FOR_PEP = "COMPANY_FOR_PEP",
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export enum MilitaryRank {
|
|
@@ -54,7 +54,7 @@ export enum MilitaryRank {
|
|
|
54
54
|
MAJOR_GENERAL = "MAJOR_GENERAL",
|
|
55
55
|
ADMIRAL = "ADMIRAL",
|
|
56
56
|
VICE_ADMIRAL = "VICE_ADMIRAL",
|
|
57
|
-
REAR_ADMIRAL = "REAR_ADMIRAL"
|
|
57
|
+
REAR_ADMIRAL = "REAR_ADMIRAL",
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Types for the state
|
|
@@ -81,6 +81,29 @@ export interface PepState {
|
|
|
81
81
|
ownerName?: string;
|
|
82
82
|
}
|
|
83
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
|
+
|
|
84
107
|
// All types for the context. This includes setter methods
|
|
85
108
|
export interface PepContextProps {
|
|
86
109
|
state: PepState;
|
|
@@ -110,7 +133,7 @@ function stateReducer(state: PepState, newState: Partial<PepState>) {
|
|
|
110
133
|
return { ...state, ...newState };
|
|
111
134
|
}
|
|
112
135
|
|
|
113
|
-
export const PepContextProvider:
|
|
136
|
+
export const PepContextProvider: React.FC = ({ children }) => {
|
|
114
137
|
const [pep, setPep] = useReducer(stateReducer, {});
|
|
115
138
|
|
|
116
139
|
return (
|
|
@@ -14,14 +14,24 @@ import {
|
|
|
14
14
|
import { PepType, PepContext, EntityType } from "./PepContext";
|
|
15
15
|
import { LABELS } from "../model/PepTexts";
|
|
16
16
|
|
|
17
|
+
export interface ExternalIsPepState {
|
|
18
|
+
ownerName: string;
|
|
19
|
+
entityType: EntityType;
|
|
20
|
+
type?: PepType;
|
|
21
|
+
onChange: (type: PepType) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
interface Props {
|
|
18
|
-
next
|
|
25
|
+
next?: () => void;
|
|
26
|
+
external?: ExternalIsPepState;
|
|
19
27
|
}
|
|
20
|
-
|
|
28
|
+
|
|
29
|
+
export const PepIsPepPage: FunctionComponent<Props> = ({ next, external }) => {
|
|
21
30
|
const pepContext = useContext(PepContext);
|
|
22
31
|
const formRef = useRef<LysaFormRef>();
|
|
23
|
-
const entityType =
|
|
24
|
-
|
|
32
|
+
const entityType =
|
|
33
|
+
external?.entityType || pepContext.state.legalEntityType || EntityType.PERSON;
|
|
34
|
+
const labels = LABELS(external?.ownerName || pepContext.state.ownerName);
|
|
25
35
|
|
|
26
36
|
const IsPepAlternatives = [
|
|
27
37
|
{
|
|
@@ -40,7 +50,7 @@ export const PepIsPepPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
40
50
|
];
|
|
41
51
|
|
|
42
52
|
const nextPage = useCallback(() => {
|
|
43
|
-
if (formRef.current && formRef.current.isValid) {
|
|
53
|
+
if (formRef.current && formRef.current.isValid && next) {
|
|
44
54
|
next();
|
|
45
55
|
}
|
|
46
56
|
}, [formRef, next]);
|
|
@@ -66,21 +76,25 @@ export const PepIsPepPage: FunctionComponent<Props> = ({ next }) => {
|
|
|
66
76
|
}, [pepContext]);
|
|
67
77
|
|
|
68
78
|
return (
|
|
69
|
-
<Form onSubmit={
|
|
79
|
+
<Form onSubmit={nextPage} lysaFormRef={formRef}>
|
|
70
80
|
<RadioGroup
|
|
71
81
|
alternatives={IsPepAlternatives}
|
|
72
82
|
onChange={alternative => {
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
if (external) {
|
|
84
|
+
external.onChange(alternative.value);
|
|
85
|
+
} else {
|
|
86
|
+
pepContext.setState({ type: alternative.value });
|
|
87
|
+
resetValues();
|
|
88
|
+
}
|
|
75
89
|
}}
|
|
76
90
|
value={IsPepAlternatives.find(
|
|
77
|
-
alt => alt.value === pepContext.state.type
|
|
91
|
+
alt => alt.value === (external?.type || pepContext.state.type)
|
|
78
92
|
)}
|
|
79
93
|
header={labels[entityType].GENERIC.IS_PEP_HEADER}
|
|
80
94
|
validators={[RequiredValidator("Du måste välja ett alternativ")]}
|
|
81
95
|
/>
|
|
82
96
|
|
|
83
|
-
<PrimaryButton type="submit">Nästa</PrimaryButton>
|
|
97
|
+
{next && <PrimaryButton type="submit">Nästa</PrimaryButton>}
|
|
84
98
|
</Form>
|
|
85
99
|
);
|
|
86
100
|
};
|