@lysaab/lysa-pep 1.0.2-0 → 1.0.3-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.
Files changed (59) hide show
  1. package/lib/Exports.d.ts +7 -7
  2. package/lib/Exports.js +7 -7
  3. package/lib/components/CountrySelect.d.ts +15 -15
  4. package/lib/components/CountrySelect.js +30 -30
  5. package/lib/components/PepAnswers.d.ts +8 -8
  6. package/lib/components/PepAnswers.js +131 -131
  7. package/lib/components/PepAnswers.scss +7 -7
  8. package/lib/model/Countries.d.ts +4 -4
  9. package/lib/model/Countries.js +1002 -1002
  10. package/lib/model/PepModel.d.ts +7 -7
  11. package/lib/model/PepModel.js +40 -40
  12. package/lib/model/PepTexts.d.ts +380 -322
  13. package/lib/model/PepTexts.js +552 -467
  14. package/lib/pages/IsPep/IsPepMessages.d.ts +32 -32
  15. package/lib/pages/IsPep/IsPepMessages.js +66 -66
  16. package/lib/pages/IsPep/IsPepPage.d.ts +14 -14
  17. package/lib/pages/IsPep/IsPepPage.js +59 -59
  18. package/lib/pages/PepContext.d.ts +80 -80
  19. package/lib/pages/PepContext.js +88 -88
  20. package/lib/pages/PepIsPepPage.d.ts +15 -6
  21. package/lib/pages/PepIsPepPage.js +59 -57
  22. package/lib/pages/PepRelationPage.d.ts +6 -6
  23. package/lib/pages/PepRelationPage.js +79 -83
  24. package/lib/pages/PepRolePage.d.ts +10 -9
  25. package/lib/pages/PepRolePage.js +127 -127
  26. package/lib/pages/PepStatusPage.d.ts +6 -6
  27. package/lib/pages/PepStatusPage.js +58 -57
  28. package/lib/pages/RelationPage/RelationMessages.d.ts +105 -105
  29. package/lib/pages/RelationPage/RelationMessages.js +283 -283
  30. package/lib/pages/RelationPage/RelationPage.d.ts +6 -6
  31. package/lib/pages/RelationPage/RelationPage.js +153 -153
  32. package/lib/pages/RolePage/RoleMessages.d.ts +185 -185
  33. package/lib/pages/RolePage/RoleMessages.js +385 -385
  34. package/lib/pages/RolePage/RolePage.d.ts +11 -11
  35. package/lib/pages/RolePage/RolePage.js +220 -220
  36. package/lib/pages/StatusPage/StatusMessages.d.ts +72 -72
  37. package/lib/pages/StatusPage/StatusMessages.js +266 -266
  38. package/lib/pages/StatusPage/StatusPage.d.ts +6 -6
  39. package/lib/pages/StatusPage/StatusPage.js +95 -95
  40. package/lib/utils/Possession.d.ts +1 -1
  41. package/lib/utils/Possession.js +18 -18
  42. package/package.json +57 -57
  43. package/src/Exports.ts +12 -12
  44. package/src/components/CountrySelect.tsx +47 -47
  45. package/src/components/PepAnswers.scss +7 -7
  46. package/src/components/PepAnswers.tsx +252 -252
  47. package/src/demo/Done.tsx +16 -16
  48. package/src/demo/Pep.tsx +112 -112
  49. package/src/model/PepModel.ts +52 -52
  50. package/src/pages/IsPep/IsPepMessages.ts +67 -67
  51. package/src/pages/IsPep/IsPepPage.tsx +115 -114
  52. package/src/pages/PepContext.tsx +144 -144
  53. package/src/pages/RelationPage/RelationMessages.ts +288 -288
  54. package/src/pages/RelationPage/RelationPage.tsx +299 -299
  55. package/src/pages/RolePage/RoleMessages.ts +393 -393
  56. package/src/pages/RolePage/RolePage.tsx +356 -356
  57. package/src/pages/StatusPage/StatusMessages.ts +272 -272
  58. package/src/pages/StatusPage/StatusPage.tsx +207 -207
  59. package/.vscode/settings.json +0 -4
