@swan-io/shared-business 13.1.9 → 13.1.10

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": "13.1.9",
3
+ "version": "13.1.10",
4
4
  "engines": {
5
5
  "node": "^22.12.0"
6
6
  },
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "license": "MIT",
27
27
  "peerDependencies": {
28
- "@swan-io/lake": "13.1.9"
28
+ "@swan-io/lake": "13.1.10"
29
29
  },
30
30
  "dependencies": {
31
31
  "@formatjs/intl": "^3.1.6",
@@ -50,6 +50,6 @@
50
50
  "@types/react-dom": "^19.1.7",
51
51
  "@types/react-native": "^0.72.8",
52
52
  "type-fest": "^4.41.0",
53
- "@swan-io/lake": "13.1.9"
53
+ "@swan-io/lake": "13.1.10"
54
54
  }
55
55
  }
@@ -1,5 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Array, Option } from "@swan-io/boxed";
3
+ import { Box } from "@swan-io/lake/src/components/Box";
3
4
  import { Form } from "@swan-io/lake/src/components/Form";
4
5
  import { LakeButton, LakeButtonGroup } from "@swan-io/lake/src/components/LakeButton";
5
6
  import { LakeCopyButton } from "@swan-io/lake/src/components/LakeCopyButton";
@@ -10,7 +11,7 @@ import { ReadOnlyFieldList } from "@swan-io/lake/src/components/ReadOnlyFieldLis
10
11
  import { Space } from "@swan-io/lake/src/components/Space";
11
12
  import { colors } from "@swan-io/lake/src/constants/design";
12
13
  import { isNotNullish } from "@swan-io/lake/src/utils/nullish";
13
- import { Request, badStatusToError } from "@swan-io/request";
14
+ import { badStatusToError, Request } from "@swan-io/request";
14
15
  import { Fragment, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
15
16
  import { StyleSheet } from "react-native";
16
17
  import { match } from "ts-pattern";
@@ -30,10 +31,17 @@ const Help = (props) => {
30
31
  })
31
32
  .with({ type: "button" }, ({ label, onPress }) => {
32
33
  var _a;
33
- return (_jsx(LakeButton, { mode: "tertiary", size: "small", color: "gray", icon: (_a = props.icon) !== null && _a !== void 0 ? _a : "question-circle-regular", onPress: onPress, style: styles.button, ariaLabel: t("supportingDocuments.help.whatIsThis"), children: label }));
34
+ return (_jsx(LakeButton, { mode: "secondary", size: "small", color: "gray", icon: (_a = props.icon) !== null && _a !== void 0 ? _a : "question-circle-regular", onPress: onPress, style: styles.button, ariaLabel: t("supportingDocuments.help.whatIsThis"), children: label }));
34
35
  })
35
36
  .exhaustive();
36
37
  };
