@swan-io/shared-business 2.7.18 → 2.7.20
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/package.json
CHANGED
|
@@ -49,9 +49,14 @@ const validateCca3CountryCode = value => {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
export const validateUbo = (editorState, accountCountry) => {
|
|
52
|
-
const isAddressRequired = accountCountry
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const isAddressRequired = match(accountCountry)
|
|
53
|
+
.with("DEU", "ESP", "NLD", () => true)
|
|
54
|
+
.otherwise(() => false);
|
|
55
|
+
const isBirthInfoRequired = match(accountCountry)
|
|
56
|
+
.with("ESP", "FRA", "NLD", () => true)
|
|
57
|
+
.otherwise(() => false);
|
|
58
|
+
const isTaxIdentificationNumberRequired = (accountCountry === "DEU" && editorState.residencyAddressCountry === "DEU") ||
|
|
59
|
+
accountCountry === "NLD";
|
|
55
60
|
const validateTaxNumber = isTaxIdentificationNumberRequired
|
|
56
61
|
? combineValidators(validateNullableRequired, validateIndividualTaxNumber(accountCountry))
|
|
57
62
|
: validateIndividualTaxNumber(accountCountry);
|
|
@@ -152,8 +157,12 @@ const requiredStepFields = [
|
|
|
152
157
|
];
|
|
153
158
|
export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step, googleMapApiKey, onStepChange, onClose, onSave, onCityLoadError, }, ref) => {
|
|
154
159
|
const [reference] = useState(() => initialState?.reference ?? uuid());
|
|
155
|
-
const isAddressRequired = accountCountry
|
|
156
|
-
|
|
160
|
+
const isAddressRequired = match(accountCountry)
|
|
161
|
+
.with("DEU", "ESP", "NLD", () => true)
|
|
162
|
+
.otherwise(() => false);
|
|
163
|
+
const isBirthInfoRequired = match(accountCountry)
|
|
164
|
+
.with("ESP", "FRA", "NLD", () => true)
|
|
165
|
+
.otherwise(() => false);
|
|
157
166
|
const initialAddress = useRef({
|
|
158
167
|
residencyAddressLine1: initialState?.residencyAddressLine1,
|
|
159
168
|
residencyAddressCity: initialState?.residencyAddressCity,
|
|
@@ -237,7 +246,7 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
|
|
|
237
246
|
initialValue: initialState?.taxIdentificationNumber,
|
|
238
247
|
validate: (value, { getFieldState }) => {
|
|
239
248
|
const uboCountry = getFieldState("country").value;
|
|
240
|
-
if (accountCountry === "DEU" && uboCountry === "DEU") {
|
|
249
|
+
if ((accountCountry === "DEU" && uboCountry === "DEU") || accountCountry === "NLD") {
|
|
241
250
|
return combineValidators(validateNullableRequired, validateIndividualTaxNumber(accountCountry))(value);
|
|
242
251
|
}
|
|
243
252
|
return validateIndividualTaxNumber(accountCountry)(value);
|
|
@@ -9,6 +9,7 @@ type Props = {
|
|
|
9
9
|
accountCountry: AccountCountry;
|
|
10
10
|
isCompany: boolean;
|
|
11
11
|
required?: boolean;
|
|
12
|
+
label?: string;
|
|
12
13
|
};
|
|
13
|
-
export declare const TaxIdentificationNumberInput: ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const TaxIdentificationNumberInput: ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, label, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export {};
|
|
@@ -6,8 +6,9 @@ import { LakeTooltip } from "@swan-io/lake/src/components/LakeTooltip";
|
|
|
6
6
|
import { colors } from "@swan-io/lake/src/constants/design";
|
|
7
7
|
import { t } from "../utils/i18n";
|
|
8
8
|
import { getCompanyTaxNumberHelp, getCompanyTaxNumberPlaceholder, getIndividualTaxNumberHelp, getIndividualTaxNumberPlaceholder, getTaxNumberTooltip, } from "../utils/templateTranslations";
|
|
9
|
-
export const TaxIdentificationNumberInput = ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, }) => {
|
|
10
|
-
|
|
9
|
+
export const TaxIdentificationNumberInput = ({ value, error, valid, disabled, onChange, onBlur, accountCountry, isCompany, required, label = t("beneficiaryForm.beneficiary.taxIdentificationNumber"), }) => {
|
|
10
|
+
const tooltipContents = getTaxNumberTooltip(accountCountry);
|
|
11
|
+
return (_jsx(LakeLabel, { label: label, optionalLabel: required === true ? undefined : t("common.optional"), help: tooltipContents != null ? (_jsx(LakeTooltip, { content: tooltipContents, placement: "top", width: accountCountry === "DEU" ? 800 : undefined, children: _jsx(Icon, { name: "question-circle-regular", size: 16, color: colors.gray[600] }) })) : null, render: id => (_jsx(LakeTextInput, { id: id, placeholder: isCompany
|
|
11
12
|
? getCompanyTaxNumberPlaceholder(accountCountry)
|
|
12
13
|
: getIndividualTaxNumberPlaceholder(accountCountry), help: isCompany
|
|
13
14
|
? getCompanyTaxNumberHelp(accountCountry)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type AccountCountry = "DEU" | "ESP" | "FRA" | "NLD";
|
|
2
2
|
export declare const getIndividualTaxNumberPlaceholder: (accountCountry: AccountCountry) => string;
|
|
3
3
|
export declare const getCompanyTaxNumberPlaceholder: (accountCountry: AccountCountry) => string;
|
|
4
|
-
export declare const getTaxNumberTooltip: (accountCountry: AccountCountry) => string;
|
|
4
|
+
export declare const getTaxNumberTooltip: (accountCountry: AccountCountry) => string | undefined;
|
|
5
5
|
export declare const getCompanyTaxNumberHelp: (accountCountry: AccountCountry) => string;
|
|
6
6
|
export declare const getIndividualTaxNumberHelp: (accountCountry: AccountCountry) => string;
|
|
@@ -11,7 +11,7 @@ export const getCompanyTaxNumberPlaceholder = (accountCountry) => match(accountC
|
|
|
11
11
|
export const getTaxNumberTooltip = (accountCountry) => match(accountCountry)
|
|
12
12
|
.with("DEU", () => t("common.form.taxIdentificationNumber.tooltip.deu"))
|
|
13
13
|
.with("ESP", () => "Número de Identificación Fiscal") // no need to translate
|
|
14
|
-
.otherwise(() =>
|
|
14
|
+
.otherwise(() => undefined);
|
|
15
15
|
export const getCompanyTaxNumberHelp = (accountCountry) => match(accountCountry)
|
|
16
16
|
.with("DEU", () => t("common.form.help.nbDigits", { nbDigits: "10-11" }))
|
|
17
17
|
.with("ESP", () => t("common.form.help.nbCharacters", { nbCharacters: "9" }))
|