@tap-payments/auth-jsconnect 2.0.3 → 2.0.4

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 (76) hide show
  1. package/build/@types/app.d.ts +5 -0
  2. package/build/@types/form.d.ts +2 -1
  3. package/build/api/auth.d.ts +20 -3
  4. package/build/api/axios.js +8 -9
  5. package/build/api/data.d.ts +1 -0
  6. package/build/api/data.js +9 -2
  7. package/build/api/entity.d.ts +5 -1
  8. package/build/api/entity.js +11 -2
  9. package/build/api/index.d.ts +6 -4
  10. package/build/api/lead.d.ts +2 -1
  11. package/build/api/lead.js +14 -2
  12. package/build/components/AnimationFlow/AnimationFlow.d.ts +2 -1
  13. package/build/components/AnimationFlow/AnimationFlow.js +2 -2
  14. package/build/components/AnimationFlow/BottomSheet.d.ts +2 -1
  15. package/build/components/AnimationFlow/BottomSheet.js +16 -4
  16. package/build/constants/api.d.ts +2 -1
  17. package/build/constants/api.js +5 -3
  18. package/build/constants/app.d.ts +5 -0
  19. package/build/constants/app.js +21 -5
  20. package/build/features/app/bank/bankStore.js +17 -10
  21. package/build/features/app/business/businessStore.d.ts +3 -5
  22. package/build/features/app/business/businessStore.js +140 -48
  23. package/build/features/app/connect/connectStore.d.ts +5 -10
  24. package/build/features/app/connect/connectStore.js +117 -25
  25. package/build/features/app/individual/individualStore.d.ts +3 -2
  26. package/build/features/app/individual/individualStore.js +42 -30
  27. package/build/features/app/password/passwordStore.d.ts +29 -1
  28. package/build/features/app/password/passwordStore.js +194 -14
  29. package/build/features/app/tax/taxStore.js +19 -12
  30. package/build/features/bank/Bank.js +3 -4
  31. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +16 -4
  32. package/build/features/business/Business.js +3 -4
  33. package/build/features/business/screens/Activities/Activities.js +1 -1
  34. package/build/features/business/screens/IDBOD/IDBOD.js +1 -1
  35. package/build/features/business/screens/OTP/OTPInput.js +3 -9
  36. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +17 -6
  37. package/build/features/connect/Connect.js +1 -1
  38. package/build/features/connect/screens/Mobile/Mobile.js +2 -2
  39. package/build/features/connect/screens/Mobile/MobileNumber.js +1 -1
  40. package/build/features/connect/screens/NID/IDNumber.js +1 -1
  41. package/build/features/connect/screens/NID/NID.js +2 -2
  42. package/build/features/connect/screens/OTP/OTPInput.js +3 -13
  43. package/build/features/featuresScreens.js +5 -0
  44. package/build/features/individual/Individual.js +3 -4
  45. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +7 -1
  46. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.d.ts +10 -0
  47. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +89 -0
  48. package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +3 -0
  49. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +1 -0
  50. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +16 -4
  51. package/build/features/password/Password.js +11 -6
  52. package/build/features/password/screens/CreatePassword/CreatePassword.js +9 -2
  53. package/build/features/password/screens/OTP/OTP.d.ts +8 -0
  54. package/build/features/password/screens/OTP/OTP.js +78 -0
  55. package/build/features/password/screens/OTP/OTPInput.d.ts +5 -0
  56. package/build/features/password/screens/OTP/OTPInput.js +46 -0
  57. package/build/features/password/screens/OTP/index.d.ts +3 -0
  58. package/build/features/password/screens/OTP/index.js +2 -0
  59. package/build/features/password/screens/OTP/validation.d.ts +8 -0
  60. package/build/features/password/screens/OTP/validation.js +4 -0
  61. package/build/features/password/screens/Success/Success.js +8 -2
  62. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +17 -5
  63. package/build/features/password/screens/Verify/OTPInput.d.ts +2 -2
  64. package/build/features/password/screens/Verify/OTPInput.js +1 -1
  65. package/build/features/shared/Button/FlowsButtons.d.ts +8 -2
  66. package/build/features/shared/Button/FlowsButtons.js +92 -5
  67. package/build/features/shared/Button/SuccessButton.js +17 -13
  68. package/build/features/tax/Tax.js +3 -4
  69. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +16 -4
  70. package/build/hooks/useAppTheme.js +3 -2
  71. package/build/index.css +4 -0
  72. package/build/theme/theme.d.ts +1 -1
  73. package/build/theme/theme.js +1 -2
  74. package/build/utils/string.d.ts +1 -0
  75. package/build/utils/string.js +4 -0
  76. package/package.json +127 -127
