@swan-io/shared-business 15.0.0 → 15.1.1

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": "15.0.0",
3
+ "version": "15.1.1",
4
4
  "engines": {
5
5
  "node": ">22.12.0"
6
6
  },
@@ -28,7 +28,7 @@
28
28
  "react": ">=19.0.0",
29
29
  "react-dom": ">=19.0.0",
30
30
  "react-native-web": ">=0.21.2",
31
- "@swan-io/lake": "15.0.0"
31
+ "@swan-io/lake": "15.1.1"
32
32
  },
33
33
  "dependencies": {
34
34
  "@formatjs/intl": "^4.1.11",
@@ -53,6 +53,6 @@
53
53
  "react-dom": "^19.2.6",
54
54
  "react-native-web": "^0.21.2",
55
55
  "type-fest": "^5.6.0",
56
- "@swan-io/lake": "15.0.0"
56
+ "@swan-io/lake": "15.1.1"
57
57
  }
58
58
  }
@@ -31,6 +31,7 @@ export declare const getInitialPhoneCountry: (phoneNumber: string | undefined, d
31
31
  idd: string;
32
32
  uid: string;
33
33
  flag: string;
34
+ isNationality: boolean;
34
35
  };
35
36
  export declare const InputPhoneNumber: ({ ref, id, country, value, countries, error, help, valid, autofocus, disabled, readOnly, countryAriaLabel, hideErrors, onCountryChange, onChangeText, onSubmitEditing, onBlur, }: Props) => import("react/jsx-runtime").JSX.Element;
36
37
  export {};
