@lysaab/lysa-pep 2.0.0 → 2.1.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.
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent } from "react";
|
|
2
2
|
import { Alternative } from "@lysaab/ui-2";
|
|
3
3
|
import { ValidationProps } from "@lysaab/ui-2/hooks/useValidation";
|
|
4
|
-
export interface Country {
|
|
5
|
-
label: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}
|
|
8
4
|
interface Props extends ValidationProps {
|
|
9
5
|
value?: string;
|
|
10
6
|
onChange?(value: Alternative<string>): void;
|
|
@@ -11,20 +11,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { useState } from "react";
|
|
13
13
|
import { Select } from "@lysaab/ui-2";
|
|
14
|
-
import
|
|
14
|
+
import countries from "@lysaab/countries";
|
|
15
15
|
import { defineMessages, useIntl } from "react-intl";
|
|
16
16
|
const messages = defineMessages({
|
|
17
17
|
placeholder: {
|
|
18
|
-
id:
|
|
19
|
-
description:
|
|
20
|
-
defaultMessage:
|
|
21
|
-
}
|
|
18
|
+
id: "component.select.country",
|
|
19
|
+
description: "Select a country placeholder",
|
|
20
|
+
defaultMessage: "Välj ett land",
|
|
21
|
+
},
|
|
22
22
|
});
|
|
23
23
|
export const CountrySelect = (_a) => {
|
|
24
24
|
var { value, omitCountries = [] } = _a, props = __rest(_a, ["value", "omitCountries"]);
|
|
25
25
|
const intl = useIntl();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
.
|
|
29
|
-
|
|
26
|
+
const lang = intl.locale.slice(0, 2);
|
|
27
|
+
const [countryAlternatives] = useState((countries[lang] || countries["en"])
|
|
28
|
+
.filter((country) => !omitCountries.includes(country.value))
|
|
29
|
+
.map((country) => ({
|
|
30
|
+
text: country.label,
|
|
31
|
+
value: country.value,
|
|
32
|
+
})));
|
|
33
|
+
return (React.createElement(Select, Object.assign({ alternatives: countryAlternatives, placeholder: intl.formatMessage(messages.placeholder), value: countryAlternatives.find((country) => country.value === value) }, props)));
|
|
30
34
|
};
|
package/components/PepAnswers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./PepAnswers.scss";
|
|
3
|
-
import
|
|
3
|
+
import countries from "@lysaab/countries";
|
|
4
4
|
import { getRoleAlts, getMilitaryAlts } from "../pages/RolePage/RolePage";
|
|
5
5
|
import { PepType } from "../pages/PepContext";
|
|
6
6
|
import { useIntl, defineMessages, FormattedMessage } from "react-intl";
|
|
@@ -102,7 +102,8 @@ export const PepAnswers = ({ answer }) => {
|
|
|
102
102
|
React.createElement(FormattedMessage, { id: "pep.anwers.notpep", description: "Not pep", defaultMessage: "Personen \u00E4r inte PEP" }))));
|
|
103
103
|
}
|
|
104
104
|
const entityType = answer.legalEntityType;
|
|
105
|
-
const
|
|
105
|
+
const lang = intl.locale.slice(0, 2);
|
|
106
|
+
const country = (countries[lang] || countries["en"]).find((country) => country.value === answer.country);
|
|
106
107
|
const role = getRoleAlts(intl).find((alt) => alt.value === answer.role);
|
|
107
108
|
const militaryRank = getMilitaryAlts(intl).find((alt) => alt.value === answer.militaryRank);
|
|
108
109
|
return (React.createElement("div", null,
|
|
@@ -122,7 +123,7 @@ export const PepAnswers = ({ answer }) => {
|
|
|
122
123
|
React.createElement(StaticInput, { label: intl.formatMessage(messages.endedLabel), value: answer.ended }))) : (React.createElement(StaticInput, { label: intl.formatMessage(messages.statusLabel), value: intl.formatMessage(messages.statusOngoingValue) })),
|
|
123
124
|
answer.country && (React.createElement(StaticInput, { label: intl.formatMessage(messages.countryLabel), value: country ? country.label : answer.country })),
|
|
124
125
|
role && (React.createElement(StaticInput, { label: intl.formatMessage(messages.roleLabel), value: role.text })),
|
|
125
|
-
answer.ambassadorCountry && (React.createElement(StaticInput, { label: intl.formatMessage(messages.ambassadorCountryLabel), value: ((_a = countries.find((country) => country.value === answer.ambassadorCountry)) === null || _a === void 0 ? void 0 : _a.label) || answer.ambassadorCountry })),
|
|
126
|
+
answer.ambassadorCountry && (React.createElement(StaticInput, { label: intl.formatMessage(messages.ambassadorCountryLabel), value: ((_a = (countries[lang] || countries["en"]).find((country) => country.value === answer.ambassadorCountry)) === null || _a === void 0 ? void 0 : _a.label) || answer.ambassadorCountry })),
|
|
126
127
|
answer.governmentCompany && (React.createElement(StaticInput, { label: intl.formatMessage(messages.governmentCompanyNameLabel), value: answer.governmentCompany })),
|
|
127
128
|
answer.governmentCompanyRole && (React.createElement(StaticInput, { label: intl.formatMessage(messages.governmentCompanyRoleLabel), value: answer.governmentCompanyRole })),
|
|
128
129
|
answer.internationalOrganisation && (React.createElement(StaticInput, { label: intl.formatMessage(messages.internationalOrganisationNameLabel), value: answer.internationalOrganisation })),
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lysaab/lysa-pep",
|
|
3
3
|
"author": "Lysa AB",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"main": "./Exports.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
+
"@lysaab/countries": "^3.1.1",
|
|
7
8
|
"@types/luxon": "^1.15.2",
|
|
8
9
|
"@types/react-intl": "^3.0.0",
|
|
9
10
|
"luxon": "^1.21.1",
|