@tap-payments/auth-jsconnect 2.9.13-development → 2.9.15-development

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.
Files changed (39) hide show
  1. package/build/@types/form.d.ts +4 -0
  2. package/build/assets/locales/ar.json +6 -1
  3. package/build/assets/locales/en.json +6 -1
  4. package/build/components/AnimationFlow/BottomSheet.js +3 -3
  5. package/build/constants/app.d.ts +6 -0
  6. package/build/constants/app.js +36 -6
  7. package/build/features/app/business/businessStore.d.ts +10 -1
  8. package/build/features/app/business/businessStore.js +107 -8
  9. package/build/features/app/connect/connectStore.d.ts +8 -1
  10. package/build/features/app/connect/connectStore.js +127 -30
  11. package/build/features/app/connectExpress/connectExpressStore.d.ts +8 -1
  12. package/build/features/app/connectExpress/connectExpressStore.js +149 -16
  13. package/build/features/business/screens/MobileOwnership/CollectMobileOwnership.d.ts +3 -0
  14. package/build/features/business/screens/MobileOwnership/CollectMobileOwnership.js +104 -0
  15. package/build/features/business/screens/MobileOwnership/MobileNumber.d.ts +3 -0
  16. package/build/features/business/screens/MobileOwnership/MobileNumber.js +72 -0
  17. package/build/features/business/screens/MobileOwnership/index.d.ts +2 -0
  18. package/build/features/business/screens/MobileOwnership/index.js +2 -0
  19. package/build/features/business/screens/MobileOwnership/validation.d.ts +8 -0
  20. package/build/features/business/screens/MobileOwnership/validation.js +38 -0
  21. package/build/features/connect/screens/MobileOwnership/CollectMobileOwnership.d.ts +3 -0
  22. package/build/features/connect/screens/MobileOwnership/CollectMobileOwnership.js +105 -0
  23. package/build/features/connect/screens/MobileOwnership/MobileNumber.d.ts +3 -0
  24. package/build/features/connect/screens/MobileOwnership/MobileNumber.js +72 -0
  25. package/build/features/connect/screens/MobileOwnership/index.d.ts +2 -0
  26. package/build/features/connect/screens/MobileOwnership/index.js +2 -0
  27. package/build/features/connect/screens/MobileOwnership/validation.d.ts +8 -0
  28. package/build/features/connect/screens/MobileOwnership/validation.js +38 -0
  29. package/build/features/connectExpress/screens/MobileOwnership/CollectMobileOwnership.d.ts +3 -0
  30. package/build/features/connectExpress/screens/MobileOwnership/CollectMobileOwnership.js +107 -0
  31. package/build/features/connectExpress/screens/MobileOwnership/MobileNumber.d.ts +3 -0
  32. package/build/features/connectExpress/screens/MobileOwnership/MobileNumber.js +72 -0
  33. package/build/features/connectExpress/screens/MobileOwnership/index.d.ts +2 -0
  34. package/build/features/connectExpress/screens/MobileOwnership/index.js +2 -0
  35. package/build/features/connectExpress/screens/MobileOwnership/validation.d.ts +8 -0
  36. package/build/features/connectExpress/screens/MobileOwnership/validation.js +38 -0
  37. package/build/features/featuresScreens.js +15 -0
  38. package/build/features/shared/Dialog/DialogContainer.js +3 -3
  39. package/package.json +1 -1
@@ -71,7 +71,7 @@ import { handleCurrentActiveScreen, handleNextScreenStep, handleSetCountryByIso2
71
71
  import { COLLECT_DOB_INFO_NAFATH, CONNECT_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, NAFATH_VERIFICATION_FAILED, OTHER_BRAND } from '../../../constants';
72
72
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
73
73
  import { AuthForType, FlowsTypes } from '../../../@types';
74
- import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, isTwitter, getIndividualName, isWebsite, sleep, sendCustomEventToGTM, isOtherThanKWOrSA, isKW, findCountryByIso2, getMetaData } from '../../../utils';
74
+ import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, isTwitter, getIndividualName, isWebsite, sleep, sendCustomEventToGTM, isOtherThanKWOrSA, isKW, findCountryByIso2, getMetaData, isSA, isNetworkError } from '../../../utils';
75
75
  export var updateBusinessCountry = createAsyncThunk('connect/updateBusinessCountry', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
76
76
  var connect, payload, data;
77
77
  return __generator(this, function (_a) {
@@ -363,7 +363,7 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
363
363
  });
364
364
  }); });
