@lysaab/lysa-pep 6.2.0 → 7.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 (84) hide show
  1. package/lib/README.md +51 -0
  2. package/lib/package.json +73 -0
  3. package/{pages → lib/pages}/PepContext.d.ts +3 -3
  4. package/package.json +19 -21
  5. package/public/favicon.ico +0 -0
  6. package/public/index.html +43 -0
  7. package/public/logo192.png +0 -0
  8. package/public/logo512.png +0 -0
  9. package/public/manifest.json +25 -0
  10. package/public/robots.txt +2 -0
  11. package/src/App.scss +5 -0
  12. package/src/App.test.tsx +9 -0
  13. package/src/App.tsx +17 -0
  14. package/src/Exports.ts +12 -0
  15. package/src/components/PepAnswers.scss +7 -0
  16. package/src/components/PepAnswers.tsx +218 -0
  17. package/src/demo/Done.tsx +21 -0
  18. package/src/demo/Localization.tsx +66 -0
  19. package/src/demo/LocalizationContext.tsx +61 -0
  20. package/src/demo/Pep.tsx +172 -0
  21. package/src/index.css +13 -0
  22. package/src/index.tsx +13 -0
  23. package/src/locales/da.json +98 -0
  24. package/src/locales/de.json +98 -0
  25. package/src/locales/defaultMessages.json +335 -0
  26. package/src/locales/en.json +98 -0
  27. package/src/locales/fi.json +98 -0
  28. package/src/locales/sv.json +98 -0
  29. package/src/locales/whitelist_da.json +2 -0
  30. package/src/locales/whitelist_en.json +2 -0
  31. package/src/locales/whitelist_fi.json +2 -0
  32. package/src/locales/whitelist_sv.json +2 -0
  33. package/src/logo.svg +1 -0
  34. package/src/model/PepModel.ts +54 -0
  35. package/src/pages/IsPep/IsPepMessages.ts +11 -0
  36. package/src/pages/IsPep/IsPepPage.tsx +119 -0
  37. package/src/pages/PepContext.tsx +150 -0
  38. package/src/pages/RelationPage/RelationMessages.ts +74 -0
  39. package/src/pages/RelationPage/RelationPage.tsx +306 -0
  40. package/src/pages/RolePage/RoleMessages.ts +128 -0
  41. package/src/pages/RolePage/RolePage.tsx +359 -0
  42. package/src/pages/StatusPage/StatusMessages.ts +59 -0
  43. package/src/pages/StatusPage/StatusPage.tsx +237 -0
  44. package/src/react-app-env.d.ts +1 -0
  45. package/src/serviceWorker.ts +143 -0
  46. package/src/utils/Possession.ts +41 -0
  47. package/translationRunner.js +7 -0
  48. package/tsconfig.json +26 -0
  49. package/tsconfig_build.json +19 -0
  50. /package/{Exports.d.ts → lib/Exports.d.ts} +0 -0
  51. /package/{Exports.js → lib/Exports.js} +0 -0
  52. /package/{components → lib/components}/PepAnswers.d.ts +0 -0
  53. /package/{components → lib/components}/PepAnswers.js +0 -0
  54. /package/{components → lib/components}/PepAnswers.scss +0 -0
  55. /package/{messages → lib/messages}/src/components/PepAnswers.json +0 -0
  56. /package/{messages → lib/messages}/src/pages/IsPep/IsPepMessages.json +0 -0
  57. /package/{messages → lib/messages}/src/pages/IsPep/IsPepPage.json +0 -0
  58. /package/{messages → lib/messages}/src/pages/RelationPage/RelationMessages.json +0 -0
  59. /package/{messages → lib/messages}/src/pages/RelationPage/RelationPage.json +0 -0
  60. /package/{messages → lib/messages}/src/pages/RolePage/RoleMessages.json +0 -0
  61. /package/{messages → lib/messages}/src/pages/RolePage/RolePage.json +0 -0
  62. /package/{messages → lib/messages}/src/pages/StatusPage/StatusMessages.json +0 -0
  63. /package/{messages → lib/messages}/src/pages/StatusPage/StatusPage.json +0 -0
  64. /package/{model → lib/model}/PepModel.d.ts +0 -0
  65. /package/{model → lib/model}/PepModel.js +0 -0
  66. /package/{pages → lib/pages}/IsPep/IsPepMessages.d.ts +0 -0
  67. /package/{pages → lib/pages}/IsPep/IsPepMessages.js +0 -0
  68. /package/{pages → lib/pages}/IsPep/IsPepPage.d.ts +0 -0
  69. /package/{pages → lib/pages}/IsPep/IsPepPage.js +0 -0
  70. /package/{pages → lib/pages}/PepContext.js +0 -0
  71. /package/{pages → lib/pages}/RelationPage/RelationMessages.d.ts +0 -0
  72. /package/{pages → lib/pages}/RelationPage/RelationMessages.js +0 -0
  73. /package/{pages → lib/pages}/RelationPage/RelationPage.d.ts +0 -0
  74. /package/{pages → lib/pages}/RelationPage/RelationPage.js +0 -0
  75. /package/{pages → lib/pages}/RolePage/RoleMessages.d.ts +0 -0
  76. /package/{pages → lib/pages}/RolePage/RoleMessages.js +0 -0
  77. /package/{pages → lib/pages}/RolePage/RolePage.d.ts +0 -0
  78. /package/{pages → lib/pages}/RolePage/RolePage.js +0 -0
  79. /package/{pages → lib/pages}/StatusPage/StatusMessages.d.ts +0 -0
  80. /package/{pages → lib/pages}/StatusPage/StatusMessages.js +0 -0
  81. /package/{pages → lib/pages}/StatusPage/StatusPage.d.ts +0 -0
  82. /package/{pages → lib/pages}/StatusPage/StatusPage.js +0 -0
  83. /package/{utils → lib/utils}/Possession.d.ts +0 -0
  84. /package/{utils → lib/utils}/Possession.js +0 -0
