@tap-payments/auth-jsconnect 2.0.56-test → 2.0.58-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.
Files changed (37) hide show
  1. package/build/api/data.d.ts +16 -16
  2. package/build/api/index.d.ts +22 -7
  3. package/build/constants/app.d.ts +1 -0
  4. package/build/constants/app.js +4 -3
  5. package/build/constants/validation.d.ts +1 -1
  6. package/build/constants/validation.js +1 -1
  7. package/build/features/app/business/businessStore.d.ts +12 -1
  8. package/build/features/app/business/businessStore.js +109 -1
  9. package/build/features/app/connect/connectStore.d.ts +2 -1
  10. package/build/features/app/connect/connectStore.js +53 -28
  11. package/build/features/business/screens/CivilID/CivilID.d.ts +5 -0
  12. package/build/features/business/screens/CivilID/CivilID.js +85 -0
  13. package/build/features/business/screens/CivilID/IDNumber.d.ts +7 -0
  14. package/build/features/business/screens/CivilID/IDNumber.js +59 -0
  15. package/build/features/business/screens/CivilID/index.d.ts +3 -0
  16. package/build/features/business/screens/CivilID/index.js +2 -0
  17. package/build/features/business/screens/CivilID/validation.d.ts +8 -0
  18. package/build/features/business/screens/CivilID/validation.js +4 -0
  19. package/build/features/business/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
  20. package/build/features/business/screens/VerifyPACI/VerifyPACI.js +158 -0
  21. package/build/features/business/screens/VerifyPACI/VerifyPACILoading.d.ts +5 -0
  22. package/build/features/business/screens/VerifyPACI/VerifyPACILoading.js +22 -0
  23. package/build/features/business/screens/VerifyPACI/VerifyPACISuccess.d.ts +5 -0
  24. package/build/features/business/screens/VerifyPACI/VerifyPACISuccess.js +8 -0
  25. package/build/features/business/screens/VerifyPACI/index.d.ts +3 -0
  26. package/build/features/business/screens/VerifyPACI/index.js +2 -0
  27. package/build/features/connect/screens/CivilID/CivilID.js +2 -1
  28. package/build/features/connect/screens/CivilID/validation.js +1 -1
  29. package/build/features/connect/screens/Individual/Individual.js +3 -2
  30. package/build/features/connect/screens/Mobile/Mobile.js +3 -1
  31. package/build/features/connect/screens/NID/NID.js +2 -1
  32. package/build/features/connect/screens/VerifyPACI/VerifyPACI.js +17 -30
  33. package/build/utils/common.d.ts +1 -0
  34. package/build/utils/common.js +3 -0
  35. package/build/utils/index.d.ts +1 -0
  36. package/build/utils/index.js +1 -0
  37. package/package.json +129 -129
