@tap-payments/auth-jsconnect 2.3.9-test → 2.3.11-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.
@@ -102,6 +102,10 @@ export declare type UpdateEntityCapitalBody = {
102
102
  };
103
103
  };
104
104
  };
105
+ export declare type UpdateEntityAOAFileBody = {
106
+ id: string;
107
+ AOA_file_id: string;
108
+ };
105
109
  declare const entityService: {
106
110
  createEntityInfo: ({ id, ...data }: EntityInfoBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
107
111
  updateEntityInfo: ({ id, ...data }: EntityInfoBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -114,5 +118,6 @@ declare const entityService: {
114
118
  updateEntityActivity: ({ id, ...data }: UpdateEntityActivityBody) => Promise<any>;
115
119
  retrieveEntityType: () => Promise<any>;
116
120
  updateEntityCapital: ({ id, ...data }: UpdateEntityCapitalBody) => Promise<any>;
121
+ updateEntityAOAFile: ({ id, ...data }: UpdateEntityAOAFileBody) => Promise<any>;
117
122
  };
118
123
  export { entityService };
@@ -69,6 +69,14 @@ var updateIndividualInfo = function (_a) {
69
69
  data: data
70
70
  });
71
71
  };
72
+ var updateEntityAOAFile = function (_a) {
73
+ var id = _a.id, data = __rest(_a, ["id"]);
74
+ return httpClient({
75
+ method: 'put',
76
+ url: "".concat(ENDPOINT_PATHS.ENTITY, "/").concat(id, "/aoa_file"),
77
+ data: data
78
+ });
79
+ };
72
80
  var retrieveEntityType = function () {
73
81
  return httpClient({
74
82
  method: 'get',
@@ -86,6 +94,7 @@ var entityService = {
86
94
  updateEntity: updateEntity,
87
95
  updateEntityActivity: updateEntityActivity,
88
96
  retrieveEntityType: retrieveEntityType,
89
- updateEntityCapital: updateEntityCapital
97
+ updateEntityCapital: updateEntityCapital,
98
+ updateEntityAOAFile: updateEntityAOAFile
90
99
  };
91
100
  export { entityService };
@@ -3,7 +3,7 @@ import { ValidateOperatorBody } from './operator';
3
3
  import { CreateAuthBody, VerifyAuthBody, CreatePasswordBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, VerifyAuthExpressOTPBody } from './auth';
4
4
  import { UpdateLeadBody, LeadVerifyBody, CreateLeadBody, LeadOTPVerifyBody, LeadIdentityUpdateBody } from './lead';
5
5
  import { CheckEmailBody, CheckBrandBody } from './availabilityServices';
6
- import { EntityInfoBody, EntityBankUpdateBody, BankDocumentInfo, UpdateEntityBody, UpdateEntityActivityBody, UpdateEntityCapitalBody } from './entity';
6
+ import { EntityInfoBody, EntityBankUpdateBody, BankDocumentInfo, UpdateEntityBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, UpdateEntityAOAFileBody } from './entity';
7
7
  import { CreateAccountBody, ExpressCreateAccountBody } from './account';
8
8
  import { DataElementBody } from './data';
9
9
  import { BrandListBody, UpdateBrandBody, UpdateIndividualBody, GetIndividualListBody } from './individual';
@@ -60,6 +60,7 @@ declare const API: {
60
60
  updateEntityActivity: ({ id, ...data }: UpdateEntityActivityBody) => Promise<any>;
61
61
  retrieveEntityType: () => Promise<any>;
62
62
  updateEntityCapital: ({ id, ...data }: UpdateEntityCapitalBody) => Promise<any>;
63
+ updateEntityAOAFile: ({ id, ...data }: UpdateEntityAOAFileBody) => Promise<any>;
63
64
  };
64
65
  availabilityServices: {
65
66
  checkEmail: (data: CheckEmailBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -141,6 +142,6 @@ declare const API: {
141
142
  removeFilesFromDocument: ({ id, ...data }: DocumentBody) => Promise<import("axios").AxiosResponse<any, any>>;
142
143
  };
143
144
  };
144
- export type { ValidateOperatorBody, CreateAuthBody, ExpressCreateAccountBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, UpdateEntityBody, DocumentUpdateBody, DocumentInfo, VerifyAuthExpressOTPBody, UpdateIndividualBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, BankDocumentInfo, GetUserListBody, GetIndividualListBody, RequestEmailBody, DocumentBody };
145
+ export type { ValidateOperatorBody, CreateAuthBody, ExpressCreateAccountBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoBody, CreateAccountBody, EntityBankUpdateBody, CreatePasswordBody, BrandListBody, VerifyOperationAuthBody, ResetPasswordVerifyAuthBody, UpdateBoardBody, UpdateBrandBody, DataElementBody, UploadFileBody, UpdateEntityBody, DocumentUpdateBody, DocumentInfo, VerifyAuthExpressOTPBody, UpdateIndividualBody, UpdateEntityActivityBody, UpdateEntityCapitalBody, BankDocumentInfo, GetUserListBody, GetIndividualListBody, RequestEmailBody, DocumentBody, UpdateEntityAOAFileBody };
145
146
  export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders, axiosInstance, getAxiosHeaders };
146
147
  export default API;
@@ -107,7 +107,7 @@ export var fetchAppSettingsSync = createAsyncThunk('fetchAppSettingsSync', funct
107
107
  },
108
108
  source: 'browser'
109
109
  };
110
- setAxiosGlobalHeaders(__assign(__assign(__assign({}, getRequestHeaders(deviceInfo)), { authorization: encryptString(appConfig.publicKey), mdn: encryptString(params.mdn || window.location.origin) }), (maturity && { maturity: maturity })));
110
+ setAxiosGlobalHeaders(__assign(__assign(__assign({}, getRequestHeaders(deviceInfo)), { authorization: encryptString(appConfig.publicKey), mdn: encryptString(params.mdn || window.location.origin), cu: window.location.href }), (maturity && { maturity: maturity })));
111
111
  return [4, API.operatorService.validateOperator(operatorData)];
112
112
  case 2:
113
113
  operatorStatus = _e.sent();
@@ -193,6 +193,9 @@ export declare const BUSINESS_FLOW_SUCCESS: {
193
193
  status: string;
194
194
  url: string;
195
195
  }[];
196
+ export declare enum FileRemoveType {
197
+ AOA_FILE_ID = "AOA_file_id"
198
+ }
196
199
  export declare enum FileType {
197
200
  IMAGES = "images",
198
201
  FILES = "files"
@@ -696,6 +696,10 @@ export var PASSWORD_OPERATION_TYPE = {
696
696
  RESET_PASSWORD: 'reset_password'
697
697
  };
698
698
  export var BUSINESS_FLOW_SUCCESS = [{ name: 'business', status: 'completed', url: '' }];
699
+ export var FileRemoveType;
700
+ (function (FileRemoveType) {
701
+ FileRemoveType["AOA_FILE_ID"] = "AOA_file_id";
702
+ })(FileRemoveType || (FileRemoveType = {}));
699
703
  export var FileType;
700
704
  (function (FileType) {
701
705
  FileType["IMAGES"] = "images";
@@ -75,8 +75,9 @@ export declare const entitySlice: import("@reduxjs/toolkit").Slice<EntityState,
75
75
  resetOTPScreen: (state: EntityState) => void;
76
76
  uploadingStatus: (state: EntityState, action: ActionState<boolean>) => void;
77
77
  uploadingArticleStatus: (state: EntityState, action: ActionState<boolean>) => void;
78
+ clearAOAFile: (state: EntityState) => void;
78
79
  }, "entity/store">;
79
- export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, uploadingStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, uploadingArticleStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>;
80
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, uploadingStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, uploadingArticleStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, clearAOAFile: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
80
81
  declare const _default: import("redux").Reducer<EntityState, import("redux").AnyAction>;
81
82
  export default _default;
82
83
  export declare const entitySelector: (state: RootState) => EntityState;
@@ -447,6 +447,10 @@ export var entitySlice = createSlice({
447
447
  },
448
448
  uploadingArticleStatus: function (state, action) {
449
449
  state.uploadingArticle = action.payload;
450
+ },
451
+ clearAOAFile: function (state) {
452
+ var entity = (state.data.verify.responseBody || {}).entity;
453
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { entity: __assign(__assign({}, entity), { AOA_file: undefined, AOA_file_id: undefined }) });
450
454
  }
451
455
  },
452
456
  extraReducers: function (builder) {
@@ -666,6 +670,6 @@ export var entitySlice = createSlice({
666
670
  });
667
671
  }
668
672
  });
669
- export var clearError = (_a = entitySlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, uploadingStatus = _a.uploadingStatus, uploadingArticleStatus = _a.uploadingArticleStatus;
673
+ export var clearError = (_a = entitySlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, uploadingStatus = _a.uploadingStatus, uploadingArticleStatus = _a.uploadingArticleStatus, clearAOAFile = _a.clearAOAFile;
670
674
  export default entitySlice.reducer;
671
675
  export var entitySelector = function (state) { return state.entity; };
@@ -15,10 +15,11 @@ import { useController, useFormContext } from 'react-hook-form';
15
15
  import { styled } from '@mui/material/styles';
16
16
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
17
17
  import { DocumentPurpose } from '../../../../@types';
18
+ import { FileRemoveType } from '../../../../constants';
18
19
  import Collapse from '../../../../components/Collapse';
19
20
  import { ScreenContainer } from '../../../shared/Containers';
20
21
  import { UploadWrapper } from '../../../shared/UploadFile';
21
- import { entitySelector, uploadingArticleStatus } from '../../../app/entity/entityStore';
22
+ import { entitySelector, uploadingArticleStatus, clearAOAFile } from '../../../app/entity/entityStore';
22
23
  var FeatureStyled = styled(ScreenContainer)(function (_a) {
23
24
  var theme = _a.theme;
24
25
  return ({
@@ -26,7 +27,7 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
26
27
  });
27
28
  });
28
29
  var Article = function (_a) {
29
- var _b, _c;
30
+ var _b;
30
31
  var show = _a.show;
31
32
  var t = useTranslation().t;
32
33
  var control = useFormContext().control;
@@ -34,13 +35,16 @@ var Article = function (_a) {
34
35
  var loading = useAppSelector(entitySelector).loading;
35
36
  var dispatch = useAppDispatch();
36
37
  var data = useAppSelector(entitySelector).data;
38
+ var _c = ((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}, AOA_file = _c.AOA_file, id = _c.id;
37
39
  var handleArticleChange = function (id) {
38
40
  articleIdControl.field.onChange(id);
39
41
  };
40
42
  var handleReset = function () {
43
+ if (AOA_file)
44
+ dispatch(clearAOAFile());
41
45
  articleIdControl.field.onChange(undefined);
42
46
  };
43
- var defaultFile = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.AOA_file;
44
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadWrapper, { id: 'articleId', control: control, label: t('title_article'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('article_of_association'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleArticleChange, isSubmitting: loading, onDeleteFile: handleReset, defaultFile: defaultFile, purpose: DocumentPurpose.ARTICLE_ASSOCIATION, fileUploadingStatus: function (uploading) { return dispatch(uploadingArticleStatus(uploading)); } }) }) })));
47
+ var defaultFile = AOA_file && __assign(__assign({}, AOA_file), { docId: id });
48
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadWrapper, { id: 'articleId', fileRemoveType: FileRemoveType.AOA_FILE_ID, control: control, label: t('title_article'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('article_of_association'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleArticleChange, isSubmitting: loading, onDeleteFile: handleReset, defaultFile: defaultFile, purpose: DocumentPurpose.ARTICLE_ASSOCIATION, fileUploadingStatus: function (uploading) { return dispatch(uploadingArticleStatus(uploading)); } }) }) })));
45
49
  };