@@ -50,9 +50,9 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import API from '../../../api';
51
51
  import { FlowsTypes } from '../../../@types';
52
52
  import { hasKey } from '../../../utils';
53
- import { handleNextScreenStep } from '../../../app/settings';
53
+ import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
54
54
  import { INDIVIDUAl_STEP_NAMES } from '../../../constants';
55
- export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
55
+ export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
56
  var payload, data, leadResponse, _a, steps, entity, hasTaxCompleted;
57
57
  var _b, _c;
58
58
  return __generator(this, function (_d) {
@@ -66,26 +66,30 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
66
66
  case 1:
67
67
  data = (_d.sent()).data;
68
68
  leadResponse = undefined;
69
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 6];
69
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 7];
70
70
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
71
71
  case 2:
72
72
  leadResponse = _d.sent();
73
73
  _a = leadResponse.data, steps = _a.steps, entity = _a.entity;
74
74
  hasTaxCompleted = hasKey(steps, INDIVIDUAl_STEP_NAMES.INDIVIDUAl_SUCCESS);
75
- if (!hasTaxCompleted) return [3, 4];
76
- return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
75
+ if (!(data.step_name === INDIVIDUAl_STEP_NAMES.PHONE_AUTH)) return [3, 3];
76
+ thunkApi.dispatch(handleCurrentActiveScreen('INDIVIDUAL_VERIFY_STEP'));
77
+ return [3, 7];
77
78
  case 3:
79
+ if (!hasTaxCompleted) return [3, 5];
80
+ return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
81
+ case 4:
78
82
  _d.sent();
79
83
  thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
80
- return [3, 6];
81
- case 4:
82
- if (!(data.step_name === INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO)) return [3, 6];
83
- return [4, thunkApi.dispatch(retrieveDataList((_c = (_b = leadResponse.data) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.country))];
84
+ return [3, 7];
84
85
  case 5:
86
+ if (!(data.step_name === INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO)) return [3, 7];
87
+ return [4, thunkApi.dispatch(retrieveDataList((_c = (_b = leadResponse.data) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.country))];
88
+ case 6:
85
89
  _d.sent();
86
90
  thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_ADDITIONAL_INDIVIDUAL_INFO_STEP'));
87
- _d.label = 6;
88
- case 6: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
91
+ _d.label = 7;
92
+ case 7: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
89
93
  }
90
94
  });
91
95
  }); });
@@ -106,23 +110,24 @@ export var resendOTP = createAsyncThunk('resendOTPIndividual', function (params,
106
110
  }
107
111
  });
108
112
  }); });
