@lysaab/lysa-pep 1.0.0 → 1.0.2-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 (65) hide show
  1. package/.vscode/settings.json +4 -0
  2. package/lib/Exports.d.ts +7 -8
  3. package/lib/Exports.js +7 -8
  4. package/lib/components/CountrySelect.d.ts +15 -22
  5. package/lib/components/CountrySelect.js +30 -21
  6. package/lib/components/PepAnswers.d.ts +8 -8
  7. package/lib/components/PepAnswers.js +131 -39
  8. package/lib/components/PepAnswers.scss +7 -7
  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 +322 -380
  14. package/lib/model/PepTexts.js +467 -552
  15. package/lib/pages/IsPep/IsPepMessages.d.ts +32 -0
  16. package/lib/pages/IsPep/IsPepMessages.js +66 -0
  17. package/lib/pages/IsPep/IsPepPage.d.ts +14 -0
  18. package/lib/pages/IsPep/IsPepPage.js +59 -0
  19. package/lib/pages/PepContext.d.ts +80 -80
  20. package/lib/pages/PepContext.js +88 -88
  21. package/lib/pages/PepIsPepPage.d.ts +6 -15
  22. package/lib/pages/PepIsPepPage.js +57 -59
  23. package/lib/pages/PepRelationPage.d.ts +6 -6
  24. package/lib/pages/PepRelationPage.js +83 -79
  25. package/lib/pages/PepRolePage.d.ts +9 -10
  26. package/lib/pages/PepRolePage.js +127 -127
  27. package/lib/pages/PepStatusPage.d.ts +6 -6
  28. package/lib/pages/PepStatusPage.js +57 -58
  29. package/lib/pages/RelationPage/RelationMessages.d.ts +105 -0
  30. package/lib/pages/RelationPage/RelationMessages.js +283 -0
  31. package/lib/pages/RelationPage/RelationPage.d.ts +6 -0
  32. package/lib/pages/RelationPage/RelationPage.js +153 -0
  33. package/lib/pages/RolePage/RoleMessages.d.ts +185 -0
  34. package/lib/pages/RolePage/RoleMessages.js +385 -0
  35. package/lib/pages/RolePage/RolePage.d.ts +11 -0
  36. package/lib/pages/RolePage/RolePage.js +220 -0
  37. package/lib/pages/StatusPage/StatusMessages.d.ts +72 -0
  38. package/lib/pages/StatusPage/StatusMessages.js +266 -0
  39. package/lib/pages/StatusPage/StatusPage.d.ts +6 -0
  40. package/lib/pages/StatusPage/StatusPage.js +95 -0
  41. package/lib/utils/Possession.d.ts +1 -0
  42. package/lib/utils/Possession.js +18 -0
  43. package/package.json +57 -53
  44. package/src/Exports.ts +12 -13
  45. package/src/components/CountrySelect.tsx +47 -43
  46. package/src/components/PepAnswers.scss +7 -7
  47. package/src/components/PepAnswers.tsx +252 -120
  48. package/src/demo/Done.tsx +16 -20
  49. package/src/demo/Pep.tsx +112 -106
  50. package/src/model/PepModel.ts +52 -52
  51. package/src/pages/IsPep/IsPepMessages.ts +67 -0
  52. package/src/pages/IsPep/IsPepPage.tsx +114 -0
  53. package/src/pages/PepContext.tsx +144 -144
  54. package/src/pages/RelationPage/RelationMessages.ts +288 -0
  55. package/src/pages/RelationPage/RelationPage.tsx +299 -0
  56. package/src/pages/RolePage/RoleMessages.ts +393 -0
  57. package/src/pages/RolePage/RolePage.tsx +356 -0
  58. package/src/pages/StatusPage/StatusMessages.ts +272 -0
  59. package/src/pages/StatusPage/StatusPage.tsx +207 -0
  60. package/src/utils/Possession.ts +21 -0
  61. package/src/model/PepTexts.ts +0 -607
  62. package/src/pages/PepIsPepPage.tsx +0 -107
  63. package/src/pages/PepRelationPage.tsx +0 -188
  64. package/src/pages/PepRolePage.tsx +0 -272
  65. package/src/pages/PepStatusPage.tsx +0 -157
