@swan-io/shared-business 2.7.19 → 2.7.21

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/shared-business",
3
- "version": "2.7.19",
3
+ "version": "2.7.21",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -49,9 +49,14 @@ const validateCca3CountryCode = value => {
49
49
  }
50
50
  };
51
51
  export const validateUbo = (editorState, accountCountry) => {
52
- const isAddressRequired = accountCountry === "DEU" || accountCountry === "ESP";
53
- const isBirthInfoRequired = accountCountry !== "DEU";
54
- const isTaxIdentificationNumberRequired = accountCountry === "DEU" && editorState.residencyAddressCountry === "DEU";
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 === "DEU" || accountCountry === "ESP";
156
- const isBirthInfoRequired = accountCountry !== "DEU";
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);
@@ -330,8 +339,10 @@ export const BeneficiaryForm = forwardRef(({ initialState, accountCountry, step,
330
339
  ? t("beneficiaryForm.beneficiary.fillBirthCountry")
331
340
  : t("beneficiaryForm.beneficiary.birthPostalCodePlaceholder"), id: id, disabled: birthCountryCode.value === undefined, value: value, onChangeText: onChange })) })) })] })) }) }), _jsx(Field, { name: "type", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.type"), type: "radioGroup", render: () => (_jsx(RadioGroup, { direction: "row", value: value, onValueChange: onChange, items: beneficiaryTypes })) })) }), _jsx(FieldsListener, { names: ["type"], children: ({ type }) => type.value === "HasCapital" ? (_jsxs(_Fragment, { children: [_jsx(Field, { name: "totalCapitalPercentage", children: ({ value, onChange, error }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.totalCapitalPercentage"), render: id => (_jsx(LakeTextInput, { error: error, unit: "%", inputMode: "decimal", "aria-valuemin": 0, "aria-valuemax": 100, id: id, value: value, onChangeText: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(Field, { name: "capitalType", children: ({ value, error, onChange }) => (_jsx(CapitalTypeCheckboxes, { value: value ?? "none", error: error, onChange: onChange })) })] })) : null })] })))
332
341
  .with("address", () => (_jsxs(View, { role: "form", children: [_jsx(Field, { name: "country", children: ({ value, onChange }) => (_jsx(LakeLabel, { label: t("beneficiaryForm.beneficiary.country"), render: id => (_jsx(CountryPicker, { id: id, value: value, countries: allCountries, onValueChange: onChange })) })) }), _jsx(Space, { height: 12 }), _jsx(FieldsListener, { names: ["country"], children: ({ country }) => (_jsxs(_Fragment, { children: [_jsx(AddressFormPart, { apiKey: googleMapApiKey, initialAddress: initialAddress.current.residencyAddressLine1 ?? "", initialCity: initialAddress.current.residencyAddressCity ?? "", initialPostalCode: initialAddress.current.residencyAddressPostalCode ?? "", country: country?.value ?? accountCountry, label: t("beneficiaryForm.beneficiary.address"), Field: Field, setFieldValue: setFieldValue, listenFields: listenFields, isLarge: large }), ((accountCountry === "DEU" && country?.value === "DEU") ||
333
- accountCountry === "ESP") && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(Field, { name: "taxIdentificationNumber", children: ({ value, error, valid, onChange }) => (_jsx(TaxIdentificationNumberInput, { value: value ?? "", error: error, valid: valid, onChange: onChange, accountCountry: accountCountry, isCompany: false,
334
- // is mandatory for German accounts and UBO living in Germany
335
- required: accountCountry === "DEU" && country?.value === "DEU" })) })] }))] })) })] })))
342
+ accountCountry === "ESP" ||
343
+ accountCountry === "NLD") && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(Field, { name: "taxIdentificationNumber", children: ({ value, error, valid, onChange }) => (_jsx(TaxIdentificationNumberInput, { value: value ?? "", error: error, valid: valid, onChange: onChange, accountCountry: accountCountry, isCompany: false,
344
+ // is mandatory for German accounts with UBO living in Germany
345
+ required: (accountCountry === "DEU" && country?.value === "DEU") ||
346
+ accountCountry === "NLD" })) })] }))] })) })] })))
336
347
  .exhaustive(), isAddressRequired && (_jsxs(_Fragment, { children: [_jsx(Space, { height: 12 }), _jsx(StepDots, { currentStep: step, steps: formSteps })] }))] })) }));
337
348
  });