@@ -1,29 +1,29 @@
1
- export interface GetOccupationBody {
1
+ declare type GetOccupationBody = {
2
2
  page: number;
3
- }
4
- export interface GetMonthlyIncomeBody {
3
+ };
4
+ declare type GetMonthlyIncomeBody = {
5
5
  page: number;
6
6
  country_code: Array<string>;
7
- }
8
- export interface DataElementBody {
7
+ };
8
+ export declare type DataElementBody = {
9
9
  en: string;
10
10
  ar: string;
11
- }
12
- export interface GetCustomerBasesBody {
11
+ };
12
+ declare type GetCustomerBasesBody = {
13
13
  page: number;
14
- }
15
- export interface GetExpectedSalesBody {
14
+ };
15
+ declare type GetExpectedSalesBody = {
16
16
  page: number;
17
- }
18
- export interface GetExpectedCustomerSalesBody {
17
+ };
18
+ declare type GetExpectedCustomerSalesBody = {
19
19
  page: number;
20
- }
21
- export interface GetSourceOfIncomeBody {
20
+ };
21
+ declare type GetSourceOfIncomeBody = {
22
22
  page: number;
23
- }
24
- export interface GetChannelsOfServicesBody {
23
+ };
24
+ declare type GetChannelsOfServicesBody = {
25
25
  page: number;
26
- }
26
+ };
27
27
  declare const dataService: {
28
28
  getChannelsOfServices: (data: GetChannelsOfServicesBody) => Promise<any>;
29
29
  getCustomerBases: (data: GetCustomerBasesBody) => Promise<any>;
@@ -54,13 +54,28 @@ declare const API: {
54
54
  createAccount: (data: CreateAccountBody) => Promise<any>;
55
55
  };
56
56
  dataService: {
57
- getChannelsOfServices: (data: import("./data").GetChannelsOfServicesBody) => Promise<any>;
58
- getCustomerBases: (data: import("./data").GetCustomerBasesBody) => Promise<any>;
59
- getExpectedSales: (data: import("./data").GetExpectedSalesBody) => Promise<any>;
60
- getExpectedCustomerSales: (data: import("./data").GetExpectedCustomerSalesBody) => Promise<any>;
61
- getSourceOfIncome: (data: import("./data").GetSourceOfIncomeBody) => Promise<any>;
62
- getMonthlyIncome: (data: import("./data").GetMonthlyIncomeBody) => Promise<any>;
63
- getOccupation: (data: import("./data").GetOccupationBody) => Promise<any>;
57
+ getChannelsOfServices: (data: {
58
+ page: number;
59
+ }) => Promise<any>;
60
+ getCustomerBases: (data: {
61
+ page: number;
62
+ }) => Promise<any>;
63
+ getExpectedSales: (data: {
64
+ page: number;
65
+ }) => Promise<any>;
66
+ getExpectedCustomerSales: (data: {
67
+ page: number;
68
+ }) => Promise<any>;
69
+ getSourceOfIncome: (data: {
70
+ page: number;
71
+ }) => Promise<any>;
72
+ getMonthlyIncome: (data: {
73
+ page: number;
74
+ country_code: string[];
75
+ }) => Promise<any>;
76
+ getOccupation: (data: {
77
+ page: number;
78
+ }) => Promise<any>;
64
79
  };
65
80
  individualService: {
66
81
  retrieveIndividualInfo: (id: string) => Promise<any>;
@@ -98,6 +98,7 @@ export declare const BUSINESS_STEP_NAMES: {
98
98
  BUSINESS_INFO: string;
99
99
  PHONE_AUTH: string;
100
100
  IDENTITY_AUTH: string;
101
+ CREATE_AUTH_CIVIL_ID: string;
101
102
  IDENTITY_VERIFY_AUTH: string;
102
103
  BUSINESS_CR_INFO: string;
103
104
  BUSINESS_INFO_CONFIRM: string;
@@ -30,7 +30,7 @@ export var CONNECT_SCREENS_NAVIGATION = [
30
30
  {
31
31
  name: 'CONNECT_MOBILE_STEP',
32
32
  next: 'CONNECT_OTP_STEP',
33
- prev: ['CONNECT_NID_STEP', 'CONNECT_ID_STEP', 'CONNECT_CIVIL_ID_STEP'],
33
+ prev: ['CONNECT_NID_STEP', 'CONNECT_CIVIL_ID_STEP'],
34
34
  order: 1
35
35
  },
36
36
  {
@@ -48,13 +48,13 @@ export var CONNECT_SCREENS_NAVIGATION = [
48
48
  {
49
49
  name: 'CONNECT_INDIVIDUAL_STEP',
50
50
  next: 'CONNECT_MERCHANT_INFO_STEP',
51
- prev: ['CONNECT_MOBILE_STEP', 'CONNECT_NID_STEP', 'CONNECT_ID_STEP'],
51
+ prev: ['CONNECT_MOBILE_STEP', 'CONNECT_NID_STEP', 'CONNECT_CIVIL_ID_STEP'],
52
52
  order: 3
53
53
  },
54
54
  {
55
55
  name: 'CONNECT_MERCHANT_INFO_STEP',
56
56
  next: 'CONNECT_THANK_YOU_STEP',
57
- prev: ['CONNECT_INDIVIDUAL_STEP', 'CONNECT_NID_STEP', 'CONNECT_MOBILE_STEP', 'CONNECT_ID_STEP'],
57
+ prev: ['CONNECT_INDIVIDUAL_STEP', 'CONNECT_NID_STEP', 'CONNECT_MOBILE_STEP', 'CONNECT_CIVIL_ID_STEP'],
58
58
  order: 4
59
59
  },
60
60
  {
@@ -415,6 +415,7 @@ export var BUSINESS_STEP_NAMES = {
415
415
  BUSINESS_INFO: 'business_info',
416
416
  PHONE_AUTH: 'business_phone_auth',
417
417
  IDENTITY_AUTH: 'business_identity_auth',
418
+ CREATE_AUTH_CIVIL_ID: 'business_create_auth_civil_id',
418
419
  IDENTITY_VERIFY_AUTH: 'business_identity_auth_verify',
419
420
  BUSINESS_CR_INFO: 'business_cr_info',
420
421
  BUSINESS_INFO_CONFIRM: 'business_info_confirm',
@@ -1,5 +1,5 @@
1
1
  export declare const ID_NUMBER_LENGTH = 10;
2
- export declare const CIVIL_ID_NUMBER_LENGTH = 15;
2
+ export declare const CIVIL_ID_NUMBER_LENGTH = 12;
3
3
  export declare const DEFAULT_TIMER_VALUE = 59;
4
4
  export declare const VAT_ID_LENGTH = 15;
5
5
  export declare const MAX_IBAN_VALUE = 34;
@@ -1,5 +1,5 @@
1
1
  export var ID_NUMBER_LENGTH = 10;
2
- export var CIVIL_ID_NUMBER_LENGTH = 15;
2
+ export var CIVIL_ID_NUMBER_LENGTH = 12;
3
3
  export var DEFAULT_TIMER_VALUE = 59;
4
4
  export var VAT_ID_LENGTH = 15;
5
5
  export var MAX_IBAN_VALUE = 34;
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { ActivitiesFormValues, CustomersFormValues, BusinessTypeFormValues, NIDFormValues, OTPFormValues, ResponseData, SharedState, FlowsTypes, Activity, SalesChannel } from '../../../@types';
2
+ import { ActivitiesFormValues, CustomersFormValues, BusinessTypeFormValues, NIDFormValues, OTPFormValues, ResponseData, SharedState, FlowsTypes, Activity, SalesChannel, CivilFormValues } from '../../../@types';
3
3
  export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
4
4
  data: any;
5
5
  leadData: any;
@@ -18,6 +18,16 @@ export declare const verifyLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
18
18
  };
19
19
  brandInfo: any;
20
20
  }, OTPFormValues, {}>;
21
+ interface verifyPACIParams {
22
+ onSuccess?: () => void | Promise<void>;
23
+ }
24
+ export declare const verifyPACI: import("@reduxjs/toolkit").AsyncThunk<{
25
+ response: any;
26
+ }, verifyPACIParams, {}>;
27
+ export declare const createCivilIdAuth: import("@reduxjs/toolkit").AsyncThunk<{
28
+ response: any;
29
+ formData: CivilFormValues;
30
+ }, CivilFormValues, {}>;
21
31
  export declare const updateLeadIdentity: import("@reduxjs/toolkit").AsyncThunk<{
22
32
  data: any;
23
33
  formData: {
@@ -74,6 +84,7 @@ export interface BusinessData {
74
84
  nidData: NIDFormValues & ResponseData & {
75
85
  type: string;
76
86
  };
87
+ civilIdData: CivilFormValues & ResponseData;
77
88
  businessTypeData: BusinessTypeFormValues & ResponseData;
78
89
  activitiesData: ActivitiesFormValues & ResponseData;
79
90
  customersData: CustomersFormValues & ResponseData;
@@ -60,7 +60,7 @@ import moment from 'moment';
60
60
  import API from '../../../api';
61
61
  import { BusinessType, FlowsTypes } from '../../../@types';
62
62
  import { BUSINESS_FLOW_SUCCESS, BUSINESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
63
- import { convertNumbers2English, getEighteenYearsAgo, hasKey } from '../../../utils';
63
+ import { convertNumbers2English, getEighteenYearsAgo, hasKey, sleep } from '../../../utils';
64
64
  import { handleNextScreenStep } from '../../../app/settings';
65
65
  export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
66
  var payload, data, leadResponse, brandInfo, boardResponse, board_id, board_info_id, steps, brandID, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted;
@@ -249,6 +249,76 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
249
249
  }
250
250
  });
251
251
  }); });
252
+ export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
253
+ var _a, settings, connect, responseBody, expiry, interval, maxCalls, response, count, data, isSuccess;
254
+ var _b, _c;
255
+ return __generator(this, function (_d) {
256
+ switch (_d.label) {
257
+ case 0:
258
+ _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
259
+ responseBody = connect.data.civilIdData.responseBody;
260
+ expiry = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.expiry) || 120;
261
+ interval = 5;
262
+ maxCalls = Math.floor(expiry / interval);
263
+ response = null;
264
+ if (thunkApi.signal.aborted) {
265
+ return [2, { response: null }];
266
+ }
267
+ count = 1;
268
+ _d.label = 1;
269
+ case 1:
270
+ if (!(count <= maxCalls)) return [3, 7];
271
+ return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
272
+ case 2:
273
+ data = _d.sent();
274
+ response = data;
275
+ if (count === 1) {
276
+ }
277
+ isSuccess = ((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
278
+ if (!isSuccess) return [3, 4];
279
+ return [4, ((_c = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _c === void 0 ? void 0 : _c.call(params))];
280
+ case 3:
281
+ _d.sent();
282
+ _d.label = 4;
283
+ case 4: return [4, sleep(interval * 1000)];
284
+ case 5:
285
+ _d.sent();
286
+ _d.label = 6;
287
+ case 6:
288
+ count++;
289
+ return [3, 1];
290
+ case 7: return [2, { response: response }];
291
+ }
292
+ });
293
+ }); });
294
+ export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
295
+ var settings, requestBody, data;
296
+ var _a, _b;
297
+ return __generator(this, function (_c) {
298
+ switch (_c.label) {
299
+ case 0:
300
+ settings = thunkApi.getState().settings;
301
+ requestBody = {
302
+ lang: settings.data.language,
303
+ user_credentail: {
304
+ identification_id: params.civilId,
305
+ country_code: 'KW'
306
+ },
307
+ sign_in: false,
308
+ step_name: BUSINESS_STEP_NAMES.CREATE_AUTH_CIVIL_ID,
309
+ encryption_contract: ['user_credentail.identification_id']
310
+ };
311
+ return [4, API.authService.createAuth(requestBody)];
312
+ case 1:
313
+ data = (_c.sent()).data;
314
+ if (!data.errors) {
315
+ thunkApi.dispatch(handleNextScreenStep());
316
+ (_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
317
+ }
318
+ return [2, { response: data, formData: params }];
319
+ }
320
+ });
321
+ }); });
252
322
  export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