package/package.json CHANGED
@@ -1,53 +1,57 @@
1
- {
2
- "name": "@lysaab/lysa-pep",
3
- "author": "Lysa AB",
4
- "version": "1.0.0",
5
- "main": "./lib/Exports.js",
6
- "dependencies": {
7
- "@types/luxon": "^1.15.2",
8
- "luxon": "^1.21.1"
9
- },
10
- "devDependencies": {
11
- "@lysaab/ui-2": "^18.0.0",
12
- "@types/jest": "24.0.20",
13
- "@types/luxon": "^1.15.2",
14
- "@types/node": "12.11.7",
15
- "@types/react": "16.9.11",
16
- "@types/react-dom": "16.9.3",
17
- "copyfiles": "^2.1.1",
18
- "luxon": "^1.21.1",
19
- "react": "^16.11.0",
20
- "react-dom": "^16.11.0",
21
- "react-scripts": "^3.4.1",
22
- "typescript": "^3.7.2"
23
- },
24
- "peerDependencies": {
25
- "@lysaab/ui-2": "^18.0.0"
26
- },
27
- "scripts": {
28
- "start": "react-scripts start",
29
- "build": "react-scripts build",
30
- "test": "react-scripts test",
31
- "eject": "react-scripts eject",
32
- "build:lib": "tsc -p ./tsconfig_build.json ",
33
- "copyscss": "copyfiles -u 1 \"src/components/**/*.scss\" lib/",
34
- "release:patch": "npm run build:lib && npm run copyscss && npm version patch && npm publish",
35
- "release:minor": "npm run build:lib && npm run copyscss && npm version minor && npm publish",
36
- "release:major": "npm run build:lib && npm run copyscss && npm version major && npm publish"
37
- },
38
- "eslintConfig": {
39
- "extends": "react-app"
40
- },
41
- "browserslist": {
42
- "production": [
43
- ">0.2%",
44
- "not dead",
45
- "not op_mini all"
46
- ],
47
- "development": [
48
- "last 1 chrome version",
49
- "last 1 firefox version",
50
- "last 1 safari version"
51
- ]
52
- }
53
- }
1
+ {
2
+ "name": "@lysaab/lysa-pep",
3
+ "author": "Lysa AB",
4
+ "version": "1.0.2-0",
5
+ "main": "./lib/Exports.js",
6
+ "dependencies": {
7
+ "@types/luxon": "^1.15.2",
8
+ "@types/react-intl": "^3.0.0",
9
+ "luxon": "^1.21.1",
10
+ "react-intl": "^4.1.1"
11
+ },
12
+ "devDependencies": {
13
+ "@lysaab/ui-2": "^18.0.0",
14
+ "@types/jest": "24.0.20",
15
+ "@types/luxon": "^1.15.2",
16
+ "@types/node": "12.11.7",
17
+ "@types/react": "^16.9.23",
18
+ "@types/react-dom": "^16.9.5",
19
+ "copyfiles": "^2.1.1",
20
+ "luxon": "^1.21.1",
21
+ "react": "^16.13.0",
22
+ "react-dom": "^16.13.0",
23
+ "react-scripts": "^3.4.0",
24
+ "typescript": "^3.7.2"
25
+ },
26
+ "peerDependencies": {
27
+ "@lysaab/ui-2": "^16.3.2"
28
+ },
29
+ "scripts": {
30
+ "start": "react-scripts start",
31
+ "build": "react-scripts build",
32
+ "test": "react-scripts test",
33
+ "eject": "react-scripts eject",
34
+ "build:lib": "tsc -p ./tsconfig_build.json ",
35
+ "copyscss": "copyfiles -u 1 \"src/components/**/*.scss\" lib/",
36
+ "release:patch": "npm run build:lib && npm run copyscss && npm version patch && npm publish",
37
+ "release:minor": "npm run build:lib && npm run copyscss && npm version minor && npm publish",
38
+ "release:major": "npm run build:lib && npm run copyscss && npm version major && npm publish",
39
+ "release:premajor": "npm run build:lib && npm run copyscss && npm version premajor && npm publish",
40
+ "release:prepatch": "npm run build:lib && npm run copyscss && npm version prepatch && npm publish"
41
+ },
42
+ "eslintConfig": {
43
+ "extends": "react-app"
44
+ },
45
+ "browserslist": {
46
+ "production": [
47
+ ">0.2%",
48
+ "not dead",
49
+ "not op_mini all"
50
+ ],
51
+ "development": [
52
+ "last 1 chrome version",
53
+ "last 1 firefox version",
54
+ "last 1 safari version"
55
+ ]
56
+ }
57
+ }
package/src/Exports.ts CHANGED
@@ -1,13 +1,12 @@
1
- export * from "./pages/PepContext";
2
- export * from "./model/PepModel";
3
- export * from "./model/PepTexts";
4
- export * from "./pages/PepIsPepPage";
5
- export { PepRelationPage } from "./pages/PepRelationPage";
6
- export {
7
- PepRolePage,
8
- militaryAlternatives,
9
- roleAlternatives
10
- } from "./pages/PepRolePage";
11
- export { PepStatusPage } from "./pages/PepStatusPage";
12
-
13
- export { PepAnswers } from "./components/PepAnswers";
1
+ export * from "./pages/PepContext";
2
+ export * from "./model/PepModel";
3
+ export * from "./pages/IsPep/IsPepPage";
4
+ export { RelationPage } from "./pages/RelationPage/RelationPage";
5
+ export {
6
+ RolePage as PepRolePage,
7
+ getMilitaryAlts,
8
+ getRoleAlts
9
+ } from "./pages/RolePage/RolePage";
10
+ export { StatusPage as PepStatusPage } from "./pages/StatusPage/StatusPage";
11
+
12
+ export { PepAnswers } from "./components/PepAnswers";
@@ -1,43 +1,47 @@
1
- import React, { useState, FunctionComponent } from "react";
2
- import { Alternative, Select } from "@lysaab/ui-2";
3
- import { ValidationProps } from "@lysaab/ui-2/hooks/useValidation";
4
- import { countries } from "../model/Countries";
5
-
6
- declare global {
7
- interface Window {
8
- lysa: { contentPath: string };
9
- }
10
- }
11
-
12
- export interface Country {
13
- label: string;
14
- value: string;
15
- }
16
-
17
- interface Props extends ValidationProps {
18
- value?: string;
19
- onChange?(value: Alternative<string>): void;
20
- label: string;
21
- removeSweden?: boolean;
22
- }
23
-
24
- export const CountrySelect: FunctionComponent<Props> = ({
25
- value,
26
- removeSweden = false,
27
- ...props
28
- }) => {
29
- const [countryAlternatives] = useState(
30
- countries
31
- .filter(country => !(removeSweden && country.value === "SE"))
32
- .map(country => ({ text: country.label, value: country.value }))
33
- );
34
-
35
- return (
36
- <Select
37
- alternatives={countryAlternatives}
38
- placeholder={"Välj ett land"}
39
- value={countryAlternatives.find(country => country.value === value)}
40
- {...props}
41
- />
42
- );
43
- };
1
+ import React, { useState, FunctionComponent } from "react";
2
+ import { Alternative, Select } from "@lysaab/ui-2";
3
+ import { ValidationProps } from "@lysaab/ui-2/hooks/useValidation";
4
+ import { countries } from "../model/Countries";
5
+ import { defineMessages, useIntl } from "react-intl";
6
+
7
+ export interface Country {
8
+ label: string;
9
+ value: string;
10
+ }
11
+
12
+ interface Props extends ValidationProps {
13
+ value?: string;
14
+ onChange?(value: Alternative<string>): void;
15
+ label: string;
16
+ omitCountries?: string[];
17
+ }
18
+
19
+ const messages = defineMessages({
20
+ placeholder: {
21
+ id: 'component.select.country',
22
+ description: 'Select a country placeholder',
23
+ defaultMessage: 'Välj ett land'
24
+ }
25
+ })
26
+
27
+ export const CountrySelect: FunctionComponent<Props> = ({
28
+ value,
29
+ omitCountries = [],
30
+ ...props
31
+ }) => {
32
+ const intl = useIntl();
33
+ const [countryAlternatives] = useState(
34
+ countries
35
+ .filter(country => !omitCountries.includes(country.value))
36
+ .map(country => ({ text: country.label, value: country.value }))
37
+ );
38
+
39
+ return (
40
+ <Select
41
+ alternatives={countryAlternatives}
42
+ placeholder={intl.formatMessage(messages.placeholder)}
43
+ value={countryAlternatives.find(country => country.value === value)}
44
+ {...props}
45
+ />
46
+ );
47
+ };
@@ -1,7 +1,7 @@
1
- .static-input {
2
- margin-bottom: 8px;
3
-
4
- .label {
5
- font-weight: bold;
6
- }
7
- }
1
+ .static-input {
2
+ margin-bottom: 8px;
3
+
4
+ .label {
5
+ font-weight: bold;
6
+ }
7
+ }
@@ -1,120 +1,252 @@
1
- import React, { FunctionComponent } from "react";
2
- import "./PepAnswers.scss";
3
- import { PepRequest } from "../model/PepModel";
4
- import { countries } from "../model/Countries";
5
- import { LABELS } from "../model/PepTexts";
6
- import { roleAlternatives, militaryAlternatives } from "../pages/PepRolePage";
7
- import { EntityType, PepType } from "../pages/PepContext";
8
-
9
- interface Props {
10
- answer: PepRequest;
11
- }
12
-
13
- export const PepAnswers: FunctionComponent<Props> = ({ answer }) => {
14
- if (!answer.type || answer.type === PepType.NOT_PEP) {
15
- return <div><p>Personen är inte PEP</p></div>;
16
- }
17
-
18
- const entityType = answer.legalEntityType || EntityType.PERSON;
19
- const labels = LABELS(answer.ownerName);
20
- const country = countries.find(country => country.value === answer.country);
21
- const role = roleAlternatives.find(alt => alt.value === answer.role);
22
- const militaryRank = militaryAlternatives.find(
23
- alt => alt.value === answer.militaryRank
24
- );
25
- return (
26
- <div>
27
- {answer.type && (
28
- <StaticInput
29
- label="Vem är pep"
30
- value={labels[entityType].GENERIC.IS_PEP[answer.type]}
31
- />
32
- )}
33
- {answer.relationToPEP && (
34
- <StaticInput
35
- label="Relation"
36
- value={
37
- labels[entityType][PepType.RELATIVE].RELATION[
38
- answer.relationToPEP
39
- ]
40
- }
41
- />
42
- )}
43
- {answer.businessRelation && (
44
- <StaticInput
45
- label="Relation"
46
- value={
47
- labels[entityType][PepType.COLLEAGUE].BUSINESS_RELATION[
48
- answer.businessRelation
49
- ]
50
- }
51
- />
52
- )}
53
- {answer.nameOfPEP && (
54
- <StaticInput label="Namn på personen" value={answer.nameOfPEP} />
55
- )}
56
- {answer.birthdayOfPEP && (
57
- <StaticInput
58
- label="Födelsedag för personen"
59
- value={answer.birthdayOfPEP}
60
- />
61
- )}
62
- {answer.ended ? (
63
- <React.Fragment>
64
- <StaticInput label="Status" value="Avslutad" />
65
- <StaticInput label="Avslutades" value={answer.ended} />
66
- </React.Fragment>
67
- ) : (
68
- <StaticInput label="Status" value="Pågående" />
69
- )}
70
- {answer.country && (
71
- <StaticInput
72
- label="Land"
73
- value={country ? country.label : answer.country}
74
- />
75
- )}
76
- {role && <StaticInput label="Roll" value={role.text} />}
77
- {answer.ambassadorCountry && (
78
- <StaticInput label="Ambassadörsland" value={answer.ambassadorCountry} />
79
- )}
80
- {answer.governmentCompany && (
81
- <StaticInput label="Företagets namn" value={answer.governmentCompany} />
82
- )}
83
- {answer.governmentCompanyRole && (
84
- <StaticInput
85
- label="Roll på företaget"
86
- value={answer.governmentCompanyRole}
87
- />
88
- )}
89
- {answer.internationalOrganisation && (
90
- <StaticInput
91
- label="Organisationens namn"
92
- value={answer.internationalOrganisation}
93
- />
94
- )}
95
- {answer.internationalOrganisationRole && (
96
- <StaticInput
97
- label="Roll i organisationen"
98
- value={answer.internationalOrganisationRole}
99
- />
100
- )}
101
- {militaryRank && (
102
- <StaticInput label="Militär grad" value={militaryRank.text} />
103
- )}
104
- </div>
105
- );
106
- };
107
-
108
- interface StaticInputProps {
109
- label: string;
110
- value: string | React.ReactNode;
111
- }
112
-
113
- const StaticInput: FunctionComponent<StaticInputProps> = ({ label, value }) => {
114
- return (
115
- <div className="static-input">
116
- <div className="label">{label}</div>
117
- <div className="value">{value}</div>
118
- </div>
119
- );
120
- };
1
+ import React, { FunctionComponent } from "react";
2
+ import "./PepAnswers.scss";
3
+ import { PepRequest } from "../model/PepModel";
4
+ import { countries } from "../model/Countries";
5
+ import { getRoleAlts, getMilitaryAlts } from "../pages/RolePage/RolePage";
6
+ import { EntityType, PepType } from "../pages/PepContext";
7
+ import { useIntl, defineMessages, FormattedMessage } from "react-intl";
8
+ import { messages as isPepMessages } from "../pages/IsPep/IsPepMessages";
9
+ import {
10
+ relationMessages,
11
+ businessRelationMessages
12
+ } from "../pages/RelationPage/RelationMessages";
13
+
14
+ interface Props {
15
+ answer: PepRequest;
16
+ }
17
+
18
+ const messages = defineMessages({
19
+ whoIsPepLabel: {
20
+ id: "pep.anwers.who.label",
21
+ description: "Who is pep label",
22
+ defaultMessage: "Vem är pep"
23
+ },
24
+ relationLabel: {
25
+ id: "pep.anwers.relation.label",
26
+ description: "Relation label",
27
+ defaultMessage: "Relation"
28
+ },
29
+ businessRelationLabel: {
30
+ id: "pep.anwers.businessRelation.label",
31
+ description: "Business relation label",
32
+ defaultMessage: "Vem är pep"
33
+ },
34
+ nameOfPepLabel: {
35
+ id: "pep.anwers.nameOfPep.label",
36
+ description: "Name of pep label",
37
+ defaultMessage: "Namn på personen"
38
+ },
39
+ birthdayOfPEPLabel: {
40
+ id: "pep.anwers.birthdayOfPEP.label",
41
+ description: "Birthday of pep label",
42
+ defaultMessage: "Födelsedag för personen"
43
+ },
44
+ statusLabel: {
45
+ id: "pep.anwers.status.label",
46
+ description: "Status label",
47
+ defaultMessage: "Status"
48
+ },
49
+ statusEndedValue: {
50
+ id: "pep.anwers.statusEnded.value",
51
+ description: "Status ended value",
52
+ defaultMessage: "Avslutad"
53
+ },
54
+ statusOngoingValue: {
55
+ id: "pep.anwers.statusOngoing.value",
56
+ description: "Status ongoing value",
57
+ defaultMessage: "Pågående"
58
+ },
59
+ endedLabel: {
60
+ id: "pep.anwers.endedStatus.label",
61
+ description: "Ended label",
62
+ defaultMessage: "Avslutades"
63
+ },
64
+ roleLabel: {
65
+ id: "pep.anwers.role.label",
66
+ description: "Role label",
67
+ defaultMessage: "Roll"
68
+ },
69
+ countryLabel: {
70
+ id: "pep.anwers.country.label",
71
+ description: "Country label",
72
+ defaultMessage: "Land"
73
+ },
74
+ ambassadorCountryLabel: {
75
+ id: "pep.anwers.ambassadorCountry.label",
76
+ description: "Ambassador country label",
77
+ defaultMessage: "Ambassadörsland"
78
+ },
79
+ governmentCompanyNameLabel: {
80
+ id: "pep.anwers.governmentCompanyName.label",
81
+ description: "Government company name label",
82
+ defaultMessage: "Företags namn"
83
+ },
84
+ governmentCompanyRoleLabel: {
85
+ id: "pep.anwers.governmentCompanyRole.label",
86
+ description: "Government company role label",
87
+ defaultMessage: "Roll på företaget"
88
+ },
89
+ internationalOrganisationNameLabel: {
90
+ id: "pep.anwers.companyName.label",
91
+ description: "International organisation name label",
92
+ defaultMessage: "Organisationens namn"
93
+ },
94
+ internationalOrganisationRoleLabel: {
95
+ id: "pep.anwers.companyRole.label",
96
+ description: "International organisation role label",
97
+ defaultMessage: "Roll i organisationen"
98
+ },
99
+ militaryGradeLabel: {
100
+ id: "pep.anwers.militaryRank.label",
101
+ description: "Military rank label",
102
+ defaultMessage: "Roll i organisationen"
103
+ }
104
+ });
105
+
106
+ export const PepAnswers: FunctionComponent<Props> = ({ answer }) => {
107
+ const intl = useIntl();
108
+ if (!answer.type || answer.type === PepType.NOT_PEP) {
109
+ return (
110
+ <div>
111
+ <p>
112
+ <FormattedMessage
113
+ id="pep.anwers.notpep"
114
+ description="Not pep"
115
+ defaultMessage="Personen är inte PEP"
116
+ />
117
+ </p>
118
+ </div>
119
+ );
120
+ }
121
+
122
+ const country = countries.find(country => country.value === answer.country);
123
+ const role = getRoleAlts(intl).find(alt => alt.value === answer.role);
124
+ const militaryRank = getMilitaryAlts(intl).find(
125
+ alt => alt.value === answer.militaryRank
126
+ );
127
+ return (
128
+ <div>
129
+ {answer.type && (
130
+ <StaticInput
131
+ label={intl.formatMessage(messages.whoIsPepLabel)}
132
+ value={intl.formatMessage(isPepMessages[answer.type], {
133
+ entityType: EntityType.PERSON
134
+ })}
135
+ />
136
+ )}
137
+ {answer.relationToPEP && (
138
+ <StaticInput
139
+ label={intl.formatMessage(messages.relationLabel)}
140
+ value={intl.formatMessage(relationMessages[answer.relationToPEP])}
141
+ />
142
+ )}
143
+ {answer.businessRelation && (
144
+ <StaticInput
145
+ label={intl.formatMessage(messages.businessRelationLabel)}
146
+ value={intl.formatMessage(
147
+ businessRelationMessages[answer.businessRelation]
148
+ )}
149
+ />
150
+ )}
151
+ {answer.nameOfPEP && (
152
+ <StaticInput
153
+ label={intl.formatMessage(messages.nameOfPepLabel)}
154
+ value={answer.nameOfPEP}
155
+ />
156
+ )}
157
+ {answer.birthdayOfPEP && (
158
+ <StaticInput
159
+ label={intl.formatMessage(messages.birthdayOfPEPLabel)}
160
+ value={answer.birthdayOfPEP}
161
+ />
162
+ )}
163
+ {answer.ended ? (
164
+ <React.Fragment>
165
+ <StaticInput
166
+ label={intl.formatMessage(messages.statusLabel)}
167
+ value={intl.formatMessage(messages.statusEndedValue)}
168
+ />
169
+ <StaticInput
170
+ label={intl.formatMessage(messages.endedLabel)}
171
+ value={answer.ended}
172
+ />
173
+ </React.Fragment>
174
+ ) : (
175
+ <StaticInput
176
+ label={intl.formatMessage(messages.statusLabel)}
177
+ value={intl.formatMessage(messages.statusOngoingValue)}
178
+ />
179
+ )}
180
+ {answer.country && (
181
+ <StaticInput
182
+ label={intl.formatMessage(messages.countryLabel)}
183
+ value={country ? country.label : answer.country}
184
+ />
185
+ )}
186
+ {role && (
187
+ <StaticInput
188
+ label={intl.formatMessage(messages.roleLabel)}
189
+ value={role.text}
190
+ />
191
+ )}
192
+ {answer.ambassadorCountry && (
193
+ <StaticInput
194
+ label={intl.formatMessage(messages.ambassadorCountryLabel)}
195
+ value={
196
+ countries.find(
197
+ country => country.value === answer.ambassadorCountry
198
+ )?.label || answer.ambassadorCountry
199
+ }
200
+ />
201
+ )}
202
+ {answer.governmentCompany && (
203
+ <StaticInput
204
+ label={intl.formatMessage(messages.governmentCompanyNameLabel)}
205
+ value={answer.governmentCompany}
206
+ />
207
+ )}
208
+ {answer.governmentCompanyRole && (
209
+ <StaticInput
210
+ label={intl.formatMessage(messages.governmentCompanyRoleLabel)}
211
+ value={answer.governmentCompanyRole}
212
+ />
213
+ )}
214
+ {answer.internationalOrganisation && (
215
+ <StaticInput
216
+ label={intl.formatMessage(
217
+ messages.internationalOrganisationNameLabel
218
+ )}
219
+ value={answer.internationalOrganisation}
220
+ />
221
+ )}
222
+ {answer.internationalOrganisationRole && (
223
+ <StaticInput
224
+ label={intl.formatMessage(
225
+ messages.internationalOrganisationRoleLabel
226
+ )}
227
+ value={answer.internationalOrganisationRole}
228
+ />
229
+ )}
230
+ {militaryRank && (
231
+ <StaticInput
232
+ label={intl.formatMessage(messages.militaryGradeLabel)}
233
+ value={militaryRank.value}
234
+ />
235
+ )}
236
+ </div>
237
+ );
238
+ };
239
+
240
+ interface StaticInputProps {
241
+ label: string;
242
+ value: string | React.ReactNode;
243
+ }
244
+
245
+ const StaticInput: FunctionComponent<StaticInputProps> = ({ label, value }) => {
246
+ return (
247
+ <div className="static-input">
248
+ <div className="label">{label}</div>
249
+ <div className="value">{value}</div>
250
+ </div>
251
+ );
252
+ };
package/src/demo/Done.tsx CHANGED
@@ -1,20 +1,16 @@
1
- import React, { useContext } from "react";
2
- import { PepContext } from "../pages/PepContext";
3
- import { stateToRequest } from "../model/PepModel";
4
- import { PepAnswers } from "../components/PepAnswers";
5
-
6
- export function Done() {
7
- const pepContext = useContext(PepContext);
8
- return (
9
- <div>
10
- <h2>Taco hej!</h2>
11
- <p>Leverpastej!</p>
12
- <PepAnswers
13
- answer={{
14
- ...stateToRequest(pepContext.state),
15
- ownerName: pepContext.state.ownerName,
16
- }}
17
- />
18
- </div>
19
- );
20
- }
1
+ import React, { useContext } from "react";
2
+ import { PepContext } from "../pages/PepContext";
3
+ import { stateToRequest } from "../model/PepModel";
4
+ import { PepAnswers } from "../components/PepAnswers";
5
+
6
+ export function Done() {
7
+ const pepContext = useContext(PepContext);
8
+ return (
9
+ <div>
10
+ <h2>Taco hej!</h2>
11
+ <p>Leverpastej!</p>
12
+ <PepAnswers answer={stateToRequest(pepContext.state)} />
13
+ <pre>{JSON.stringify(stateToRequest(pepContext.state), null, 2)}</pre>
14
+ </div>
15
+ );
16
+ }