@@ -15,7 +15,7 @@ import { badStatusToError, Request } from "@swan-io/request";
15
15
  import { Fragment, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
16
16
  import { StyleSheet } from "react-native";
17
17
  import { match, P } from "ts-pattern";
18
- import { isTranslationKey, locale, t } from "../utils/i18n";
18
+ import { locale, t } from "../utils/i18n";
19
19
  import { FilesUploader } from "./FilesUploader";
20
20
  import { LakeModal } from "./LakeModal";
21
21
  const ACCEPTED_FORMATS = ["application/pdf", "image/png", "image/jpeg", "image/heic"];
@@ -55,17 +55,8 @@ const getSupportLink = (language, country) => match({ language, country })
55
55
  .with(P.union({ country: "NLD" }, { country: P.nullish, language: "nl" }), () => `https://support.swan.io/hc/${language}/articles/22543228421277`)
56
56
  .with(P.union({ country: "BEL" }), () => `https://support.swan.io/hc/${language}/articles/31233251462173`)
57
57
  .otherwise(() => "https://support.swan.io/hc/en-150/articles/22620756787869-Proof-of-company-registration");
58
- // Fallback helpers kept temporarily as a safety net
59
- // Remove after ~1 month if backend reliably returns translated label/description for every purpose.
60
- const getSupportingDocumentPurposeLabel = (purpose) => {
61
- const key = `supportingDocuments.purpose.${purpose}`;
62
- return isTranslationKey(key) ? t(key) : purpose;
63
- };
64
- const getSupportingDocumentPurposeDescriptionLabel = (purpose) => {
65
- const key = `supportingDocuments.purpose.${purpose}.description`;
66
- return isTranslationKey(key) ? t(key) : "";
67
- };
68
58
  export const SupportingDocumentCollection = ({ ref, documents, generateUpload, uploadFile, documentPurposes, templateLanguage = locale.language, status, onChange, onRemoveFile, showIds = false, readOnly = false, getPurposeMetadata, companyCountry, readonlyDocumentPurposes = [], }) => {
59
+ var _a, _b;
69
60
  const [showPowerOfAttorneyModal, setShowPowerOfAttorneyModal] = useState(false);
70
61
  const [showSwornStatementModal, setShowSwornStatementModal] = useState(false);
71
62
  const [currentMetadata, setCurrentMetadata] = useState(undefined);
@@ -79,7 +70,7 @@ export const SupportingDocumentCollection = ({ ref, documents, generateUpload, u
79
70
  // 1 = purpose is required
80
71
  // 2 = otherwise
81
72
  const entries = [...allPurposes].map(purpose => {
82
- var _a, _b;
73
+ var _a;
83
74
  const purposeDocuments = allDocuments.filter(document => document.purpose === purpose);
84
75
  const areAllDocumentsValidated = purposeDocuments.length > 0 &&
85
76
  purposeDocuments.every(document => document.file.statusInfo.status === "Validated");
@@ -92,8 +83,8 @@ export const SupportingDocumentCollection = ({ ref, documents, generateUpload, u
92
83
  isRequired,
93
84
  areAllDocumentsValidated,
94
85
  priority,
95
- label: (_a = info === null || info === void 0 ? void 0 : info.label) !== null && _a !== void 0 ? _a : getSupportingDocumentPurposeLabel(purpose),
96
- description: (_b = info === null || info === void 0 ? void 0 : info.description) !== null && _b !== void 0 ? _b : getSupportingDocumentPurposeDescriptionLabel(purpose),
86
+ label: (_a = info === null || info === void 0 ? void 0 : info.label) !== null && _a !== void 0 ? _a : purpose,
87
+ description: info === null || info === void 0 ? void 0 : info.description,
97
88
  purposeDetails: info === null || info === void 0 ? void 0 : info.purposeDetails,
98
89
  };
99
90
  });
@@ -126,6 +117,7 @@ export const SupportingDocumentCollection = ({ ref, documents, generateUpload, u
126
117
  }
127
118
  return true;
128
119
  });
120
+ const swornStatementPurpose = orderedDocumentPurposes.find(({ purpose }) => purpose === "SwornStatement");
129
121
  return (_jsxs(Form, { children: [showableDocumentPurposes.map(({ purpose, files, areAllDocumentsValidated, isRequired, label, description, purposeDetails, }) => {
130
122
  const metadata = getPurposeMetadata === null || getPurposeMetadata === void 0 ? void 0 : getPurposeMetadata(purpose);
131
123
  return (_jsxs(Fragment, { children: [_jsx(LakeLabel, { label: label, description: purposeDetails !== null && purposeDetails !== void 0 ? purposeDetails : description, render: () => (_jsxs(_Fragment, { children: [_jsxs(Box, { direction: "row", children: [_jsx(Box, { direction: "row", children: isNotNullish(metadata) ? (purpose === "CompanyRegistration" ? (_jsxs(_Fragment, { children: [_jsx(LakeButton, { size: "small", mode: "secondary", icon: "question-circle-regular", onPress: () => window.open(getSupportLink(locale.language, companyCountry)), ariaLabel: t("supportingDocuments.help.howToSendAGoodDocument"), children: t("supportingDocuments.help.howToSendAGoodDocument") }), _jsx(Space, { width: 8 })] })) : (_jsxs(_Fragment, { children: [_jsx(Help, { type: "button", label: metadata.title, onPress: () => setCurrentMetadata(metadata) }), _jsx(Space, { width: 8 })] }))) : (match(purpose)
@@ -174,7 +166,7 @@ export const SupportingDocumentCollection = ({ ref, documents, generateUpload, u
174
166
  .with("de", () => "de")
175
167
  .with("es", () => "es")
176
168
  .with("it", () => "it")
177
- .otherwise(() => "en")}.pdf`), children: t("supportingDocuments.downloadTemplate") }) })] }), _jsxs(LakeModal, { visible: showSwornStatementModal, title: t("supportingDocuments.purpose.SwornStatement"), icon: "document-regular", onPressClose: () => setShowSwornStatementModal(false), children: [_jsx(LakeText, { children: t("supportingDocuments.purpose.SwornStatement.description") }), _jsx(Space, { height: 16 }), _jsx(LakeButtonGroup, { paddingBottom: 0, children: _jsx(LakeButton, { grow: true, color: "current", onPress: () => {
169
+ .otherwise(() => "en")}.pdf`), children: t("supportingDocuments.downloadTemplate") }) })] }), _jsxs(LakeModal, { visible: showSwornStatementModal, title: (_a = swornStatementPurpose === null || swornStatementPurpose === void 0 ? void 0 : swornStatementPurpose.label) !== null && _a !== void 0 ? _a : "Sworn Statement", icon: "document-regular", onPressClose: () => setShowSwornStatementModal(false), children: [_jsx(LakeText, { children: (_b = swornStatementPurpose === null || swornStatementPurpose === void 0 ? void 0 : swornStatementPurpose.description) !== null && _b !== void 0 ? _b : "" }), _jsx(Space, { height: 16 }), _jsx(LakeButtonGroup, { paddingBottom: 0, children: _jsx(LakeButton, { grow: true, color: "current", onPress: () => {
178
170
  window.open(`/sworn-statement-template/${match(templateLanguage)
179
171
  .with("nl", () => "nl")
180
172
  .with("es", () => "es")