@swan-io/shared-business 13.7.8 → 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.
|
|
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.
|
|
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.
|
|
53
|
+
"@swan-io/lake": "13.7.10"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -36,7 +36,11 @@ type Props<Purpose extends string> = {
|
|
|
36
36
|
status: SupportingDocumentCollectionStatus;
|
|
37
37
|
generateUpload: (input: UploadInput<Purpose>) => Future<Result<UploadOutputWithId<UploadOutput>, unknown>>;
|
|
38
38
|
documents: Document<Purpose>[];
|
|
39
|
-
requiredDocumentPurposes: Purpose
|
|
39
|
+
requiredDocumentPurposes: Record<Purpose, {
|
|
40
|
+
label: string;
|
|
41
|
+
description: string;
|
|
42
|
+
purposeDetails?: string;
|
|
43
|
+
} | undefined>;
|
|
40
44
|
uploadFile?: (config: UploadFileInput<UploadOutput>) => Future<Result<Response<string>, NetworkError | TimeoutError>>;
|
|
41
45
|
onChange?: (documents: Document<Purpose>[]) => void;
|
|
42
46
|
onRemoveFile?: (file: SwanFile) => Future<Result<unknown, unknown>>;
|
|
@@ -45,10 +49,8 @@ type Props<Purpose extends string> = {
|
|
|
45
49
|
readOnly?: boolean;
|
|
46
50
|
getPurposeMetadata?: (purose: Purpose) => PurposeMetadata | undefined;
|
|
47
51
|
readonlyDocumentPurposes?: Purpose[];
|
|
48
|
-
purposeLabelOverrides?: Partial<Record<Purpose, string>>;
|
|
49
|
-
purposeDescriptionLabelOverrides?: Partial<Record<Purpose, string>>;
|
|
50
52
|
};
|
|
51
53
|
export declare const getSupportingDocumentPurposeLabel: (purpose: string) => string;
|
|
52
54
|
export declare const getSupportingDocumentPurposeDescriptionLabel: (purpose: string) => string;
|
|
53
|
-
export declare const SupportingDocumentCollection: <Purpose extends string>({ ref, documents, generateUpload, uploadFile, requiredDocumentPurposes, templateLanguage, status, onChange, onRemoveFile, showIds, readOnly, getPurposeMetadata, readonlyDocumentPurposes,
|
|
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 {};
|
|
@@ -50,14 +50,14 @@ export const getSupportingDocumentPurposeDescriptionLabel = (purpose) => {
|
|
|
50
50
|
const key = `supportingDocuments.purpose.${purpose}.description`;
|
|
51
51
|
return isTranslationKey(key) ? t(key) : "";
|
|
52
52
|
};
|
|
53
|
-
export const SupportingDocumentCollection = ({ ref, documents, generateUpload, uploadFile, requiredDocumentPurposes, templateLanguage = locale.language, status, onChange, onRemoveFile, showIds = false, readOnly = false, getPurposeMetadata, readonlyDocumentPurposes = [],
|
|
53
|
+
export const SupportingDocumentCollection = ({ ref, documents, generateUpload, uploadFile, requiredDocumentPurposes, templateLanguage = locale.language, status, onChange, onRemoveFile, showIds = false, readOnly = false, getPurposeMetadata, readonlyDocumentPurposes = [], }) => {
|
|
54
54
|
const [showPowerOfAttorneyModal, setShowPowerOfAttorneyModal] = useState(false);
|
|
55
55
|
const [showSwornStatementModal, setShowSwornStatementModal] = useState(false);
|
|
56
56
|
const [currentMetadata, setCurrentMetadata] = useState(undefined);
|
|
57
57
|
const [addedDocuments, setAddedDocuments] = useState([]);
|
|
58
58
|
const orderedDocumentPurposes = useMemo(() => {
|
|
59
59
|
// Get all purposes to display: the required ones and the ones that have at least a document
|
|
60
|
-
const allPurposes = new Set(requiredDocumentPurposes);
|
|
60
|
+
const allPurposes = new Set(Object.keys(requiredDocumentPurposes));
|
|
61
61
|
const allDocuments = [...addedDocuments, ...documents];
|
|
62
62
|
allDocuments.forEach(document => allPurposes.add(document.purpose));
|
|
63
63
|
const documentsByPurpose = new Map([...allPurposes].map(purpose => {
|
|
@@ -66,7 +66,7 @@ export const SupportingDocumentCollection = ({ ref, documents, generateUpload, u
|
|
|
66
66
|
}));
|
|
67
67
|
// Map purposes to their priorities (lower priority comes first)
|
|
68
68
|
// We precompute it to avoid running on each `sort` callback call
|
|
69
|
-
const allRequiredPurposes = new Set(requiredDocumentPurposes);
|
|
69
|
+
const allRequiredPurposes = new Set(Object.keys(requiredDocumentPurposes));
|
|
70
70
|
// Indices:
|
|
71
71
|
// -> 0: documents aren't empty and all validated
|
|
72
72
|
// -> 1: purpose is required
|
|
@@ -129,10 +129,9 @@ export const SupportingDocumentCollection = ({ ref, documents, generateUpload, u
|
|
|
129
129
|
return true;
|
|
130
130
|
});
|
|
131
131
|
return (_jsxs(Form, { children: [showableDocumentPurposes.map(({ purpose, files, areAllDocumentsValidated, isRequired }) => {
|
|
132
|
-
var _a, _b;
|
|
132
|
+
var _a, _b, _c, _d, _e, _f;
|
|
133
133
|
const metadata = getPurposeMetadata === null || getPurposeMetadata === void 0 ? void 0 : getPurposeMetadata(purpose);
|
|
134
|
-
|
|
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, 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)
|
|
136
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") })))
|
|
137
136
|
.otherwise(() => null)) }), match(purpose)
|
|
138
137
|
.with("PowerOfAttorney", () => (_jsx(Help, { type: "button", icon: "arrow-down-filled", label: t("supportingDocuments.help.downloadTemplate"), onPress: () => setShowPowerOfAttorneyModal(true) })))
|