@tap-payments/auth-jsconnect 2.1.90-test → 2.1.92-test

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.
@@ -25,6 +25,6 @@ var BankStatement = function (_a) {
25
25
  var handleReset = function (ids) {
26
26
  bankStatementIdControl.field.onChange(ids);
27
27
  };
28
- return (_jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { label: t('title_bank_statement'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleBankStatementChange, isSubmitting: loading, required: required, onDeleteFile: handleReset, purpose: 'bank_statement', maxLimit: 4, fileUploadingStatus: function (uploading) { return dispatch(bankStatementUploadingStatus(uploading)); } }) }));
28
+ return (_jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'bankStatementId', control: control, label: t('title_bank_statement'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleBankStatementChange, isSubmitting: loading, required: required, onDeleteFile: handleReset, purpose: 'bank_statement', maxLimit: 4, fileUploadingStatus: function (uploading) { return dispatch(bankStatementUploadingStatus(uploading)); } }) }));
29
29
  };
30
30
  export default BankStatement;
@@ -37,6 +37,6 @@ var LicenseCertificate = function (_a) {
37
37
  var handleReset = function (ids) {
38
38
  certificateIdControl.field.onChange(ids);
39
39
  };
40
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'commercial_registration', fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) }) })));
40
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'certificateId', control: control, label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'commercial_registration', fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) }) })));
41
41
  };
42
42
  export default LicenseCertificate;
@@ -37,6 +37,6 @@ var LicenseCertificate = function (_a) {
37
37
  var handleReset = function (ids) {
38
38
  certificateIdControl.field.onChange(ids);
39
39
  };
40
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'commercial_registration', fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) }) })));
40
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'certificateId', control: control, label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'commercial_registration', fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) }) })));
41
41
  };
42
42
  export default LicenseCertificate;
@@ -24,6 +24,6 @@ var CivilIDFile = function () {
24
24
  var handleReset = function (ids) {
25
25
  civilIDFileIdControl.field.onChange(ids);
26
26
  };
27
- return (_jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { label: t('title_civil_id'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_civilID'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_civil_id'), onFileUploaded: handleCivilIDChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'identity_document', fileUploadingStatus: function (uploading) { return dispatch(civilIDUploadingStatus(uploading)); } }) }));
27
+ return (_jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'civilID', control: control, label: t('title_civil_id'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_civilID'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_civil_id'), onFileUploaded: handleCivilIDChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'identity_document', fileUploadingStatus: function (uploading) { return dispatch(civilIDUploadingStatus(uploading)); } }) }));
28
28
  };
29
29
  export default CivilIDFile;
@@ -37,6 +37,6 @@ var SignatureFile = function (_a) {
37
37
  var handleReset = function (ids) {
38
38
  signatureFileIdControl.field.onChange(ids);
39
39
  };
40
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { label: t('title_signature_file'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_signature'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_signature_file'), onFileUploaded: handleSignatureChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'customer_signature', fileUploadingStatus: function (uploading) { return dispatch(signatureFileUploadingStatus(uploading)); } }) }) })));
40
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'signatureFileId', control: control, label: t('title_signature_file'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_signature'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_signature_file'), onFileUploaded: handleSignatureChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'customer_signature', fileUploadingStatus: function (uploading) { return dispatch(signatureFileUploadingStatus(uploading)); } }) }) })));
41
41
  };
42
42
  export default SignatureFile;
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
+ import { FileInfo } from './UploadFile';
3
+ import { Control, FieldValues } from 'react-hook-form';
2
4
  export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
3
5
  children?: React.ReactNode;
4
6
  component?: React.ElementType<any> | undefined;
@@ -8,6 +10,8 @@ export declare const InputContainerStyled: import("@emotion/styled").StyledCompo
8
10
  ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
9
11
  }, keyof import("@mui/material/OverridableComponent").CommonProps | ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "ref" | "children" | "component" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