@@ -1,114 +1,115 @@
1
- import React, {
2
- FunctionComponent,
3
- useRef,
4
- useCallback,
5
- useContext,
6
- } from "react";
7
- import {
8
- Form,
9
- RadioGroup,
10
- RequiredValidator,
11
- PrimaryButton,
12
- LysaFormRef,
13
- } from "@lysaab/ui-2";
14
- import { PepType, PepContext, EntityType } from "../PepContext";
15
- import { useIntl, FormattedMessage } from "react-intl";
16
- import { messages } from "./IsPepMessages";
17
-
18
- export interface ExternalIsPepState {
19
- ownerName: string;
20
- entityType: EntityType;
21
- type?: PepType;
22
- onChange: (type: PepType) => void;
23
- }
24
-
25
- interface Props {
26
- next?: () => void;
27
- }
28
-
29
- export const IsPepRadioGroup: FunctionComponent<ExternalIsPepState> = ({
30
- ownerName,
31
- entityType,
32
- type,
33
- onChange,
34
- }) => {
35
- const intl = useIntl();
36
-
37
- const IsPepAlternatives = [
38
- {
39
- text: intl.formatMessage(messages[PepType.NOT_PEP], {
40
- entityType,
41
- name: ownerName,
42
- }),
43
- value: PepType.NOT_PEP,
44
- },
45
- {
46
- text: intl.formatMessage(messages[PepType.ME], {
47
- entityType,
48
- name: ownerName,
49
- }),
50
- value: PepType.ME,
51
- },
52
- {
53
- text: intl.formatMessage(messages[PepType.RELATIVE], {
54
- entityType,
55
- name: ownerName,
56
- }),
57
- value: PepType.RELATIVE,
58
- },
59
- {
60
- text: intl.formatMessage(messages[PepType.COLLEAGUE], {
61
- entityType,
62
- name: ownerName,
63
- }),
64
- value: PepType.COLLEAGUE,
65
- },
66
- ];
67
-
68
- return (
69
- <RadioGroup
70
- alternatives={IsPepAlternatives}
71
- onChange={(alt) => onChange(alt.value)}
72
- value={IsPepAlternatives.find((alt) => alt.value === type)}
73
- header={intl.formatMessage(messages.header, {
74
- entityType,
75
- name: ownerName,
76
- })}
77
- validators={[
78
- new RequiredValidator(intl.formatMessage(messages.required)),
79
- ]}
80
- />
81
- );
82
- };
83
-
84
- export const IsPepPage: FunctionComponent<Props> = ({ next }) => {
85
- const pepContext = useContext(PepContext);
86
- const formRef = useRef<LysaFormRef>();
87
-
88
- const nextPage = useCallback(() => {
89
- if (formRef.current && formRef.current.isValid && next) {
90
- next();
91
- }
92
- }, [formRef, next]);
93
-
94
- return (
95
- <Form onSubmit={nextPage} lysaFormRef={formRef}>
96
- <IsPepRadioGroup
97
- entityType={pepContext.state.legalEntityType || EntityType.PERSON}
98
- ownerName={pepContext.state.ownerName || ""}
99
- type={pepContext.state.type}
100
- onChange={(type) => {
101
- pepContext.setState({ type });
102
- }}
103
- />
104
-
105
- <PrimaryButton type="submit">
106
- <FormattedMessage
107
- id="pep.ispep.next"
108
- description="Next button"
109
- defaultMessage="Gå vidare"
110
- />
111
- </PrimaryButton>
112
- </Form>
113
- );
114
- };
1
+ import React, {
2
+ FunctionComponent,
3
+ useRef,
4
+ useCallback,
5
+ useContext,
6
+ } from "react";
7
+ import {
8
+ Form,
9
+ RadioGroup,
10
+ RequiredValidator,
11
+ PrimaryButton,
12
+ LysaFormRef,
13
+ } from "@lysaab/ui-2";
14
+ import { PepType, PepContext, EntityType } from "../PepContext";
15
+ import { useIntl, FormattedMessage } from "react-intl";
16
+ import { messages } from "./IsPepMessages";
17
+
18
+ export interface ExternalIsPepState {
19
+ ownerName: string;
20
+ entityType: EntityType;
21
+ type?: PepType;
22
+ onChange: (type: PepType) => void;
23
+ }
24
+
25
+ interface Props {
26
+ next?: () => void;
27
+ }
28
+
29
+ export const IsPepRadioGroup: FunctionComponent<ExternalIsPepState> = ({
30
+ ownerName,
31
+ entityType,
32
+ type,
33
+ onChange,
34
+ }) => {
35
+ const intl = useIntl();
36
+
37
+ const IsPepAlternatives = [
38
+ {
39
+ text: intl.formatMessage(messages[PepType.NOT_PEP], {
40
+ entityType,
41
+ name: ownerName,
42
+ }),
43
+ value: PepType.NOT_PEP,
44
+ },
45
+ {
46
+ text: intl.formatMessage(messages[PepType.ME], {
47
+ entityType,
48
+ name: ownerName,
49
+ }),
50
+ value: PepType.ME,
51
+ },
52
+ {
53
+ text: intl.formatMessage(messages[PepType.RELATIVE], {
54
+ entityType,
55
+ name: ownerName,
56
+ }),
57
+ value: PepType.RELATIVE,
58
+ },
59
+ {
60
+ text: intl.formatMessage(messages[PepType.COLLEAGUE], {
61
+ entityType,
62
+ name: ownerName,
63
+ }),
64
+ value: PepType.COLLEAGUE,
65
+ },
66
+ ];
67
+
68
+ return (
69
+ <RadioGroup
70
+ alternatives={IsPepAlternatives}
71
+ onChange={(alt) => onChange(alt.value)}
72
+ value={IsPepAlternatives.find((alt) => alt.value === type)}
73
+ header={intl.formatMessage(messages.header, {
74
+ entityType,
75
+ name: ownerName,
76
+ })}
77
+ validators={[
78
+ new RequiredValidator(intl.formatMessage(messages.required)),
79
+ ]}
80
+ data-test-id="pep-ispep"
81
+ />
82
+ );
83
+ };
84
+
85
+ export const IsPepPage: FunctionComponent<Props> = ({ next }) => {
86
+ const pepContext = useContext(PepContext);
87
+ const formRef = useRef<LysaFormRef>();
88
+
89
+ const nextPage = useCallback(() => {
90
+ if (formRef.current && formRef.current.isValid && next) {
91
+ next();
92
+ }
93
+ }, [formRef, next]);
94
+
95
+ return (
96
+ <Form onSubmit={nextPage} lysaFormRef={formRef}>
97
+ <IsPepRadioGroup
98
+ entityType={pepContext.state.legalEntityType || EntityType.PERSON}
99
+ ownerName={pepContext.state.ownerName || ""}
100
+ type={pepContext.state.type}
101
+ onChange={(type) => {
102
+ pepContext.setState({ type });
103
+ }}
104
+ />
105
+
106
+ <PrimaryButton type="submit">
107
+ <FormattedMessage
108
+ id="pep.ispep.next"
109
+ description="Next button"
110
+ defaultMessage="Gå vidare"
111
+ />
112
+ </PrimaryButton>
113
+ </Form>
114
+ );
115
+ };
@@ -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
+ };