@swan-io/shared-business 1.6.0 → 1.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/shared-business",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "engines": {
5
5
  "node": ">=14.0.0",
6
6
  "yarn": "^1.20.0"
@@ -29,30 +29,30 @@
29
29
  "@swan-io/lake": "^1.3.2"
30
30
  },
31
31
  "dependencies": {
32
- "@formatjs/intl": "^2.6.9",
32
+ "@formatjs/intl": "^2.7.0",
33
33
  "@googlemaps/js-api-loader": "^1.15.1",
34
- "@swan-io/boxed": "^0.12.1",
34
+ "@swan-io/boxed": "^0.13.0",
35
35
  "dayjs": "^1.11.7",
36
36
  "react": "^18.2.0",
37
37
  "react-atomic-state": "^1.2.7",
38
38
  "react-dom": "^18.2.0",
39
39
  "react-dropzone": "^14.2.3",
40
- "react-native-web": "^0.19.1",
40
+ "react-native-web": "^0.19.4",
41
41
  "react-ux-form": "^1.3.0",
42
42
  "rifm": "^0.12.1",
43
- "ts-pattern": "^4.2.1",
43
+ "ts-pattern": "^4.2.2",
44
44
  "uuid": "^9.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@swan-io/lake": "^1.3.2",
47
+ "@swan-io/lake": "^1.7.0",
48
48
  "@testing-library/react": "^14.0.0",
49
49
  "@testing-library/user-event": "^14.4.3",
50
- "@types/google.maps": "^3.52.3",
51
- "@types/react": "^18.0.28",
50
+ "@types/google.maps": "^3.52.5",
51
+ "@types/react": "^18.0.35",
52
52
  "@types/react-dom": "^18.0.11",
53
53
  "@types/react-native": "^0.71.5",
54
54
  "@types/uuid": "^9.0.1",
55
55
  "jsdom": "^21.1.1",
56
- "vitest": "^0.29.7"
56
+ "vitest": "^0.30.1"
57
57
  }
58
58
  }
@@ -8,7 +8,7 @@ export type EditorState = {
8
8
  firstName: string;
9
9
  lastName: string;
10
10
  birthDate: string;
11
- birthCountryCode: CountryCCA3;
11
+ birthCountryCode: CountryCCA3 | undefined;
12
12
  birthCity: string;
13
13
  birthCityPostalCode: string;
14
14
  type: BeneficiaryType;
@@ -38,6 +38,16 @@ const beneficiaryTypes = [
38
38
  { value: "HasCapital", name: t("beneficiaryForm.beneficiary.ownershipOfCapital") },
39
39
  { value: "Other", name: t("beneficiaryForm.beneficiary.other") },
40
40
  ];
41
+ const validateCca3CountryCode = value => {
42
+ if (value == null) {
43
+ return t("error.requiredField");
44
+ }
45
+ if (!isCountryCCA3(value)) {
46
+ // no need to set an error message because country picker contains only valid values
47
+ // this is used only for validateUbo function to display an error indicator without opening UBO modal
48
+ return " ";
49
+ }
50
+ };
41
51
  export const validateUbo = (editorState, accountCountry) => {
42
52
  const isAddressRequired = accountCountry === "DEU";
43
53
  const isBirthInfoRequired = accountCountry !== "DEU";
@@ -51,7 +61,7 @@ export const validateUbo = (editorState, accountCountry) => {
51
61
  birthDate: isBirthInfoRequired
52
62
  ? validateNullableRequired(editorState.birthDate)
53
63
  : undefined,
54
- birthCountryCode: validateNullableRequired(editorState.birthCountryCode),
64
+ birthCountryCode: validateCca3CountryCode(editorState.birthCountryCode),
55
65
  birthCity: isBirthInfoRequired
56
66
  ? validateNullableRequired(editorState.birthCity)
57
67
  : undefined,
@@ -38,9 +38,13 @@ export const GMapAddressSearchInput = ({ inputRef, id, country, disabled, error,
38
38
  const onSuggestionSelected = useCallback((suggestion) => {
39
39
  getPlaceDetails(suggestion.id).onResolve(result => {
40
40
  if (result.isOk()) {
41
- onSuggestion?.(result.value);
41
+ const dependsOnCountriesWithMultipleCCA3 = countriesWithMultipleCCA3[country]?.includes(result.value.country);
42
+ onSuggestion?.({
43
+ ...result.value,
44
+ country: dependsOnCountriesWithMultipleCCA3 === true ? country : result.value.country,
45
+ });
42
46
  }
43
47
  });
44
- }, [onSuggestion]);
48
+ }, [country, onSuggestion]);
45
49
  return (_jsx(AutocompleteSearchInput, { inputRef: inputRef, value: value, onValueChange: onValueChange, disabled: disabled, id: id, placeholder: placeholder, error: error, emptyResultText: emptyResultText, ListFooterComponent: _jsx(Box, { direction: "row", justifyContent: "end", style: styles.poweredByGoogle, children: _jsx(AutoWidthImage, { height: 14, sourceUri: poweredByGoogle }) }), shouldDisplaySuggestions: shouldDisplaySuggestions, loadSuggestions: loadSuggestions, onSuggestion: onSuggestionSelected }));
46
50
  };