365
365
  export var verifyNafath = createAsyncThunk('connect/verifyNafath', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
366
- var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, isFailed, countryCode, lead_id, leadResponse, channels, brand, err_5, brands, err_6, phone, isNextScreenDob, stepName;
366
+ var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, error_1, isSuccess, isFailed, countryCode, lead_id, leadResponse, channels, brand, err_5, brands, err_6, phone, isNextScreenDob, stepName;
367
367
  var _b, _c, _d, _e, _f, _g, _h;
368
368
  return __generator(this, function (_j) {
369
369
  switch (_j.label) {
@@ -376,58 +376,70 @@ export var verifyNafath = createAsyncThunk('connect/verifyNafath', function (par
376
376
  count = 1;
377
377
  _j.label = 1;
378
378
  case 1:
379
- if (!(count <= maxCalls)) return [3, 16];
379
+ if (!(count <= maxCalls)) return [3, 19];
380
380
  if (thunkApi.signal.aborted) {
381
- return [3, 16];
381
+ return [3, 19];
382
382
  }
383
- return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
383
+ authResponse = void 0;
384
+ _j.label = 2;
384
385
  case 2:
386
+ _j.trys.push([2, 4, , 5]);
387
+ return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
388
+ case 3:
385
389
  authResponse = _j.sent();
386
- isSuccess = ((_b = authResponse.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
390
+ return [3, 5];
391
+ case 4:
392
+ error_1 = _j.sent();
393
+ if (!isNetworkError(error_1.message)) {
394
+ throw new Error(error_1);
395
+ }
396
+ return [3, 5];
397
+ case 5:
398
+ isSuccess = ((_b = authResponse === null || authResponse === void 0 ? void 0 : authResponse.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
387
399
  isFailed = ((_c = authResponse === null || authResponse === void 0 ? void 0 : authResponse.status) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'failed';
388
400
  countryCode = settings.data.businessCountry;
389
401
  if (isFailed) {
390
402
  (_d = params.onFailure) === null || _d === void 0 ? void 0 : _d.call(params);
391
403
  return [2, { authResponse: authResponse, countryCode: countryCode }];
392
404
  }
393
- if (!isSuccess) return [3, 13];
405
+ if (!isSuccess) return [3, 16];
394
406
  lead_id = authResponse.lead_id;
395
407
  if (!lead_id)
396
408
  throw new Error('Lead id is missing');
397
409
  return [4, API.leadService.retrieveLead(lead_id)];
398
- case 3:
410
+ case 6:
399
411
  leadResponse = (_j.sent()).data;
400
412
  if ((_e = leadResponse.errors) === null || _e === void 0 ? void 0 : _e.length)
401
413
  throw new Error(leadResponse.errors[0].description);
402
414
  return [4, API.dataService.getChannelsOfServices({ page: 0 })];
403
- case 4:
415
+ case 7:
404
416
  channels = (_j.sent()).list;
405
417
  leadResponse.channel_list = channels;
406
- _j.label = 5;
407
- case 5:
408
- _j.trys.push([5, 7, , 8]);
418
+ _j.label = 8;
419
+ case 8:
420
+ _j.trys.push([8, 10, , 11]);
409
421
  return [4, API.brandService.retrieveBrand(leadResponse.brand.id)];
410
- case 6:
422
+ case 9:
411
423
  brand = (_j.sent()).brand;
412
424
  leadResponse.brand = __assign(__assign({}, leadResponse.brand), brand);
413
- return [3, 8];
414
- case 7:
425
+ return [3, 11];
426
+ case 10:
415
427
  err_5 = _j.sent();
416
- return [3, 8];
417
- case 8:
418
- _j.trys.push([8, 10, , 11]);
428
+ return [3, 11];
429
+ case 11:
430
+ _j.trys.push([11, 13, , 14]);
419
431
  return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
420
- case 9:
432
+ case 12:
421
433
  brands = (_j.sent()).brands;
422
434
  leadResponse.brand_list = fixBrandList(brands, channels);
423
- return [3, 11];
424
- case 10:
435
+ return [3, 14];
436
+ case 13:
425
437
  err_6 = _j.sent();
426
- return [3, 11];
427
- case 11:
438
+ return [3, 14];
439
+ case 14:
428
440
  (_f = params.onSuccess) === null || _f === void 0 ? void 0 : _f.call(params);
429
441
  return [4, sleep(3000)];
430
- case 12:
442
+ case 15:
431
443
  _j.sent();
432
444
  phone = (leadResponse.contact || {}).phone;
433
445
  if (phone === null || phone === void 0 ? void 0 : phone.country_code)
@@ -437,14 +449,14 @@ export var verifyNafath = createAsyncThunk('connect/verifyNafath', function (par
437
449
  stepName = isNextScreenDob ? 'CONNECT_DOB_STEP' : 'CONNECT_INDIVIDUAL_STEP';
438
450
  thunkApi.dispatch(handleNextScreenStep(stepName));
439
451
  return [2, { authResponse: authResponse, leadResponse: leadResponse, countryCode: countryCode, isNextScreenDob: isNextScreenDob }];
440
- case 13: return [4, sleep(interval * 1000)];
441
- case 14:
452
+ case 16: return [4, sleep(interval * 1000)];
453
+ case 17:
442
454
  _j.sent();
443
- _j.label = 15;
444
- case 15:
455
+ _j.label = 18;
456
+ case 18:
445
457
  count++;
446
458
  return [3, 1];
447
- case 16: throw new Error(NAFATH_VERIFICATION_FAILED);
459
+ case 19: throw new Error(NAFATH_VERIFICATION_FAILED);
448
460
  }
449
461
  });
450
462
  }); });
@@ -497,7 +509,12 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
497
509
  leadResponse = _g.sent();
498
510
  leadResponse.brand = __assign(__assign({}, leadResponse.brand), brandData);
499
511
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
500
- thunkApi.dispatch(handleNextScreenStep());
512
+ if (isSA(leadResponse.country_code) && leadResponse.step_name === CONNECT_STEP_NAMES.CONNECT_MOBILE_OWNERSHIP) {
513
+ thunkApi.dispatch(handleNextScreenStep('CONNECT_MOBILE_OWNERSHIP'));
514
+ }
515
+ else {
516
+ thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
517
+ }
501
518
  return [2, { leadResponse: leadResponse, formData: params }];
502
519
  }
503
520
  });
@@ -678,6 +695,59 @@ export var updateLeadBrandSegment = createAsyncThunk('updateLeadBrandSegment', f
678
695
  }
679
696
  });
680
697
  }); });
