@lysaab/lysa-pep 1.0.0-0 → 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.
Files changed (78) hide show
  1. package/README.md +0 -0
  2. package/lib/Exports.d.ts +8 -7
  3. package/lib/Exports.js +8 -7
  4. package/lib/components/CountrySelect.d.ts +22 -15
  5. package/lib/components/CountrySelect.js +21 -30
  6. package/lib/components/PepAnswers.d.ts +8 -8
  7. package/lib/components/PepAnswers.js +39 -131
  8. package/lib/components/PepAnswers.scss +0 -0
  9. package/lib/model/Countries.d.ts +4 -4
  10. package/lib/model/Countries.js +1002 -1002
  11. package/lib/model/PepModel.d.ts +7 -7
  12. package/lib/model/PepModel.js +40 -40
  13. package/lib/model/PepTexts.d.ts +380 -0
  14. package/lib/model/PepTexts.js +552 -0
  15. package/lib/pages/PepContext.d.ts +80 -80
  16. package/lib/pages/PepContext.js +88 -88
  17. package/lib/pages/PepIsPepPage.d.ts +15 -0
  18. package/lib/pages/PepIsPepPage.js +59 -0
  19. package/lib/pages/{StatusPage/StatusPage.d.ts → PepRelationPage.d.ts} +6 -6
  20. package/lib/pages/PepRelationPage.js +79 -0
  21. package/lib/pages/PepRolePage.d.ts +10 -0
  22. package/lib/pages/PepRolePage.js +127 -0
  23. package/lib/pages/{RelationPage/RelationPage.d.ts → PepStatusPage.d.ts} +6 -6
  24. package/lib/pages/PepStatusPage.js +58 -0
  25. package/package.json +10 -13
  26. package/public/favicon.ico +0 -0
  27. package/public/index.html +0 -0
  28. package/public/logo192.png +0 -0
  29. package/public/logo512.png +0 -0
  30. package/public/manifest.json +0 -0
  31. package/public/robots.txt +0 -0
  32. package/src/App.css +0 -0
  33. package/src/App.test.tsx +0 -0
  34. package/src/App.tsx +0 -0
  35. package/src/Exports.ts +8 -7
  36. package/src/components/CountrySelect.tsx +10 -14
  37. package/src/components/PepAnswers.scss +0 -0
  38. package/src/components/PepAnswers.tsx +34 -166
  39. package/src/demo/Done.tsx +6 -2
  40. package/src/demo/Pep.tsx +81 -87
  41. package/src/index.css +0 -0
  42. package/src/index.tsx +0 -0
  43. package/src/logo.svg +0 -0
  44. package/src/model/Countries.ts +0 -0
  45. package/src/model/PepModel.ts +0 -0
  46. package/src/model/PepTexts.ts +607 -0
  47. package/src/pages/PepContext.tsx +0 -0
  48. package/src/pages/PepIsPepPage.tsx +107 -0
  49. package/src/pages/PepRelationPage.tsx +188 -0
  50. package/src/pages/PepRolePage.tsx +272 -0
  51. package/src/pages/PepStatusPage.tsx +157 -0
  52. package/src/react-app-env.d.ts +0 -0
  53. package/src/serviceWorker.ts +0 -0
  54. package/tsconfig.json +0 -0
  55. package/tsconfig_build.json +0 -0
  56. package/.vscode/settings.json +0 -3
  57. package/lib/pages/IsPep/IsPepMessages.d.ts +0 -32
  58. package/lib/pages/IsPep/IsPepMessages.js +0 -74
  59. package/lib/pages/IsPep/IsPepPage.d.ts +0 -14
  60. package/lib/pages/IsPep/IsPepPage.js +0 -39
  61. package/lib/pages/RelationPage/RelationMessages.d.ts +0 -105
  62. package/lib/pages/RelationPage/RelationMessages.js +0 -282
  63. package/lib/pages/RelationPage/RelationPage.js +0 -142
  64. package/lib/pages/RolePage/RoleMessages.d.ts +0 -185
  65. package/lib/pages/RolePage/RoleMessages.js +0 -381
  66. package/lib/pages/RolePage/RolePage.d.ts +0 -11
  67. package/lib/pages/RolePage/RolePage.js +0 -214
  68. package/lib/pages/StatusPage/StatusMessages.d.ts +0 -72
  69. package/lib/pages/StatusPage/StatusMessages.js +0 -74
  70. package/lib/pages/StatusPage/StatusPage.js +0 -75
  71. package/src/pages/IsPep/IsPepMessages.ts +0 -75
  72. package/src/pages/IsPep/IsPepPage.tsx +0 -94
  73. package/src/pages/RelationPage/RelationMessages.ts +0 -287
  74. package/src/pages/RelationPage/RelationPage.tsx +0 -269
  75. package/src/pages/RolePage/RoleMessages.ts +0 -389
  76. package/src/pages/RolePage/RolePage.tsx +0 -342
  77. package/src/pages/StatusPage/StatusMessages.ts +0 -80
  78. package/src/pages/StatusPage/StatusPage.tsx +0 -172