109
- export var retrieveDataList = createAsyncThunk('retrieveDataList', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
110
- var settings, _a, sourceIncome, monthlyIncome, countries;
113
+ export var retrieveDataList = createAsyncThunk('individualRetrieveDataList', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
114
+ var _a, sourceIncome, monthlyIncome, occupation, settings, countries;
111
115
  return __generator(this, function (_b) {
112
116
  switch (_b.label) {
113
- case 0:
114
- settings = thunkApi.getState().settings;
115
- return [4, Promise.all([
116
- API.dataService.getSourceOfIncome(),
117
- API.dataService.getMonthlyIncome(countryCode)
118
- ])];
117
+ case 0: return [4, Promise.all([
118
+ API.dataService.getSourceOfIncome(),
119
+ API.dataService.getMonthlyIncome(countryCode),
120
+ API.dataService.getOccupation()
121
+ ])];
119
122
  case 1:
120
- _a = _b.sent(), sourceIncome = _a[0].data, monthlyIncome = _a[1].data;
123
+ _a = _b.sent(), sourceIncome = _a[0].data, monthlyIncome = _a[1].data, occupation = _a[2];
124
+ settings = thunkApi.getState().settings;
121
125
  countries = settings.data.countries;
122
126
  return [2, {
123
127
  sourceIncome: sourceIncome,
124
128
  monthlyIncome: monthlyIncome,
125
129
  countryCode: countryCode,
130
+ occupation: occupation,
126
131
  countries: countries
127
132
  }];
128
133
  }
@@ -157,7 +162,7 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
157
162
  return [4, API.leadService.verifyLeadOTP(payload)];
158
163
  case 1:
159
164
  data = (_g.sent()).data;
160
- if (!!data.errors) return [3, 5];
165
+ if (!!(data === null || data === void 0 ? void 0 : data.errors)) return [3, 5];
161
166
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
162
167
  steps = responseBody === null || responseBody === void 0 ? void 0 : responseBody.steps;
163
168
  hasIndividualCompleted = hasKey(steps, INDIVIDUAl_STEP_NAMES.INDIVIDUAl_SUCCESS);
@@ -184,20 +189,21 @@ export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', funct
184
189
  case 0:
185
190
  _a = thunkApi.getState(), settings = _a.settings, individual = _a.individual;
186
191
  requestBody = {
187
- id: (_c = (_b = individual.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.id,
192
+ id: (_b = individual.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.individual_id,
193
+ occupation: (_c = params.occupation) === null || _c === void 0 ? void 0 : _c.id,
188
194
  employer_name: params.employerName,
189
- employer_city: (_d = params.employerLocation) === null || _d === void 0 ? void 0 : _d.iso2,
195
+ employer_country: (_d = params.employerLocation) === null || _d === void 0 ? void 0 : _d.iso2,
190
196
  source_income: [(_e = params.sourceIncome) === null || _e === void 0 ? void 0 : _e.id],
191
197
  actual_income: (_f = params.monthlyIncome) === null || _f === void 0 ? void 0 : _f.id,
192
198
  is_relative_PEP: params.isPEP,
193
199
  is_influencer: params.isInfluencer,
194
- encryption_contract: ['employer_name', 'employer_city', 'actual_income'],
200
+ encryption_contract: ['employer_name', 'employer_city', 'actual_income', 'source_income[0]'],
195
201
  step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_INFO
196
202
  };
197
- return [4, API.entityService.updateEntityInfo(requestBody)];
203
+ return [4, API.entityService.updateIndividualInfo(requestBody)];
198
204
  case 1:
199
205
  data = (_j.sent()).data;
200
- if (!data.errors) {
206
+ if (!(data === null || data === void 0 ? void 0 : data.errors)) {
201
207
  thunkApi.dispatch(handleNextScreenStep());
202
208
  (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, requestBody);
203
209
  }
@@ -205,7 +211,7 @@ export var updateIndividualInfo = createAsyncThunk('updateIndividualInfo', funct
205
211
  }
206
212
  });
207
213
  }); });
208
- export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
214
+ export var updateLeadSuccess = createAsyncThunk('individualUpdateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
209
215
  var _a, settings, individual, id, payload, data;
210
216
  var _b, _c, _d, _e, _f;
211
217
  return __generator(this, function (_g) {
@@ -224,13 +230,15 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
224
230
  return [4, API.leadService.updateLead(payload)];
225
231
  case 1:
226
232
  data = (_g.sent()).data;
233
+ if (!!data.errors) return [3, 3];
227
234
  return [4, thunkApi.dispatch(retrieveEntityInfo((_b = data.entity) === null || _b === void 0 ? void 0 : _b.id))];
228
235
  case 2:
229
236
  _g.sent();
230
237
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
231
238
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
232
239
  thunkApi.dispatch(handleNextScreenStep());
233
- return [2, { response: data, formData: params }];
240
+ _g.label = 3;
241
+ case 3: return [2, { response: data, formData: params }];
234
242
  }
235
243
  });
236
244
  }); });
@@ -246,6 +254,7 @@ var initialState = {
246
254
  otp: ''
247
255
  },