253
323
  var _a, settings, business, identification_id_type, stepName, requestBody, data;
254
324
  var _b, _c, _d;
@@ -550,6 +620,9 @@ var initialState = {
550
620
  otp: '',
551
621
  isNID: false
552
622
  },
623
+ civilIdData: {
624
+ civilId: ''
625
+ },
553
626
  nidData: {
554
627
  nid: '',
555
628
  dob: getEighteenYearsAgo(),
@@ -753,6 +826,41 @@ export var businessSlice = createSlice({
753
826
  .addCase(verifyLeadOTP.rejected, function (state, action) {
754
827
  state.loading = false;
755
828
  state.error = action.error.message;
829
+ })
830
+ .addCase(createCivilIdAuth.pending, function (state, action) {
831
+ state.loading = true;
832
+ state.error = null;
833
+ })
834
+ .addCase(createCivilIdAuth.fulfilled, function (state, action) {
835
+ var _a;
836
+ state.loading = false;
837
+ state.error = null;
838
+ var _b = action.payload, formData = _b.formData, response = _b.response;
839
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
840
+ if (description) {
841
+ state.error = description;
842
+ return;
843
+ }
844
+ })
845
+ .addCase(createCivilIdAuth.rejected, function (state, action) {
846
+ state.loading = false;
847
+ state.error = action.error.message;
848
+ })
849
+ .addCase(verifyPACI.pending, function (state) {
850
+ state.loading = true;
851
+ state.error = null;
852
+ })
853
+ .addCase(verifyPACI.fulfilled, function (state, action) {
854
+ state.loading = false;
855
+ state.error = null;
856
+ state.data.otpData.responseBody = action.payload.response;
857
+ })
858
+ .addCase(verifyPACI.rejected, function (state, action) {
859
+ state.loading = false;
860
+ var error = action.error.message;
861
+ if (error !== 'Aborted') {
862
+ state.error = error;
863
+ }
756
864
  })
757
865
  .addCase(updateLeadIdentity.pending, function (state) {
758
866
  state.loading = true;
@@ -102,11 +102,12 @@ export declare const connectSlice: import("@reduxjs/toolkit").Slice<ConnectState
102
102
  stopLoader: (state: ConnectState) => void;
103
103
  resetMobileScreen: (state: ConnectState) => void;
104
104
  resetNIDScreen: (state: ConnectState) => void;
105
+ resetCivilScreen: (state: ConnectState) => void;
105
106
  resetOTPScreen: (state: ConnectState) => void;
106
107
  resetIndividualScreen: (state: ConnectState) => void;
107
108
  resetMerchantScreen: (state: ConnectState) => void;
108
109
  }, "connect/store">;
109
- export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetIndividualScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMerchantScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
110
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetIndividualScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMerchantScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCivilScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
110
111
  declare const _default: import("redux").Reducer<ConnectState, import("redux").AnyAction>;
111
112
  export default _default;
112
113
  export declare const connectSelector: (state: RootState) => ConnectState;
@@ -61,7 +61,7 @@ import { FlowsTypes } from '../../../@types';
61
61
  import API from '../../../api';
62
62
  import { CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, OTHER_BRAND, TWITTER_URL } from '../../../constants';
63
63
  import { defaultCountry } from '../../../constants';
64
- import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo } from '../../../utils';
64
+ import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo, sleep } from '../../../utils';
65
65
  export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
66
  var settings, requestBody, data;
67
67
  var _a, _b;
@@ -105,7 +105,7 @@ export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (p
105
105
  },
106
106
  sign_in: false,
107
107
  step_name: CONNECT_STEP_NAMES.CREATE_AUTH_CIVIL_ID,
108
- encryption_contract: ['user_credentail.civil_id']
108
+ encryption_contract: ['user_credentail.identification_id']
109
109
  };
110
110
  return [4, API.authService.createAuth(requestBody)];
111
111
  case 1:
@@ -266,46 +266,63 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
266
266
  });