698
+ export var updateLeadMobile = createAsyncThunk('connect/updateLeadMobile', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
699
+ var _a, settings, connect, lead_id, payload, leadResponse;
700
+ var _b, _c;
701
+ return __generator(this, function (_d) {
702
+ switch (_d.label) {
703
+ case 0:
704
+ _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
705
+ lead_id = (connect.data.otpData.responseBody || {}).lead_id;
706
+ payload = {
707
+ id: lead_id || '',
708
+ contact: {
709
+ phone: {
710
+ country_code: params.countryCode.idd_prefix.toString(),
711
+ number: params.mobile
712
+ }
713
+ },
714
+ step_name: CONNECT_STEP_NAMES.CONNECT_MOBILE_OWNERSHIP,
715
+ encryption_contract: ['contact.phone.country_code', 'contact.phone.number']
716
+ };
717
+ return [4, API.leadService.updateLead(payload)];
718
+ case 1:
719
+ leadResponse = _d.sent();
720
+ if (leadResponse.step_name === CONNECT_STEP_NAMES.CONNECT_MOBILE_OWNERSHIP) {
721
+ throw new Error("The new mobile number doesn't match the national ID, please update the mobile to the correct one");
722
+ }
723
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, params);
724
+ thunkApi.dispatch(handleNextScreenStep());
725
+ return [2, { leadResponse: leadResponse, formData: params }];
726
+ }
727
+ });
728
+ }); });
729
+ export var skipUpdateLeadMobile = createAsyncThunk('connect/skipUpdateLeadMobile', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
730
+ var _a, settings, connect, lead_id, payload, leadResponse;
731
+ var _b, _c;
732
+ return __generator(this, function (_d) {
733
+ switch (_d.label) {
734
+ case 0:
735
+ _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
736
+ lead_id = (connect.data.otpData.responseBody || {}).lead_id;
737
+ payload = {
738
+ id: lead_id || '',
739
+ step_name: CONNECT_STEP_NAMES.CONNECT_MOBILE_OWNERSHIP_SKIPPED,
740
+ encryption_contract: []
741
+ };
742
+ return [4, API.leadService.updateLead(payload)];
743
+ case 1:
744
+ leadResponse = _d.sent();
745
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, {});
746
+ thunkApi.dispatch(handleNextScreenStep());
747
+ return [2, { leadResponse: leadResponse }];
748
+ }
749
+ });
750
+ }); });
681
751
  export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', function (_a, thunkApi) {
682
752
  var email = _a.email, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