46
50
  export default Article;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SxProps, Theme } from '@mui/material/styles';
3
- import { FileInfo } from '../../../constants';
3
+ import { FileInfo, FileRemoveType } from '../../../constants';
4
4
  export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
5
5
  children?: React.ReactNode;
6
6
  component?: React.ElementType<any> | undefined;
@@ -14,6 +14,7 @@ export declare type FileUploadProps = {
14
14
  show: boolean;
15
15
  purpose: string;
16
16
  file: File;
17
+ fileRemoveType: FileRemoveType;
17
18
  required?: boolean;
18
19
  title?: string;
19
20
  uploadedFile: FileInfo;
@@ -22,6 +23,7 @@ export declare type FileUploadProps = {
22
23
  onUpdate: (file: FileInfo, loadingStatus: boolean) => void;
23
24
  sx?: SxProps<Theme> | undefined;
24
25
  isSubmitting?: boolean;
26
+ initialFileId?: string;
25
27
  };
26
- declare const FileUpload: ({ key, show, title, file, uploadedFile, onSuccess, onDelete, onUpdate, sx, purpose, isSubmitting }: FileUploadProps) => JSX.Element;
28
+ declare const FileUpload: ({ key, show, title, file, uploadedFile, onSuccess, onDelete, onUpdate, sx, purpose, isSubmitting, fileRemoveType, initialFileId }: FileUploadProps) => JSX.Element;
27
29
  export default FileUpload;
@@ -58,7 +58,7 @@ import Text from '../../../components/Text';
58
58
  import Icon from '../../../components/Icon';
59
59
  import { maskFileName } from '../../../utils';
60
60
  import API from '../../../api';
61
- import { FileStatus, ICONS_NAMES, MAX_FILE_SIZE_FOUR_MB, VALID_FILE_FORMATS } from '../../../constants';
61
+ import { DeleteFileStatus, FileStatus, ICONS_NAMES, MAX_FILE_SIZE_FOUR_MB, VALID_FILE_FORMATS, FileRemoveType } from '../../../constants';
62
62
  import CheckIcon from '../../shared/CheckIcon';
63
63
  var BoxStyled = styled(Box)(function (_a) {
64
64
  var theme = _a.theme;
@@ -108,11 +108,11 @@ var WarningContainer = styled(Box)(function (_a) {
108
108
  return (__assign({ background: alpha(theme.palette.warning.main, 0.1), paddingBlock: theme.spacing(1.5), paddingInlineStart: theme.spacing(2.5), flexDirection: 'row', display: 'flex', justifyContent: 'center', color: theme.palette.warning.light, padding: theme.spacing(0.5, 1), borderRadius: '101px', alignItems: 'center', marginTop: theme.spacing(1.25) }, theme.typography.caption));
109
109
  });
110
110
  var FileUpload = function (_a) {
111
- var key = _a.key, show = _a.show, title = _a.title, file = _a.file, uploadedFile = _a.uploadedFile, onSuccess = _a.onSuccess, onDelete = _a.onDelete, onUpdate = _a.onUpdate, sx = _a.sx, purpose = _a.purpose, isSubmitting = _a.isSubmitting;
111
+ var key = _a.key, show = _a.show, title = _a.title, file = _a.file, uploadedFile = _a.uploadedFile, onSuccess = _a.onSuccess, onDelete = _a.onDelete, onUpdate = _a.onUpdate, sx = _a.sx, purpose = _a.purpose, isSubmitting = _a.isSubmitting, fileRemoveType = _a.fileRemoveType, initialFileId = _a.initialFileId;
112
112
  var theme = useTheme();
113
113
  var t = useTranslation().t;
114
114
  var _b = file || {}, name = _b.name, size = _b.size, type = _b.type;
115
- var _c = uploadedFile || {}, status = _c.status, progress = _c.progress, error = _c.error, fileId = _c.fileId;
115
+ var _c = uploadedFile || {}, status = _c.status, progress = _c.progress, error = _c.error, fileId = _c.fileId, deleteStatus = _c.deleteStatus;
116
116
  var uploadFile = function () { return __awaiter(void 0, void 0, void 0, function () {
117
117
  var uploadPayload, onUploadProgress, data, fileId;
118
118
  return __generator(this, function (_a) {
@@ -177,7 +177,50 @@ var FileUpload = function (_a) {
177
177
  }
178
178
  });
179
179
  }); };
180
+ var deleteFile = function () { return __awaiter(void 0, void 0, void 0, function () {
181
+ var payload, data, entity, _a;
182
+ var _b;
183
+ return __generator(this, function (_c) {
184
+ switch (_c.label) {
185
+ case 0:
186
+ _c.trys.push([0, 3, , 4]);
187
+ uploadedFile = __assign(__assign({}, uploadedFile), { deleteStatus: DeleteFileStatus.DELETING, error: '' });
188
+ onUpdate(uploadedFile, true);
189
+ if (!(fileRemoveType === FileRemoveType.AOA_FILE_ID)) return [3, 2];
190
+ payload = (_b = {
191
+ id: uploadedFile.docId
192
+ },
193
+ _b[fileRemoveType] = '',
194
+ _b);
195
+ return [4, API.entityService.updateEntityAOAFile(payload)];
196
+ case 1:
197
+ data = _c.sent();
198
+ entity = (data || {}).entity;
199
+ if (entity === null || entity === void 0 ? void 0 : entity.id) {
200
+ uploadedFile = __assign(__assign({}, uploadedFile), { deleteStatus: DeleteFileStatus.SUCCESS, fileId: '', error: '', docId: '' });
201
+ onUpdate(uploadedFile, false);
202
+ onDelete();
203
+ }
204
+ else {
205
+ uploadedFile = __assign(__assign({}, uploadedFile), { deleteStatus: DeleteFileStatus.ERROR, error: 'file_delete_error' });
206
+ onUpdate(uploadedFile, false);
207
+ }
208
+ _c.label = 2;
209
+ case 2: return [3, 4];
210
+ case 3:
211
+ _a = _c.sent();
212
+ uploadedFile = __assign(__assign({}, uploadedFile), { deleteStatus: DeleteFileStatus.ERROR, error: 'file_delete_error' });
213
+ onUpdate(uploadedFile, false);
214
+ return [3, 4];
215
+ case 4: return [2];
216
+ }
217
+ });
218
+ }); };
180
219
  var handleDeleteFile = function () {
220
+ if (initialFileId === uploadedFile.fileId) {
221
+ deleteFile();
222
+ return;
223
+ }
181
224
  onDelete();
182
225
  };
183
226
  var getProgressComponent = function () {
@@ -215,6 +258,6 @@ var FileUpload = function (_a) {
215
258
  flexDirection: 'column',
216
259
  padding: theme.spacing(1.5, 0, 1.5),
217
260
  width: '100%'
218
- } }, { children: [_jsxs(Box, __assign({ sx: { display: 'flex', flexDirection: 'row', cursor: canDownloadFile ? 'pointer' : 'auto' }, onClick: canDownloadFile ? function () { return downloadFile(); } : undefined }, { children: [_jsx(Icon, { src: ICONS_NAMES.DOC_ICON }), _jsx(Text, { children: name && maskFileName(name) })] })), _jsx(Box, __assign({ sx: { display: 'flex', flexDirection: 'row', justifyContent: 'center' } }, { children: _jsx(Collapse, __assign({ in: !!error, timeout: 400 }, { children: _jsxs(WarningContainer, { children: [_jsx(WarningIconStyled, { src: ICONS_NAMES.WARNING_ICON }), _jsx(Text, { children: t(error) })] }) })) }))] })), _jsx(ProgressBoxStyled, { children: getProgressComponent() })] }), _jsx(UploadBoxStyled, __assign({ uploading: status === FileStatus.UPLOADING || status === FileStatus.DOWNLOADING, onClick: canDeleteFile ? function () { return handleDeleteFile(); } : undefined }, { children: _jsx(ClearIconStyled, {}) }))] })) }), key) })));
261
+ } }, { children: [_jsxs(Box, __assign({ sx: { display: 'flex', flexDirection: 'row', cursor: canDownloadFile ? 'pointer' : 'auto' }, onClick: canDownloadFile ? function () { return downloadFile(); } : undefined }, { children: [_jsx(Icon, { src: ICONS_NAMES.DOC_ICON }), _jsx(Text, { children: name && maskFileName(name) })] })), _jsx(Box, __assign({ sx: { display: 'flex', flexDirection: 'row', justifyContent: 'center' } }, { children: _jsx(Collapse, __assign({ in: !!error, timeout: 400 }, { children: _jsxs(WarningContainer, { children: [_jsx(WarningIconStyled, { src: ICONS_NAMES.WARNING_ICON }), _jsx(Text, { children: t(error) })] }) })) }))] })), _jsx(ProgressBoxStyled, { children: getProgressComponent() })] }), _jsx(UploadBoxStyled, __assign({ uploading: status === FileStatus.UPLOADING || status === FileStatus.DOWNLOADING, onClick: canDeleteFile ? function () { return handleDeleteFile(); } : undefined }, { children: deleteStatus === DeleteFileStatus.DELETING ? (_jsx(MUICircularProgress, { size: 25, thickness: 5, sx: { color: theme.palette.common.white } })) : (_jsx(ClearIconStyled, {})) }))] })) }), key) })));
219
262
  };