267
267
  }); });
268
268
  export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
269
- var _a, settings, connect, responseBody, data, params_3, params_4;
269
+ var _a, settings, connect, responseBody, expiry, interval, maxCalls, response, count, data, isSuccess, leadBody, leadBody;
270
270
  var _b, _c, _d, _e;
271
271
  return __generator(this, function (_f) {
272
272
  switch (_f.label) {
273
273
  case 0:
274
274
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
275
275
  responseBody = connect.data.civilIdData.responseBody;
276
- return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
276
+ expiry = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.expiry) || 120;
277
+ interval = 3;
278
+ maxCalls = Math.floor(expiry / interval);
279
+ response = null;
280
+ count = 1;
281
+ _f.label = 1;
277
282
  case 1:
283
+ if (!(count <= maxCalls)) return [3, 7];
284
+ if (thunkApi.signal.aborted) {
285
+ return [3, 7];
286
+ }
287
+ return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
288
+ case 2:
278
289
  data = _f.sent();
279
- if (!(((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success')) return [3, 6];
290
+ response = data;
291
+ if (count === 1) {
292
+ thunkApi.dispatch(retrieveBrandList(data === null || data === void 0 ? void 0 : data.individual_id));
293
+ thunkApi.dispatch(retrieveChannels());
294
+ }
295
+ isSuccess = ((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
296
+ if (!isSuccess) return [3, 4];
280
297
  return [4, ((_c = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _c === void 0 ? void 0 : _c.call(params))];
281
- case 2:
282
- _f.sent();
283
- (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, {});
284
- if (!(responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user)) return [3, 3];
285
- params_3 = {
286
- leadId: data === null || data === void 0 ? void 0 : data.lead_id,
287
- stepName: 'CONNECT_INDIVIDUAL_STEP'
288
- };
289
- thunkApi.dispatch(retrieveLead(params_3));
290
- return [3, 6];
291
- case 3: return [4, thunkApi.dispatch(retrieveBrandList(data === null || data === void 0 ? void 0 : data.individual_id))];
292
- case 4:
293
- _f.sent();
294
- return [4, thunkApi.dispatch(retrieveChannels())];
295
- case 5:
298
+ case 3:
296
299
  _f.sent();
297
- if (!(data === null || data === void 0 ? void 0 : data.lead_id)) {
298
- params_4 = {
300
+ if (responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) {
301
+ leadBody = {
302
+ leadId: data === null || data === void 0 ? void 0 : data.lead_id,
303
+ stepName: 'CONNECT_INDIVIDUAL_STEP'
304
+ };
305
+ thunkApi.dispatch(retrieveLead(leadBody));
306
+ }
307
+ else if (!(data === null || data === void 0 ? void 0 : data.lead_id)) {
308
+ leadBody = {
299
309
  individualId: data === null || data === void 0 ? void 0 : data.individual_id,
300
310
  stepName: 'CONNECT_MERCHANT_INFO_STEP'
301
311
  };
302
- thunkApi.dispatch(createLead(params_4));
312
+ thunkApi.dispatch(createLead(leadBody));
303
313
  }
304
- else {
314
+ else
305
315
  thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
306
- }
316
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, {});
317
+ return [3, 7];
318
+ case 4: return [4, sleep(interval * 1000)];
319
+ case 5:
320
+ _f.sent();
307
321
  _f.label = 6;
308
- case 6: return [2, { response: data }];
322
+ case 6:
323
+ count++;
324
+ return [3, 1];
325
+ case 7: return [2, { response: response }];
309
326
  }
310
327
  });
311
328
  }); });
@@ -591,8 +608,13 @@ export var connectSlice = createSlice({
591
608
  state.loading = false;
592
609
  },
593
610
  resetMobileScreen: function (state) {
611
+ state.data.mobileData = __assign(__assign({}, state.data.mobileData), initialState.data.mobileData);
594
612
  },
595
613
  resetNIDScreen: function (state) {
614
+ state.data.nidData = __assign(__assign({}, state.data.nidData), initialState.data.nidData);
615
+ },
616
+ resetCivilScreen: function (state) {
617
+ state.data.civilIdData = __assign(__assign({}, state.data.civilIdData), initialState.data.civilIdData);
596
618
  },
597
619
  resetOTPScreen: function (state) {
598
620
  state.data.otpData.otp = '';
@@ -676,7 +698,10 @@ export var connectSlice = createSlice({
676
698
  })
677
699
  .addCase(verifyPACI.rejected, function (state, action) {
678
700
  state.loading = false;
679
- state.error = action.error.message;
701
+ var error = action.error.message;
702
+ if (error !== 'Aborted') {
703
+ state.error = error;
704
+ }
680
705
  })
681
706
  .addCase(createNIDAuth.fulfilled, function (state, action) {
682
707
  var _a;
@@ -931,6 +956,6 @@ export var connectSlice = createSlice({
931
956
  });
932
957
  }
933
958
  });
934
- export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetMobileScreen = _a.resetMobileScreen, resetOTPScreen = _a.resetOTPScreen, resetIndividualScreen = _a.resetIndividualScreen, resetMerchantScreen = _a.resetMerchantScreen, resetNIDScreen = _a.resetNIDScreen;
959
+ export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetMobileScreen = _a.resetMobileScreen, resetOTPScreen = _a.resetOTPScreen, resetIndividualScreen = _a.resetIndividualScreen, resetMerchantScreen = _a.resetMerchantScreen, resetNIDScreen = _a.resetNIDScreen, resetCivilScreen = _a.resetCivilScreen;
935
960
  export default connectSlice.reducer;
936
961
  export var connectSelector = function (state) { return state.connect; };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface CivilIDProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: CivilIDProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,85 @@
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 * as React from 'react';
14
+ import { useTranslation } from 'react-i18next';
15
+ import { alpha, styled } from '@mui/material/styles';
16
+ import { useForm, FormProvider } from 'react-hook-form';
17
+ import { yupResolver } from '@hookform/resolvers/yup';
18
+ import { civilIDValidationSchema } from './validation';
19
+ import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
20
+ import { settingsSelector, handlePrevScreenStep } from '../../../../app/settings';
21
+ import { clearError, businessSelector, createCivilIdAuth } from '../../../app/business/businessStore';
22
+ import Form from '../../../../components/Form';
23
+ import Button, { MobileButton } from '../../../shared/Button';
24
+ import { ScreenContainer } from '../../../shared/Containers';
25
+ import Collapse from '../../../../components/Collapse';
26
+ import Box from '@mui/material/Box';
27
+ import Divider from '@mui/material/Divider';
28
+ import Text from '../../../../components/Text';
29
+ import IDNumber from './IDNumber';
30
+ var FormStyled = styled(Form)(function () { return ({
31
+ display: 'flex',
32
+ flexDirection: 'column'
33
+ }); });
34
+ var TextStyled = styled(Text)(function (_a) {
35
+ var theme = _a.theme;
36
+ return ({
37
+ color: alpha(theme.palette.primary.dark, 0.4)
38
+ });
39
+ });
40
+ var DividerStyled = styled(Divider)(function (_a) {
41
+ var theme = _a.theme;
42
+ return ({
43
+ width: '45%',
44
+ borderColor: alpha(theme.palette.primary.dark, 0.4),
45
+ marginBlockEnd: theme.spacing(0.62)
46
+ });
47
+ });
48
+ var OrBoxStyled = styled(Box)(function (_a) {
49
+ var theme = _a.theme;
50
+ return ({
51
+ display: 'flex',
52
+ justifyContent: 'space-between',
53
+ marginBlockEnd: theme.spacing(1.62),
54
+ marginBlockStart: theme.spacing(-1.25),
55
+ marginInline: theme.spacing(2.5)
56
+ });
57
+ });
58
+ var CivilID = function (_a) {
59
+ var isAr = useLanguage().isAr;
60
+ var dispatch = useAppDispatch();
61
+ var t = useTranslation().t;
62
+ var _b = useAppSelector(businessSelector), data = _b.data, loading = _b.loading, error = _b.error;
63
+ var settingsStore = useAppSelector(settingsSelector);
64
+ var methods = useForm({
65
+ resolver: yupResolver(civilIDValidationSchema),
66
+ defaultValues: {},
67
+ mode: 'onChange'
68
+ });
69
+ React.useEffect(function () {
70
+ handleClearError();
71
+ }, [methods.formState.isValid]);
72
+ var onSubmit = function (data) {
73
+ dispatch(createCivilIdAuth(data));
74
+ };
75
+ var handleClearError = function () {
76
+ if (error)
77
+ dispatch(clearError());
78
+ };
79
+ var onBack = function () {
80
+ dispatch(handlePrevScreenStep('CONNECT_MOBILE_STEP'));
81
+ };
82
+ var disabled = !methods.formState.isValid || !!error;
83
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, { sx: { mb: methods.formState.isValid ? 7.5 : 0, transition: 'mb 0.3s' } }), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(Collapse, __assign({ in: !methods.formState.isValid }, { children: [_jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(MobileButton, __assign({ onClick: function () { return onBack(); }, disabled: loading || settingsStore.loading }, { children: t('mobile_button_label') }))] }))] })) })) }));
84
+ };
85
+ export default React.memo(CivilID);
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { SxProps, Theme } from '@mui/material/styles';
3
+ interface IDNumberProps {
4
+ sx: SxProps<Theme> | undefined;
5
+ }
6
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<IDNumberProps & React.RefAttributes<unknown>>>;
7
+ export default _default;
@@ -0,0 +1,59 @@
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 * as React from 'react';
14
+ import Box from '@mui/material/Box';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useController, useFormContext } from 'react-hook-form';
17
+ import { styled, alpha } from '@mui/material/styles';
18
+ import Text from '../../../../components/Text';
19
+ import Input from '../../../shared/Input';
20
+ import ClearIcon from '../../../shared/ClearIcon';
21
+ import CheckIcon from '../../../shared/CheckIcon';
22
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
23
+ import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
24
+ import { CIVIL_ID_NUMBER_LENGTH } from '../../../../constants';
25
+ var LabelContainerStyled = styled(Box)(function (_a) {
26
+ var theme = _a.theme;
27
+ return ({
28
+ display: 'flex',
29
+ justifyContent: 'space-between',
30
+ padding: theme.spacing(0, 2.5, 1.25, 2.5)
31
+ });
32
+ });
33
+ var InputLabelStyled = styled(Text)(function (_a) {
34
+ var theme = _a.theme;
35
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
36
+ });
37
+ var IDNumber = React.forwardRef(function (_a, ref) {
38
+ var _b;
39
+ var sx = _a.sx;
40
+ var t = useTranslation().t;
41
+ var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
42
+ var civilIdControl = useController({ control: control, name: 'civilId' });
43
+ React.useEffect(function () {
44
+ if (civilIdControl.field.value)
45
+ setValue('civilId', civilIdControl.field.value, { shouldValidate: true });
46
+ }, []);
47
+ var handleIdChange = function (_a) {
48
+ var target = _a.target;
49
+ var value = removeAllOtherThanCharsAndNumber(target.value);
50
+ civilIdControl.field.onChange(value);
51
+ };
52
+ var clearIdNumber = function () {
53
+ civilIdControl.field.onChange('');
54
+ };
55
+ var idValue = civilIdControl.field.value;
56
+ var error = (_b = civilIdControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
57
+ return (_jsxs(ScreenContainer, __assign({ ref: ref, sx: sx }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_civil_id') }) }), _jsx(Input, { dir: 'ltr', type: 'text', inputProps: { maxLength: CIVIL_ID_NUMBER_LENGTH }, onChange: handleIdChange, value: idValue, endAdornment: !error && idValue ? _jsx(CheckIcon, {}) : idValue && _jsx(ClearIcon, { onClick: clearIdNumber }), placeholder: t('civil_id_placeholder'), warningType: 'alert', warningMessage: error && t(error), required: true })] })));
58
+ });
59
+ export default React.memo(IDNumber);
@@ -0,0 +1,3 @@
1
+ import CivilID, { CivilIDProps } from './CivilID';
2
+ export type { CivilIDProps };
3
+ export default CivilID;
@@ -0,0 +1,2 @@
1
+ import CivilID from './CivilID';
2
+ export default CivilID;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const civilIDValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var civilIDValidationSchema = yup.object().shape({
3
+ civilId: yup.string().matches(/^\d+$/, 'invalid_civil_id').min(12, 'invalid_civil_id').required('invalid_civil_id')
4
+ });