@tap-payments/auth-jsconnect 1.0.51 → 1.0.54

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 (105) hide show
  1. package/build/@types/app.d.ts +3 -3
  2. package/build/@types/form.d.ts +23 -3
  3. package/build/api/data.d.ts +1 -1
  4. package/build/api/data.js +2 -2
  5. package/build/api/entity.d.ts +5 -2
  6. package/build/api/index.d.ts +4 -4
  7. package/build/api/lead.d.ts +1 -1
  8. package/build/app/rootReducer.d.ts +4 -0
  9. package/build/app/rootReducer.js +9 -1
  10. package/build/app/store.d.ts +8 -0
  11. package/build/assets/locales/ar.json +2 -1
  12. package/build/assets/locales/en.json +3 -2
  13. package/build/components/AnimationFlow/AnimationFlow.d.ts +3 -1
  14. package/build/components/AnimationFlow/AnimationFlow.js +9 -1
  15. package/build/components/AnimationFlow/Error.d.ts +6 -0
  16. package/build/components/AnimationFlow/Error.js +32 -0
  17. package/build/components/AnimationFlow/Loader.d.ts +2 -0
  18. package/build/components/AnimationFlow/Loader.js +16 -0
  19. package/build/components/Loader/Loader.d.ts +1 -0
  20. package/build/components/Loader/Loader.js +1 -1
  21. package/build/components/SimpleList/SimpleList.js +1 -0
  22. package/build/constants/app.d.ts +24 -0
  23. package/build/constants/app.js +61 -19
  24. package/build/constants/dummy.d.ts +2 -0
  25. package/build/constants/dummy.js +12 -6
  26. package/build/features/app/bank/bankStore.d.ts +36 -0
  27. package/build/features/app/bank/bankStore.js +218 -0
  28. package/build/features/app/business/businessStore.d.ts +2 -3
  29. package/build/features/app/business/businessStore.js +79 -85
  30. package/build/features/app/connect/connectStore.js +31 -30
  31. package/build/features/app/individual/individualStore.d.ts +36 -0
  32. package/build/features/app/individual/individualStore.js +222 -0
  33. package/build/features/app/password/passwordStore.d.ts +36 -0
  34. package/build/features/app/password/passwordStore.js +218 -0
  35. package/build/features/app/tax/taxStore.d.ts +38 -0
  36. package/build/features/app/tax/taxStore.js +271 -0
  37. package/build/features/bank/Bank.d.ts +2 -1
  38. package/build/features/bank/Bank.js +17 -7
  39. package/build/features/bank/screens/BankDetails/BankDetails.js +1 -2
  40. package/build/features/bank/screens/Verify/OTPInput.d.ts +5 -0
  41. package/build/features/bank/screens/Verify/OTPInput.js +42 -0
  42. package/build/features/bank/screens/Verify/Verify.d.ts +5 -0
  43. package/build/features/bank/screens/Verify/Verify.js +78 -0
  44. package/build/features/bank/screens/Verify/index.d.ts +2 -0
  45. package/build/features/bank/screens/Verify/index.js +2 -0
  46. package/build/features/bank/screens/Verify/validation.d.ts +8 -0
  47. package/build/features/bank/screens/Verify/validation.js +4 -0
  48. package/build/features/business/Business.js +2 -2
  49. package/build/features/business/screens/Activities/Activities.js +8 -8
  50. package/build/features/business/screens/Activities/ActivitiesList.js +7 -7
  51. package/build/features/business/screens/Activities/SalesChannels.js +1 -1
  52. package/build/features/business/screens/BusinessType/CRNumber.d.ts +2 -1
  53. package/build/features/business/screens/BusinessType/CRNumber.js +2 -2
  54. package/build/features/business/screens/BusinessType/CompanyLicense.js +2 -1
  55. package/build/features/business/screens/BusinessType/FLNumber.d.ts +2 -1
  56. package/build/features/business/screens/BusinessType/FLNumber.js +2 -2
  57. package/build/features/business/screens/BusinessType/FreelanceLicense.js +2 -1
  58. package/build/features/business/screens/Confirm/Confirm.js +1 -1
  59. package/build/features/business/screens/Customers/Customers.js +3 -3
  60. package/build/features/business/screens/Customers/ExpectedCustomers.js +3 -3
  61. package/build/features/connect/Connect.js +2 -2
  62. package/build/features/connect/screens/Merchant/BrandList.d.ts +0 -2
  63. package/build/features/connect/screens/Merchant/BrandList.js +16 -40
  64. package/build/features/connect/screens/Merchant/Merchant.js +42 -23
  65. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +2 -1
  66. package/build/features/connect/screens/Merchant/SocialMedia.js +30 -3
  67. package/build/features/connect/screens/Merchant/validation.d.ts +6 -1
  68. package/build/features/connect/screens/Merchant/validation.js +67 -7
  69. package/build/features/connect/screens/Mobile/MobileNumber.js +1 -1
  70. package/build/features/featuresScreens.js +20 -10
  71. package/build/features/individual/Individual.d.ts +2 -1
  72. package/build/features/individual/Individual.js +17 -9
  73. package/build/features/individual/screens/Verify/OTPInput.d.ts +5 -0
  74. package/build/features/individual/screens/Verify/OTPInput.js +42 -0
  75. package/build/features/individual/screens/Verify/Verify.d.ts +5 -0
  76. package/build/features/individual/screens/Verify/Verify.js +78 -0
  77. package/build/features/individual/screens/Verify/index.d.ts +2 -0
  78. package/build/features/individual/screens/Verify/index.js +2 -0
  79. package/build/features/individual/screens/Verify/validation.d.ts +8 -0
  80. package/build/features/individual/screens/Verify/validation.js +4 -0
  81. package/build/features/password/Password.d.ts +2 -1
  82. package/build/features/password/Password.js +17 -9
  83. package/build/features/password/screens/Verify/OTPInput.d.ts +5 -0
  84. package/build/features/password/screens/Verify/OTPInput.js +42 -0
  85. package/build/features/password/screens/Verify/Verify.d.ts +5 -0
  86. package/build/features/password/screens/Verify/Verify.js +78 -0
  87. package/build/features/password/screens/Verify/index.d.ts +2 -0
  88. package/build/features/password/screens/Verify/index.js +2 -0
  89. package/build/features/password/screens/Verify/validation.d.ts +8 -0
  90. package/build/features/password/screens/Verify/validation.js +4 -0
  91. package/build/features/tax/Tax.d.ts +2 -1
  92. package/build/features/tax/Tax.js +17 -9
  93. package/build/features/tax/screens/Success/Success.js +6 -0
  94. package/build/features/tax/screens/TaxDetails/TaxDetails.js +6 -7
  95. package/build/features/tax/screens/Verify/OTPInput.d.ts +5 -0
  96. package/build/features/tax/screens/Verify/OTPInput.js +42 -0
  97. package/build/features/tax/screens/Verify/Verify.d.ts +5 -0
  98. package/build/features/tax/screens/Verify/Verify.js +78 -0
  99. package/build/features/tax/screens/Verify/index.d.ts +2 -0
  100. package/build/features/tax/screens/Verify/index.js +2 -0
  101. package/build/features/tax/screens/Verify/validation.d.ts +8 -0
  102. package/build/features/tax/screens/Verify/validation.js +4 -0
  103. package/build/hooks/useAppDispatch.d.ts +4 -0
  104. package/build/utils/string.js +0 -1
  105. package/package.json +1 -1