220
263
  export default FileUpload;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Control, FieldValues } from 'react-hook-form';
3
3
  import { FileDetails } from '../../../@types';
4
+ import { FileRemoveType } from '../../../constants';
4
5
  export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
5
6
  children?: React.ReactNode;
6
7
  component?: React.ElementType<any> | undefined;
@@ -14,6 +15,7 @@ interface UploadWrapperProps {
14
15
  control: Control<FieldValues, any>;
15
16
  label: string;
16
17
  purpose: string;
18
+ fileRemoveType: FileRemoveType;
17
19
  fileTitle?: string;
18
20
  required?: boolean;
19
21
  title: string;
@@ -27,5 +29,5 @@ interface UploadWrapperProps {
27
29
  onDeleteFile: () => void;
28
30
  defaultFile?: FileDetails;
29
31
  }
30
- declare const UploadWrapper: ({ id, label, control, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, purpose, fileTitle, defaultFile }: UploadWrapperProps) => JSX.Element;
31
- export default UploadWrapper;
32
+ declare const _default: React.MemoExoticComponent<({ id, label, control, required, fileRemoveType, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, purpose, fileTitle, defaultFile }: UploadWrapperProps) => JSX.Element>;
33
+ export default _default;
@@ -18,7 +18,7 @@ import Box from '@mui/material/Box';
18
18
  import { DragAndDrop } from '../../../components/FileInput';
19
19
  import Collapse from '../../../components/Collapse';
20
20
  import { getFileType } from '../../../utils';
21
- import { FileStatus } from '../../../constants';
21
+ import { DeleteFileStatus, FileStatus } from '../../../constants';
22
22
  import { InputLabelStyled } from '../../shared/Input/Input';
23
23
  import { ScreenContainer } from '../../shared/Containers';
24
24
  import Mandatory from '../../shared/Mandatory';
@@ -44,7 +44,7 @@ export var InputContainerStyled = styled(Box)(function () { return ({
44
44
  justifyContent: 'center'
45
45
  }); });
46
46
  var UploadWrapper = function (_a) {
47
- 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, purpose = _a.purpose, fileTitle = _a.fileTitle, defaultFile = _a.defaultFile;
47
+ var id = _a.id, label = _a.label, control = _a.control, required = _a.required, fileRemoveType = _a.fileRemoveType, 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, purpose = _a.purpose, fileTitle = _a.fileTitle, defaultFile = _a.defaultFile;
48
48
  var t = useTranslation().t;
49
49
  var _b = React.useState(''), error = _b[0], setError = _b[1];
50
50
  var fileControl = useController({ name: "".concat(id, "File"), control: control });
@@ -89,8 +89,8 @@ var UploadWrapper = function (_a) {
89
89
  setError('');
90
90
  if (required)
91
91
  setError(t('should_upload_file'));
92
- fileControl.field.onChange(undefined);
93
- fileInfoControl.field.onChange(undefined);
92
+ fileControl.field.onChange(null);
93
+ fileInfoControl.field.onChange(null);
94
94
  onDeleteFile();
95
95
  }
96
96
  };
@@ -108,7 +108,7 @@ var UploadWrapper = function (_a) {
108
108
  }
109
109
  };