248
256
  individualData: {
257
+ occupation: undefined,
249
258
  sourceIncome: undefined,
250
259
  monthlyIncome: undefined,
251
260
  employerName: '',
@@ -337,9 +346,9 @@ export var individualSlice = createSlice({
337
346
  .addCase(retrieveDataList.fulfilled, function (state, action) {
338
347
  state.loading = false;
339
348
  state.error = null;
340
- var _a = action.payload, sourceIncome = _a.sourceIncome, monthlyIncome = _a.monthlyIncome, countryCode = _a.countryCode, countries = _a.countries;
349
+ var _a = action.payload, sourceIncome = _a.sourceIncome, monthlyIncome = _a.monthlyIncome, countryCode = _a.countryCode, countries = _a.countries, occupation = _a.occupation;
341
350
  var data = state.data.individualData.responseBody;
342
- state.data.individualData.responseBody = __assign(__assign({}, data), { sourceIncomeList: sourceIncome || [], monthlyIncomeList: monthlyIncome || [] });
351
+ state.data.individualData.responseBody = __assign(__assign({}, data), { sourceIncomeList: sourceIncome || [], monthlyIncomeList: monthlyIncome || [], occupationList: occupation || [] });
343
352
  var selectedSourceIncome = sourceIncome === null || sourceIncome === void 0 ? void 0 : sourceIncome[0];
344
353
  if (!!selectedSourceIncome)
345
354
  state.data.individualData.sourceIncome = selectedSourceIncome;
@@ -350,6 +359,9 @@ export var individualSlice = createSlice({
350
359
  var employerLocation = countries.find(function (country) { return country.iso2 === countryCode; });
351
360
  state.data.individualData.employerLocation = employerLocation;
352
361
  }
362
+ var selectedOccupation = occupation === null || occupation === void 0 ? void 0 : occupation[0];
363
+ if (!!selectedOccupation)
364
+ state.data.individualData.occupation = selectedOccupation;
353
365
  })
354
366
  .addCase(retrieveDataList.rejected, function (state, action) {
355
367
  state.loading = false;
@@ -25,8 +25,32 @@ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
25
25
  response: any;
26
26
  formData: void;
27
27
  } | undefined, void, {}>;
28
+ export declare const verifyOperationToken: import("@reduxjs/toolkit").AsyncThunk<{
29
+ data: any;
30
+ token: string;
31
+ leadId: string;
32
+ }, {
33
+ token: string;
34
+ leadId: string;
35
+ }, {}>;
36
+ export declare const resendOperationOTP: import("@reduxjs/toolkit").AsyncThunk<{
37
+ data: any;
38
+ }, void, {}>;
39
+ export declare const resetPassword: import("@reduxjs/toolkit").AsyncThunk<{
40
+ data: any;
41
+ formData: {
42
+ password: string;
43
+ confirmPassword: string;
44
+ responseBody?: {
45
+ [key: string]: any;
46
+ } | undefined;
47
+ otp: string;
48
+ };
49
+ }, OTPFormValues, {}>;
50
+ export declare const retrieveLead: import("@reduxjs/toolkit").AsyncThunk<any, void, {}>;
28
51
  declare type VerifyData = {
29
52
  token: string;
53
+ operationType?: string;
30
54
  };
31
55
  export interface PasswordData {
32
56
  verify: ResponseData & VerifyData;
@@ -40,8 +64,12 @@ export declare const passwordSlice: import("@reduxjs/toolkit").Slice<PasswordSta
40
64
  clearError: (state: PasswordState) => void;
41
65
  stopLoader: (state: PasswordState) => void;
42
66
  resetOTPScreen: (state: PasswordState) => void;
67
+ storePasswordScreen: (state: PasswordState, action: {
68
+ payload: any;
69
+ type: string;
70
+ }) => void;
43
71
  }, "password/store">;
44
- export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
72
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, storePasswordScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
45
73
  declare const _default: import("redux").Reducer<PasswordState, import("redux").AnyAction>;
46
74
  export default _default;
47
75
  export declare const passwordSelector: (state: RootState) => PasswordState;
@@ -50,9 +50,9 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import API from '../../../api';
51
51
  import { FlowsTypes } from '../../../@types';
52
52
  import { hasKey } from '../../../utils';
53
- import { handleNextScreenStep } from '../../../app/settings';
54
- import { PASSWORD_STEP_NAMES } from '../../../constants';
55
- export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
53
+ import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
54
+ import { PASSWORD_OPERATION_TYPE, PASSWORD_STEP_NAMES } from '../../../constants';
55
+ export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
56
  var payload, data, leadResponse, _a, steps, entity, hasCompleted;
57
57
  return __generator(this, function (_b) {
58
58
  switch (_b.label) {
@@ -65,24 +65,28 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
65
65
  case 1:
66
66
  data = (_b.sent()).data;
67
67
  leadResponse = undefined;
68
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 5];
68
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 6];
69
69
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
70
70
  case 2:
71
71
  leadResponse = _b.sent();
72
72
  _a = leadResponse.data, steps = _a.steps, entity = _a.entity;
73
73
  hasCompleted = hasKey(steps, PASSWORD_STEP_NAMES.PASSWORD_SUCCESS);
74
- if (!hasCompleted) return [3, 4];
75
- return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
74
+ if (!(data.step_name === PASSWORD_STEP_NAMES.PHONE_AUTH)) return [3, 3];
75
+ thunkApi.dispatch(handleCurrentActiveScreen('PASSWORD_VERIFY_STEP'));
76
+ return [3, 6];
76
77
  case 3:
78
+ if (!hasCompleted) return [3, 5];
79
+ return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
80
+ case 4:
77
81
  _b.sent();
78
82
  thunkApi.dispatch(handleNextScreenStep('PASSWORD_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
79
- return [3, 5];
80
- case 4:
83
+ return [3, 6];
84
+ case 5:
81
85
  if (data.step_name === PASSWORD_STEP_NAMES.PASSWORD_INFO) {
82
86
  thunkApi.dispatch(handleNextScreenStep('PASSWORD_CREATE_PASSWORD_STEP'));
83
87
  }
84
- _b.label = 5;
85
- case 5: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
88
+ _b.label = 6;
89
+ case 6: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
86
90
  }
87
91
  });
88
92
  }); });
@@ -166,14 +170,14 @@ export var createPassword = createAsyncThunk('createPassword', function (params,
166
170
  case 1:
167
171
  data = (_f.sent()).data;
168
172
  if (!data.errors) {
169
- thunkApi.dispatch(handleNextScreenStep());
173
+ thunkApi.dispatch(handleNextScreenStep('PASSWORD_SUCCESS_STEP'));
170
174
  (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, requestBody);
171
175
  }
172
176
  return [2, { data: data, formData: params }];
173
177
  }
174
178
  });