@@ -0,0 +1,218 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var _a;
49
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import API from '../../../api';
51
+ import { removeRequestHeaders } from '../../../utils';
52
+ import { handleNextScreenStep } from '../../../app/settings';
53
+ import { BANK_STEP_NAMES } from '../../../constants';
54
+ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
55
+ var payload, data, leadResponse;
56
+ return __generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0:
59
+ payload = {
60
+ service_name: 'tap_email',
61
+ verify_token: token
62
+ };
63
+ return [4, API.leadService.verifyLeadToken(payload)];
64
+ case 1:
65
+ data = (_a.sent()).data;
66
+ leadResponse = undefined;
67
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
68
+ return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
69
+ case 2:
70
+ leadResponse = _a.sent();
71
+ if (data.step_name === BANK_STEP_NAMES.IDENTITY_AUTH) {
72
+ thunkApi.dispatch(handleNextScreenStep());
73
+ }
74
+ _a.label = 3;
75
+ case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
76
+ }
77
+ });
78
+ }); });
79
+ export var verifyBankLeadOTP = createAsyncThunk('verifyBankLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
80
+ var _a, bank, settings, responseBody, payload, data;
81
+ var _b, _c, _d;
82
+ return __generator(this, function (_e) {
83
+ switch (_e.label) {
84
+ case 0:
85
+ _a = thunkApi.getState(), bank = _a.bank, settings = _a.settings;
86
+ responseBody = bank.data.verify.responseBody;
87
+ payload = {
88
+ data: params.otp,
89
+ service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
90
+ verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
91
+ step_name: BANK_STEP_NAMES.PHONE_AUTH,
92
+ encryption_contract: ['data']
93
+ };
94
+ return [4, API.leadService.verifyLeadOTP(payload)];
95
+ case 1:
96
+ data = (_e.sent()).data;
97
+ if (!data.errors) {
98
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
99
+ thunkApi.dispatch(handleNextScreenStep());
100
+ }
101
+ return [2, { data: data, formData: __assign({}, params) }];
102
+ }
103
+ });
104
+ }); });
105
+ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
106
+ var _a, settings, bank, payload, data;
107
+ var _b, _c, _d, _e, _f;
108
+ return __generator(this, function (_g) {
109
+ switch (_g.label) {
110
+ case 0:
111
+ _a = thunkApi.getState(), settings = _a.settings, bank = _a.bank;
112
+ payload = {
113
+ step_name: BANK_STEP_NAMES.BANK_SUCCESS,
114
+ id: ((_b = bank.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
115
+ encryption_contract: []
116
+ };
117
+ return [4, API.leadService.updateLead(payload)];
118
+ case 1:
119
+ data = (_g.sent()).data;
120
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
121
+ (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
122
+ return [2, { response: data, formData: params }];
123
+ }
124
+ });
125
+ }); });
126
+ var initialState = {
127
+ error: null,
128
+ loading: false,
129
+ data: {
130
+ verify: {
131
+ token: ''
132
+ },
133
+ otpData: {
134
+ otp: ''
135
+ },
136
+ bankData: {
137
+ iban: '',
138
+ beneficiaryName: '',
139
+ bankName: ''
140
+ }
141
+ }
142
+ };
143
+ export var bankSlice = createSlice({
144
+ name: 'bank/store',
145
+ initialState: initialState,
146
+ reducers: {
147
+ clearError: function (state) {
148
+ state.error = null;
149
+ },
150
+ stopLoader: function (state) {
151
+ state.loading = false;
152
+ },
153
+ resetOTPScreen: function (state) {
154
+ state.data.otpData.otp = '';
155
+ }
156
+ },
157
+ extraReducers: function (builder) {
158
+ builder
159
+ .addCase(verifyLeadToken.fulfilled, function (state, action) {
160
+ var _a;
161
+ state.error = null;
162
+ var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
163
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
164
+ if (description) {
165
+ state.error = description;
166
+ return;
167
+ }
168
+ state.data.verify.responseBody = __assign(__assign({}, data), leadData);
169
+ state.data.verify.token = token;
170
+ })
171
+ .addCase(verifyLeadToken.rejected, function (state, action) {
172
+ state.error = action.error.message;
173
+ })
174
+ .addCase(verifyBankLeadOTP.pending, function (state) {
175
+ state.loading = true;
176
+ state.error = null;
177
+ })
178
+ .addCase(verifyBankLeadOTP.fulfilled, function (state, action) {
179
+ var _a;
180
+ state.loading = false;
181
+ state.error = null;
182
+ var _b = action.payload, data = _b.data, formData = _b.formData;
183
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
184
+ if (description) {
185
+ state.error = description;
186
+ return;
187
+ }
188
+ state.data.otpData = formData;
189
+ })
190
+ .addCase(verifyBankLeadOTP.rejected, function (state, action) {
191
+ state.loading = false;
192
+ state.error = action.error.message;
193
+ })
194
+ .addCase(updateLeadSuccess.fulfilled, function (state, action) {
195
+ var _a;
196
+ state.loading = false;
197
+ state.error = null;
198
+ var response = action.payload.response;
199
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
200
+ if (description) {
201
+ state.error = description;
202
+ return;
203
+ }
204
+ removeRequestHeaders();
205
+ })
206
+ .addCase(updateLeadSuccess.pending, function (state) {
207
+ state.loading = true;
208
+ state.error = null;
209
+ })
210
+ .addCase(updateLeadSuccess.rejected, function (state, action) {
211
+ state.loading = false;
212
+ state.error = action.error.message;
213
+ });
214
+ }
215
+ });
216
+ export var clearError = (_a = bankSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen;
217
+ export default bankSlice.reducer;
218
+ export var bankSelector = function (state) { return state.bank; };
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { ActivitiesFormValues, BusinessInfoFormValues, CustomersFormValues, BusinessTypeFormValues, CountryCode, License, NIDFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
2
+ import { ActivitiesFormValues, CustomersFormValues, BusinessTypeFormValues, CountryCode, License, NIDFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
3
  export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
4
4
  businessCountry: any;
5
5
  countries: any;
@@ -55,7 +55,7 @@ export declare const updateCustomersInfo: import("@reduxjs/toolkit").AsyncThunk<
55
55
  data: any;
56
56
  formData: {
57
57
  customerLocations: import("../../../@types").CustomerLocation[];
58
- expectedCustomers: import("../../../@types").ExpectedCustomer | undefined;
58
+ expectedCustomer: import("../../../@types").ExpectedCustomer | undefined;
59
59
  expectedSalesRange: import("../../../@types").ExpectedSaleRange | undefined;
60
60
  refundPolicy: boolean;
61
61
  transactionPolicy: boolean;
@@ -81,7 +81,6 @@ export interface BusinessData {
81
81
  businessTypeData: BusinessTypeFormValues & ResponseData;
82
82
  crInfos: Array<License>;
83
83
  flInfos: Array<License>;
84
- businessInfo: BusinessInfoFormValues & ResponseData;
85
84
  activitiesData: ActivitiesFormValues & ResponseData;
86
85
  customersData: CustomersFormValues & ResponseData;
87
86
  }
@@ -51,7 +51,6 @@ import moment from 'moment';
51
51
  import API from '../../../api';
52
52
  import { BusinessType } from '../../../@types';
53
53
  import { BUSINESS_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE } from '../../../constants';
54
- import i18n from '../../../i18n';
55
54
  import { convertNumbers2English, removeRequestHeaders } from '../../../utils';
56
55
  import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
57
56
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
@@ -71,9 +70,10 @@ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi
71
70
  });
72
71
  }); });
