@tap-payments/auth-jsconnect 2.1.96-test → 2.1.98-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.
- package/build/@types/app.d.ts +17 -0
- package/build/@types/app.js +9 -0
- package/build/features/app/business/businessStore.js +2 -2
- package/build/features/app/entity/entityStore.js +2 -2
- package/build/features/app/individual/individualStore.d.ts +9 -0
- package/build/features/app/individual/individualStore.js +35 -0
- package/build/features/bank/screens/BankDetails/BankStatement.js +8 -2
- package/build/features/business/screens/BusinessType/LicenseCertificate.js +2 -1
- package/build/features/entity/screens/EntityName/LicenseCertificate.js +9 -3
- package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +8 -2
- package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +8 -2
- package/build/features/individual/screens/IndividualList/CollectPhoneEmail.d.ts +2 -0
- package/build/features/individual/screens/IndividualList/CollectPhoneEmail.js +3 -2
- package/build/features/individual/screens/IndividualList/Email.d.ts +5 -1
- package/build/features/individual/screens/IndividualList/Email.js +73 -8
- package/build/features/individual/screens/IndividualList/UserList.js +28 -16
- package/build/features/individual/screens/IndividualList/validation.js +2 -1
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +3 -4
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +21 -2
- package/build/features/tax/screens/TaxDetails/TaxDocument.js +8 -2
- package/build/utils/array.d.ts +1 -0
- package/build/utils/array.js +8 -0
- package/build/utils/string.d.ts +1 -0
- package/build/utils/string.js +14 -0
- package/package.json +1 -1
package/build/@types/app.d.ts
CHANGED
|
@@ -324,4 +324,21 @@ export declare enum IndividualType {
|
|
|
324
324
|
CUSTOMER = "customer",
|
|
325
325
|
BUYER = "buyer"
|
|
326
326
|
}
|
|
327
|
+
export declare enum DocumentPurpose {
|
|
328
|
+
CR = "commercial_registration",
|
|
329
|
+
ARTICLE_ASSOCIATION = "article_of_association",
|
|
330
|
+
BANK_STATEMENT = "bank_statement",
|
|
331
|
+
IDENTITY_DOCUMENT = "identity_document",
|
|
332
|
+
CUSTOMER_SIGNATURE = "customer_signature",
|
|
333
|
+
TAX_DOCUMENT = "tax_document_user_upload"
|
|
334
|
+
}
|
|
335
|
+
export declare type FileDetails = {
|
|
336
|
+
created: string;
|
|
337
|
+
id: string;
|
|
338
|
+
object: string;
|
|
339
|
+
purpose: string;
|
|
340
|
+
size: string;
|
|
341
|
+
title: string;
|
|
342
|
+
type: string;
|
|
343
|
+
};
|
|
327
344
|
export {};
|
package/build/@types/app.js
CHANGED
|
@@ -59,3 +59,12 @@ export var IndividualType;
|
|
|
59
59
|
IndividualType["CUSTOMER"] = "customer";
|
|
60
60
|
IndividualType["BUYER"] = "buyer";
|
|
61
61
|
})(IndividualType || (IndividualType = {}));
|
|
62
|
+
export var DocumentPurpose;
|
|
63
|
+
(function (DocumentPurpose) {
|
|
64
|
+
DocumentPurpose["CR"] = "commercial_registration";
|
|
65
|
+
DocumentPurpose["ARTICLE_ASSOCIATION"] = "article_of_association";
|
|
66
|
+
DocumentPurpose["BANK_STATEMENT"] = "bank_statement";
|
|
67
|
+
DocumentPurpose["IDENTITY_DOCUMENT"] = "identity_document";
|
|
68
|
+
DocumentPurpose["CUSTOMER_SIGNATURE"] = "customer_signature";
|
|
69
|
+
DocumentPurpose["TAX_DOCUMENT"] = "tax_document_user_upload";
|
|
70
|
+
})(DocumentPurpose || (DocumentPurpose = {}));
|
|
@@ -57,7 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
57
57
|
var _a;
|
|
58
58
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
59
59
|
import API from '../../../api';
|
|
60
|
-
import { BusinessType, FlowsTypes } from '../../../@types';
|
|
60
|
+
import { BusinessType, FlowsTypes, DocumentPurpose } from '../../../@types';
|
|
61
61
|
import { BUSINESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
|
|
62
62
|
import { convertNumbers2English, getEighteenYearsAgo, hasKey, sleep, isKW, isSA, dateFormat } from '../../../utils';
|
|
63
63
|
import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
@@ -528,7 +528,7 @@ export var uploadArticle = createAsyncThunk('businessUploadArticle', function (_
|
|
|
528
528
|
uploadPayload = {
|
|
529
529
|
file_link_create: true,
|
|
530
530
|
title: file === null || file === void 0 ? void 0 : file.name,
|
|
531
|
-
purpose:
|
|
531
|
+
purpose: DocumentPurpose.ARTICLE_ASSOCIATION,
|
|
532
532
|
type: type,
|
|
533
533
|
file: file
|
|
534
534
|
};
|
|
@@ -59,7 +59,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
59
59
|
var _a;
|
|
60
60
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
61
61
|
import API from '../../../api';
|
|
62
|
-
import { BusinessType, FieldType, FlowsTypes } from '../../../@types';
|
|
62
|
+
import { BusinessType, DocumentPurpose, FieldType, FlowsTypes } from '../../../@types';
|
|
63
63
|
import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
64
64
|
import { ENTITY_STEP_NAMES } from '../../../constants';
|
|
65
65
|
import moment from 'moment';
|
|
@@ -331,7 +331,7 @@ export var uploadArticle = createAsyncThunk('entityUploadArticle', function (_a)
|
|
|
331
331
|
uploadPayload = {
|
|
332
332
|
file_link_create: true,
|
|
333
333
|
title: file === null || file === void 0 ? void 0 : file.name,
|
|
334
|
-
purpose:
|
|
334
|
+
purpose: DocumentPurpose.ARTICLE_ASSOCIATION,
|
|
335
335
|
type: type,
|
|
336
336
|
file: file
|
|
337
337
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RootState } from '../../../app/store';
|
|
2
2
|
import { CountryCode, FlowsTypes, IndividualExtraFormValues, OTPFormValues, ResponseData, SharedState, ActionState, User, IndividualPersonalInfoFormValues, IndividualEmailMobileFormValues } from '../../../@types';
|
|
3
|
+
import { CancelToken } from 'axios';
|
|
3
4
|
interface VerifyLeadTokenProps {
|
|
4
5
|
token: string;
|
|
5
6
|
isInternally?: boolean;
|
|
@@ -88,6 +89,14 @@ export declare const updateIndividualInfo: import("@reduxjs/toolkit").AsyncThunk
|
|
|
88
89
|
data: any;
|
|
89
90
|
formData: IndividualExtraFormValues;
|
|
90
91
|
}, IndividualExtraFormValues, {}>;
|
|
92
|
+
export declare const checkEmailAvailability: import("@reduxjs/toolkit").AsyncThunk<{
|
|
93
|
+
response: any;
|
|
94
|
+
formData: string;
|
|
95
|
+
} | undefined, {
|
|
96
|
+
email: string;
|
|
97
|
+
cancelToken: CancelToken;
|
|
98
|
+
onSuccess?: (() => void) | undefined;
|
|
99
|
+
}, {}>;
|
|
91
100
|
export declare const updateBoardSuccess: import("@reduxjs/toolkit").AsyncThunk<{
|
|
92
101
|
response: any;
|
|
93
102
|
formData: void;
|
|
@@ -650,6 +650,28 @@ export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', funct
|
|
|
650
650
|
}
|
|
651
651
|
});
|
|
652
652
|
}); });
|
|
653
|
+
export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', function (_a) {
|
|
654
|
+
var email = _a.email, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
|
|
655
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
656
|
+
var requestBody, data;
|
|
657
|
+
return __generator(this, function (_b) {
|
|
658
|
+
switch (_b.label) {
|
|
659
|
+
case 0:
|
|
660
|
+
requestBody = {
|
|
661
|
+
email: email,
|
|
662
|
+
encryption_contract: ['email']
|
|
663
|
+
};
|
|
664
|
+
return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
|
|
665
|
+
case 1:
|
|
666
|
+
data = (_b.sent()).data;
|
|
667
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
668
|
+
if (!data.errors)
|
|
669
|
+
return [2, { response: data, formData: email }];
|
|
670
|
+
return [2];
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
});
|
|
674
|
+
});
|
|
653
675
|
export var updateBoardSuccess = createAsyncThunk('individualUpdateBoardSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
654
676
|
var _a, settings, individual, _b, id, infoId, payload, data, boardInfoStatus;
|
|
655
677
|
var _c, _d, _e, _f;
|
|
@@ -1031,6 +1053,19 @@ export var individualSlice = createSlice({
|
|
|
1031
1053
|
.addCase(retrieveBoardDetails.rejected, function (state, action) {
|
|
1032
1054
|
state.error = action.error.message;
|
|
1033
1055
|
state.loading = false;
|
|
1056
|
+
})
|
|
1057
|
+
.addCase(checkEmailAvailability.fulfilled, function (state, action) {
|
|
1058
|
+
var _a;
|
|
1059
|
+
state.error = null;
|
|
1060
|
+
state.data.individualCollectData.responseBody = __assign(__assign({}, state.data.individualCollectData.responseBody), (_a = action.payload) === null || _a === void 0 ? void 0 : _a.response);
|
|
1061
|
+
})
|
|
1062
|
+
.addCase(checkEmailAvailability.pending, function (state) {
|
|
1063
|
+
state.error = null;
|
|
1064
|
+
})
|
|
1065
|
+
.addCase(checkEmailAvailability.rejected, function (state, action) {
|
|
1066
|
+
if (action.error.message === 'Aborted')
|
|
1067
|
+
return;
|
|
1068
|
+
state.error = action.error.message;
|
|
1034
1069
|
})
|
|
1035
1070
|
.addCase(updateBoardSuccess.fulfilled, function (state, action) {
|
|
1036
1071
|
var _a;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { styled } from '@mui/material/styles';
|
|
3
4
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import { useController, useFormContext } from 'react-hook-form';
|
|
6
7
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
8
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
9
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
7
10
|
import { bankSelector, bankStatementUploadingStatus } from '../../../app/bank/bankStore';
|
|
8
11
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
9
12
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
@@ -13,18 +16,21 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
13
16
|
});
|
|
14
17
|
});
|
|
15
18
|
var BankStatement = function (_a) {
|
|
19
|
+
var _b;
|
|
16
20
|
var required = _a.required;
|
|
17
21
|
var t = useTranslation().t;
|
|
18
22
|
var control = useFormContext().control;
|
|
19
23
|
var bankStatementIdControl = useController({ name: 'bankStatementId', control: control });
|
|
20
|
-
var
|
|
24
|
+
var _c = useAppSelector(bankSelector), loading = _c.loading, data = _c.data;
|
|
21
25
|
var dispatch = useAppDispatch();
|
|
26
|
+
var document = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.bank_account) || {}).document;
|
|
22
27
|
var handleBankStatementChange = function (ids) {
|
|
23
28
|
bankStatementIdControl.field.onChange(ids);
|
|
24
29
|
};
|
|
25
30
|
var handleReset = function (ids) {
|
|
26
31
|
bankStatementIdControl.field.onChange(ids);
|
|
27
32
|
};
|
|
28
|
-
|
|
33
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(document ? [document] : [], DocumentPurpose.BANK_STATEMENT); }, [document]);
|
|
34
|
+
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: DocumentPurpose.BANK_STATEMENT, defaultFiles: defaultFiles, maxLimit: 4, fileUploadingStatus: function (uploading) { return dispatch(bankStatementUploadingStatus(uploading)); } }) }));
|
|
29
35
|
};
|
|
30
36
|
export default BankStatement;
|
|
@@ -13,6 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
14
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
15
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
16
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
16
17
|
import { styled } from '@mui/material/styles';
|
|
17
18
|
import Collapse from '../../../../components/Collapse';
|
|
18
19
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
@@ -37,6 +38,6 @@ var LicenseCertificate = function (_a) {
|
|
|
37
38
|
var handleReset = function (ids) {
|
|
38
39
|
certificateIdControl.field.onChange(ids);
|
|
39
40
|
};
|
|
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:
|
|
41
|
+
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: DocumentPurpose.CR, fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) }) })));
|
|
41
42
|
};
|
|
42
43
|
export default LicenseCertificate;
|
|
@@ -10,11 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import React from 'react';
|
|
13
14
|
import { useTranslation } from 'react-i18next';
|
|
14
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
|
-
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
16
16
|
import { styled } from '@mui/material/styles';
|
|
17
17
|
import Collapse from '../../../../components/Collapse';
|
|
18
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
19
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
20
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
18
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
19
22
|
import { entitySelector, uploadingStatus } from '../../../app/entity/entityStore';
|
|
20
23
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
@@ -25,18 +28,21 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
25
28
|
});
|
|
26
29
|
});
|
|
27
30
|
var LicenseCertificate = function (_a) {
|
|
31
|
+
var _b;
|
|
28
32
|
var show = _a.show;
|
|
29
33
|
var t = useTranslation().t;
|
|
30
34
|
var control = useFormContext().control;
|
|
31
35
|
var dispatch = useAppDispatch();
|
|
32
36
|
var certificateIdControl = useController({ name: 'certificateId', control: control });
|
|
33
|
-
var
|
|
37
|
+
var _c = useAppSelector(entitySelector), loading = _c.loading, data = _c.data;
|
|
38
|
+
var documents = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}).documents;
|
|
34
39
|
var handleLicenseCertificateChange = function (ids) {
|
|
35
40
|
certificateIdControl.field.onChange(ids);
|
|
36
41
|
};
|
|
37
42
|
var handleReset = function (ids) {
|
|
38
43
|
certificateIdControl.field.onChange(ids);
|
|
39
44
|
};
|
|
40
|
-
|
|
45
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.CR); }, [documents]);
|
|
46
|
+
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, defaultFiles: defaultFiles, purpose: DocumentPurpose.CR, fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) }) })));
|
|
41
47
|
};
|
|
42
48
|
export default LicenseCertificate;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { ScreenContainer } from '../../../../features/shared/Containers';
|
|
3
4
|
import { styled } from '@mui/material/styles';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import { useController, useFormContext } from 'react-hook-form';
|
|
6
7
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
8
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
9
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
7
10
|
import { civilIDUploadingStatus, individualSelector } from '../../../app/individual/individualStore';
|
|
8
11
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
9
12
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
@@ -13,17 +16,20 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
13
16
|
});
|
|
14
17
|
});
|
|
15
18
|
var CivilIDFile = function () {
|
|
19
|
+
var _a;
|
|
16
20
|
var t = useTranslation().t;
|
|
17
21
|
var dispatch = useAppDispatch();
|
|
18
22
|
var control = useFormContext().control;
|
|
19
23
|
var civilIDFileIdControl = useController({ name: 'civilID', control: control });
|
|
20
|
-
var
|
|
24
|
+
var _b = useAppSelector(individualSelector), loading = _b.loading, data = _b.data;
|
|
25
|
+
var documents = (((_a = data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.user) || {}).documents;
|
|
21
26
|
var handleCivilIDChange = function (ids) {
|
|
22
27
|
civilIDFileIdControl.field.onChange(ids);
|
|
23
28
|
};
|
|
24
29
|
var handleReset = function (ids) {
|
|
25
30
|
civilIDFileIdControl.field.onChange(ids);
|
|
26
31
|
};
|
|
27
|
-
|
|
32
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.IDENTITY_DOCUMENT); }, [documents]);
|
|
33
|
+
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, defaultFiles: defaultFiles, purpose: DocumentPurpose.IDENTITY_DOCUMENT, fileUploadingStatus: function (uploading) { return dispatch(civilIDUploadingStatus(uploading)); } }) }));
|
|
28
34
|
};
|
|
29
35
|
export default CivilIDFile;
|
|
@@ -10,10 +10,13 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import React from 'react';
|
|
13
14
|
import { useTranslation } from 'react-i18next';
|
|
14
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
16
|
import { styled } from '@mui/material/styles';
|
|
16
17
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
18
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
19
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
17
20
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
18
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
19
22
|
import { individualSelector, signatureFileUploadingStatus } from '../../../app/individual/individualStore';
|
|
@@ -25,11 +28,13 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
25
28
|
});
|
|
26
29
|
});
|
|
27
30
|
var SignatureFile = function (_a) {
|
|
31
|
+
var _b;
|
|
28
32
|
var show = _a.show;
|
|
29
33
|
var t = useTranslation().t;
|
|
30
34
|
var control = useFormContext().control;
|
|
31
35
|
var signatureFileIdControl = useController({ name: 'signatureFileId', control: control });
|
|
32
|
-
var
|
|
36
|
+
var _c = useAppSelector(individualSelector), loading = _c.loading, data = _c.data;
|
|
37
|
+
var documents = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.user) || {}).documents;
|
|
33
38
|
var dispatch = useAppDispatch();
|
|
34
39
|
var handleSignatureChange = function (ids) {
|
|
35
40
|
signatureFileIdControl.field.onChange(ids);
|
|
@@ -37,6 +42,7 @@ var SignatureFile = function (_a) {
|
|
|
37
42
|
var handleReset = function (ids) {
|
|
38
43
|
signatureFileIdControl.field.onChange(ids);
|
|
39
44
|
};
|
|
40
|
-
|
|
45
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.CUSTOMER_SIGNATURE); }, [documents]);
|
|
46
|
+
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, defaultFiles: defaultFiles, purpose: DocumentPurpose.CUSTOMER_SIGNATURE, fileUploadingStatus: function (uploading) { return dispatch(signatureFileUploadingStatus(uploading)); } }) }) })));
|
|
41
47
|
};
|
|
42
48
|
export default SignatureFile;
|
|
@@ -2,6 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
import { User } from '../../../../@types';
|
|
3
3
|
export interface CollectPhoneEmailProps {
|
|
4
4
|
activeUser?: User;
|
|
5
|
+
emailChecking: boolean;
|
|
6
|
+
setEmailChecking: (flag: boolean) => void;
|
|
5
7
|
}
|
|
6
8
|
declare const _default: React.MemoExoticComponent<{
|
|
7
9
|
({ activeUser }: CollectPhoneEmailProps): JSX.Element;
|
|
@@ -23,9 +23,10 @@ var CollectPhoneEmail = function (_a) {
|
|
|
23
23
|
var countries = settingsData.countries;
|
|
24
24
|
var _b = (activeUser === null || activeUser === void 0 ? void 0 : activeUser.contact) || { email: '' }, email = _b.email, phone = _b.phone;
|
|
25
25
|
var isPhoneAvailable = (phone === null || phone === void 0 ? void 0 : phone.country_code) && (phone === null || phone === void 0 ? void 0 : phone.number);
|
|
26
|
+
var _c = React.useState(false), emailChecking = _c[0], setEmailChecking = _c[1];
|
|
26
27
|
var isEmailAvailable = isValidEmail(email);
|
|
27
|
-
var
|
|
28
|
-
return (_jsxs(Box, __assign({ sx: { mb: 0 } }, { children: [_jsx(MobileNumber, { sx: { mb: isEmailAvailable ? 0 : 3 }, show: !isPhoneAvailable, countries: countries, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(Email, { show: !listActive && !isEmailAvailable })] })));
|
|
28
|
+
var _d = React.useState(), listActive = _d[0], setListActive = _d[1];
|
|
29
|
+
return (_jsxs(Box, __assign({ sx: { mb: 0 } }, { children: [_jsx(MobileNumber, { sx: { mb: isEmailAvailable ? 0 : 3 }, show: !isPhoneAvailable, countries: countries, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(Email, { show: !listActive && !isEmailAvailable, fetchingEmail: function (v) { return setEmailChecking(v); }, emailChecking: emailChecking })] })));
|
|
29
30
|
};
|
|
30
31
|
export default React.memo(CollectPhoneEmail);
|
|
31
32
|
CollectPhoneEmail.defaultProps = {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { User } from '../../../../@types';
|
|
2
3
|
export interface EmailProps {
|
|
3
4
|
show: boolean;
|
|
5
|
+
fetchingEmail: (flag: boolean) => void;
|
|
6
|
+
emailChecking: boolean;
|
|
7
|
+
activeUser?: User;
|
|
4
8
|
}
|
|
5
|
-
declare const _default: React.MemoExoticComponent<({ show }: EmailProps) => JSX.Element>;
|
|
9
|
+
declare const _default: React.MemoExoticComponent<({ show, fetchingEmail, emailChecking, activeUser }: EmailProps) => JSX.Element>;
|
|
6
10
|
export default _default;
|
|
@@ -9,40 +9,105 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
49
|
import * as React from 'react';
|
|
50
|
+
import { debounce } from 'lodash-es';
|
|
51
|
+
import axios from 'axios';
|
|
14
52
|
import { useTranslation } from 'react-i18next';
|
|
15
53
|
import { useController, useFormContext } from 'react-hook-form';
|
|
16
54
|
import { styled } from '@mui/material/styles';
|
|
17
|
-
import
|
|
55
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
56
|
+
import { useAppDispatch } from '../../../../hooks';
|
|
57
|
+
import { isValidEmail } from '../../../../utils';
|
|
18
58
|
import Collapse from '../../../../components/Collapse';
|
|
19
59
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
20
60
|
import Input from '../../../shared/Input';
|
|
21
61
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
22
62
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
23
|
-
import {
|
|
63
|
+
import { checkEmailAvailability } from '../../../app/individual/individualStore';
|
|
24
64
|
var InputStyled = styled(Input)(function () { return ({
|
|
25
65
|
input: {
|
|
26
66
|
textTransform: 'lowercase'
|
|
27
67
|
}
|
|
28
68
|
}); });
|
|
69
|
+
var cancelToken = null;
|
|
29
70
|
var Email = function (_a) {
|
|
30
71
|
var _b;
|
|
31
|
-
var show = _a.show;
|
|
72
|
+
var show = _a.show, fetchingEmail = _a.fetchingEmail, emailChecking = _a.emailChecking, activeUser = _a.activeUser;
|
|
32
73
|
var t = useTranslation().t;
|
|
74
|
+
var dispatch = useAppDispatch();
|
|
75
|
+
var _c = React.useState(''), storedEmail = _c[0], setStoredEmail = _c[1];
|
|
33
76
|
var control = useFormContext().control;
|
|
34
77
|
var emailControl = useController({ name: 'email', control: control });
|
|
35
|
-
var data = useAppSelector(individualSelector).data;
|
|
36
78
|
var emailValue = emailControl.field.value;
|
|
37
79
|
var error = (_b = emailControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
38
|
-
var
|
|
39
|
-
|
|
80
|
+
var checkEmail = debounce(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
+
var onSuccess;
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
if (cancelToken) {
|
|
84
|
+
cancelToken.cancel('Aborted');
|
|
85
|
+
}
|
|
86
|
+
cancelToken = axios.CancelToken.source();
|
|
87
|
+
onSuccess = function () { return fetchingEmail(false); };
|
|
88
|
+
dispatch(checkEmailAvailability({ email: value, cancelToken: cancelToken.token, onSuccess: onSuccess }));
|
|
89
|
+
return [2];
|
|
90
|
+
});
|
|
91
|
+
}); }, 500);
|
|
92
|
+
React.useEffect(function () {
|
|
93
|
+
var _a;
|
|
94
|
+
var email = (_a = activeUser === null || activeUser === void 0 ? void 0 : activeUser.contact) === null || _a === void 0 ? void 0 : _a.email;
|
|
95
|
+
if (!!email)
|
|
96
|
+
setStoredEmail(email);
|
|
97
|
+
}, [activeUser]);
|
|
98
|
+
React.useEffect(function () {
|
|
99
|
+
var isValid = isValidEmail(emailValue) && !error && emailValue.length > 3;
|
|
100
|
+
if (isValid && emailValue != storedEmail) {
|
|
101
|
+
fetchingEmail(true);
|
|
102
|
+
checkEmail(emailValue);
|
|
103
|
+
}
|
|
104
|
+
}, [emailValue, error]);
|
|
40
105
|
var handleEmailChange = function (event) {
|
|
41
106
|
emailControl.field.onChange(event.target.value);
|
|
42
107
|
};
|
|
43
|
-
var
|
|
108
|
+
var clearEmail = function () {
|
|
44
109
|
emailControl.field.onChange('');
|
|
45
110
|
};
|
|
46
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('signup_email_lable'), value: emailValue, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: !error && emailValue ? _jsx(CheckIcon, {}) : emailValue && _jsx(ClearIcon, { onClick:
|
|
111
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('signup_email_lable'), value: emailValue, onEnterPressed: function (e) { return e.preventDefault(); }, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: emailChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && emailValue ? (_jsx(CheckIcon, {})) : (emailValue && _jsx(ClearIcon, { onClick: clearEmail })) }) }) })));
|
|
47
112
|
};
|
|
48
113
|
export default React.memo(Email);
|
|
@@ -73,17 +73,20 @@ var IndividualRequestType;
|
|
|
73
73
|
IndividualRequestType[IndividualRequestType["COLLECT_EMAIL_MOBILE"] = 2] = "COLLECT_EMAIL_MOBILE";
|
|
74
74
|
})(IndividualRequestType || (IndividualRequestType = {}));
|
|
75
75
|
var UserList = function (_a) {
|
|
76
|
-
var _b
|
|
77
|
-
var
|
|
78
|
-
var
|
|
79
|
-
var
|
|
80
|
-
var
|
|
76
|
+
var _b, _c;
|
|
77
|
+
var _d = React.useState([]), usersMenuList = _d[0], setUsersMenuList = _d[1];
|
|
78
|
+
var _e = React.useState(null), anchorEl = _e[0], setAnchorEl = _e[1];
|
|
79
|
+
var _f = React.useState(false), showCollectForm = _f[0], setShowCollectForm = _f[1];
|
|
80
|
+
var _g = React.useState(), activeUser = _g[0], setActiveUser = _g[1];
|
|
81
|
+
var _h = React.useState(IndividualRequestType.ADD), type = _h[0], setType = _h[1];
|
|
81
82
|
var t = useTranslation().t;
|
|
82
83
|
var isAr = useLanguage().isAr;
|
|
83
84
|
var dispatch = useAppDispatch();
|
|
85
|
+
var _j = React.useState(false), emailChecking = _j[0], setEmailChecking = _j[1];
|
|
84
86
|
var theme = useTheme();
|
|
85
|
-
var
|
|
86
|
-
var
|
|
87
|
+
var _k = useAppSelector(individualSelector), data = _k.data, loading = _k.loading, error = _k.error;
|
|
88
|
+
var _l = data.individualCollectData, email = _l.email, mobile = _l.mobile, responseBody = _l.responseBody;
|
|
89
|
+
var is_available = (responseBody || {}).is_available;
|
|
87
90
|
var verify = data.verify;
|
|
88
91
|
var userList = (verify.responseBody || {}).userList;
|
|
89
92
|
var methods = useForm({
|
|
@@ -95,14 +98,17 @@ var UserList = function (_a) {
|
|
|
95
98
|
mode: 'onChange'
|
|
96
99
|
});
|
|
97
100
|
useSetFromDefaultValues(methods, data.individualCollectData);
|
|
101
|
+
var isUserEmailAvailable = isValidEmail(((_b = activeUser === null || activeUser === void 0 ? void 0 : activeUser.contact) === null || _b === void 0 ? void 0 : _b.email) || '');
|
|
102
|
+
var isEmailValid = typeof is_available === 'undefined' ? ((_c = activeUser === null || activeUser === void 0 ? void 0 : activeUser.contact) === null || _c === void 0 ? void 0 : _c.email) === methods.watch('email') : is_available;
|
|
103
|
+
var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email || !!error;
|
|
104
|
+
var disabled = !isUserEmailAvailable ? emailChecking || emailErrChecks || !isEmailValid : !methods.formState.isValid;
|
|
98
105
|
React.useEffect(function () {
|
|
99
106
|
if ((userList === null || userList === void 0 ? void 0 : userList.length) > 0) {
|
|
100
107
|
var list = __spreadArray([], userList, true);
|
|
101
108
|
setUsersMenuList(list);
|
|
102
109
|
var user = list.find(function (user) { return user.id === (activeUser === null || activeUser === void 0 ? void 0 : activeUser.id); }) || list[0];
|
|
103
110
|
setActiveUser(user);
|
|
104
|
-
|
|
105
|
-
resetFormData();
|
|
111
|
+
resetFormData();
|
|
106
112
|
}
|
|
107
113
|
}, [userList]);
|
|
108
114
|
var onOpenUserAction = function (event) {
|
|
@@ -113,15 +119,16 @@ var UserList = function (_a) {
|
|
|
113
119
|
};
|
|
114
120
|
var resetFormData = function () {
|
|
115
121
|
if (showCollectForm) {
|
|
122
|
+
setEmailChecking(false);
|
|
116
123
|
methods.setValue('email', '', { shouldValidate: true });
|
|
117
124
|
methods.setValue('mobile', '', { shouldValidate: true });
|
|
118
125
|
setShowCollectForm(false);
|
|
119
126
|
}
|
|
120
127
|
};
|
|
121
128
|
var onClickUser = function (user, e) {
|
|
129
|
+
setActiveUser(user);
|
|
122
130
|
resetFormData();
|
|
123
131
|
setAnchorEl(null);
|
|
124
|
-
setActiveUser(user);
|
|
125
132
|
onOpenUserAction(e);
|
|
126
133
|
};
|
|
127
134
|
var onAddDetails = function () {
|
|
@@ -132,7 +139,7 @@ var UserList = function (_a) {
|
|
|
132
139
|
}
|
|
133
140
|
};
|
|
134
141
|
var onRequestEmail = function () {
|
|
135
|
-
if (!isPhoneAndEmailAvailable(activeUser) &&
|
|
142
|
+
if (!isPhoneAndEmailAvailable(activeUser) && disabled) {
|
|
136
143
|
setShowCollectForm(true);
|
|
137
144
|
return;
|
|
138
145
|
}
|
|
@@ -151,7 +158,7 @@ var UserList = function (_a) {
|
|
|
151
158
|
};
|
|
152
159
|
var isPhoneAndEmailAvailable = function (user) {
|
|
153
160
|
var _a = (user === null || user === void 0 ? void 0 : user.contact) || { email: '' }, resEmail = _a.email, phone = _a.phone;
|
|
154
|
-
return isValidEmail(resEmail) && (phone === null || phone === void 0 ? void 0 : phone.country_code) && (phone === null || phone === void 0 ? void 0 : phone.number);
|
|
161
|
+
return !!(isValidEmail(resEmail) && (phone === null || phone === void 0 ? void 0 : phone.country_code) && (phone === null || phone === void 0 ? void 0 : phone.number));
|
|
155
162
|
};
|
|
156
163
|
var getUserRole = function (user) {
|
|
157
164
|
var _a, _b, _c, _d, _e;
|
|
@@ -165,11 +172,16 @@ var UserList = function (_a) {
|
|
|
165
172
|
};
|
|
166
173
|
var getCollectForm = function (user) {
|
|
167
174
|
var show = showCollectForm && isActiveUser(user);
|
|
168
|
-
return (_jsx(CollapseStyled, __assign({ in: show }, { children: _jsx(ScreenContainer, __assign({ sx: { mb: 1.5, mt: 0 } }, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsx(Form, { children: _jsx(CollectPhoneEmail, { activeUser: activeUser }) }) })) })) })));
|
|
175
|
+
return (_jsx(CollapseStyled, __assign({ in: show }, { children: _jsx(ScreenContainer, __assign({ sx: { mb: 1.5, mt: 0 } }, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsx(Form, { children: _jsx(CollectPhoneEmail, { activeUser: activeUser, emailChecking: emailChecking, setEmailChecking: setEmailChecking }) }) })) })) })));
|
|
169
176
|
};
|
|
170
|
-
|
|
177
|
+
React.useEffect(function () {
|
|
178
|
+
if (is_available === false)
|
|
179
|
+
methods.setError('email', { message: 'tap_js_email_already_exist' });
|
|
180
|
+
}, [responseBody]);
|
|
171
181
|
return (_jsx(ScreenContainerStyled, { children: usersMenuList.map(function (user, index) {
|
|
172
|
-
return (_jsxs(Box, __assign({ sx: index !== usersMenuList.length - 1 ? { borderBottom: "1px solid ".concat(alpha(theme.palette.divider, 0.8)) } : {} }, { children: [_jsxs(TextBoxStyled, __assign({
|
|
182
|
+
return (_jsxs(Box, __assign({ sx: index !== usersMenuList.length - 1 ? { borderBottom: "1px solid ".concat(alpha(theme.palette.divider, 0.8)) } : {} }, { children: [_jsxs(TextBoxStyled, __assign({ sx: {
|
|
183
|
+
cursor: emailChecking ? 'default' : 'pointer'
|
|
184
|
+
}, onClick: !!anchorEl && isActiveUser(user) ? function () { return onCloseUserAction(); } : function (e) { return onClickUser(user, e); } }, { children: [_jsxs(TextStyled, { children: [getName(user) || '', _jsx(RoleTextStyled, { children: getUserRole(user) || '' })] }), (user === null || user === void 0 ? void 0 : user.isRequestedEmail) ? _jsx(CheckIcon, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl && isActiveUser(user) })] })), _jsx(Collapse, __assign({ in: !!anchorEl && isActiveUser(user), timeout: 300 }, { children: _jsx(ListButton, { isAr: isAr, addDetails: {
|
|
173
185
|
title: t('add_details'),
|
|
174
186
|
onClick: onAddDetails,
|
|
175
187
|
loading: isActiveUser(user) && loading && type === IndividualRequestType.ADD
|
|
@@ -177,7 +189,7 @@ var UserList = function (_a) {
|
|
|
177
189
|
children: getCollectForm(user),
|
|
178
190
|
title: t('request_details_by_email'),
|
|
179
191
|
isRequested: (user === null || user === void 0 ? void 0 : user.isRequestedEmail) || false,
|
|
180
|
-
disabled: disabled,
|
|
192
|
+
disabled: showCollectForm ? disabled : false,
|
|
181
193
|
onClick: onRequestEmail,
|
|
182
194
|
loading: isActiveUser(user) && loading && type === IndividualRequestType.REQUEST_EMAIL
|
|
183
195
|
} }) }))] }), index));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
+
import { isValidEmail } from '../../../../utils';
|
|
2
3
|
export var IndividualCollectInfoValidationSchema = function (activeUser) {
|
|
3
4
|
var _a = (activeUser === null || activeUser === void 0 ? void 0 : activeUser.contact) || {}, phone = _a.phone, email = _a.email;
|
|
4
5
|
var isPhoneAvailable = (phone === null || phone === void 0 ? void 0 : phone.number) && (phone === null || phone === void 0 ? void 0 : phone.country_code);
|
|
5
|
-
var isEmailAvailable =
|
|
6
|
+
var isEmailAvailable = isValidEmail(email || '');
|
|
6
7
|
return yup.object().shape({
|
|
7
8
|
mobile: isPhoneAvailable
|
|
8
9
|
? yup.string().optional()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FileDetails } from '../../../@types';
|
|
3
3
|
import { Control, FieldValues } from 'react-hook-form';
|
|
4
4
|
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
5
5
|
children?: React.ReactNode;
|
|
@@ -26,8 +26,7 @@ interface UploadMultipleFileProps {
|
|
|
26
26
|
fileUploadingStatus?: (uploading: boolean) => void;
|
|
27
27
|
onDeleteFile: (fileIds: Array<string>) => void;
|
|
28
28
|
maxLimit?: number;
|
|
29
|
-
|
|
30
|
-
initialFileInfoArray?: Array<FileInfo>;
|
|
29
|
+
defaultFiles?: Array<FileDetails>;
|
|
31
30
|
}
|
|
32
|
-
declare const UploadMultipleFile: ({ id, label, control, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle }: UploadMultipleFileProps) => JSX.Element;
|
|
31
|
+
declare const UploadMultipleFile: ({ id, label, control, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle, defaultFiles }: UploadMultipleFileProps) => JSX.Element;
|
|
33
32
|
export default UploadMultipleFile;
|
|
@@ -30,6 +30,7 @@ import { ScreenContainer } from '../../shared/Containers';
|
|
|
30
30
|
import Mandatory from '../../shared/Mandatory';
|
|
31
31
|
import UploadFile, { FileStatus } from './UploadFile';
|
|
32
32
|
import { useController } from 'react-hook-form';
|
|
33
|
+
import { getFileType } from '../../../utils';
|
|
33
34
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
34
35
|
var theme = _a.theme;
|
|
35
36
|
return ({
|
|
@@ -60,7 +61,7 @@ var UploadCountBox = styled(Box)(function (_a) {
|
|
|
60
61
|
});
|
|
61
62
|
});
|
|
62
63
|
var UploadMultipleFile = function (_a) {
|
|
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;
|
|
64
|
+
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, defaultFiles = _a.defaultFiles;
|
|
64
65
|
var t = useTranslation().t;
|
|
65
66
|
var theme = useTheme();
|
|
66
67
|
var _b = React.useState(''), error = _b[0], setError = _b[1];
|
|
@@ -68,6 +69,23 @@ var UploadMultipleFile = function (_a) {
|
|
|
68
69
|
var fileInfoControl = useController({ name: "".concat(id, "FileInfo"), control: control });
|
|
69
70
|
var fileArray = fileControl.field.value || [];
|
|
70
71
|
var fileInfoArray = fileInfoControl.field.value || [];
|
|
72
|
+
React.useEffect(function () {
|
|
73
|
+
var files = defaultFiles || [];
|
|
74
|
+
if (fileArray.length === 0 && files.length > 0) {
|
|
75
|
+
files.forEach(function (file) {
|
|
76
|
+
fileArray.push({ name: file.title, size: file.size, type: getFileType(file.type) });
|
|
77
|
+
fileInfoArray.push({
|
|
78
|
+
fileId: file.id,
|
|
79
|
+
status: FileStatus.SUCCESS,
|
|
80
|
+
progress: 100,
|
|
81
|
+
error: '',
|
|
82
|
+
name: file.title || ''
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
fileControl.field.onChange(__spreadArray([], fileArray, true));
|
|
86
|
+
fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
|
|
87
|
+
}
|
|
88
|
+
}, [defaultFiles]);
|
|
71
89
|
var uploadedFileCount = React.useMemo(function () { return (fileInfoArray || []).filter(function (file) { return file.fileId; }).length; }, [fileInfoArray]);
|
|
72
90
|
var handleFileChange = function (files) {
|
|
73
91
|
if (!isSubmitting) {
|
|
@@ -124,7 +142,8 @@ var UploadMultipleFile = function (_a) {
|
|
|
124
142
|
fileInfoArray[index] = file;
|
|
125
143
|
fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
|
|
126
144
|
var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
|
|
127
|
-
|
|
145
|
+
var filteredFromDefaultFiles = fileIds.filter(function (id) { return !(defaultFiles || []).some(function (file) { return file.id === id; }); });
|
|
146
|
+
onFileUploaded(filteredFromDefaultFiles);
|
|
128
147
|
fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
|
|
129
148
|
}
|
|
130
149
|
};
|
|
@@ -10,11 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import React from 'react';
|
|
13
14
|
import { useTranslation } from 'react-i18next';
|
|
14
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
16
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
17
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
16
18
|
import { styled } from '@mui/material/styles';
|
|
17
19
|
import Collapse from '../../../../components/Collapse';
|
|
20
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
18
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
19
22
|
import { taxSelector, uploadingStatus } from '../../../app/tax/taxStore';
|
|
20
23
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
@@ -25,18 +28,21 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
25
28
|
});
|
|
26
29
|
});
|
|
27
30
|
var TaxDocument = function (_a) {
|
|
31
|
+
var _b;
|
|
28
32
|
var show = _a.show;
|
|
29
33
|
var t = useTranslation().t;
|
|
30
34
|
var control = useFormContext().control;
|
|
31
35
|
var dispatch = useAppDispatch();
|
|
32
36
|
var documentIdControl = useController({ name: 'documentId', control: control });
|
|
33
|
-
var
|
|
37
|
+
var _c = useAppSelector(taxSelector), loading = _c.loading, data = _c.data;
|
|
38
|
+
var documents = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}).documents;
|
|
34
39
|
var handleTaxDocumentChange = function (ids) {
|
|
35
40
|
documentIdControl.field.onChange(ids);
|
|
36
41
|
};
|
|
37
42
|
var handleReset = function (ids) {
|
|
38
43
|
documentIdControl.field.onChange(ids);
|
|
39
44
|
};
|
|
40
|
-
|
|
45
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.TAX_DOCUMENT); }, [documents]);
|
|
46
|
+
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, defaultFiles: defaultFiles, purpose: DocumentPurpose.TAX_DOCUMENT, fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) })) })));
|
|
41
47
|
};
|
|
42
48
|
export default TaxDocument;
|
package/build/utils/array.d.ts
CHANGED
|
@@ -62,3 +62,4 @@ export declare const fixBrandList: (items: Array<{
|
|
|
62
62
|
}[];
|
|
63
63
|
export declare const findFirstId: (items: Array<SaleChannel>) => string;
|
|
64
64
|
export declare const sortActivitiesByName: (items: Array<Activity>, path: string) => Activity[];
|
|
65
|
+
export declare const getRecentDocumentFiles: (documents: Array<any>, purpose: string) => any;
|
package/build/utils/array.js
CHANGED
|
@@ -142,3 +142,11 @@ export var sortActivitiesByName = function (items, path) {
|
|
|
142
142
|
return get(a, path).trim().toLowerCase().localeCompare(get(b, path).trim().toLowerCase().trim().toLowerCase());
|
|
143
143
|
});
|
|
144
144
|
};
|
|
145
|
+
export var getRecentDocumentFiles = function (documents, purpose) {
|
|
146
|
+
var _a;
|
|
147
|
+
if ((documents === null || documents === void 0 ? void 0 : documents.length) === 0)
|
|
148
|
+
return [];
|
|
149
|
+
return (((_a = (documents || [])
|
|
150
|
+
.filter(function (doc) { return (doc.file_details || []).find(function (file) { return file.purpose === purpose; }); })
|
|
151
|
+
.sort(function (a, b) { return b.created - a.created; })[0]) === null || _a === void 0 ? void 0 : _a.file_details) || []);
|
|
152
|
+
};
|
package/build/utils/string.d.ts
CHANGED
package/build/utils/string.js
CHANGED
|
@@ -278,3 +278,17 @@ export var getUserNameObject = function (name) {
|
|
|
278
278
|
var lastName = rest.join(' ') || '';
|
|
279
279
|
return { first: first, middle: middle || '', third: third || '', last: lastName };
|
|
280
280
|
};
|
|
281
|
+
export var getFileType = function (type) {
|
|
282
|
+
switch (type) {
|
|
283
|
+
case 'jpeg':
|
|
284
|
+
return 'image/jpeg';
|
|
285
|
+
case 'png':
|
|
286
|
+
return 'image/png';
|
|
287
|
+
case 'jpg':
|
|
288
|
+
return 'image/jpg';
|
|
289
|
+
case 'pdf':
|
|
290
|
+
return 'application/pdf';
|
|
291
|
+
default:
|
|
292
|
+
return '';
|
|
293
|
+
}
|
|
294
|
+
};
|