10
12
  interface UploadMultipleFileProps {
13
+ id: string;
14
+ control: Control<FieldValues, any>;
11
15
  label: string;
12
16
  purpose: string;
13
17
  fileTitle?: string;
@@ -22,6 +26,8 @@ interface UploadMultipleFileProps {
22
26
  fileUploadingStatus?: (uploading: boolean) => void;
23
27
  onDeleteFile: (fileIds: Array<string>) => void;
24
28
  maxLimit?: number;
29
+ initialFiles?: Array<File>;
30
+ initialFileInfoArray?: Array<FileInfo>;
25
31
  }
26
- declare const UploadMultipleFile: ({ label, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle }: UploadMultipleFileProps) => JSX.Element;
32
+ declare const UploadMultipleFile: ({ id, label, control, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle }: UploadMultipleFileProps) => JSX.Element;
27
33
  export default UploadMultipleFile;
@@ -29,6 +29,7 @@ import { InputLabelStyled } from '../../shared/Input/Input';
29
29
  import { ScreenContainer } from '../../shared/Containers';
30
30
  import Mandatory from '../../shared/Mandatory';
31
31
  import UploadFile, { FileStatus } from './UploadFile';
32
+ import { useController } from 'react-hook-form';
32
33
  var FeatureStyled = styled(ScreenContainer)(function (_a) {
33
34
  var theme = _a.theme;
34
35
  return ({
@@ -59,12 +60,14 @@ var UploadCountBox = styled(Box)(function (_a) {
59
60
  });
60
61
  });
61
62
  var UploadMultipleFile = function (_a) {
62
- var label = _a.label, required = _a.required, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, onFileUploaded = _a.onFileUploaded, fileUploadingStatus = _a.fileUploadingStatus, onDeleteFile = _a.onDeleteFile, maxLimit = _a.maxLimit, purpose = _a.purpose, fileTitle = _a.fileTitle;
63
+ var id = _a.id, label = _a.label, control = _a.control, required = _a.required, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, onFileUploaded = _a.onFileUploaded, fileUploadingStatus = _a.fileUploadingStatus, onDeleteFile = _a.onDeleteFile, maxLimit = _a.maxLimit, purpose = _a.purpose, fileTitle = _a.fileTitle;
63
64
  var t = useTranslation().t;
64
65
  var theme = useTheme();
65
66
  var _b = React.useState(''), error = _b[0], setError = _b[1];
66
- var _c = React.useState([]), fileArray = _c[0], setFileArray = _c[1];
67
- var _d = React.useState([]), fileInfoArray = _d[0], setFileInfoArray = _d[1];
67
+ var fileControl = useController({ name: "".concat(id, "File"), control: control });
68
+ var fileInfoControl = useController({ name: "".concat(id, "FileInfo"), control: control });
69
+ var fileArray = fileControl.field.value || [];
70
+ var fileInfoArray = fileInfoControl.field.value || [];
68
71
  var uploadedFileCount = React.useMemo(function () { return (fileInfoArray || []).filter(function (file) { return file.fileId; }).length; }, [fileInfoArray]);
69
72
  var handleFileChange = function (files) {
70
73
  if (!isSubmitting) {
@@ -96,8 +99,8 @@ var UploadMultipleFile = function (_a) {
96
99
  fileInfoArray.push({ fileId: '', status: FileStatus.INIT, progress: 0, error: '', name: file.name });
97
100
  }
98
101
  });
99
- setFileArray(__spreadArray([], fileArray, true));
100
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
102
+ fileControl.field.onChange(__spreadArray([], fileArray, true));
103
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
101
104
  }
102
105
  }
103
106
  };
@@ -108,9 +111,9 @@ var UploadMultipleFile = function (_a) {
108
111
  if (required && fileInfoArray.length === 1)
109
112
  setError(t('file_upload_at_least_one'));
110
113
  fileArray.splice(index, 1);
111
- setFileArray(__spreadArray([], fileArray, true));
114
+ fileControl.field.onChange(__spreadArray([], fileArray, true));
112
115
  fileInfoArray.splice(index, 1);
113
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
116
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
114
117
  var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
115
118
  onDeleteFile(fileIds);
116
119
  }
@@ -119,7 +122,7 @@ var UploadMultipleFile = function (_a) {
119
122
  var handleSuccess = function (index, file) {
120
123
  if (fileInfoArray.length > 0) {
121
124
  fileInfoArray[index] = file;
122
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
125
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
123
126
  var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
124
127
  onFileUploaded(fileIds);
125
128
  fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
@@ -128,14 +131,14 @@ var UploadMultipleFile = function (_a) {
128
131
  var handleFailure = function (index, file) {
129
132
  if (fileInfoArray.length > 0) {
130
133
  fileInfoArray[index] = file;
131
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
134
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
132
135
  fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
133
136
  }
134
137
  };
135
138
  var handleProgress = function (index, file) {
136
139
  if (fileInfoArray.length > 0) {
137
140
  fileInfoArray[index] = file;
138
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
141
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
139
142
  fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(true);
140
143
  }
141
144
  };
@@ -37,6 +37,6 @@ var TaxDocument = function (_a) {
37
37
  var handleReset = function (ids) {
38
38
  documentIdControl.field.onChange(ids);
39
39
  };
40
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(UploadMultipleFile, { label: t('title_tax_document'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_tax_document'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleTaxDocumentChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'tax_document_user_upload', fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) })) })));
40
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(UploadMultipleFile, { id: 'documentId', control: control, label: t('title_tax_document'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_tax_document'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleTaxDocumentChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'tax_document_user_upload', fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) })) })));
41
41
  };
42
42
  export default TaxDocument;
@@ -90,9 +90,9 @@ export var findCountryByIddPrefix = function (countries, iddPrefix) {
90
90
  export var mapSalesChannel = function (salesChannel) {
91
91
  return salesChannel.map(function (item) {
92
92
  var hasSub = item.sub && item.sub.length > 0;
93
- return __assign(__assign(__assign({}, item), { address: (item.address || '').replaceAll('https://', '').replaceAll('@', '') }), (hasSub && {
93
+ return __assign(__assign(__assign({}, item), { address: (item.address || '').replaceAll('https://', '').replaceAll('www.', '').replaceAll('@', '') }), (hasSub && {
94
94
  sub: item.sub.map(function (subItem) {
95
- return __assign(__assign({}, subItem), { address: (subItem.address || '').replaceAll('https://', '').replaceAll('@', '') });
95
+ return __assign(__assign({}, subItem), { address: (subItem.address || '').replaceAll('https://', '').replaceAll('www.', '').replaceAll('@', '') });
96
96
  })
97
97
  }));
98
98
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.1.90-test",
3
+ "version": "2.1.92-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",