175
179
  }); });
176
- export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
180
+ export var updateLeadSuccess = createAsyncThunk('passwordUpdateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
177
181
  var _a, settings, password, id, payload, data;
178
182
  var _b, _c, _d, _e, _f;
179
183
  return __generator(this, function (_g) {
@@ -192,13 +196,104 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
192
196
  return [4, API.leadService.updateLead(payload)];
193
197
  case 1:
194
198
  data = (_g.sent()).data;
199
+ if (!!data.errors) return [3, 3];
195
200
  return [4, thunkApi.dispatch(retrieveEntityInfo((_b = data.entity) === null || _b === void 0 ? void 0 : _b.id))];
196
201
  case 2:
197
202
  _g.sent();
198
203
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
199
204
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
200
205
  thunkApi.dispatch(handleNextScreenStep());
201
- return [2, { response: data, formData: params }];
206
+ _g.label = 3;
207
+ case 3: return [2, { response: data, formData: params }];
208
+ }
209
+ });
210
+ }); });
211
+ export var verifyOperationToken = createAsyncThunk('verifyOperationToken', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
212
+ var token, leadId, payload, data;
213
+ var _a, _b;
214
+ return __generator(this, function (_c) {
215
+ switch (_c.label) {
216
+ case 0:
217
+ token = params.token, leadId = params.leadId;
218
+ payload = {
219
+ auth_type: 7,
220
+ auth_token: token
221
+ };
222
+ return [4, API.authService.verifyAuth(payload)];
223
+ case 1:
224
+ data = (_c.sent()).data;
225
+ thunkApi.dispatch(handleNextScreenStep('PASSWORD_CREATE_PASSWORD_STEP'));
226
+ if ((data === null || data === void 0 ? void 0 : data.errors) || (data === null || data === void 0 ? void 0 : data.mw_error)) {
227
+ alert((_b = (_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.description);
228
+ }
229
+ return [2, { data: data, token: token, leadId: leadId }];
230
+ }
231
+ });
232
+ }); });
233
+ export var resendOperationOTP = createAsyncThunk('resendOperationOTPPassword', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
234
+ var password, payload, data;
235
+ return __generator(this, function (_a) {
236
+ switch (_a.label) {
237
+ case 0:
238
+ password = thunkApi.getState().password;
239
+ payload = {
240
+ auth_type: 7,
241
+ auth_token: password.data.verify.token
242
+ };
243
+ return [4, API.authService.verifyAuth(payload)];
244
+ case 1:
245
+ data = (_a.sent()).data;
246
+ return [2, { data: data }];
247
+ }
248
+ });
249
+ }); });
250
+ export var resetPassword = createAsyncThunk('resetPassword', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
251
+ var _a, password, settings, responseBody, passwordData, payload, data;
252
+ var _b, _c;
253
+ return __generator(this, function (_d) {
254
+ switch (_d.label) {
255
+ case 0:
256
+ _a = thunkApi.getState(), password = _a.password, settings = _a.settings;
257
+ responseBody = password.data.verify.responseBody;
258
+ passwordData = password.data.passwordData;
259
+ payload = {
260
+ auth_type: responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_type,
261
+ auth_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token,
262
+ step_name: PASSWORD_STEP_NAMES.RESET_PASSWORD,
263
+ user_credentail: {
264
+ otp: params.otp,
265
+ new_password: passwordData.password
266
+ },
267
+ encryption_contract: ['user_credentail.otp', 'user_credentail.new_password']
268
+ };
269
+ return [4, API.authService.verifyAuth(payload)];
270
+ case 1:
271
+ data = (_d.sent()).data;
272
+ if (!(data === null || data === void 0 ? void 0 : data.errors)) {
273
+ thunkApi.dispatch(handleNextScreenStep('PASSWORD_SUCCESS_STEP'));
274
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, payload);
275
+ }
276
+ return [2, { data: data, formData: __assign(__assign({}, params), passwordData) }];
277
+ }
278
+ });
279
+ }); });
280
+ export var retrieveLead = createAsyncThunk('retrieveLeadPassword', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
281
+ var _a, password, settings, id, data;
282
+ var _b, _c, _d, _e;
283
+ return __generator(this, function (_f) {
284
+ switch (_f.label) {
285
+ case 0:
286
+ _a = thunkApi.getState(), password = _a.password, settings = _a.settings;
287
+ id = (password.data.verify.responseBody || { id: '' }).id;
288
+ return [4, API.leadService.retrieveLead(id)];
289
+ case 1:
290
+ data = (_f.sent()).data;
291
+ if (!(data === null || data === void 0 ? void 0 : data.errors)) {
292
+ thunkApi.dispatch(handleNextScreenStep());
293
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, { id: id });
294
+ (_e = (_d = settings.data.appConfig).onFlowCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, { data: data });
295
+ }
296
+ return [2, data];
202
297
  }
203
298
  });