package/lib/README.md ADDED
@@ -0,0 +1,51 @@
1
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2
+
3
+ ## Available Scripts
4
+
5
+ In the project directory, you can run:
6
+
7
+ ### `npm start`
8
+
9
+ Runs the app in the development mode.<br />
10
+ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11
+
12
+ The page will reload if you make edits.<br />
13
+ You will also see any lint errors in the console.
14
+
15
+ ### `npm test`
16
+
17
+ Launches the test runner in the interactive watch mode.<br />
18
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19
+
20
+ ### `npm run build`
21
+
22
+ Builds the app for production to the `build` folder.<br />
23
+ It correctly bundles React in production mode and optimizes the build for the best performance.
24
+
25
+ The build is minified and the filenames include the hashes.<br />
26
+ Your app is ready to be deployed!
27
+
28
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29
+
30
+ ### `npm run eject`
31
+
32
+ **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33
+
34
+ If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35
+
36
+ Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37
+
38
+ You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39
+
40
+ ## Learn More
41
+
42
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43
+
44
+ To learn React, check out the [React documentation](https://reactjs.org/).
45
+
46
+ ## Testing pre-release version
47
+
48
+ 1. `npm run build`
49
+ 2. Copy the built files to where you want to use them. Example (standing in a
50
+ project that you want to test the new version in):
51
+ `cp -r ../lysa-pep/lib/* node_modules/\@lysaab/lysa-pep/`
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@lysaab/lysa-pep",
3
+ "author": "Lysa AB",
4
+ "version": "7.0.0",
5
+ "main": "./Exports.js",
6
+ "dependencies": {
7
+ "@types/luxon": "^1.15.2",
8
+ "luxon": "^1.21.1"
9
+ },
10
+ "devDependencies": {
11
+ "@formatjs/cli": "^1.1.22",
12
+ "@lysaab/ui-2": "^45.0.1",
13
+ "@types/jest": "24.0.20",
14
+ "@types/luxon": "^1.15.2",
15
+ "@types/node": "12.11.7",
16
+ "@types/react": "^18.3.3",
17
+ "@types/react-datepicker": "^6.2.0",
18
+ "@types/react-dom": "^18.3.0",
19
+ "copyfiles": "^2.3.0",
20
+ "eslint-plugin-formatjs": "^3.0.0",
21
+ "luxon": "^1.21.1",
22
+ "react": "^18.3.1",
23
+ "react-datepicker": "^6.9.0",
24
+ "react-dom": "^18.3.1",
25
+ "react-intl": "^6.6.8",
26
+ "react-intl-translations-manager": "^5.0.3",
27
+ "react-router-dom": "^5.2.0",
28
+ "react-scripts": "^5.0.0",
29
+ "sass": "^1.50.0",
30
+ "typescript": "^4.3.4"
31
+ },
32
+ "peerDependencies": {
33
+ "@lysaab/ui-2": "^45.0.1",
34
+ "react": "17 - 18",
35
+ "react-intl": "^6.6.8",
36
+ "react-router-dom": "^5.2.0"
37
+ },
38
+ "scripts": {
39
+ "start": "react-scripts start",
40
+ "build": "react-scripts build",
41
+ "test": "react-scripts test",
42
+ "eject": "react-scripts eject",
43
+ "build:lib": "tsc -p ./tsconfig_build.json && npm run copyscss",
44
+ "translations:extract": "formatjs extract --messages-dir ./build/messages \"./src/**/*.tsx\" \"./src/**/*.ts\"",
45
+ "translations:manage": "node ./translationRunner.js",
46
+ "translations": "npm run translations:extract && npm run translations:manage",
47
+ "copyscss": "copyfiles -u 1 \"src/components/**/*.scss\" lib/",
48
+ "copymessages": "copyfiles -u 1 \"build/messages/**/*.json\" lib/",
49
+ "copypkgfiles": "cp README.md ./lib/ && cp package.json ./lib/",
50
+ "postversioning": "npm run translations:extract && npm run copymessages && npm run copypkgfiles && cd lib",
51
+ "release:patch": "npm run build:lib && npm version patch && npm run postversioning && npm publish",
52
+ "release:minor": "npm run build:lib && npm version minor && npm run postversioning && npm publish",
53
+ "release:major": "npm run build:lib && npm version major && npm run postversioning && npm publish",
54
+ "release:premajor": "npm run build:lib && npm version premajor && npm run postversioning && npm publish --tag next",
55
+ "release:prepatch": "npm run build:lib && npm version prepatch && npm run postversioning && npm publish --tag next",
56
+ "release:prerelease": "npm run build:lib && npm version prerelease && npm run postversioning && npm publish --tag next"
57
+ },
58
+ "eslintConfig": {
59
+ "extends": "react-app"
60
+ },
61
+ "browserslist": {
62
+ "production": [
63
+ ">0.2%",
64
+ "not dead",
65
+ "not op_mini all"
66
+ ],
67
+ "development": [
68
+ "last 1 chrome version",
69
+ "last 1 firefox version",
70
+ "last 1 safari version"
71
+ ]
72
+ }
73
+ }
@@ -1,4 +1,4 @@
1
- import { WorldCountry } from "@lysaab/countries";
1
+ import { WorldCountry } from "@lysaab/ui-2";
2
2
  import React from "react";