110
110
  var fileExists = !!fileInfo;
111
- var fileUploaded = (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.SUCCESS || (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.DOWNLOADING;
112
- return (_jsxs(FeatureStyled, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: _jsxs(_Fragment, { children: [label, required && _jsx(Mandatory, {})] }) }) }), _jsx(Collapse, __assign({ in: !fileUploaded }, { children: _jsx(InputContainerStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: fileExists, uploadingTitle: uploadingTitle, successTitle: successTitle, progress: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.progress, uploading: (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.UPLOADING, uploadSuccess: fileUploaded, onSuccess: handleFileChange, error: (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.error) || error, multiple: false }) })) })), _jsx(Collapse, __assign({ in: fileExists, timeout: 300 }, { children: _jsx(FileUpload, { show: fileUploaded, purpose: purpose, title: fileTitle || '', isSubmitting: isSubmitting, uploadedFile: fileInfo, file: fileData, onSuccess: handleSuccess, onDelete: handleDelete, onUpdate: handleUpdate }) }))] }));
111
+ var showUploadedInputField = (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.SUCCESS || (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.DOWNLOADING || (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.deleteStatus) === DeleteFileStatus.DELETING;
112
+ return (_jsxs(FeatureStyled, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: _jsxs(_Fragment, { children: [label, required && _jsx(Mandatory, {})] }) }) }), _jsx(Collapse, __assign({ in: !showUploadedInputField }, { children: _jsx(InputContainerStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: fileExists, uploadingTitle: uploadingTitle, successTitle: successTitle, progress: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.progress, uploading: (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.UPLOADING, uploadSuccess: (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.SUCCESS, onSuccess: handleFileChange, error: (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.error) || error, multiple: false }) })) })), _jsx(Collapse, __assign({ in: fileExists, timeout: 300 }, { children: _jsx(FileUpload, { show: showUploadedInputField, fileRemoveType: fileRemoveType, purpose: purpose, title: fileTitle || '', isSubmitting: isSubmitting, uploadedFile: fileInfo, file: fileData, onSuccess: handleSuccess, onDelete: handleDelete, onUpdate: handleUpdate, initialFileId: defaultFile === null || defaultFile === void 0 ? void 0 : defaultFile.id }) }))] }));
113
113
  };
