@tap-payments/auth-jsconnect 2.1.97-test → 2.1.99-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 +1 -0
- package/build/components/Lottie/Lottie.d.ts +1 -2
- package/build/components/Lottie/Lottie.js +1 -1
- package/build/components/Lottie/index.d.ts +2 -2
- package/build/components/Lottie/index.js +2 -2
- package/build/features/app/brand/brandStore.js +2 -12
- package/build/features/app/individual/individualStore.d.ts +9 -0
- package/build/features/app/individual/individualStore.js +99 -57
- 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 +29 -17
- package/build/features/individual/screens/IndividualList/validation.js +2 -1
- package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.js +11 -1
- package/package.json +1 -1
package/build/@types/app.d.ts
CHANGED
|
@@ -176,6 +176,7 @@ interface LibCallbacks {
|
|
|
176
176
|
onStepStarted?: (name: string) => void;
|
|
177
177
|
onBoardButtonClick?: (data: Record<string, any>) => void;
|
|
178
178
|
onCreated?: (res: Record<string, any>) => void;
|
|
179
|
+
onBoardCompleted?: () => void;
|
|
179
180
|
}
|
|
180
181
|
export interface LibConfig extends LibCallbacks {
|
|
181
182
|
publicKey: string;
|
|
@@ -4193,9 +4193,8 @@ export declare const LottieAnimationFiles: {
|
|
|
4193
4193
|
markers: never[];
|
|
4194
4194
|
};
|
|
4195
4195
|
};
|
|
4196
|
-
export declare type LottieAnimationFiles = typeof LottieAnimationFiles[keyof typeof LottieAnimationFiles];
|
|
4197
4196
|
interface LottieFileProps extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
4198
|
-
file: LottieAnimationFiles;
|
|
4197
|
+
file: (typeof LottieAnimationFiles)[keyof typeof LottieAnimationFiles];
|
|
4199
4198
|
width?: number | string;
|
|
4200
4199
|
height?: number | string;
|
|
4201
4200
|
loop?: boolean;
|
|
@@ -58,7 +58,7 @@ var LottieFile = function (_a) {
|
|
|
58
58
|
return (_jsx(_Fragment, { children: _jsx("div", __assign({ ref: lottieContainer, style: {
|
|
59
59
|
width: width || '100%',
|
|
60
60
|
height: height || '100%'
|
|
61
|
-
}, className: "".concat(props.className
|
|
61
|
+
}, className: "".concat(props.className || '') }, props)) }));
|
|
62
62
|
};
|
|
63
63
|
LottieFile.defaultProps = {
|
|
64
64
|
file: LottieAnimationFiles.start_loading
|
|
@@ -51,7 +51,7 @@ import API from '../../../api';
|
|
|
51
51
|
import { FieldType, FlowsTypes } from '../../../@types';
|
|
52
52
|
import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
53
53
|
import { BRAND_STEP_NAMES } from '../../../constants';
|
|
54
|
-
import { isKW,
|
|
54
|
+
import { isKW, isTwitter, isWebsite, sleep } from '../../../utils';
|
|
55
55
|
export var verifyLeadToken = createAsyncThunk('brandVerifyLeadToken', function (_a, thunkApi) {
|
|
56
56
|
var token = _a.token, isInternally = _a.isInternally;
|
|
57
57
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -610,23 +610,13 @@ export var brandSlice = createSlice({
|
|
|
610
610
|
state.error = null;
|
|
611
611
|
})
|
|
612
612
|
.addCase(retrieveDataList.fulfilled, function (state, action) {
|
|
613
|
-
var _a, _b;
|
|
614
613
|
state.loading = false;
|
|
615
614
|
state.error = null;
|
|
616
|
-
var
|
|
617
|
-
var regional = customerBases.at(1);
|
|
615
|
+
var _a = action.payload, customerBases = _a.customerBases, expectedSales = _a.expectedSales, expectedCustomerSales = _a.expectedCustomerSales, countryISO2 = _a.countryISO2;
|
|
618
616
|
var local = customerBases.at(0);
|
|
619
|
-
var expectedSale = (_b = (_a = expectedSales.at(0)) === null || _a === void 0 ? void 0 : _a.sub) === null || _b === void 0 ? void 0 : _b.at(4);
|
|
620
|
-
var expectedCustomerSale = expectedCustomerSales.at(3);
|
|
621
617
|
state.data.brandActivities.responseBody = __assign(__assign({}, state.data.brandActivities.responseBody), { customerBases: customerBases, expectedSales: expectedSales, expectedCustomerSales: expectedCustomerSales });
|
|
622
618
|
if (local && isKW(countryISO2))
|
|
623
619
|
state.data.brandActivities.customerLocations = [local];
|
|
624
|
-
if (regional && local && isSA(countryISO2))
|
|
625
|
-
state.data.brandActivities.customerLocations = [regional, local];
|
|
626
|
-
if (!!expectedSale)
|
|
627
|
-
state.data.brandActivities.expectedSale = expectedSale;
|
|
628
|
-
if (!!expectedCustomerSale)
|
|
629
|
-
state.data.brandActivities.expectedCustomer = expectedCustomerSale;
|
|
630
620
|
})
|
|
631
621
|
.addCase(retrieveDataList.rejected, function (state, action) {
|
|
632
622
|
state.loading = false;
|
|
@@ -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;
|
|
@@ -382,10 +382,10 @@ export var retrieveBoardDetails = createAsyncThunk('retrieveIndividualBoardDetai
|
|
|
382
382
|
});
|
|
383
383
|
}); });
|
|
384
384
|
export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
385
|
-
var _a, individual, settings, responseBody, _b, board_id, board_info_id, countries, payload, data, boardInfoData, individualData, boardData,
|
|
386
|
-
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
387
|
-
return __generator(this, function (
|
|
388
|
-
switch (
|
|
385
|
+
var _a, individual, settings, responseBody, _b, board_id, board_info_id, countries, payload, data, boardInfoData, individualData, boardData, boardInfoStatus, countryCode, notification, _c, id, type, payload_2, info, hasIndividualCompleted, birthCountry;
|
|
386
|
+
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
387
|
+
return __generator(this, function (_q) {
|
|
388
|
+
switch (_q.label) {
|
|
389
389
|
case 0:
|
|
390
390
|
_a = thunkApi.getState(), individual = _a.individual, settings = _a.settings;
|
|
391
391
|
responseBody = individual.data.verify.responseBody;
|
|
@@ -400,76 +400,83 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
|
|
|
400
400
|
};
|
|
401
401
|
return [4, API.leadService.verifyLeadOTP(payload)];
|
|
402
402
|
case 1:
|
|
403
|
-
data = (
|
|
403
|
+
data = (_q.sent()).data;
|
|
404
404
|
boardInfoStatus = undefined;
|
|
405
|
-
if (
|
|
406
|
-
|
|
407
|
-
return [
|
|
408
|
-
case 2:
|
|
409
|
-
boardInfoStatus = _p.sent();
|
|
405
|
+
if ((_e = data.errors) === null || _e === void 0 ? void 0 : _e.length)
|
|
406
|
+
throw new Error(data.errors[0].description);
|
|
407
|
+
if (!board_id) return [3, 3];
|
|
410
408
|
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
409
|
+
case 2:
|
|
410
|
+
boardData = _q.sent();
|
|
411
|
+
_q.label = 3;
|
|
411
412
|
case 3:
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
case 4:
|
|
415
|
-
countryCode = (_e = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _e === void 0 ? void 0 : _e.country;
|
|
416
|
-
if (!(board_id && board_info_id)) return [3, 7];
|
|
413
|
+
countryCode = (_f = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _f === void 0 ? void 0 : _f.country;
|
|
414
|
+
if (!(board_id && board_info_id)) return [3, 6];
|
|
417
415
|
return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
|
|
418
|
-
case
|
|
419
|
-
boardInfoData =
|
|
416
|
+
case 4:
|
|
417
|
+
boardInfoData = _q.sent();
|
|
420
418
|
notification = (boardInfoData || {}).notification;
|
|
421
419
|
_c = (notification === null || notification === void 0 ? void 0 : notification.recipient) || {}, id = _c.id, type = _c.type;
|
|
422
|
-
if (!(id && type)) return [3,
|
|
420
|
+
if (!(id && type)) return [3, 6];
|
|
423
421
|
return [4, thunkApi.dispatch(retrieveIndividualInfo({ id: id, type: type, countryCode: countryCode }))];
|
|
424
|
-
case
|
|
425
|
-
payload_2 = (
|
|
422
|
+
case 5:
|
|
423
|
+
payload_2 = (_q.sent()).payload;
|
|
426
424
|
individualData = payload_2.data || {};
|
|
427
|
-
|
|
425
|
+
_q.label = 6;
|
|
426
|
+
case 6:
|
|
427
|
+
if (countryCode)
|
|
428
|
+
thunkApi.dispatch(handleSetCountryByIso2(countryCode));
|
|
429
|
+
if (!board_id) return [3, 8];
|
|
430
|
+
return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
|
|
428
431
|
case 7:
|
|
432
|
+
boardInfoStatus = _q.sent();
|
|
433
|
+
_q.label = 8;
|
|
434
|
+
case 8:
|
|
429
435
|
info = (boardInfoStatus || {}).info;
|
|
430
|
-
hasIndividualCompleted = ((
|
|
431
|
-
|
|
432
|
-
if (!hasIndividualCompleted) return [3, 8];
|
|
436
|
+
hasIndividualCompleted = ((_g = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _g === void 0 ? void 0 : _g.status) === 'completed';
|
|
437
|
+
if (!hasIndividualCompleted) return [3, 9];
|
|
433
438
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
434
|
-
return [3,
|
|
435
|
-
case 8:
|
|
436
|
-
if (!(individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized)) return [3, 11];
|
|
437
|
-
if (!((_j = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _j === void 0 ? void 0 : _j.id)) return [3, 10];
|
|
438
|
-
return [4, thunkApi.dispatch(getIndividualList((_k = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _k === void 0 ? void 0 : _k.id))];
|
|
439
|
+
return [3, 15];
|
|
439
440
|
case 9:
|
|
440
|
-
|
|
441
|
-
|
|
441
|
+
if (!(individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized)) return [3, 12];
|
|
442
|
+
if (!((_h = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _h === void 0 ? void 0 : _h.id)) return [3, 11];
|
|
443
|
+
return [4, thunkApi.dispatch(getIndividualList((_j = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _j === void 0 ? void 0 : _j.id))];
|
|
442
444
|
case 10:
|
|
443
|
-
|
|
444
|
-
|
|
445
|
+
_q.sent();
|
|
446
|
+
_q.label = 11;
|
|
445
447
|
case 11:
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return [4, thunkApi.dispatch(getCityList(birthCountry))];
|
|
448
|
+
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_LIST_STEP'));
|
|
449
|
+
return [3, 15];
|
|
449
450
|
case 12:
|
|
450
|
-
|
|
451
|
-
|
|
451
|
+
birthCountry = ((_k = individualData === null || individualData === void 0 ? void 0 : individualData.birth) === null || _k === void 0 ? void 0 : _k.country) || countryCode;
|
|
452
|
+
if (!birthCountry) return [3, 14];
|
|
453
|
+
return [4, thunkApi.dispatch(getCityList(birthCountry))];
|
|
452
454
|
case 13:
|
|
455
|
+
_q.sent();
|
|
456
|
+
_q.label = 14;
|
|
457
|
+
case 14:
|
|
453
458
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP'));
|
|
454
|
-
|
|
455
|
-
case
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
459
|
+
_q.label = 15;
|
|
460
|
+
case 15:
|
|
461
|
+
(_m = (_l = settings.data.appConfig).onStepCompleted) === null || _m === void 0 ? void 0 : _m.call(_l, settings.data.activeScreen.name, { otp: params.otp });
|
|
462
|
+
return [2, {
|
|
463
|
+
data: data,
|
|
464
|
+
boardResponse: {
|
|
465
|
+
brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
|
|
466
|
+
bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
|
|
467
|
+
entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity,
|
|
468
|
+
merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
|
|
469
|
+
merchant_id: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.merchant_id,
|
|
470
|
+
name: (_o = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _o === void 0 ? void 0 : _o.names,
|
|
471
|
+
contact: (_p = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _p === void 0 ? void 0 : _p.contact,
|
|
472
|
+
individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals,
|
|
473
|
+
countries: countries,
|
|
474
|
+
countryCode: countryCode,
|
|
475
|
+
notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification,
|
|
476
|
+
flows: (boardInfoStatus === null || boardInfoStatus === void 0 ? void 0 : boardInfoStatus.info) || []
|
|
477
|
+
},
|
|
478
|
+
formData: __assign({}, params)
|
|
479
|
+
}];
|
|
473
480
|
}
|
|
474
481
|
});
|
|
475
482
|
}); });
|
|
@@ -650,6 +657,28 @@ export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', funct
|
|
|
650
657
|
}
|
|
651
658
|
});
|
|
652
659
|
}); });
|
|
660
|
+
export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', function (_a) {
|
|
661
|
+
var email = _a.email, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
|
|
662
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
663
|
+
var requestBody, data;
|
|
664
|
+
return __generator(this, function (_b) {
|
|
665
|
+
switch (_b.label) {
|
|
666
|
+
case 0:
|
|
667
|
+
requestBody = {
|
|
668
|
+
email: email,
|
|
669
|
+
encryption_contract: ['email']
|
|
670
|
+
};
|
|
671
|
+
return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
|
|
672
|
+
case 1:
|
|
673
|
+
data = (_b.sent()).data;
|
|
674
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
|
675
|
+
if (!data.errors)
|
|
676
|
+
return [2, { response: data, formData: email }];
|
|
677
|
+
return [2];
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
});
|
|
681
|
+
});
|
|
653
682
|
export var updateBoardSuccess = createAsyncThunk('individualUpdateBoardSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
654
683
|
var _a, settings, individual, _b, id, infoId, payload, data, boardInfoStatus;
|
|
655
684
|
var _c, _d, _e, _f;
|
|
@@ -1031,6 +1060,19 @@ export var individualSlice = createSlice({
|
|
|
1031
1060
|
.addCase(retrieveBoardDetails.rejected, function (state, action) {
|
|
1032
1061
|
state.error = action.error.message;
|
|
1033
1062
|
state.loading = false;
|
|
1063
|
+
})
|
|
1064
|
+
.addCase(checkEmailAvailability.fulfilled, function (state, action) {
|
|
1065
|
+
var _a;
|
|
1066
|
+
state.error = null;
|
|
1067
|
+
state.data.individualCollectData.responseBody = __assign(__assign({}, state.data.individualCollectData.responseBody), (_a = action.payload) === null || _a === void 0 ? void 0 : _a.response);
|
|
1068
|
+
})
|
|
1069
|
+
.addCase(checkEmailAvailability.pending, function (state) {
|
|
1070
|
+
state.error = null;
|
|
1071
|
+
})
|
|
1072
|
+
.addCase(checkEmailAvailability.rejected, function (state, action) {
|
|
1073
|
+
if (action.error.message === 'Aborted')
|
|
1074
|
+
return;
|
|
1075
|
+
state.error = action.error.message;
|
|
1034
1076
|
})
|
|
1035
1077
|
.addCase(updateBoardSuccess.fulfilled, function (state, action) {
|
|
1036
1078
|
var _a;
|
|
@@ -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);
|
|
@@ -57,7 +57,7 @@ var TextBoxStyled = styled(Box)(function (_a) {
|
|
|
57
57
|
});
|
|
58
58
|
var TextStyled = styled(Box)(function (_a) {
|
|
59
59
|
var theme = _a.theme;
|
|
60
|
-
return (__assign(__assign({}, theme.typography.subtitle2), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightRegular, background: theme.palette.background.default }));
|
|
60
|
+
return (__assign(__assign({}, theme.typography.subtitle2), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightRegular, background: theme.palette.background.default, display: 'inline-flex' }));
|
|
61
61
|
});
|
|
62
62
|
var RoleTextStyled = styled(Text)(function (_a) {
|
|
63
63
|
var theme = _a.theme;
|
|
@@ -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: [_jsx("span", { 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()
|
|
@@ -100,9 +100,19 @@ var SuccessFlowButtons = function (_a) {
|
|
|
100
100
|
});
|
|
101
101
|
setButtons(mappedFlows);
|
|
102
102
|
};
|
|
103
|
+
var checkIfFlowsAreCompletedExceptPassword = function (data) {
|
|
104
|
+
var isFlowsCompleted = data.every(function (flow) { return flow.status === 'completed' && flow.name !== 'password'; });
|
|
105
|
+
return isFlowsCompleted;
|
|
106
|
+
};
|
|
103
107
|
useEffect(function () {
|
|
104
|
-
|
|
108
|
+
var _a, _b;
|
|
109
|
+
if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0) {
|
|
105
110
|
reMapFlowData(flows);
|
|
111
|
+
var isFlowsCompleted = checkIfFlowsAreCompletedExceptPassword(flows);
|
|
112
|
+
if (isFlowsCompleted) {
|
|
113
|
+
(_b = (_a = settings.data.appConfig).onBoardCompleted) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
106
116
|
}, [flows, isAr]);
|
|
107
117
|
return (_jsxs(ContainerStyled, { children: [_jsxs(TitleStyled, { children: [t('account_details'), " "] }), _jsx(AcceptancePayouts, { showAcceptance: isAcceptance, showPayout: isPayout }), _jsx(ButtonGroupStyled, { children: _jsx(FlowsButtons, { buttons: buttons, data: {
|
|
108
118
|
flowName: flowName,
|