@swan-io/shared-business 13.7.9 → 13.7.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.7.9",
3
+ "version": "13.7.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.7.9"
28
+ "@swan-io/lake": "13.7.10"
29
29
  },
30
30
  "dependencies": {
31
31
  "@formatjs/intl": "^4.1.2",
@@ -50,6 +50,6 @@
50
50
  "@types/react-dom": "^19.2.3",
51
51
  "@types/react-native": "^0.72.8",
52
52
  "type-fest": "^5.4.3",
53
- "@swan-io/lake": "13.7.9"
53
+ "@swan-io/lake": "13.7.10"
54
54
  }
55
55
  }
@@ -40,7 +40,7 @@ type Props<Purpose extends string> = {
40
40
  label: string;
41
41
  description: string;
42
42
  purposeDetails?: string;
43
- }>;
43
+ } | undefined>;
44
44
  uploadFile?: (config: UploadFileInput<UploadOutput>) => Future<Result<Response<string>, NetworkError | TimeoutError>>;
45
45
  onChange?: (documents: Document<Purpose>[]) => void;
46
46
  onRemoveFile?: (file: SwanFile) => Future<Result<unknown, unknown>>;
@@ -50,5 +50,7 @@ type Props<Purpose extends string> = {
50
50
  getPurposeMetadata?: (purose: Purpose) => PurposeMetadata | undefined;
51
51
  readonlyDocumentPurposes?: Purpose[];
52
52
  };
53
+ export declare const getSupportingDocumentPurposeLabel: (purpose: string) => string;
54
+ export declare const getSupportingDocumentPurposeDescriptionLabel: (purpose: string) => string;
53
55
  export declare const SupportingDocumentCollection: <Purpose extends string>({ ref, documents, generateUpload, uploadFile, requiredDocumentPurposes, templateLanguage, status, onChange, onRemoveFile, showIds, readOnly, getPurposeMetadata, readonlyDocumentPurposes, }: Props<Purpose>) => import("react/jsx-runtime").JSX.Element;
54
56
  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 } from "ts-pattern";
18
- import { locale, t } from "../utils/i18n";
18
+ import { isTranslationKey, 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"];
@@ -42,6 +42,14 @@ const getSupportLink = (language) => match(language)
42
42
  .with("es", () => "https://support.swan.io/hc/en-150/articles/22544703221021--Proof-of-registration-for-Spanish-companies")
43
43
  .with("nl", () => "https://support.swan.io/hc/en-150/articles/22543228421277--Proof-of-registration-for-Dutch-companies")
44
44
  .otherwise(() => "https://support.swan.io/hc/en-150/articles/22620756787869-Proof-of-company-registration");
45
+ export const getSupportingDocumentPurposeLabel = (purpose) => {
46
+ const key = `supportingDocuments.purpose.${purpose}`;
47
+ return isTranslationKey(key) ? t(key) : purpose;
48
+ };
49
+ export const getSupportingDocumentPurposeDescriptionLabel = (purpose) => {
50
+ const key = `supportingDocuments.purpose.${purpose}.description`;
51
+ return isTranslationKey(key) ? t(key) : "";
52
+ };
45
53
  export const SupportingDocumentCollection = ({ ref, documents, generateUpload, uploadFile, requiredDocumentPurposes, templateLanguage = locale.language, status, onChange, onRemoveFile, showIds = false, readOnly = false, getPurposeMetadata, readonlyDocumentPurposes = [], }) => {
46
54
  const [showPowerOfAttorneyModal, setShowPowerOfAttorneyModal] = useState(false);
47
55
  const [showSwornStatementModal, setShowSwornStatementModal] = useState(false);
@@ -121,9 +129,9 @@ export const SupportingDocumentCollection = ({ ref, documents, generateUpload, u
121
129
  return true;
122
130
  });
123
131
  return (_jsxs(Form, { children: [showableDocumentPurposes.map(({ purpose, files, areAllDocumentsValidated, isRequired }) => {
124
- var _a;
132
+ var _a, _b, _c, _d, _e, _f;
125
133
  const metadata = getPurposeMetadata === null || getPurposeMetadata === void 0 ? void 0 : getPurposeMetadata(purpose);
126
- return (_jsxs(Fragment, { children: [_jsx(LakeLabel, { label: requiredDocumentPurposes[purpose].label, description: (_a = requiredDocumentPurposes[purpose].purposeDetails) !== null && _a !== void 0 ? _a : requiredDocumentPurposes[purpose].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)), 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)
134
+ return (_jsxs(Fragment, { children: [_jsx(LakeLabel, { label: (_b = (_a = requiredDocumentPurposes[purpose]) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : getSupportingDocumentPurposeLabel(purpose), description: (_f = (_d = (_c = requiredDocumentPurposes[purpose]) === null || _c === void 0 ? void 0 : _c.purposeDetails) !== null && _d !== void 0 ? _d : (_e = requiredDocumentPurposes[purpose]) === null || _e === void 0 ? void 0 : _e.description) !== null && _f !== void 0 ? _f : getSupportingDocumentPurposeDescriptionLabel(purpose), 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)), 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)
127
135
  .with("CompanyRegistration", () => (_jsx(LakeButton, { size: "small", mode: "secondary", icon: "question-circle-regular", onPress: () => window.open(getSupportLink(locale.language)), ariaLabel: t("supportingDocuments.help.howToSendAGoodDocument"), children: t("supportingDocuments.help.howToSendAGoodDocument") })))
128
136
  .otherwise(() => null)) }), match(purpose)
129
137
  .with("PowerOfAttorney", () => (_jsx(Help, { type: "button", icon: "arrow-down-filled", label: t("supportingDocuments.help.downloadTemplate"), onPress: () => setShowPowerOfAttorneyModal(true) })))