38
+ const getSupportLink = (language) => match(language)
39
+ .with("fr", () => "https://support.swan.io/hc/en-150/articles/22502977563933--Proof-of-registration-for-French-companies")
40
+ .with("it", () => "https://support.swan.io/hc/en-150/articles/22537604831005--Proof-of-registration-for-Italian-companies")
41
+ .with("de", () => "https://support.swan.io/hc/en-150/articles/22535023588509--Proof-of-registration-for-German-companies")
42
+ .with("es", () => "https://support.swan.io/hc/en-150/articles/22544703221021--Proof-of-registration-for-Spanish-companies")
43
+ .with("nl", () => "https://support.swan.io/hc/en-150/articles/22543228421277--Proof-of-registration-for-Dutch-companies")
44
+ .otherwise(() => "https://support.swan.io/hc/en-150/articles/22620756787869-Proof-of-company-registration");
37
45
  export const getSupportingDocumentPurposeLabel = (purpose) => {
38
46
  const key = `supportingDocuments.purpose.${purpose}`;
39
47
  return isTranslationKey(key) ? t(key) : purpose;
@@ -124,37 +132,41 @@ export const SupportingDocumentCollection = ({ ref, documents, generateUpload, u
124
132
  var _a, _b;
125
133
  const metadata = getPurposeMetadata === null || getPurposeMetadata === void 0 ? void 0 : getPurposeMetadata(purpose);
126
134
  const label = (_a = purposeDescriptionLabelOverrides === null || purposeDescriptionLabelOverrides === void 0 ? void 0 : purposeDescriptionLabelOverrides[purpose]) !== null && _a !== void 0 ? _a : getSupportingDocumentPurposeDescriptionLabel(purpose);
127
- return (_jsxs(Fragment, { children: [_jsx(LakeLabel, { label: (_b = purposeLabelOverrides === null || purposeLabelOverrides === void 0 ? void 0 : purposeLabelOverrides[purpose]) !== null && _b !== void 0 ? _b : getSupportingDocumentPurposeLabel(purpose), description: label, help: isNotNullish(metadata) ? (_jsx(Help, { type: "button", label: metadata.title, onPress: () => setCurrentMetadata(metadata) })) : (match(purpose)
135
+ return (_jsxs(Fragment, { children: [_jsx(LakeLabel, { label: (_b = purposeLabelOverrides === null || purposeLabelOverrides === void 0 ? void 0 : purposeLabelOverrides[purpose]) !== null && _b !== void 0 ? _b : getSupportingDocumentPurposeLabel(purpose), description: label, help: isNotNullish(metadata) ? (purpose === "CompanyRegistration" ? (_jsx(LakeButton, { size: "small", mode: "tertiary", icon: "question-circle-regular", onPress: () => window.open(getSupportLink(locale.language)), ariaLabel: t("supportingDocuments.help.howToSendAGoodDocument"), children: t("supportingDocuments.help.howToSendAGoodDocument") })) : (_jsx(Help, { type: "button", label: metadata.title, onPress: () => setCurrentMetadata(metadata) }))) : (match(purpose)
128
136
  .with("PowerOfAttorney", () => (_jsx(Help, { type: "button", icon: "arrow-down-filled", label: t("supportingDocuments.help.downloadTemplate"), onPress: () => setShowPowerOfAttorneyModal(true) })))
129
137
  .with("SwornStatement", () => (_jsx(Help, { type: "button", icon: "arrow-down-filled", label: t("supportingDocuments.help.downloadTemplate"), onPress: () => setShowSwornStatementModal(true) })))
130
- .otherwise(() => null)), render: () => (_jsx(FilesUploader, { ref: ref => {
131
- filesUploaderRefByPurpose.current[purpose] = ref;
132
- },
133
- // Only allow uploading is the Supporting Document Collection awaits for docs
134
- // and that the specific purpose isn't already fully validated
135
- canUpload: !readonlyDocumentPurposes.includes(purpose) &&
136
- !readOnly &&
137
- status === "WaitingForDocument" &&
138
- !areAllDocumentsValidated, accept: ACCEPTED_FORMATS, maxSize: 20000000, icon: "document-regular", initialFiles: files, generateUpload: generateUpload, getUploadConfig: file => ({ fileName: file.name, purpose }), uploadFile: isNotNullish(uploadFile)
139
- ? uploadFile
140
- : ({ upload, file, onProgress }) => {
141
- const body = new FormData();
142
- upload.fields.forEach(({ key, value }) => body.append(key, value));
143
- body.append("file", file);
144
- setTimeout(() => onProgress(0.8), 100);
145
- return Request.make({
146
- url: upload.url,
147
- method: "POST",
148
- body,
149
- type: "text",
150
- }).mapOkToResult(badStatusToError);
151
- }, formatAndSizeDescription: t("supportingDocuments.documentTypes", {
152
- maxSizeMB: 20000000 / 1000000,
153
- }), onRemoveFile: readOnly ? undefined : onRemoveFile, onChange: files => {
154
- if (isRequired) {
155
- filesByRequiredPurpose.current.set(purpose, files);
156
- }
157
- }, showIds: showIds })) }), _jsx(Space, { height: 24 })] }, purpose));
138
+ .with("CompanyRegistration", () => (_jsx(LakeButton, { size: "small", mode: "tertiary", icon: "question-circle-regular", onPress: () => window.open(getSupportLink(locale.language)), ariaLabel: t("supportingDocuments.help.howToSendAGoodDocument"), children: t("supportingDocuments.help.howToSendAGoodDocument") })))
139
+ .otherwise(() => null)), render: () => (_jsxs(_Fragment, { children: [_jsx(Box, { direction: "row", children: match(purpose)
140
+ .with("PowerOfAttorney", () => (_jsx(Help, { type: "button", icon: "arrow-down-filled", label: t("supportingDocuments.help.downloadTemplate"), onPress: () => setShowPowerOfAttorneyModal(true) })))
141
+ .with("SwornStatement", () => (_jsx(Help, { type: "button", icon: "arrow-down-filled", label: t("supportingDocuments.help.downloadTemplate"), onPress: () => setShowSwornStatementModal(true) })))
142
+ .otherwise(() => null) }), _jsx(Space, { height: 16 }), _jsx(FilesUploader, { ref: ref => {
143
+ filesUploaderRefByPurpose.current[purpose] = ref;
144
+ },
145
+ // Only allow uploading is the Supporting Document Collection awaits for docs
146
+ // and that the specific purpose isn't already fully validated
147
+ canUpload: !readonlyDocumentPurposes.includes(purpose) &&
148
+ !readOnly &&
149
+ status === "WaitingForDocument" &&
150
+ !areAllDocumentsValidated, accept: ACCEPTED_FORMATS, maxSize: 20000000, icon: "document-regular", initialFiles: files, generateUpload: generateUpload, getUploadConfig: file => ({ fileName: file.name, purpose }), uploadFile: isNotNullish(uploadFile)
151
+ ? uploadFile
152
+ : ({ upload, file, onProgress }) => {
153
+ const body = new FormData();
154
+ upload.fields.forEach(({ key, value }) => body.append(key, value));
155
+ body.append("file", file);
156
+ setTimeout(() => onProgress(0.8), 100);
157
+ return Request.make({
158
+ url: upload.url,
159
+ method: "POST",
160
+ body,
161
+ type: "text",
162
+ }).mapOkToResult(badStatusToError);
163
+ }, formatAndSizeDescription: t("supportingDocuments.documentTypes", {
164
+ maxSizeMB: 20000000 / 1000000,
165
+ }), onRemoveFile: readOnly ? undefined : onRemoveFile, onChange: files => {
166
+ if (isRequired) {
167
+ filesByRequiredPurpose.current.set(purpose, files);
168
+ }
169
+ }, showIds: showIds })] })) }), _jsx(Space, { height: 24 })] }, purpose));
158
170
  }), showableDocumentPurposes.length === 0 ? (_jsxs(_Fragment, { children: [_jsx(Space, { height: 24 }), _jsx(LakeText, { align: "center", children: t("supportingDocuments.noDocuments") }), _jsx(Space, { height: 24 })] })) : null, _jsxs(LakeModal, { visible: showPowerOfAttorneyModal, title: t("supportingDocuments.powerOfAttorneyModal.title"), icon: "document-regular", onPressClose: () => setShowPowerOfAttorneyModal(false), children: [_jsx(LakeText, { children: t("supportingDocuments.powerOfAttorneyModal.description") }), _jsx(Space, { height: 16 }), _jsx(LakeButtonGroup, { paddingBottom: 0, children: _jsx(LakeButton, { grow: true, color: "current", onPress: () => window.open(`/power-of-attorney-template/${match(templateLanguage)
159
171
  .with("fr", () => "fr")
160
172
  .with("de", () => "de")
@@ -298,6 +298,7 @@
298
298
  "supportingDocuments.help.whatIsThis": "What is this?",
299
299
  "supportingDocuments.informations": "Document details",
300
300
  "supportingDocuments.noDocuments": "No documents.",
301
+ "supportingDocuments.help.howToSendAGoodDocument": "How to send a good document?",
301
302
  "supportingDocuments.powerOfAttorneyModal.description": "A signed and dated document authorizing an individual to represent or act on behalf of a company's legal representative.",
302
303
  "supportingDocuments.powerOfAttorneyModal.title": "Power of attorney signed by the legal representative",
303
304
  "supportingDocuments.purpose.AdministratorDecisionOfAppointment": "Administrator appointment letter",