@lysaab/lysa-pep 7.0.1 → 7.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.
package/Exports.d.ts CHANGED
@@ -2,6 +2,6 @@ export * from "./pages/PepContext";
2
2
  export * from "./model/PepModel";
3
3
  export * from "./pages/IsPep/IsPepPage";
4
4
  export { RelationPage } from "./pages/RelationPage/RelationPage";
5
- export { RolePage as PepRolePage, getMilitaryAlts, getRoleAlts } from "./pages/RolePage/RolePage";
5
+ export { RolePage as PepRolePage, getMilitaryAlts, getRoleAlts, } from "./pages/RolePage/RolePage";
6
6
  export { StatusPage as PepStatusPage } from "./pages/StatusPage/StatusPage";
7
- export { PepAnswers } from "./components/PepAnswers";
7
+ export { PepAnswers, getPepAnswersTexts } from "./components/PepAnswers";
package/Exports.js CHANGED
@@ -2,6 +2,6 @@ export * from "./pages/PepContext";
2
2
  export * from "./model/PepModel";
3
3
  export * from "./pages/IsPep/IsPepPage";
4
4
  export { RelationPage } from "./pages/RelationPage/RelationPage";
5
- export { RolePage as PepRolePage, getMilitaryAlts, getRoleAlts } from "./pages/RolePage/RolePage";
5
+ export { RolePage as PepRolePage, getMilitaryAlts, getRoleAlts, } from "./pages/RolePage/RolePage";
6
6
  export { StatusPage as PepStatusPage } from "./pages/StatusPage/StatusPage";
7
- export { PepAnswers } from "./components/PepAnswers";
7
+ export { PepAnswers, getPepAnswersTexts } from "./components/PepAnswers";
@@ -1,8 +1,14 @@
1
1
  import { FunctionComponent } from "react";
2
2
  import "./PepAnswers.scss";
3
3
  import { PepRequest } from "../model/PepModel";
4
+ import { IntlShape } from "react-intl";
4
5
  interface Props {
5
6
  answer: PepRequest;
6
7
  }
8
+ interface PepAnswerText {
9
+ label: string;
10
+ value: string;
11
+ }
12
+ export declare function getPepAnswersTexts(answer: PepRequest, intl: IntlShape): string | PepAnswerText[];
7
13
  export declare const PepAnswers: FunctionComponent<Props>;
8
14
  export {};
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import "./PepAnswers.scss";
3
3
  import { getRoleAlts, getMilitaryAlts } from "../pages/RolePage/RolePage";
4
4
  import { PepType } from "../pages/PepContext";
5
- import { useIntl, defineMessages, FormattedMessage } from "react-intl";
5
+ import { useIntl, defineMessages } from "react-intl";
6
6
  import { messages as isPepMessages } from "../pages/IsPep/IsPepMessages";
7
7
  import { relationMessages, businessRelationMessages, } from "../pages/RelationPage/RelationMessages";