73
72
  export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
74
- var payload, data, leadResponse;
75
- return __generator(this, function (_a) {
76
- switch (_a.label) {
73
+ var payload, data, leadResponse, steps, hasBusinessCompleted;
74
+ var _a;
75
+ return __generator(this, function (_b) {
76
+ switch (_b.label) {
77
77
  case 0:
78
78
  payload = {
79
79
  service_name: 'tap_email',
@@ -81,19 +81,25 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
81
81
  };
82
82
  return [4, API.leadService.verifyLeadToken(payload)];
83
83
  case 1:
84
- data = (_a.sent()).data;
84
+ data = (_b.sent()).data;
85
85
  leadResponse = undefined;
86
86
  if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
87
87
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
88
88
  case 2:
89
- leadResponse = _a.sent();
89
+ leadResponse = _b.sent();
90
+ steps = (_a = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _a === void 0 ? void 0 : _a.steps;
91
+ hasBusinessCompleted = Object.keys(steps).find(function (key) { return key === BUSINESS_STEP_NAMES.BUSINESS_SUCCESS; });
92
+ if (hasBusinessCompleted) {
93
+ thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_SUCCESS_STEP'));
94
+ return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
95
+ }
90
96
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH) {
91
97
  thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_IDBOD_STEP'));
92
98
  }
93
99
  if (data.step_name === 'business_info') {
94
100
  thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_BUSINESS_TYPE_STEP'));
95
101
  }
96
- _a.label = 3;
102
+ _b.label = 3;
97
103
  case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
98
104
  }
99
105
  });
@@ -189,7 +195,7 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
189
195
  case 0:
190
196
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
191
197
  payload = {
192
- lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
198
+ id: ((_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
193
199
  license_number: params.businessType === BusinessType.FL ? params.flNumber : params.crNumber,
194
200
  license_type: params.businessType === BusinessType.FL ? 'freelance' : 'commercial_registration',
195
201
  business_type: params.businessType,
@@ -200,7 +206,7 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
200
206
  case 1:
201
207
  data = (_e.sent()).data;
202
208
  if (!data.errors) {
203
- thunkApi.dispatch(handleNextScreenStep());
209
+ thunkApi.dispatch(createAccount());
204
210
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
205
211
  }
206
212
  return [2, { data: data, formData: params }];
@@ -215,7 +221,7 @@ export var createAccount = createAsyncThunk('createAccount', function (params, t
215
221
  case 0:
216
222
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
217
223
  requestBody = {
218
- lead_id: (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id,
224
+ lead_id: (_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.id,
219
225
  notify: {
220
226
  email: false,
221
227
  phone: false
@@ -251,8 +257,8 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
251
257
  return value;
252
258
  });
253
259
  activities = (_b = (params.activities || [])) === null || _b === void 0 ? void 0 : _b.map(function (_a) {
254
- var id = _a.id;
255
- return id === null || id === void 0 ? void 0 : id.toString();
260
+ var en = _a.en;
261
+ return en;
256
262
  });
257
263
  requestBody = {
258
264
  activities: activities,
@@ -260,42 +266,42 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
260
266
  business_operation_start_at: params.operationStartDate,
261
267
  step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES
262
268
  };
263
- headers = { entity_id: (_c = business.data.businessInfo.responseBody) === null || _c === void 0 ? void 0 : _c.entity_id };
269
+ headers = { entity_id: (_c = business.data.businessTypeData.responseBody) === null || _c === void 0 ? void 0 : _c.entity_id };
264
270
  return [4, API.entityService.createEntityInfo(requestBody, { headers: headers })];
265
271
  case 1:
266
272
  data = (_f.sent()).data;
267
- if (!data.errors) {
268
- thunkApi.dispatch(retrieveDataList());
269
- thunkApi.dispatch(handleNextScreenStep());
270
- (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, requestBody);
271
- }
272
- return [2, { data: data, formData: __assign({}, params) }];
273
+ if (!!data.errors) return [3, 3];
274
+ return [4, thunkApi.dispatch(retrieveDataList())];
275
+ case 2:
276
+ _f.sent();
277
+ thunkApi.dispatch(handleNextScreenStep());
278
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, requestBody);
279
+ _f.label = 3;
280
+ case 3: return [2, { data: data, formData: __assign({}, params) }];
273
281
  }
274
282
  });
275
283
  }); });
276
284
  export var retrieveDataList = createAsyncThunk('retrieveDataList', function () { return __awaiter(void 0, void 0, void 0, function () {
277
- var customerBases, expectedSales, expectedCustomerSales;
278
- return __generator(this, function (_a) {
279
- switch (_a.label) {
280
- case 0: return [4, API.dataService.getCustomerBases()];
285
+ var _a, customerBases, expectedSales, expectedCustomerSales;
286
+ return __generator(this, function (_b) {
287
+ switch (_b.label) {
288
+ case 0: return [4, Promise.all([
289
+ API.dataService.getCustomerBases(),
290
+ API.dataService.getExpectedSales(),
291
+ API.dataService.getExpectedCustomerSales()
292
+ ])];
281
293
  case 1:
282
- customerBases = _a.sent();
283
- return [4, API.dataService.getExpectedSales()];
284
- case 2:
285
- expectedSales = _a.sent();
286
- return [4, API.dataService.getExpectedCutomerSales()];
287
- case 3:
288
- expectedCustomerSales = _a.sent();
294
+ _a = _b.sent(), customerBases = _a[0].data, expectedSales = _a[1].data, expectedCustomerSales = _a[2].data;
289
295
  return [2, {
290
- customerBases: customerBases === null || customerBases === void 0 ? void 0 : customerBases.data,
291
- expectedSales: expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.data,
292
- expectedCustomerSales: expectedCustomerSales === null || expectedCustomerSales === void 0 ? void 0 : expectedCustomerSales.data
296
+ customerBases: customerBases,
297
+ expectedSales: expectedSales,
298
+ expectedCustomerSales: expectedCustomerSales
293
299
  }];
294
300
  }
295
301
  });
296
302
  }); });
297
303
  export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
298
- var _a, settings, business, customerBase, requestBody, headers, data;
304
+ var _a, settings, business, customerBase, requestBody, data;
299
305
  var _b, _c, _d, _e, _f;
300
306
  return __generator(this, function (_g) {
301
307
  switch (_g.label) {
@@ -307,14 +313,14 @@ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', functio
307
313
  });
308
314
  requestBody = {
309
315
  customers_base: customerBase,
310
- customers_served_monthly: parseInt(((_b = params.expectedCustomers) === null || _b === void 0 ? void 0 : _b.id) || '0'),
311
- yearly_sales_range: ((_c = params.expectedSalesRange) === null || _c === void 0 ? void 0 : _c.title) || '',
316
+ id: (_b = business.data.businessTypeData.responseBody) === null || _b === void 0 ? void 0 : _b.entity_id,
317
+ customers_served_monthly: parseInt(((_c = params.expectedCustomer) === null || _c === void 0 ? void 0 : _c.id) || '0'),
318
+ yearly_sales_range: ((_d = params.expectedSalesRange) === null || _d === void 0 ? void 0 : _d.title) || '',
312
319
  agree_refund: params.refundPolicy,
313
320
  agree_chargeback: params.transactionPolicy,
314
321
  step_name: BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS
315
322
  };
316
- headers = { entity_id: (_d = business.data.activitiesData.responseBody) === null || _d === void 0 ? void 0 : _d.entity_id };
317
- return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
323
+ return [4, API.entityService.updateEntityInfo(requestBody)];
318
324
  case 1:
319
325
  data = (_g.sent()).data;
320
326
  if (!data.errors) {
@@ -326,23 +332,26 @@ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', functio
326
332
  });
327
333
  }); });
328
334
  export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
329
- var _a, settings, business, payload, data;
330
- var _b, _c, _d, _e, _f;
331
- return __generator(this, function (_g) {
332
- switch (_g.label) {
335
+ var _a, settings, business, response, payload;
336
+ var _b, _c, _d, _e, _f, _g;
337
+ return __generator(this, function (_h) {
338
+ switch (_h.label) {
333
339
  case 0:
334
340
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
341
+ response = undefined;
342
+ if (!!!((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id)) return [3, 2];
335
343
  payload = {
336
344
  step_name: BUSINESS_STEP_NAMES.BUSINESS_SUCCESS,
337
- lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
345
+ id: ((_c = business.data.otpData.responseBody) === null || _c === void 0 ? void 0 : _c.id) || '',
338
346
  encryption_contract: []
339
347
  };
340
348
  return [4, API.leadService.updateLead(payload)];
341
349
  case 1:
342
- data = (_g.sent()).data;
343
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
344
- (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
345
- return [2, { response: data, formData: params }];
350
+ response = _h.sent();
351
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, params);
352
+ (_g = (_f = settings.data.appConfig).onFlowCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, { data: response === null || response === void 0 ? void 0 : response.data });
353
+ _h.label = 2;
354
+ case 2: return [2, { response: response === null || response === void 0 ? void 0 : response.data, formData: params }];
346
355
  }
347
356
  });
348
357
  }); });
@@ -371,11 +380,6 @@ var initialState = {
371
380
  },
372
381
  crInfos: [],
373
382
  flInfos: [],
374
- businessInfo: {
375
- licenseNumber: '',
376
- brandName: '',
377
- legalName: ''
378
- },
379
383
  activitiesData: {
380
384
  activities: [],
381
385
  salesChannels: [],
@@ -383,7 +387,7 @@ var initialState = {
383
387
  },
384
388
  customersData: {
385
389
  customerLocations: [],
386
- expectedCustomers: undefined,
390
+ expectedCustomer: undefined,
387
391
  expectedSalesRange: undefined,
388
392
  refundPolicy: false,
389
393
  transactionPolicy: false
@@ -422,9 +426,9 @@ export var businessSlice = createSlice({
422
426
  state.error = null;
423
427
  })
424
428
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
425
- var _a;
429
+ var _a, _b, _c, _d, _e;
426
430
  state.error = null;
427
- var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
431
+ var _f = action.payload, data = _f.data, token = _f.token, leadData = _f.leadData;
428
432
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
429
433
  if (description) {
430
434
  state.error = description;
@@ -433,6 +437,13 @@ export var businessSlice = createSlice({
433
437
  state.data.verify.responseBody = __assign(__assign({}, data), leadData);
434
438
  state.data.verify.token = token;
435
439
  state.data.otpData.isNID = false;
440
+ if (!!((_c = (_b = leadData === null || leadData === void 0 ? void 0 : leadData.entity) === null || _b === void 0 ? void 0 : _b.license) === null || _c === void 0 ? void 0 : _c.issuing_date)) {
441
+ state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_e = (_d = leadData === null || leadData === void 0 ? void 0 : leadData.entity) === null || _d === void 0 ? void 0 : _d.license) === null || _e === void 0 ? void 0 : _e.issuing_date).format('YYYY-MM-DD'));
442
+ }
443
+ var activities = (leadData === null || leadData === void 0 ? void 0 : leadData.entity_activities) || [];
444
+ var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
445
+ if (!!selectedActivity)
446
+ state.data.activitiesData.activities = [selectedActivity];
436
447
  })
437
448
  .addCase(verifyLeadToken.rejected, function (state, action) {
438
449
  state.error = action.error.message;
@@ -511,35 +522,24 @@ export var businessSlice = createSlice({
511
522
  state.error = null;
512
523
  })
513
524
  .addCase(updateLeadBusinessType.fulfilled, function (state, action) {
514
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
515
- state.loading = false;
525
+ var _a, _b, _c, _d, _e;
526
+ state.loading = true;
516
527
  state.error = null;
517
- var _t = action.payload, data = _t.data, formData = _t.formData;
528
+ var _f = action.payload, data = _f.data, formData = _f.formData;
518
529
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
519
530
  if (description) {
520
531
  state.error = description;
521
532
  return;
522
533
  }
523
534
  state.data.businessTypeData = formData;
524
- var isAr = i18n.dir() === 'rtl';
525
- state.data.businessInfo.brandName = isAr ? (_c = (_b = data === null || data === void 0 ? void 0 : data.brand) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.ar : (_e = (_d = data === null || data === void 0 ? void 0 : data.brand) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.en;
526
- state.data.businessInfo.licenseNumber = (data === null || data === void 0 ? void 0 : data.license_number) || '';
527
- state.data.businessInfo.legalName = isAr ? (_g = (_f = data === null || data === void 0 ? void 0 : data.entity) === null || _f === void 0 ? void 0 : _f.legal_name) === null || _g === void 0 ? void 0 : _g.ar : (_j = (_h = data === null || data === void 0 ? void 0 : data.entity) === null || _h === void 0 ? void 0 : _h.legal_name) === null || _j === void 0 ? void 0 : _j.en;
528
- if (!!((_l = (_k = data === null || data === void 0 ? void 0 : data.entity) === null || _k === void 0 ? void 0 : _k.license) === null || _l === void 0 ? void 0 : _l.issuing_date)) {
529
- state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_o = (_m = data === null || data === void 0 ? void 0 : data.entity) === null || _m === void 0 ? void 0 : _m.license) === null || _o === void 0 ? void 0 : _o.issuing_date).format('YYYY-MM-DD'));
530
- }
531
- if (formData.businessType === BusinessType.CR) {
532
- var activities = ((_q = (_p = data === null || data === void 0 ? void 0 : data.license) === null || _p === void 0 ? void 0 : _p.activities) === null || _q === void 0 ? void 0 : _q.isic) || [];
533
- var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
534
- if (!!selectedActivity)
535
- state.data.activitiesData.activities = [selectedActivity];
536
- state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: activities });
537
- return;
535
+ if (!!((_c = (_b = data === null || data === void 0 ? void 0 : data.entity) === null || _b === void 0 ? void 0 : _b.license) === null || _c === void 0 ? void 0 : _c.issuing_date)) {
536
+ state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_e = (_d = data === null || data === void 0 ? void 0 : data.entity) === null || _d === void 0 ? void 0 : _d.license) === null || _e === void 0 ? void 0 : _e.issuing_date).format('YYYY-MM-DD'));
538
537
  }