204
299
  }); });
@@ -231,12 +326,16 @@ export var passwordSlice = createSlice({
231
326
  },
232
327
  resetOTPScreen: function (state) {
233
328
  state.data.otpData.otp = '';
329
+ },
330
+ storePasswordScreen: function (state, action) {
331
+ state.data.passwordData = action.payload;
234
332
  }
235
333
  },
236
334
  extraReducers: function (builder) {
237
335
  builder
238
336
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
239
337
  var _a;
338
+ state.data.verify.operationType = PASSWORD_OPERATION_TYPE.SET_PASSWORD;
240
339
  state.error = null;
241
340
  state.customLoading = false;
242
341
  var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
@@ -355,9 +454,90 @@ export var passwordSlice = createSlice({
355
454
  .addCase(updateLeadSuccess.rejected, function (state, action) {
356
455
  state.loading = false;
357
456
  state.error = action.error.message;
457
+ })
458
+ .addCase(verifyOperationToken.fulfilled, function (state, action) {
459
+ var _a;
460
+ state.data.verify.operationType = PASSWORD_OPERATION_TYPE.RESET_PASSWORD;
461
+ state.error = null;
462
+ state.customLoading = false;
463
+ var _b = action.payload, data = _b.data, token = _b.token, leadId = _b.leadId;
464
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
465
+ if (description) {
466
+ state.error = description;
467
+ return;
468
+ }
469
+ state.data.verify.responseBody = __assign(__assign(__assign({}, data), state.data.verify.responseBody), { id: leadId });
470
+ state.data.verify.token = token;
471
+ })
472
+ .addCase(verifyOperationToken.pending, function (state) {
473
+ state.customLoading = true;
474
+ state.error = null;
475
+ })
476
+ .addCase(verifyOperationToken.rejected, function (state, action) {
477
+ state.error = action.error.message;
478
+ state.customLoading = false;
479
+ })
480
+ .addCase(resendOperationOTP.pending, function (state) {
481
+ state.error = null;
482
+ })
483
+ .addCase(resendOperationOTP.fulfilled, function (state, action) {
484
+ var _a;
485
+ state.error = null;
486
+ var data = action.payload.data;
487
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
488
+ if (description) {
489
+ state.error = description;
490
+ return;
491
+ }
492
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), data);
493
+ })
494
+ .addCase(resendOperationOTP.rejected, function (state, action) {
495
+ state.error = action.error.message;
496
+ })
497
+ .addCase(resetPassword.fulfilled, function (state, action) {
498
+ var _a;
499
+ state.data.verify.operationType = PASSWORD_OPERATION_TYPE.RESET_PASSWORD;
500
+ state.error = null;
501
+ state.loading = false;
502
+ var _b = action.payload, data = _b.data, formData = _b.formData;
503
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
504
+ if (description) {
505
+ state.error = description;
506
+ return;
507
+ }
508
+ state.data.passwordData = formData;
509
+ state.data.passwordData.responseBody = data;
510
+ })
511
+ .addCase(resetPassword.pending, function (state) {
512
+ state.loading = true;
513
+ state.error = null;
514
+ })
515
+ .addCase(resetPassword.rejected, function (state, action) {
516
+ state.error = action.error.message;
517
+ state.loading = false;
518
+ })
519
+ .addCase(retrieveLead.fulfilled, function (state, action) {
520
+ var _a;
521
+ state.loading = false;
522
+ state.error = null;
523
+ var data = action.payload;
524
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
525
+ if (description) {
526
+ state.error = description;
527
+ return;
528
+ }
529
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), data);
530
+ })
531
+ .addCase(retrieveLead.pending, function (state) {
532
+ state.loading = true;
533
+ state.error = null;
534
+ })
535
+ .addCase(retrieveLead.rejected, function (state, action) {
536
+ state.loading = false;
537
+ state.error = action.error.message;
358
538
  });