683
753
  return __awaiter(void 0, void 0, void 0, function () {
@@ -1123,6 +1193,33 @@ export var connectSlice = createSlice({
1123
1193
  .addCase(updateLeadBrandSegment.rejected, function (state, action) {
1124
1194
  state.loading = false;
1125
1195
  state.error = action.error.message;
1196
+ })
1197
+ .addCase(updateLeadMobile.fulfilled, function (state, action) {
1198
+ state.loading = false;
1199
+ state.error = null;
1200
+ state.data.individualData.mobile = action.payload.leadResponse.contact.phone.number;
1201
+ state.data.individualData.responseBody = action.payload.leadResponse;
1202
+ })
1203
+ .addCase(updateLeadMobile.pending, function (state) {
1204
+ state.loading = true;
1205
+ state.error = null;
1206
+ })
1207
+ .addCase(updateLeadMobile.rejected, function (state, action) {
1208
+ state.loading = false;
1209
+ state.error = action.error.message;
1210
+ })
1211
+ .addCase(skipUpdateLeadMobile.fulfilled, function (state, action) {
1212
+ state.loading = false;
1213
+ state.error = null;
1214
+ state.data.individualData.responseBody = action.payload.leadResponse;
1215
+ })
1216
+ .addCase(skipUpdateLeadMobile.pending, function (state) {
1217
+ state.loading = true;
1218
+ state.error = null;
1219
+ })
1220
+ .addCase(skipUpdateLeadMobile.rejected, function (state, action) {
1221
+ state.loading = false;
1222
+ state.error = action.error.message;
1126
1223
  })
1127
1224
  .addCase(checkEmailAvailability.fulfilled, function (state, action) {
1128
1225
  var _a;
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { MobileFormValues, NIDFormValues, CivilFormValues, OTPFormValues, IndividualFormValues, SharedState, FlowsTypes, ActionState, CountryCode, AuthForType, BusinessDataFormValues, AsyncThunkParams, AuthenticationListFormValues, AuthMerchantFormValues, DOBFormValues } from '../../../@types';
2
+ import { MobileFormValues, NIDFormValues, CivilFormValues, OTPFormValues, IndividualFormValues, SharedState, FlowsTypes, ActionState, CountryCode, AuthForType, BusinessDataFormValues, AsyncThunkParams, AuthenticationListFormValues, AuthMerchantFormValues, DOBFormValues, MobileOwnershipFormValues } from '../../../@types';
3
3
  import { CancelToken } from 'axios';
4
4
  export declare const updateBusinessCountryAsync: import("@reduxjs/toolkit").AsyncThunk<any, string, {}>;
5
5
  export declare const retrieveLeadIdentityByIdAsync: import("@reduxjs/toolkit").AsyncThunk<{
@@ -126,6 +126,13 @@ export declare const updateLeadBusinessDataAsync: import("@reduxjs/toolkit").Asy
126
126
  response: any;
127
127
  formData: BusinessDataFormValues;
128
128
  }, AsyncThunkParams<BusinessDataFormValues>, {}>;
129
+ export declare const updateLeadMobile: import("@reduxjs/toolkit").AsyncThunk<{
130
+ leadResponse: any;
131
+ formData: MobileOwnershipFormValues;
132
+ }, MobileOwnershipFormValues, {}>;
133
+ export declare const skipUpdateLeadMobile: import("@reduxjs/toolkit").AsyncThunk<{
134
+ leadResponse: any;
135
+ }, void, {}>;
129
136
  export declare const confirmInfo: import("@reduxjs/toolkit").AsyncThunk<{
130
137
  boardInfo: any;
131
138
  boardData: any;
@@ -685,18 +685,18 @@ export var createNIDNafathAuthIdentityAsync = createAsyncThunk('connectExpress/c
685
685
  });
686
686
  }); });
687
687
  export var verifyNafathIdentityAsync = createAsyncThunk('connectExpress/verifyNafathIdentityAsync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
688
- var connectExpress, authData, expiry, interval, maxCalls, count, data, isSuccess, isFailed, needToCollectMoreInfo, creatingAccount, askDobInfo;
689
- var _a, _b, _c, _d, _e, _f, _g;
690
- return __generator(this, function (_h) {
691
- switch (_h.label) {
688
+ var _a, connectExpress, settings, authData, expiry, interval, maxCalls, count, data, isSuccess, isFailed, needToCollectMoreInfo, creatingAccount, askDobInfo, collectPhoneOwnershipScreen;
689
+ var _b, _c, _d, _e, _f, _g, _h;
690
+ return __generator(this, function (_j) {
691
+ switch (_j.label) {
692
692
  case 0:
693
- connectExpress = thunkApi.getState().connectExpress;
693
+ _a = thunkApi.getState(), connectExpress = _a.connectExpress, settings = _a.settings;
694
694
  authData = (connectExpress.data.responseData || {}).authData;
695
695
  expiry = (authData === null || authData === void 0 ? void 0 : authData.expiry) || 120;
696
696
  interval = 3;
697
697
  maxCalls = Math.floor(expiry / interval);
698
698
  count = 1;
699
- _h.label = 1;
699
+ _j.label = 1;
700
700
  case 1:
701
701
  if (!(count <= maxCalls)) return [3, 7];
702
702
  if (thunkApi.signal.aborted) {
@@ -704,21 +704,25 @@ export var verifyNafathIdentityAsync = createAsyncThunk('connectExpress/verifyNa
704
704
  }
705
705
  return [4, API.authService.getExpressTokenVerify({ token: authData === null || authData === void 0 ? void 0 : authData.verify_token, leadId: authData === null || authData === void 0 ? void 0 : authData.lead_id })];
706
706
  case 2:
707
- data = _h.sent();
708
- isSuccess = ((_b = (_a = data.auth) === null || _a === void 0 ? void 0 : _a.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
709
- isFailed = ((_d = (_c = data.auth) === null || _c === void 0 ? void 0 : _c.status) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === 'failed';
707
+ data = _j.sent();
708
+ isSuccess = ((_c = (_b = data.auth) === null || _b === void 0 ? void 0 : _b.status) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'success';
709
+ isFailed = ((_e = (_d = data.auth) === null || _d === void 0 ? void 0 : _d.status) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === 'failed';
710
710
  if (isFailed) {
711
- (_e = params.onFailure) === null || _e === void 0 ? void 0 : _e.call(params);
711
+ (_f = params.onFailure) === null || _f === void 0 ? void 0 : _f.call(params);
712
712
  return [2, { data: data }];
713
713
  }
714
714
  if (!isSuccess) return [3, 4];
715
- return [4, thunkApi.dispatch(getLeadByIdAsync((_f = data.auth) === null || _f === void 0 ? void 0 : _f.lead_id)).unwrap()];
715
+ return [4, thunkApi.dispatch(getLeadByIdAsync((_g = data.auth) === null || _g === void 0 ? void 0 : _g.lead_id)).unwrap()];
716
716
  case 3:
717
- _h.sent();
717
+ _j.sent();
718
718
  needToCollectMoreInfo = data.step_name === 'collect_info';
719
719
  creatingAccount = data.step_name === 'create_account';
720
720
  askDobInfo = data.step_name === COLLECT_DOB_INFO_NAFATH;
721
- (_g = params.onSuccess) === null || _g === void 0 ? void 0 : _g.call(params);
721
+ collectPhoneOwnershipScreen = data.step_name === CONNECT_EXPRESS_STEP_NAMES.COLLECT_MOBILE_OWNERSHIP;
722
+ (_h = params.onSuccess) === null || _h === void 0 ? void 0 : _h.call(params);
723
+ if (isSA(settings.data.businessCountry.iso2) && collectPhoneOwnershipScreen) {
724
+ sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('COLLECT_MOBILE_OWNERSHIP')); });
725
+ }
722
726
  if (askDobInfo) {
723
727
  sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_COLLECT_DOB_INFO_STEP')); });
724
728
  }
@@ -731,8 +735,8 @@ export var verifyNafathIdentityAsync = createAsyncThunk('connectExpress/verifyNa
731
735
  return [2, { data: data, isNextScreenIsDob: askDobInfo }];
732
736
  case 4: return [4, sleep(interval * 1000)];
733
737
  case 5:
734
- _h.sent();
735
- _h.label = 6;
738
+ _j.sent();
739
+ _j.label = 6;
736
740
  case 6:
737
741
  count++;
738
742
  return [3, 1];
@@ -1010,7 +1014,7 @@ export var updateLeadDOBAsync = createAsyncThunk('connectExpress/updateLeadDOBAs
1010
1014
  export var updateLeadIndividualAsync = createAsyncThunk('connectExpress/updateLeadIndividualAsync', function (_a, thunkApi) {
1011
1015
  var formData = _a.formData, originalFormData = _a.originalFormData;
1012
1016
  return __awaiter(void 0, void 0, void 0, function () {
1013
- var _b, settings, connectExpress, id, countryCode, name, email, mobile, phoneCountry, isContactAvailable, payload, data, needToCollectMoreInfo, creatingAccount, isSaudi;
1017
+ var _b, settings, connectExpress, id, countryCode, name, email, mobile, phoneCountry, isContactAvailable, payload, data, needToCollectMoreInfo, creatingAccount, collectPhoneOwnershipScreen, isSaudi;
1014
1018
  var _c, _d, _e, _f, _g;
1015
1019
  return __generator(this, function (_h) {
1016
1020
  switch (_h.label) {
@@ -1029,6 +1033,10 @@ export var updateLeadIndividualAsync = createAsyncThunk('connectExpress/updateLe
1029
1033
  (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, formData);
1030
1034
  needToCollectMoreInfo = data.step_name === 'collect_info';
1031
1035
  creatingAccount = data.step_name === 'create_account';
1036
+ collectPhoneOwnershipScreen = data.step_name === CONNECT_EXPRESS_STEP_NAMES.COLLECT_MOBILE_OWNERSHIP;
1037
+ if (isSA(settings.data.businessCountry.iso2) && collectPhoneOwnershipScreen) {
1038
+ sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('COLLECT_MOBILE_OWNERSHIP')); });
1039
+ }
1032
1040
  if (creatingAccount) {
1033
1041
  sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_WAITING_FOR_CREATING_ACCOUNT_STEP')); });
1034
1042
  }
@@ -1088,6 +1096,104 @@ export var updateLeadBusinessDataAsync = createAsyncThunk('updateLeadBusinessDat
1088
1096
  });
1089
1097
  });
1090
1098
  });
1099
+ export var updateLeadMobile = createAsyncThunk('connect/updateLeadMobile', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
1100
+ var _a, settings, connectExpress, id, startWithNID, payload, leadResponse, needToCollectMoreInfo, creatingAccount, askDobInfo, collectPhoneOwnershipScreen;
1101
+ var _b, _c, _d;
1102
+ return __generator(this, function (_e) {
1103
+ switch (_e.label) {
1104
+ case 0:
1105
+ _a = thunkApi.getState(), settings = _a.settings, connectExpress = _a.connectExpress;
1106
+ id = (((_b = connectExpress.data.responseData) === null || _b === void 0 ? void 0 : _b.leadData) || {}).id;
1107
+ startWithNID = connectExpress.data.otpData.authFor === AuthForType.NATIONAL_ID;
1108
+ payload = {
1109
+ id: id || '',
1110
+ contact: {
1111
+ phone: {
1112
+ country_code: params.countryCode.idd_prefix.toString(),
1113
+ number: params.mobile
1114
+ }
1115
+ },
1116
+ step_name: CONNECT_EXPRESS_STEP_NAMES.COLLECT_MOBILE_OWNERSHIP,
1117
+ encryption_contract: ['contact.phone.country_code', 'contact.phone.number']
1118
+ };
1119
+ return [4, API.leadService.updateLeadExpress(payload)];
1120
+ case 1:
1121
+ leadResponse = _e.sent();
1122
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
1123
+ needToCollectMoreInfo = leadResponse.step_name === 'collect_info';
1124
+ creatingAccount = leadResponse.step_name === 'create_account';
1125
+ askDobInfo = leadResponse.step_name === COLLECT_DOB_INFO_NAFATH;
1126
+ collectPhoneOwnershipScreen = leadResponse.step_name === CONNECT_EXPRESS_STEP_NAMES.COLLECT_MOBILE_OWNERSHIP;
1127
+ if (collectPhoneOwnershipScreen) {
1128
+ throw new Error("The new mobile number doesn't match the national ID, please update the mobile to the correct one");
1129
+ }
1130
+ if (askDobInfo) {
1131
+ sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_COLLECT_DOB_INFO_STEP')); });
1132
+ }
1133
+ if (creatingAccount) {
1134
+ sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_WAITING_FOR_CREATING_ACCOUNT_STEP')); });
1135
+ }
1136
+ if (!needToCollectMoreInfo) return [3, 5];
1137
+ if (!startWithNID) return [3, 4];
1138
+ if (!isSA(settings.data.businessCountry.iso2)) return [3, 3];
1139
+ return [4, thunkApi.dispatch(retrieveEntityListAsync(leadResponse.lead.id)).unwrap()];
1140
+ case 2:
1141
+ _e.sent();
1142
+ _e.label = 3;
1143
+ case 3:
1144
+ sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_COLLECT_BUSINESS_INFO_STEP')); });
1145
+ return [3, 5];
1146
+ case 4:
1147
+ sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_COLLECT_INDIVIDUAL_INFO_STEP')); });
1148
+ _e.label = 5;
1149
+ case 5: return [2, { leadResponse: leadResponse, formData: params }];
1150
+ }
1151
+ });
1152
+ }); });
1153
+ export var skipUpdateLeadMobile = createAsyncThunk('connect/skipUpdateLeadMobile', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
1154
+ var _a, settings, connectExpress, id, startWithNID, payload, leadResponse, needToCollectMoreInfo, creatingAccount, askDobInfo;
1155
+ var _b, _c, _d;
1156
+ return __generator(this, function (_e) {
1157
+ switch (_e.label) {
1158
+ case 0:
1159
+ _a = thunkApi.getState(), settings = _a.settings, connectExpress = _a.connectExpress;
1160
+ id = (((_b = connectExpress.data.responseData) === null || _b === void 0 ? void 0 : _b.leadData) || {}).id;
1161
+ startWithNID = connectExpress.data.otpData.authFor === AuthForType.NATIONAL_ID;
1162
+ payload = {
1163
+ id: id || '',
1164
+ step_name: CONNECT_EXPRESS_STEP_NAMES.COLLECT_MOBILE_OWNERSHIP_SKIPPED,
1165
+ encryption_contract: []
1166
+ };
1167
+ return [4, API.leadService.updateLeadExpress(payload)];
1168
+ case 1:
1169
+ leadResponse = _e.sent();
1170
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, {});
1171
+ needToCollectMoreInfo = leadResponse.step_name === 'collect_info';
1172
+ creatingAccount = leadResponse.step_name === 'create_account';
1173
+ askDobInfo = leadResponse.step_name === COLLECT_DOB_INFO_NAFATH;
1174
+ if (askDobInfo) {
1175
+ sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_COLLECT_DOB_INFO_STEP')); });
1176
+ }
1177
+ if (creatingAccount) {
1178
+ sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_WAITING_FOR_CREATING_ACCOUNT_STEP')); });
1179
+ }
1180
+ if (!needToCollectMoreInfo) return [3, 5];
1181
+ if (!startWithNID) return [3, 4];
1182
+ if (!isSA(settings.data.businessCountry.iso2)) return [3, 3];
1183
+ return [4, thunkApi.dispatch(retrieveEntityListAsync(leadResponse.lead.id)).unwrap()];
1184
+ case 2:
1185
+ _e.sent();
1186
+ _e.label = 3;
1187
+ case 3:
1188
+ sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_COLLECT_BUSINESS_INFO_STEP')); });
1189
+ return [3, 5];
1190
+ case 4:
1191
+ sleep(100).then(function () { return thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_COLLECT_INDIVIDUAL_INFO_STEP')); });
1192
+ _e.label = 5;
1193
+ case 5: return [2, { leadResponse: leadResponse }];
1194
+ }
1195
+ });
1196
+ }); });
1091
1197
  export var confirmInfo = createAsyncThunk('connectExpress/confirmInfo', function (_a, thunkApi) {
1092
1198
  var brandInfo = _a.brandInfo, entityInfo = _a.entityInfo, merchantInfo = _a.merchantInfo;
1093
1199
  return __awaiter(void 0, void 0, void 0, function () {
@@ -1639,6 +1745,33 @@ export var connectSlice = createSlice({
1639
1745
  .addCase(updateLeadBusinessDataAsync.rejected, function (state, action) {
1640
1746
  state.loading = false;
1641
1747
  state.error = action.error.message;
1748
+ })
1749
+ .addCase(updateLeadMobile.fulfilled, function (state, action) {
1750
+ state.loading = false;
1751
+ state.error = null;
1752
+ state.data.individualData.mobile = action.payload.formData.mobile;
1753
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { individualData: action.payload.leadResponse });
1754
+ })
1755
+ .addCase(updateLeadMobile.pending, function (state) {
1756
+ state.loading = true;
1757
+ state.error = null;
1758
+ })
1759
+ .addCase(updateLeadMobile.rejected, function (state, action) {
1760
+ state.loading = false;
1761
+ state.error = action.error.message;
1762
+ })
1763
+ .addCase(skipUpdateLeadMobile.fulfilled, function (state, action) {
1764
+ state.loading = false;
1765
+ state.error = null;
1766
+ state.data.responseData = __assign(__assign({}, state.data.responseData), { individualData: action.payload.leadResponse });
1767
+ })
1768
+ .addCase(skipUpdateLeadMobile.pending, function (state) {
1769
+ state.loading = true;
1770
+ state.error = null;
1771
+ })
1772
+ .addCase(skipUpdateLeadMobile.rejected, function (state, action) {
1773
+ state.loading = false;
1774
+ state.error = action.error.message;
1642
1775
  })
1643
1776
  .addCase(createAccountAsync.pending, function (state) {
1644
1777
  state.loading = true;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const CollectMobileOwnership: () => JSX.Element;
3
+ export default CollectMobileOwnership;
@@ -0,0 +1,104 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { FormProvider, useForm } from 'react-hook-form';
14
+ import { ScreenContainer } from '../../../../features/shared/Containers';
15
+ import { styled } from '@mui/material/styles';
16
+ import Form from '../../../../components/Form';
17
+ import { yupResolver } from '@hookform/resolvers/yup';
18
+ import { PhoneValidationSchema } from './validation';
19
+ import { Box, alpha } from '@mui/material';
20
+ import { useTranslation } from 'react-i18next';
21
+ import Text from '../../../../components/Text';
22
+ import { Button as SharedButton } from '../../../shared/Button';
23
+ import { useAppDispatch, useAppSelector, useLanguage } from '../../../../hooks';
24
+ import { handlePrevScreenStep } from '../../../../app/settings';
25
+ import { businessSelector, skipUpdateLeadMobile, updateLeadMobile } from '../../../../features/app/business/businessStore';
26
+ import Button from '../../../../components/Button';
27
+ import MobileNumber from './MobileNumber';
28
+ var FormStyled = styled(Form)(function () { return ({
29
+ display: 'flex',
30
+ flexDirection: 'column',
31
+ justifyContent: 'flex-start'
32
+ }); });
33
+ var TitleContainerStyled = styled(Box)(function (_a) {
34
+ var theme = _a.theme;
35
+ return ({
36
+ background: theme.palette.common.white,
37
+ borderTop: '1px solid rgba(227, 232, 238, 0.8)',
38
+ borderBottom: '1px solid rgba(227, 232, 238, 0.8)',
39
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25)
40
+ });
41
+ });
42
+ var TitleStyled = styled(Text)(function (_a) {
43
+ var theme = _a.theme;
44
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, margin: theme.spacing(1.75, 2.5), lineHeight: 1.2 }));
45
+ });
46
+ var InputLabelStyled = styled(Text)(function (_a) {
47
+ var theme = _a.theme;
48
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightRegular }, theme.typography.caption), { lineHeight: 1.2 }));
49
+ });
50
+ var CurrentMobileContainerStyled = styled(Box)(function (_a) {
51
+ var theme = _a.theme;
52
+ return ({
53
+ display: 'flex',
54
+ flexDirection: 'column',
55
+ rowGap: theme.spacing(1.6),
56
+ height: theme.spacing(9.375),
57
+ marginTop: theme.spacing(2.85),
58
+ marginInlineStart: theme.spacing(2.375)
59
+ });
60
+ });
61
+ var MobileNumberContainer = styled(Box)(function (_a) {
62
+ var theme = _a.theme;
63
+ return ({
64
+ display: 'flex',
65
+ columnGap: theme.spacing(0.9)
66
+ });
67
+ });
68
+ var CountryCodeStyled = styled(Text)(function (_a) {
69
+ var theme = _a.theme;
70
+ return (__assign(__assign({}, theme.typography.body2), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightMedium, lineHeight: 1.2 }));
71
+ });
72
+ var MobileNumberStyled = styled(Text)(function (_a) {
73
+ var theme = _a.theme;
74
+ return (__assign(__assign({}, theme.typography.body2), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightRegular, lineHeight: 1.2 }));
75
+ });
76
+ var UpdateLaterContainerStyled = styled(Box)(function (_a) {
77
+ var theme = _a.theme;
78
+ return ({
79
+ marginLeft: theme.spacing(2.5),
80
+ marginRight: theme.spacing(2.5)
81
+ });
82
+ });
83
+ var CollectMobileOwnership = function () {
84
+ var dispatch = useAppDispatch();
85
+ var t = useTranslation().t;
86
+ var isAr = useLanguage().isAr;
87
+ var _a = useAppSelector(businessSelector), data = _a.data, loading = _a.loading, error = _a.error;
88
+ var methods = useForm({
89
+ resolver: yupResolver(PhoneValidationSchema()),
90
+ defaultValues: { mobile: '', countryCode: data.mobileData.countryCode },
91
+ mode: 'onChange'
92
+ });
93
+ var onSubmit = function (data) {
94
+ dispatch(updateLeadMobile(data));
95
+ };
96
+ var onBack = function () {
97
+ dispatch(handlePrevScreenStep());
98
+ };
99
+ var onUpdateLater = function () {
100
+ dispatch(skipUpdateLeadMobile());
101
+ };
102
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(TitleContainerStyled, { children: _jsx(TitleStyled, { children: t('mobile_ownership_title') }) }), _jsxs(CurrentMobileContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('current_mobile_number') }), _jsxs(MobileNumberContainer, { children: [_jsxs(CountryCodeStyled, { children: ["+", data.mobileData.countryCode.idd_prefix] }), _jsx(MobileNumberStyled, { children: data.mobileData.mobile })] })] }), _jsx(MobileNumber, {}), _jsx(SharedButton, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: !methods.formState.isValid, loading: loading, error: t(error || '') }, { children: t('update_mobile_number') })), _jsx(UpdateLaterContainerStyled, { children: _jsx(Button, __assign({ variant: 'text', onClick: function () { return onUpdateLater(); } }, { children: t('update_later') })) })] })) })) }));
103
+ };
104
+ export default CollectMobileOwnership;
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ declare const _default: React.MemoExoticComponent<() => JSX.Element>;
3
+ export default _default;