539
- var category = (_s = (_r = data === null || data === void 0 ? void 0 : data.license) === null || _r === void 0 ? void 0 : _r.License) === null || _s === void 0 ? void 0 : _s.Category;
540
- if (!!category)
541
- state.data.activitiesData.activities = [category];
542
- state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: !!category ? [category] : [] });
538
+ var activities = (data === null || data === void 0 ? void 0 : data.entity_activities) || [];
539
+ var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
540
+ if (!!selectedActivity)
541
+ state.data.activitiesData.activities = [selectedActivity];
542
+ state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: activities });
543
543
  })
544
544
  .addCase(updateLeadBusinessType.rejected, function (state, action) {
545
545
  state.loading = false;
@@ -563,7 +563,7 @@ export var businessSlice = createSlice({
563
563
  state.error = 'signup_user_exists_error';
564
564
  return;
565
565
  }
566
- state.data.businessInfo.responseBody = __assign(__assign({}, data), { channelList: channelsData || [] });
566
+ state.data.businessTypeData.responseBody = __assign(__assign({}, data), { channelList: channelsData || [] });
567
567
  var selectedChannel = channelsData === null || channelsData === void 0 ? void 0 : channelsData[0];
568
568
  if (!!selectedChannel)
569
569
  state.data.activitiesData.salesChannels = [selectedChannel];
@@ -598,15 +598,9 @@ export var businessSlice = createSlice({
598
598
  state.error = null;
599
599
  })
600
600
  .addCase(retrieveDataList.fulfilled, function (state, action) {
601
- var _a, _b, _c;
602
601
  state.loading = false;
603
602
  state.error = null;
604
- var _d = action.payload, customerBases = _d.customerBases, expectedSales = _d.expectedSales, expectedCustomerSales = _d.expectedCustomerSales;
605
- var description = (((_a = customerBases === null || customerBases === void 0 ? void 0 : customerBases.errors) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.errors) === null || _b === void 0 ? void 0 : _b[0]) || ((_c = expectedCustomerSales === null || expectedCustomerSales === void 0 ? void 0 : expectedCustomerSales.errors) === null || _c === void 0 ? void 0 : _c[0]) || {}).description;
606
- if (description) {
607
- state.error = description;
608
- return;
609
- }
603
+ var _a = action.payload, customerBases = _a.customerBases, expectedSales = _a.expectedSales, expectedCustomerSales = _a.expectedCustomerSales;
610
604
  var data = state.data.activitiesData.responseBody;
611
605
  state.data.activitiesData.responseBody = __assign(__assign({}, data), { customerBases: customerBases || [], expectedSales: expectedSales || [], expectedCustomerSales: expectedCustomerSales || [] });
612
606
  var selectedCustomerBase = customerBases === null || customerBases === void 0 ? void 0 : customerBases[0];
@@ -617,7 +611,7 @@ export var businessSlice = createSlice({
617
611
  state.data.customersData.expectedSalesRange = selectedExpectedSale;
618
612
  var selectedExpectedCustomerSale = expectedCustomerSales === null || expectedCustomerSales === void 0 ? void 0 : expectedCustomerSales[(expectedCustomerSales === null || expectedCustomerSales === void 0 ? void 0 : expectedCustomerSales.length) - 1];
619
613
  if (!!selectedExpectedCustomerSale)
620
- state.data.customersData.expectedCustomers = selectedExpectedCustomerSale;
614
+ state.data.customersData.expectedCustomer = selectedExpectedCustomerSale;
621
615
  })
622
616
  .addCase(retrieveDataList.rejected, function (state, action) {
623
617
  state.loading = false;