3
3
  export declare enum EntityType {
4
4
  PERSON = "PERSON",
@@ -78,5 +78,5 @@ export interface PepContextProps {
78
78
  setState: (newState: Partial<PepState>) => void;
79
79
  }
80
80
  export declare const PepContext: React.Context<PepContextProps>;
81
- export declare const withPep: <P extends object>(Component: React.ComponentType<P>) => React.FC<Omit<P, keyof PepContextProps>>;
82
- export declare const PepContextProvider: React.FC;
81
+ export declare const withPep: <P extends object>(Component: React.ComponentType<React.PropsWithChildren<P>>) => React.FC<React.PropsWithChildren<Omit<P, keyof PepContextProps>>>;
82
+ export declare const PepContextProvider: React.FC<React.PropsWithChildren<unknown>>;
package/package.json CHANGED
@@ -1,30 +1,28 @@
1
1
  {
2
2
  "name": "@lysaab/lysa-pep",
3
3
  "author": "Lysa AB",
4
- "version": "6.2.0",
4
+ "version": "7.0.0",
5
5
  "main": "./Exports.js",
6
6
  "dependencies": {
7
- "@lysaab/countries": "^5.0.2",
8
7
  "@types/luxon": "^1.15.2",
9
- "@types/react-intl": "^3.0.0",
10
8
  "luxon": "^1.21.1"
11
9
  },
12
10
  "devDependencies": {
13
11
  "@formatjs/cli": "^1.1.22",
14
- "@lysaab/ui-2": "^41.0.0",
12
+ "@lysaab/ui-2": "^45.0.1",
15
13
  "@types/jest": "24.0.20",
16
14
  "@types/luxon": "^1.15.2",
17
15
  "@types/node": "12.11.7",
18
- "@types/react": "^17.0.0",
19
- "@types/react-datepicker": "^4.3.4",
20
- "@types/react-dom": "^17.0.0",
16
+ "@types/react": "^18.3.3",
17
+ "@types/react-datepicker": "^6.2.0",
18
+ "@types/react-dom": "^18.3.0",
21
19
  "copyfiles": "^2.3.0",
22
20
  "eslint-plugin-formatjs": "^3.0.0",
23
21
  "luxon": "^1.21.1",
24
- "react": "^17.0.1",
25
- "react-datepicker": "^4.7.0",
26
- "react-dom": "^17.0.1",
27
- "react-intl": "^5.20.2",
22
+ "react": "^18.3.1",
23
+ "react-datepicker": "^6.9.0",
24
+ "react-dom": "^18.3.1",
25
+ "react-intl": "^6.6.8",
28
26
  "react-intl-translations-manager": "^5.0.3",
29
27
  "react-router-dom": "^5.2.0",
30
28
  "react-scripts": "^5.0.0",
@@ -32,9 +30,9 @@
32
30
  "typescript": "^4.3.4"
33
31
  },
34
32
  "peerDependencies": {
35
- "@lysaab/ui-2": "^41.0.0",
36
- "react": "^17.0.1",
37
- "react-intl": "^5.20.2",
33
+ "@lysaab/ui-2": "^45.0.1",
34
+ "react": "17 - 18",
35
+ "react-intl": "^6.6.8",
38
36
  "react-router-dom": "^5.2.0"
39
37
  },
40
38
  "scripts": {
@@ -49,13 +47,13 @@
49
47
  "copyscss": "copyfiles -u 1 \"src/components/**/*.scss\" lib/",
50
48
  "copymessages": "copyfiles -u 1 \"build/messages/**/*.json\" lib/",
51
49
  "copypkgfiles": "cp README.md ./lib/ && cp package.json ./lib/",
52
- "postversioning": "npm run translations:extract && npm run copymessages && npm run copypkgfiles && cd lib && npm publish",
53
- "release:patch": "npm run build:lib && npm version patch && npm run postversioning",
54
- "release:minor": "npm run build:lib && npm version minor && npm run postversioning",
55
- "release:major": "npm run build:lib && npm version major && npm run postversioning",
56
- "release:premajor": "npm run build:lib && npm version premajor && npm run postversioning",
57
- "release:prepatch": "npm run build:lib && npm version prepatch && npm run postversioning",
58
- "release:prerelease": "npm run build:lib && npm version prerelease && npm run postversioning"
50
+ "postversioning": "npm run translations:extract && npm run copymessages && npm run copypkgfiles && cd lib",
51
+ "release:patch": "npm run build:lib && npm version patch && npm run postversioning && npm publish",
52
+ "release:minor": "npm run build:lib && npm version minor && npm run postversioning && npm publish",
53
+ "release:major": "npm run build:lib && npm version major && npm run postversioning && npm publish",
54
+ "release:premajor": "npm run build:lib && npm version premajor && npm run postversioning && npm publish --tag next",
55
+ "release:prepatch": "npm run build:lib && npm version prepatch && npm run postversioning && npm publish --tag next",
56
+ "release:prerelease": "npm run build:lib && npm version prerelease && npm run postversioning && npm publish --tag next"
59
57
  },
60
58
  "eslintConfig": {
61
59
  "extends": "react-app"
Binary file
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
@@ -0,0 +1,2 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
package/src/App.scss ADDED
@@ -0,0 +1,5 @@
1
+ @import "~@lysaab/ui-2/components/styling/layout";
2
+
3
+ .lysa-story .lysa-story-body {
4
+ min-height: calc(100vh - 300px) !important;
5
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import App from './App';
4
+
5
+ it('renders without crashing', () => {
6
+ const div = document.createElement('div');
7
+ ReactDOM.render(<App />, div);
8
+ ReactDOM.unmountComponentAtNode(div);
9
+ });
package/src/App.tsx ADDED
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { LocalizationContextProvider } from "./demo/LocalizationContext";
3
+ import { Pep } from "./demo/Pep";
4
+ import { PepContextProvider } from "./pages/PepContext";
5
+ import "./App.scss";
6
+
7
+ const App: React.FC = () => {
8
+ return (
9
+ <LocalizationContextProvider>
10
+ <PepContextProvider>
11
+ <Pep />
12
+ </PepContextProvider>
13
+ </LocalizationContextProvider>
14
+ );
15
+ };
16
+
17
+ export default App;
package/src/Exports.ts ADDED
@@ -0,0 +1,12 @@
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";
@@ -0,0 +1,7 @@
1
+ .static-input {
2
+ margin-bottom: 8px;
3
+
4
+ .label {
5
+ font-weight: bold;
6
+ }
7
+ }
@@ -0,0 +1,218 @@
1
+ import React, { FunctionComponent } from "react";
2
+ import "./PepAnswers.scss";
3
+ import { PepRequest } from "../model/PepModel";
4
+ import { getRoleAlts, getMilitaryAlts } from "../pages/RolePage/RolePage";
5
+ import { PepType } from "../pages/PepContext";
6
+ import { useIntl, defineMessages, FormattedMessage } from "react-intl";
7
+ import { messages as isPepMessages } from "../pages/IsPep/IsPepMessages";
8
+ import {
9
+ relationMessages,
10
+ businessRelationMessages,
11
+ } from "../pages/RelationPage/RelationMessages";
12
+
13
+ interface Props {
14
+ answer: PepRequest;
15
+ }
16
+
17
+ const messages = defineMessages({
18
+ whoIsPepLabel: {
19
+ id: "pep.answers.who.label",
20
+ },
21
+ relationLabel: {
22
+ id: "pep.answers.relationship.label",
23
+ },
24
+ businessRelationLabel: {
25
+ id: "pep.answers.businessRelationship.label",
26
+ },
27
+ nameOfPepLabel: {
28
+ id: "pep.answers.nameOfPep.label",
29
+ },
30
+ birthdayOfPEPLabel: {
31
+ id: "pep.answers.birthdayOfPEP.label",
32
+ },
33
+ statusLabel: {
34
+ id: "pep.answers.status.label",
35
+ },
36
+ statusEndedValue: {
37
+ id: "pep.answers.statusEnded.value",
38
+ },
39
+ statusOngoingValue: {
40
+ id: "pep.answers.statusOngoing.value",
41
+ },
42
+ endedLabel: {
43
+ id: "pep.answers.endedStatus.label",
44
+ },
45
+ roleLabel: {
46
+ id: "pep.answers.role.label",
47
+ },
48
+ countryLabel: {
49
+ id: "pep.answers.country.label",
50
+ },
51
+ ambassadorCountryLabel: {
52
+ id: "pep.answers.ambassadorCountry.label",
53
+ },
54
+ governmentCompanyNameLabel: {
55
+ id: "pep.answers.governmentCompanyName.label",
56
+ },
57
+ governmentCompanyRoleLabel: {
58
+ id: "pep.answers.governmentCompanyRole.label",
59
+ },
60
+ internationalOrganisationNameLabel: {
61
+ id: "pep.answers.companyName.label",
62
+ },
63
+ internationalOrganisationRoleLabel: {
64
+ id: "pep.answers.companyRole.label",
65
+ },
66
+ militaryGradeLabel: {
67
+ id: "pep.answers.militaryRank.label",
68
+ },
69
+ });
70
+
71
+ export const PepAnswers: FunctionComponent<Props> = ({ answer }) => {
72
+ const intl = useIntl();
73
+
74
+ if (!answer.type || answer.type === PepType.NOT_PEP) {
75
+ return (
76
+ <div>
77
+ <p>
78
+ <FormattedMessage id="pep.answers.notpep" />
79
+ </p>
80
+ </div>
81
+ );
82
+ }
83
+
84
+ const entityType = answer.legalEntityType;
85
+ const role = getRoleAlts(intl).find((alt) => alt.value === answer.role);
86
+ const militaryRank = getMilitaryAlts(intl).find(
87
+ (alt) => alt.value === answer.militaryRank
88
+ );
89
+
90
+ return (
91
+ <div>
92
+ {answer.type && (
93
+ <StaticInput
94
+ label={intl.formatMessage(messages.whoIsPepLabel)}
95
+ value={intl.formatMessage(isPepMessages[answer.type], {
96
+ entityType,
97
+ name: answer.ownerName,
98
+ })}
99
+ />
100
+ )}
101
+ {answer.relationToPEP && (
102
+ <StaticInput
103
+ label={intl.formatMessage(messages.relationLabel)}
104
+ value={intl.formatMessage(relationMessages[answer.relationToPEP], {
105
+ entityType,
106
+ name: answer.ownerName,
107
+ })}
108
+ />
109
+ )}
110
+ {answer.businessRelation && (
111
+ <StaticInput
112
+ label={intl.formatMessage(messages.businessRelationLabel)}
113
+ value={intl.formatMessage(
114
+ businessRelationMessages[answer.businessRelation],
115
+ { entityType, name: answer.ownerName }
116
+ )}
117
+ />
118
+ )}
119
+ {answer.nameOfPEP && (
120
+ <StaticInput
121
+ label={intl.formatMessage(messages.nameOfPepLabel)}
122
+ value={answer.nameOfPEP}
123
+ />
124
+ )}
125
+ {answer.birthdayOfPEP && (
126
+ <StaticInput
127
+ label={intl.formatMessage(messages.birthdayOfPEPLabel)}
128
+ value={answer.birthdayOfPEP}
129
+ />
130
+ )}
131
+ {answer.ended ? (
132
+ <React.Fragment>
133
+ <StaticInput
134
+ label={intl.formatMessage(messages.statusLabel)}
135
+ value={intl.formatMessage(messages.statusEndedValue)}
136
+ />
137
+ <StaticInput
138
+ label={intl.formatMessage(messages.endedLabel)}
139
+ value={answer.ended}
140
+ />
141
+ </React.Fragment>
142
+ ) : (
143
+ <StaticInput
144
+ label={intl.formatMessage(messages.statusLabel)}
145
+ value={intl.formatMessage(messages.statusOngoingValue)}
146
+ />
147
+ )}
148
+ {answer.country && (
149
+ <StaticInput
150
+ label={intl.formatMessage(messages.countryLabel)}
151
+ value={intl.formatDisplayName(answer.country, { type: "region" })}
152
+ />
153
+ )}
154
+ {role && (
155
+ <StaticInput
156
+ label={intl.formatMessage(messages.roleLabel)}
157
+ value={role.text}
158
+ />
159
+ )}
160
+ {answer.ambassadorCountry && (
161
+ <StaticInput
162
+ label={intl.formatMessage(messages.ambassadorCountryLabel)}
163
+ value={intl.formatDisplayName(answer.ambassadorCountry, {
164
+ type: "region",
165
+ })}
166
+ />
167
+ )}
168
+ {answer.governmentCompany && (
169
+ <StaticInput
170
+ label={intl.formatMessage(messages.governmentCompanyNameLabel)}
171
+ value={answer.governmentCompany}
172
+ />
173
+ )}
174
+ {answer.governmentCompanyRole && (
175
+ <StaticInput
176
+ label={intl.formatMessage(messages.governmentCompanyRoleLabel)}
177
+ value={answer.governmentCompanyRole}
178
+ />
179
+ )}
180
+ {answer.internationalOrganisation && (
181
+ <StaticInput
182
+ label={intl.formatMessage(
183
+ messages.internationalOrganisationNameLabel
184
+ )}
185
+ value={answer.internationalOrganisation}
186
+ />
187
+ )}
188
+ {answer.internationalOrganisationRole && (
189
+ <StaticInput
190
+ label={intl.formatMessage(
191
+ messages.internationalOrganisationRoleLabel
192
+ )}
193
+ value={answer.internationalOrganisationRole}
194
+ />
195
+ )}
196
+ {militaryRank && (
197
+ <StaticInput
198
+ label={intl.formatMessage(messages.militaryGradeLabel)}
199
+ value={militaryRank.text}
200
+ />
201
+ )}
202
+ </div>
203
+ );
204
+ };
205
+
206
+ interface StaticInputProps {
207
+ label: string;
208
+ value: string | React.ReactNode;
209
+ }
210
+
211
+ const StaticInput: FunctionComponent<StaticInputProps> = ({ label, value }) => {
212
+ return (
213
+ <div className="static-input">
214
+ <div className="label">{label}</div>
215
+ <div className="value">{value}</div>
216
+ </div>
217
+ );
218
+ };
@@ -0,0 +1,21 @@
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
+ <pre>{JSON.stringify(stateToRequest(pepContext.state), null, 2)}</pre>
19
+ </div>
20
+ );
21
+ }
@@ -0,0 +1,66 @@
1
+ import React, { useContext, useEffect } from "react";
2
+ import { IntlProvider } from "react-intl";
3
+ import { Language, LocalizationContext } from "./LocalizationContext";
4
+ import svMessages from "../locales/sv.json";
5
+ import enMessages from "../locales/en.json";
6
+ import deMessages from "../locales/de.json";
7
+ import { enGB, sv, de } from "date-fns/esm/locale";
8
+ import { registerLocale, setDefaultLocale } from "react-datepicker";
9
+
10
+ /**
11
+ * Setup locales for all datepickers. We use the country code
12
+ * as the key for the datepicker locale data
13
+ */
14
+ registerLocale(Language.SWEDISH, sv);
15
+ registerLocale(Language.ENGLISH, enGB);
16
+ registerLocale(Language.GERMAN, de);
17
+
18
+ console.log("sv", sv);
19
+
20
+ declare global {
21
+ interface Window {
22
+ setLanguage?: (lang: Language) => void;
23
+ }
24
+ }
25
+
26
+ const languagePacks = {
27
+ [Language.ENGLISH]: enMessages,
28
+ [Language.SWEDISH]: svMessages,
29
+ [Language.GERMAN]: deMessages,
30
+ };
31
+
32
+ const DEFAULT_LOCALE = "en";
33
+
34
+ export const Localization: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
35
+ const localizationContext = useContext(LocalizationContext);
36
+
37
+ useEffect(() => {
38
+ /**
39
+ * Change datepicker locale when language is changed
40
+ */
41
+ setDefaultLocale(localizationContext.state.language);
42
+ console.log(
43
+ "datepicker locale change to",
44
+ localizationContext.state.language
45
+ );
46
+ }, [localizationContext.state.language]);
47
+
48
+ useEffect(() => {
49
+ window.setLanguage = (lang: Language) => {
50
+ localizationContext.setState({ language: lang });
51
+ };
52
+ return () => {
53
+ delete window.setLanguage;
54
+ };
55
+ }, [localizationContext]);
56
+
57
+ return (
58
+ <IntlProvider
59
+ locale={localizationContext.getLocale()}
60
+ defaultLocale={DEFAULT_LOCALE}
61
+ messages={languagePacks[localizationContext.state.language] as any}
62
+ >
63
+ {children}
64
+ </IntlProvider>
65
+ );
66
+ };