359
539
  }
360
540
  });
361
- export var clearError = (_a = passwordSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen;
541
+ export var clearError = (_a = passwordSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, storePasswordScreen = _a.storePasswordScreen;
362
542
  export default passwordSlice.reducer;
363
543
  export var passwordSelector = function (state) { return state.password; };
@@ -50,9 +50,9 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import API from '../../../api';
51
51
  import { FlowsTypes } from '../../../@types';
52
52
  import { hasKey } from '../../../utils';
53
- import { handleNextScreenStep } from '../../../app/settings';
53
+ import { handleNextScreenStep, handleCurrentActiveScreen } from '../../../app/settings';
54
54
  import { TAX_STEP_NAMES } from '../../../constants';
55
- export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
55
+ export var verifyLeadToken = createAsyncThunk('taxVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
56
  var payload, data, leadResponse, _a, steps, entity, hasTaxCompleted;
57
57
  return __generator(this, function (_b) {
58
58
  switch (_b.label) {
@@ -65,24 +65,28 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
65
65
  case 1:
66
66
  data = (_b.sent()).data;
67
67
  leadResponse = undefined;
68
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 5];
68
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 6];
69
69
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
70
70
  case 2:
71
71
  leadResponse = _b.sent();
72
72
  _a = leadResponse.data, steps = _a.steps, entity = _a.entity;
73
73
  hasTaxCompleted = hasKey(steps, TAX_STEP_NAMES.TAX_SUCCESS);
74
- if (!hasTaxCompleted) return [3, 4];
75
- return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
74
+ if (!(data.step_name === TAX_STEP_NAMES.PHONE_AUTH)) return [3, 3];
75
+ thunkApi.dispatch(handleCurrentActiveScreen('TAX_VERIFY_STEP'));
76
+ return [3, 6];
76
77
  case 3:
78
+ if (!hasTaxCompleted) return [3, 5];
79
+ return [4, thunkApi.dispatch(retrieveEntityInfo(entity === null || entity === void 0 ? void 0 : entity.id))];
80
+ case 4:
77
81
  _b.sent();
78
82
  thunkApi.dispatch(handleNextScreenStep('TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
79
- return [3, 5];
80
- case 4:
83
+ return [3, 6];
84
+ case 5:
81
85
  if (data.step_name === TAX_STEP_NAMES.TAX_INFO) {
82
86
  thunkApi.dispatch(handleNextScreenStep('TAX_TAX_DETAILS_STEP'));
83
87
  }
84
- _b.label = 5;
85
- case 5: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
88
+ _b.label = 6;
89
+ case 6: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
86
90
  }
87
91
  });
88
92
  }); });