114
- export default UploadWrapper;
114
+ export default React.memo(UploadWrapper);
@@ -23,5 +23,5 @@ export declare type UploadFileProps = {
23
23
  sx?: SxProps<Theme> | undefined;
24
24
  isSubmitting?: boolean;
25
25
  };
26
- declare const UploadFile: ({ index, title, file, fileType, uploadedFiles, onSuccess, onDelete, onUpdate, sx, purpose, required, isSubmitting }: UploadFileProps) => JSX.Element;
26
+ declare const UploadFile: ({ index, title, file, fileType, uploadedFiles, onSuccess, onDelete, onUpdate, sx, purpose, isSubmitting }: UploadFileProps) => JSX.Element;
27
27
  export default UploadFile;
@@ -108,7 +108,7 @@ var WarningContainer = styled(Box)(function (_a) {
108
108
  return (__assign({ background: alpha(theme.palette.warning.main, 0.1), paddingBlock: theme.spacing(1.5), paddingInlineStart: theme.spacing(2.5), flexDirection: 'row', display: 'flex', justifyContent: 'center', color: theme.palette.warning.light, padding: theme.spacing(0.5, 1), borderRadius: '101px', alignItems: 'center', marginTop: theme.spacing(1.25) }, theme.typography.caption));
109
109
  });
