@swan-io/shared-business 7.0.4 → 7.0.6

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": "7.0.4",
3
+ "version": "7.0.6",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -27,6 +27,7 @@ type Props<Purpose extends string> = {
27
27
  onRemoveFile?: (file: SwanFile) => Future<Result<unknown, unknown>>;
28
28
  templateLanguage?: string;
29
29
  showIds?: boolean;
30
+ readOnly?: boolean;
30
31
  };
31
32
  export declare const getSupportingDocumentPurposeLabel: (purpose: string) => string;
32
33
  export declare const getSupportingDocumentPurposeDescriptionLabel: (purpose: string) => string;
@@ -34,7 +35,7 @@ export type SupportingDocumentCollectionRef<Purpose extends string> = {
34
35
  areAllRequiredDocumentsFilled: () => boolean;
35
36
  addDocument: (document: Document<Purpose>) => void;
36
37
  };
37
- export declare const SupportingDocumentCollectionWithRef: <Purpose extends string>({ documents, generateUpload, requiredDocumentPurposes, templateLanguage, status, onRemoveFile, showIds, }: Props<Purpose>, ref: Ref<SupportingDocumentCollectionRef<Purpose>>) => import("react/jsx-runtime").JSX.Element;
38
+ export declare const SupportingDocumentCollectionWithRef: <Purpose extends string>({ documents, generateUpload, requiredDocumentPurposes, templateLanguage, status, onRemoveFile, showIds, readOnly, }: Props<Purpose>, ref: Ref<SupportingDocumentCollectionRef<Purpose>>) => import("react/jsx-runtime").JSX.Element;
38
39
  export declare const SupportingDocumentCollection: <I extends string>(props: Props<I> & {
39
40
  ref?: ForwardedRef<SupportingDocumentCollectionRef<I>>;
40
41
  }) => ReturnType<typeof SupportingDocumentCollectionWithRef>;
@@ -48,7 +48,7 @@ export const getSupportingDocumentPurposeDescriptionLabel = (purpose) => {
48
48
  return "";
49
49
  }
50
50
  };
51
- export const SupportingDocumentCollectionWithRef = ({ documents, generateUpload, requiredDocumentPurposes, templateLanguage = locale.language, status, onRemoveFile, showIds = false, }, ref) => {
51
+ export const SupportingDocumentCollectionWithRef = ({ documents, generateUpload, requiredDocumentPurposes, templateLanguage = locale.language, status, onRemoveFile, showIds = false, readOnly = false, }, ref) => {
52
52
  const [showPowerOfAttorneyModal, setShowPowerOfAttorneyModal] = useState(false);
53
53
  const [showSwornStatementModal, setShowSwornStatementModal] = useState(false);
54
54
  const [addedDocuments, setAddedDocuments] = useState([]);
@@ -128,7 +128,7 @@ export const SupportingDocumentCollectionWithRef = ({ documents, generateUpload,
128
128
  }), render: () => (_jsx(FilesUploader, { ref: ref => (filesUploaderRefByPurpose.current[purpose] = ref),
129
129
  // Only allow uploading is the Supporting Document Collection awaits for docs
130
130
  // and that the specific purpose isn't already fully validated
131
- canUpload: status === "WaitingForDocument" && !areAllDocumentsValidated, accept: ACCEPTED_FORMATS, maxSize: 20000000, icon: "document-regular", initialFiles: files, generateUpload: generateUpload, getUploadConfig: file => ({ fileName: file.name, purpose }), uploadFile: ({ upload, file, onLoadStart, onProgress }) => {
131
+ canUpload: !readOnly && status === "WaitingForDocument" && !areAllDocumentsValidated, accept: ACCEPTED_FORMATS, maxSize: 20000000, icon: "document-regular", initialFiles: files, generateUpload: generateUpload, getUploadConfig: file => ({ fileName: file.name, purpose }), uploadFile: ({ upload, file, onLoadStart, onProgress }) => {
132
132
  const body = new FormData();
133
133
  upload.fields.forEach(({ key, value }) => body.append(key, value));
134
134
  body.append("file", file);
@@ -141,7 +141,7 @@ export const SupportingDocumentCollectionWithRef = ({ documents, generateUpload,
141
141
  }).mapOkToResult(badStatusToError);
142
142
  }, formatAndSizeDescription: t("supportingDocuments.documentTypes", {
143
143
  maxSizeMB: 20000000 / 1000000,
144
- }), onRemoveFile: onRemoveFile, onChange: files => {
144
+ }), onRemoveFile: readOnly ? undefined : onRemoveFile, onChange: files => {
145
145
  if (isRequired) {
146
146
  filesByRequiredPurpose.current.set(purpose, files);
147
147
  }