@@ -0,0 +1,157 @@
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
+ Datepicker,
14
+ } from "@lysaab/ui-2";
15
+ import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
16
+ import { PepContext, PepStatus, EntityType, PepType } from "./PepContext";
17
+ import { CountrySelect } from "../components/CountrySelect";
18
+ import {
19
+ LABELS,
20
+ getStatusOngoingHeader,
21
+ getStatusCountryHeader,
22
+ } from "../model/PepTexts";
23
+
24
+ const stateAlternatives: Alternative<PepStatus>[] = [
25
+ {
26
+ text: "Pågående",
27
+ value: PepStatus.ONGOING,
28
+ },
29
+ {
30
+ text: "Avslutad",
31
+ value: PepStatus.ENDED,
32
+ },
33
+ ];
34
+
35
+ const isSwedenAlternatives: Alternative<string>[] = [
36
+ { text: "Sverige", value: "sweden" },
37
+ { text: "Annat", value: "other" },
38
+ ];
39
+
40
+ interface Props {
41
+ next: () => void;
42
+ }
43
+
44
+ export const PepStatusPage: FunctionComponent<Props> = ({ next }) => {
45
+ const pepContext = useContext(PepContext);
46
+ const formRef = useRef<LysaFormRef>();
47
+
48
+ const nextPage = useCallback(() => {
49
+ if (formRef.current && formRef.current.isValid) {
50
+ next();
51
+ }
52
+ }, [formRef, next]);
53
+
54
+ const updateIsSweden = useCallback(
55
+ (alternative: Alternative<string>) => {
56
+ pepContext.setState({ isSweden: alternative.value });
57
+
58
+ if (alternative.value === "other") {
59
+ pepContext.setState({ country: undefined });
60
+ }
61
+ },
62
+ [pepContext]
63
+ );
64
+
65
+ const updateIsOngoing = useCallback(
66
+ (alternative: Alternative<PepStatus>) => {
67
+ pepContext.setState({ isOngoing: alternative.value });
68
+
69
+ if (alternative.value === PepStatus.ONGOING) {
70
+ pepContext.setState({ ended: undefined });
71
+ }
72
+ },
73
+ [pepContext]
74
+ );
75
+
76
+ const labels = LABELS(pepContext.state.ownerName);
77
+ const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
78
+ const type = pepContext.state.type;
79
+
80
+ if (!type || type === PepType.NOT_PEP) {
81
+ return null;
82
+ }
83
+
84
+ return (
85
+ <div>
86
+ <Form
87
+ lysaFormRef={formRef}
88
+ onSubmit={() => {
89
+ nextPage();
90
+ }}
91
+ >
92
+ <RadioGroup
93
+ alternatives={stateAlternatives}
94
+ header={getStatusOngoingHeader(
95
+ entityType,
96
+ type,
97
+ pepContext.state.relationToPEP,
98
+ pepContext.state.businessRelation,
99
+ pepContext.state.ownerName
100
+ )}
101
+ onChange={updateIsOngoing}
102
+ value={stateAlternatives.find(
103
+ (alt) => alt.value === pepContext.state.isOngoing
104
+ )}
105
+ validators={[new RequiredValidator("Du måste välja ett alternativ")]}
106
+ />
107
+
108
+ {pepContext.state.isOngoing &&
109
+ pepContext.state.isOngoing === PepStatus.ENDED ? (
110
+ <Datepicker
111
+ label="När avslutades uppdraget?"
112
+ selected={pepContext.state.ended}
113
+ onChange={(event) =>
114
+ pepContext.setState({ ended: event || undefined })
115
+ }
116
+ validators={[new RequiredValidator("Du måste ange datum")]}
117
+ showMonthYearPicker
118
+ dateFormat="yyyy-MM"
119
+ maxDate={new Date()}
120
+ />
121
+ ) : null}
122
+
123
+ <RadioGroup
124
+ alternatives={isSwedenAlternatives}
125
+ header={getStatusCountryHeader(
126
+ entityType,
127
+ type,
128
+ pepContext.state.relationToPEP,
129
+ pepContext.state.businessRelation,
130
+ pepContext.state.ownerName
131
+ )}
132
+ onChange={updateIsSweden}
133
+ value={isSwedenAlternatives.find(
134
+ (alt) => alt.value === pepContext.state.isSweden
135
+ )}
136
+ validators={[new RequiredValidator("Du måste välja ett alternativ")]}
137
+ />
138
+
139
+ {pepContext.state.isSweden && pepContext.state.isSweden === "other" ? (
140
+ <CountrySelect
141
+ label="Välj i vilket land befattningen är"
142
+ onChange={(event) =>
143
+ pepContext.setState({
144
+ country: event.value ? event.value.toString() : undefined,
145
+ })
146
+ }
147
+ validators={[new RequiredValidator("Du måste välja land")]}
148
+ value={pepContext.state.country}
149
+ removeSweden={true}
150
+ />
151
+ ) : null}
152
+
153
+ <PrimaryButton type="submit">Nästa</PrimaryButton>
154
+ </Form>
155
+ </div>
156
+ );
157
+ };
File without changes
File without changes
package/tsconfig.json CHANGED
File without changes
File without changes
@@ -1,3 +0,0 @@
1
- {
2
- "i18n-ally.localesPaths": []
3
- }
@@ -1,32 +0,0 @@
1
- export declare const messages: {
2
- header: {
3
- id: string;
4
- description: string;
5
- defaultMessage: string;
6
- };
7
- required: {
8
- id: string;
9
- description: string;
10
- defaultMessage: string;
11
- };
12
- NOT_PEP: {
13
- id: string;
14
- description: string;
15
- defaultMessage: string;
16
- };
17
- ME: {
18
- id: string;
19
- description: string;
20
- defaultMessage: string;
21
- };
22
- RELATIVE: {
23
- id: string;
24
- description: string;
25
- defaultMessage: string;
26
- };
27
- COLLEAGUE: {
28
- id: string;
29
- description: string;
30
- defaultMessage: string;
31
- };
32
- };
@@ -1,74 +0,0 @@
1
- import { defineMessages } from "react-intl";
2
- import { PepType } from "../PepContext";
3
- export const messages = defineMessages({
4
- header: {
5
- id: 'pep.ispep.header',
6
- description: 'Not pep',
7
- defaultMessage: `{
8
- entityType, select,
9
- PERSON {
10
- Är du eller en närstående till dig en person i politisk utsatt ställning? (PEP)
11
- }
12
- CORPORATION {
13
- Är {name} eller en närstående till {name} en person i politisk utsatt ställning? (PEP)
14
- }
15
- }`
16
- },
17
- required: {
18
- id: 'pep.ispep.header',
19
- description: 'Not pep',
20
- defaultMessage: `{
21
- entityType, select,
22
- PERSON {
23
- Är du eller en närstående till dig en person i politisk utsatt ställning? (PEP)
24
- }
25
- CORPORATION {
26
- Är {name} eller en närstående till {name} en person i politisk utsatt ställning? (PEP)
27
- }
28
- }`
29
- },
30
- [PepType.NOT_PEP]: {
31
- id: 'pep.ispep.NOT_PEP',
32
- description: 'Not pep',
33
- defaultMessage: 'Nej'
34
- },
35
- [PepType.ME]: {
36
- id: 'pep.ispep.ME',
37
- description: 'The person is pep',
38
- defaultMessage: `{
39
- entityType, select,
40
- PERSON {
41
- Jag har en funktion som gör mig till PEP
42
- }
43
- CORPORATION {
44
- På grund av sin funktion är {name} PEP
45
- }
46
- }`
47
- },
48
- [PepType.RELATIVE]: {
49
- id: 'pep.ispep.RELATIVE',
50
- description: 'Jag har en relation med en person som är PEP',
51
- defaultMessage: `{
52
- entityType, select,
53
- PERSON {
54
- Jag har en relation med en person som är PEP
55
- }
56
- CORPORATION {
57
- {name} är medarbetare till, eller har en affärsrelation med, en person som är PEP
58
- }
59
- }`
60
- },
61
- [PepType.COLLEAGUE]: {
62
- id: 'pep.ispep.COLLEAGUE',
63
- description: 'The person has a colleague that is pep',
64
- defaultMessage: `{
65
- entityType, select,
66
- PERSON {
67
- Jag är medarbetare till, eller har en affärsrelation med, en person som är PEP
68
- }
69
- CORPORATION {
70
- På grund av sin funktion är {name} PEP
71
- }
72
- }`
73
- },
74
- });
@@ -1,14 +0,0 @@
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
- }
9
- interface Props {
10
- next?: () => void;
11
- }
12
- export declare const IsPepRadioGroup: FunctionComponent<ExternalIsPepState>;
13
- export declare const IsPepPage: FunctionComponent<Props>;
14
- export {};
@@ -1,39 +0,0 @@
1
- import React, { useRef, useCallback, useContext } from "react";
2
- import { Form, RadioGroup, RequiredValidator, PrimaryButton } from "@lysaab/ui-2";
3
- import { PepType, PepContext, EntityType } from "../PepContext";
4
- import { useIntl, FormattedMessage } from "react-intl";
5
- import { messages } from "./IsPepMessages";
6
- export const IsPepRadioGroup = ({ ownerName, entityType, type, onChange }) => {
7
- const intl = useIntl();
8
- const IsPepAlternatives = [
9
- {
10
- text: intl.formatMessage(messages[PepType.NOT_PEP], { entityType, name: ownerName }),
11
- value: PepType.NOT_PEP
12
- },
13
- { text: intl.formatMessage(messages[PepType.ME], { entityType, name: ownerName }), value: PepType.ME },
14
- {
15
- text: intl.formatMessage(messages[PepType.RELATIVE], { entityType, name: ownerName }),
16
- value: PepType.RELATIVE
17
- },
18
- {
19
- text: intl.formatMessage(messages[PepType.COLLEAGUE], { entityType, name: ownerName }),
20
- value: PepType.COLLEAGUE
21
- }
22
- ];
23
- return (React.createElement(RadioGroup, { alternatives: IsPepAlternatives, onChange: alt => onChange(alt.value), value: IsPepAlternatives.find(alt => alt.value === type), header: intl.formatMessage(messages.header, { entityType, name: ownerName }), validators: [RequiredValidator(intl.formatMessage(messages.required))] }));
24
- };
25
- export const IsPepPage = ({ next }) => {
26
- const pepContext = useContext(PepContext);
27
- const formRef = useRef();
28
- const nextPage = useCallback(() => {
29
- if (formRef.current && formRef.current.isValid && next) {
30
- next();
31
- }
32
- }, [formRef, next]);
33
- return (React.createElement(Form, { onSubmit: nextPage, lysaFormRef: formRef },
34
- React.createElement(IsPepRadioGroup, { entityType: pepContext.state.legalEntityType || EntityType.PERSON, ownerName: pepContext.state.ownerName || "", type: pepContext.state.type, onChange: type => {
35
- pepContext.setState({ type });
36
- } }),
37
- React.createElement(PrimaryButton, { type: "submit" },
38
- React.createElement(FormattedMessage, { id: "pep.ispep.next", description: "Next button", defaultMessage: 'G\u00E5 vidare' }))));
39
- };
@@ -1,105 +0,0 @@
1
- export declare const relationMessages: {
2
- header: {
3
- id: string;
4
- description: string;
5
- defaultMessage: string;
6
- };
7
- required: {
8
- id: string;
9
- description: string;
10
- defaultMessage: string;
11
- };
12
- MARRIED_PARTNER: {
13
- id: string;
14
- description: string;
15
- defaultMessage: string;
16
- };
17
- COLIVING_PARTNER: {
18
- id: string;
19
- description: string;
20
- defaultMessage: string;
21
- };
22
- CHILD: {
23
- id: string;
24
- description: string;
25
- defaultMessage: string;
26
- };
27
- PARENT: {
28
- id: string;
29
- description: string;
30
- defaultMessage: string;
31
- };
32
- CHILD_MARRIED_PARTNER: {
33
- id: string;
34
- description: string;
35
- defaultMessage: string;
36
- };
37
- CHILD_COLIVING_PARTNER: {
38
- id: string;
39
- description: string;
40
- defaultMessage: string;
41
- };
42
- };
43
- export declare const businessRelationMessages: {
44
- header: {
45
- id: string;
46
- description: string;
47
- defaultMessage: string;
48
- };
49
- required: {
50
- id: string;
51
- description: string;
52
- defaultMessage: string;
53
- };
54
- CO_OWNERSHIP: {
55
- id: string;
56
- description: string;
57
- defaultMessage: string;
58
- };
59
- CLOSE_CONNECTION: {
60
- id: string;
61
- description: string;
62
- defaultMessage: string;
63
- };
64
- COMPANY_FOR_PEP: {
65
- id: string;
66
- description: string;
67
- defaultMessage: string;
68
- };
69
- };
70
- export declare const relativeNameMessages: {
71
- header: {
72
- id: string;
73
- description: string;
74
- defaultMessage: string;
75
- };
76
- required: {
77
- id: string;
78
- description: string;
79
- defaultMessage: string;
80
- };
81
- };
82
- export declare const birthdayMessages: {
83
- header: {
84
- id: string;
85
- description: string;
86
- defaultMessage: string;
87
- };
88
- required: {
89
- id: string;
90
- description: string;
91
- defaultMessage: string;
92
- };
93
- };
94
- export declare const colleagueNameMessages: {
95
- header: {
96
- id: string;
97
- description: string;
98
- defaultMessage: string;
99
- };
100
- required: {
101
- id: string;
102
- description: string;
103
- defaultMessage: string;
104
- };
105
- };