110
110
  var UploadFile = function (_a) {
111
- var index = _a.index, title = _a.title, file = _a.file, fileType = _a.fileType, uploadedFiles = _a.uploadedFiles, onSuccess = _a.onSuccess, onDelete = _a.onDelete, onUpdate = _a.onUpdate, sx = _a.sx, purpose = _a.purpose, required = _a.required, isSubmitting = _a.isSubmitting;
111
+ var index = _a.index, title = _a.title, file = _a.file, fileType = _a.fileType, uploadedFiles = _a.uploadedFiles, onSuccess = _a.onSuccess, onDelete = _a.onDelete, onUpdate = _a.onUpdate, sx = _a.sx, purpose = _a.purpose, isSubmitting = _a.isSubmitting;
112
112
  var theme = useTheme();
113
113
  var t = useTranslation().t;
114
114
  var _b = file || {}, name = _b.name, size = _b.size, type = _b.type;
@@ -219,8 +219,7 @@ var UploadFile = function (_a) {
219
219
  });
220
220
  }); };
221
221
  var handleDeleteFile = function (index) {
222
- var canDeleteFile = required ? uploadedFiles.length > 1 : true;
223
- if (canDeleteFile && uploadedFile.docId) {
222
+ if (uploadedFile.docId) {
224
223
  deleteFile(index);
225
224
  return;
226
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.3.9-test",
3
+ "version": "2.3.11-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",