@@ -159,7 +163,8 @@ export var updateTaxInfo = createAsyncThunk('updateTaxInfo', function (params, t
159
163
  requestBody = {
160
164
  id: (_c = (_b = tax.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.id,
161
165
  vat_id: params.vatId,
162
- step_name: TAX_STEP_NAMES.TAX_INFO
166
+ step_name: TAX_STEP_NAMES.TAX_INFO,
167
+ is_vat_acknowledged: params.confirmPolicy
163
168
  };
164
169
  return [4, API.entityService.updateEntityInfo(requestBody)];
165
170
  case 1:
@@ -172,7 +177,7 @@ export var updateTaxInfo = createAsyncThunk('updateTaxInfo', function (params, t
172
177
  }
173
178
  });
174
179
  }); });
175
- export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
180
+ export var updateLeadSuccess = createAsyncThunk('taxUpdateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
176
181
  var _a, settings, tax, id, payload, data;
177
182
  var _b, _c, _d, _e, _f;
178
183
  return __generator(this, function (_g) {
@@ -191,13 +196,15 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
191
196
  return [4, API.leadService.updateLead(payload)];
192
197
  case 1:
193
198
  data = (_g.sent()).data;
199
+ if (!!data.errors) return [3, 3];
194
200
  return [4, thunkApi.dispatch(retrieveEntityInfo((_b = data.entity) === null || _b === void 0 ? void 0 : _b.id))];
195
201
  case 2:
196
202
  _g.sent();
197
203
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
198
204
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
199
205
  thunkApi.dispatch(handleNextScreenStep());
200
- return [2, { response: data, formData: params }];
206
+ _g.label = 3;
207
+ case 3: return [2, { response: data, formData: params }];
201
208
  }
202
209
  });
203
210
  }); });
@@ -36,18 +36,17 @@ var Bank = memo(function (props) {
36
36
  var verifyToken = function () {
37
37
  var token = getParameterByName('token');
38
38
  var lang = getParameterByName('lang');
39
+ if (lang)
40
+ dispatch(handleLanguage(lang));
39
41
  if (!token)
40
42
  throw new Error('Auth token is not found!');
41
- if (!lang)
42
- throw new Error('Language is not found!');
43
- dispatch(handleLanguage(lang));
44
43
  dispatch(verifyLeadToken(token));
45
44
  };
46
45
  useEffect(function () {
47
46
  if (!settingLoading)
48
47
  verifyToken();
49
48
  }, [settingLoading]);
50
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: bankFeatureScreens.map(function (_a, index) {
49
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: bankFeatureScreens.map(function (_a, index) {
51
50
  var Element = _a.element, name = _a.name;
52
51
  var isActive = activeScreen.name === name;
53
52
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));