8
8
  const messages = defineMessages({
@@ -58,41 +58,122 @@ const messages = defineMessages({
58
58
  id: "pep.answers.militaryRank.label",
59
59
  },
60
60
  });
61
- export const PepAnswers = ({ answer }) => {
62
- const intl = useIntl();
61
+ export function getPepAnswersTexts(answer, intl) {
62
+ var _a, _b;
63
63
  if (!answer.type || answer.type === PepType.NOT_PEP) {
64
- return (React.createElement("div", null,
65
- React.createElement("p", null,
66
- React.createElement(FormattedMessage, { id: "pep.answers.notpep" }))));
64
+ return intl.formatMessage({ id: "pep.answers.notpep" });
67
65
  }
68
66
  const entityType = answer.legalEntityType;
69
67
  const role = getRoleAlts(intl).find((alt) => alt.value === answer.role);
70
68
  const militaryRank = getMilitaryAlts(intl).find((alt) => alt.value === answer.militaryRank);
71
- return (React.createElement("div", null,
72
- answer.type && (React.createElement(StaticInput, { label: intl.formatMessage(messages.whoIsPepLabel), value: intl.formatMessage(isPepMessages[answer.type], {
69
+ const result = [];
70
+ if (answer.type) {
71
+ result.push({
72
+ label: intl.formatMessage(messages.whoIsPepLabel),
73
+ value: intl.formatMessage(isPepMessages[answer.type], {
73
74
  entityType,
74
75
  name: answer.ownerName,
75
- }) })),
76
- answer.relationToPEP && (React.createElement(StaticInput, { label: intl.formatMessage(messages.relationLabel), value: intl.formatMessage(relationMessages[answer.relationToPEP], {
76
+ }),
77
+ });
78
+ }
79
+ if (answer.relationToPEP) {
80
+ result.push({
81
+ label: intl.formatMessage(messages.relationLabel),
82
+ value: intl.formatMessage(relationMessages[answer.relationToPEP], {
77
83
  entityType,
78
84
  name: answer.ownerName,
79
- }) })),
80
- answer.businessRelation && (React.createElement(StaticInput, { label: intl.formatMessage(messages.businessRelationLabel), value: intl.formatMessage(businessRelationMessages[answer.businessRelation], { entityType, name: answer.ownerName }) })),
81
- answer.nameOfPEP && (React.createElement(StaticInput, { label: intl.formatMessage(messages.nameOfPepLabel), value: answer.nameOfPEP })),
82
- answer.birthdayOfPEP && (React.createElement(StaticInput, { label: intl.formatMessage(messages.birthdayOfPEPLabel), value: answer.birthdayOfPEP })),
83
- answer.ended ? (React.createElement(React.Fragment, null,
84
- React.createElement(StaticInput, { label: intl.formatMessage(messages.statusLabel), value: intl.formatMessage(messages.statusEndedValue) }),
85
- React.createElement(StaticInput, { label: intl.formatMessage(messages.endedLabel), value: answer.ended }))) : (React.createElement(StaticInput, { label: intl.formatMessage(messages.statusLabel), value: intl.formatMessage(messages.statusOngoingValue) })),
86
- answer.country && (React.createElement(StaticInput, { label: intl.formatMessage(messages.countryLabel), value: intl.formatDisplayName(answer.country, { type: "region" }) })),
87
- role && (React.createElement(StaticInput, { label: intl.formatMessage(messages.roleLabel), value: role.text })),
88
- answer.ambassadorCountry && (React.createElement(StaticInput, { label: intl.formatMessage(messages.ambassadorCountryLabel), value: intl.formatDisplayName(answer.ambassadorCountry, {
85
+ }),
86
+ });
87
+ }
88
+ if (answer.businessRelation) {
89
+ result.push({
90
+ label: intl.formatMessage(messages.businessRelationLabel),
91
+ value: intl.formatMessage(businessRelationMessages[answer.businessRelation], { entityType, name: answer.ownerName }),
92
+ });
93
+ }
94
+ if (answer.nameOfPEP) {
95
+ result.push({
96
+ label: intl.formatMessage(messages.nameOfPepLabel),
97
+ value: answer.nameOfPEP,
98
+ });
99
+ }
100
+ if (answer.birthdayOfPEP) {
101
+ result.push({
102
+ label: intl.formatMessage(messages.birthdayOfPEPLabel),
103
+ value: answer.birthdayOfPEP,
104
+ });
105
+ }
106
+ if (answer.ended) {
107
+ result.push({
108
+ label: intl.formatMessage(messages.statusLabel),
109
+ value: intl.formatMessage(messages.statusEndedValue),
110
+ }, {
111
+ label: intl.formatMessage(messages.endedLabel),
112
+ value: answer.ended,
113
+ });
114
+ }
115
+ else {
116
+ result.push({
117
+ label: intl.formatMessage(messages.statusLabel),
118
+ value: intl.formatMessage(messages.statusOngoingValue),
119
+ });
120
+ }
121
+ if (answer.country) {
122
+ result.push({
123
+ label: intl.formatMessage(messages.countryLabel),
124
+ value: (_a = intl.formatDisplayName(answer.country, { type: "region" })) !== null && _a !== void 0 ? _a : "-",
125
+ });
126
+ }
127
+ if (role) {
128
+ result.push({
129
+ label: intl.formatMessage(messages.roleLabel),
130
+ value: role.text,
131
+ });
132
+ }
133
+ if (answer.ambassadorCountry) {
134
+ result.push({
135
+ label: intl.formatMessage(messages.ambassadorCountryLabel),
136
+ value: (_b = intl.formatDisplayName(answer.ambassadorCountry, {
89
137
  type: "region",
90
- }) })),
91
- answer.governmentCompany && (React.createElement(StaticInput, { label: intl.formatMessage(messages.governmentCompanyNameLabel), value: answer.governmentCompany })),
92
- answer.governmentCompanyRole && (React.createElement(StaticInput, { label: intl.formatMessage(messages.governmentCompanyRoleLabel), value: answer.governmentCompanyRole })),
93
- answer.internationalOrganisation && (React.createElement(StaticInput, { label: intl.formatMessage(messages.internationalOrganisationNameLabel), value: answer.internationalOrganisation })),
94
- answer.internationalOrganisationRole && (React.createElement(StaticInput, { label: intl.formatMessage(messages.internationalOrganisationRoleLabel), value: answer.internationalOrganisationRole })),
95
- militaryRank && (React.createElement(StaticInput, { label: intl.formatMessage(messages.militaryGradeLabel), value: militaryRank.text }))));
138
+ })) !== null && _b !== void 0 ? _b : "-",
139
+ });
140
+ }
141
+ if (answer.governmentCompany) {
142
+ result.push({
143
+ label: intl.formatMessage(messages.governmentCompanyNameLabel),
144
+ value: answer.governmentCompany,
145
+ });
146
+ }
147
+ if (answer.governmentCompanyRole) {
148
+ result.push({
149
+ label: intl.formatMessage(messages.governmentCompanyRoleLabel),
150
+ value: answer.governmentCompanyRole,
151
+ });
152
+ }
153
+ if (answer.internationalOrganisation) {
154
+ result.push({
155
+ label: intl.formatMessage(messages.internationalOrganisationNameLabel),
156
+ value: answer.internationalOrganisation,
157
+ });
158
+ }
159
+ if (answer.internationalOrganisationRole) {
160
+ result.push({
161
+ label: intl.formatMessage(messages.internationalOrganisationRoleLabel),
162
+ value: answer.internationalOrganisationRole,
163
+ });
164
+ }
165
+ if (militaryRank) {
166
+ result.push({
167
+ label: intl.formatMessage(messages.militaryGradeLabel),
168
+ value: militaryRank.text,
169
+ });
170
+ }
171
+ return result;
172
+ }
173
+ export const PepAnswers = ({ answer }) => {
174
+ const intl = useIntl();
175
+ const texts = getPepAnswersTexts(answer, intl);
176
+ return (React.createElement("div", null, typeof texts === "string" ? (React.createElement("p", null, texts)) : (texts.map((item, index) => (React.createElement(StaticInput, { key: index, label: item.label, value: item.value }))))));
96
177
  };
97
178
  const StaticInput = ({ label, value }) => {
98
179
  return (React.createElement("div", { className: "static-input" },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lysaab/lysa-pep",
3
3
  "author": "Lysa AB",
4
- "version": "7.0.1",
4
+ "version": "7.1.0",
5
5
  "main": "./Exports.js",
6
6
  "dependencies": {
7
7
  "@types/luxon": "^1.15.2",
@@ -1,5 +1,7 @@
1
1
  import React, { FunctionComponent } from "react";
2
2
  import { PepType, EntityType } from "../PepContext";
3
+ import { IntlShape } from "react-intl";
4
+ export declare function getIsPepQuestionText(entityType: EntityType | undefined, name: string | undefined, intl: IntlShape): string;
3
5
  export interface QuestionsProps {
4
6
  ownerName?: string;
5
7
  entityType?: EntityType;
@@ -3,6 +3,12 @@ import { Form, RadioGroup, RequiredValidator, Button, Card, } from "@lysaab/ui-2
3
3
  import { PepType, PepContext, EntityType } from "../PepContext";
4
4
  import { useIntl, FormattedMessage } from "react-intl";
5
5
  import { messages } from "./IsPepMessages";
6
+ export function getIsPepQuestionText(entityType, name, intl) {
7
+ return intl.formatMessage(messages.header, {
8
+ entityType,
9
+ name,
10
+ });
11
+ }
6
12
  export const IsPepQuestion = ({ ownerName, entityType, type, onChange, resetValues, }) => {
7
13
  const intl = useIntl();
8
14
  const IsPepAlternatives = [
@@ -38,10 +44,7 @@ export const IsPepQuestion = ({ ownerName, entityType, type, onChange, resetValu
38
44
  return (React.createElement(RadioGroup, { alternatives: IsPepAlternatives, onChange: (alternative) => {
39
45
  onChange(alternative.value);
40
46
  resetValues === null || resetValues === void 0 ? void 0 : resetValues();
41
- }, value: IsPepAlternatives.find((alt) => alt.value === type), header: intl.formatMessage(messages.header, {
42
- entityType,
43
- name: ownerName,
44
- }), validators: [
47
+ }, value: IsPepAlternatives.find((alt) => alt.value === type), header: getIsPepQuestionText(entityType, ownerName, intl), validators: [
45
48
  new RequiredValidator(intl.formatMessage(messages.required)),
46
49
  ], "data-test-id": "pep-ispep" }));
47
50
  };