@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,38 @@
1
+ import { RootState } from '../../../app/store';
2
+ import { OTPFormValues, ResponseData, SharedState, TaxFormValues } from '../../../@types';
3
+ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
4
+ data: any;
5
+ leadData: any;
6
+ token: string;
7
+ }, string, {}>;
8
+ export declare const verifyTaxLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
9
+ data: any;
10
+ formData: OTPFormValues;
11
+ }, OTPFormValues, {}>;
12
+ export declare const updateTaxInfo: import("@reduxjs/toolkit").AsyncThunk<{
13
+ data: any;
14
+ formData: TaxFormValues;
15
+ }, TaxFormValues, {}>;
16
+ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
17
+ response: any;
18
+ formData: void;
19
+ }, void, {}>;
20
+ declare type VerifyData = {
21
+ token: string;
22
+ };
23
+ export interface TaxData {
24
+ verify: ResponseData & VerifyData;
25
+ otpData: OTPFormValues & ResponseData;
26
+ taxData: TaxFormValues & ResponseData;
27
+ }
28
+ export interface TaxState extends SharedState<TaxData> {
29
+ }
30
+ export declare const taxSlice: import("@reduxjs/toolkit").Slice<TaxState, {
31
+ clearError: (state: TaxState) => void;
32
+ stopLoader: (state: TaxState) => void;
33
+ resetOTPScreen: (state: TaxState) => void;
34
+ }, "tax/store">;
35
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
36
+ declare const _default: import("redux").Reducer<TaxState, import("redux").AnyAction>;
37
+ export default _default;
38
+ export declare const taxSelector: (state: RootState) => TaxState;
@@ -0,0 +1,271 @@
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 { TAX_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 === TAX_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 verifyTaxLeadOTP = createAsyncThunk('verifyTaxLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
80
+ var _a, tax, settings, responseBody, payload, data, steps, hasTaxCompleted;
81
+ var _b, _c, _d, _e;
82
+ return __generator(this, function (_f) {
83
+ switch (_f.label) {
84
+ case 0:
85
+ _a = thunkApi.getState(), tax = _a.tax, settings = _a.settings;
86
+ responseBody = tax.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: TAX_STEP_NAMES.PHONE_AUTH,
92
+ encryption_contract: ['data']
93
+ };
94
+ return [4, API.leadService.verifyLeadOTP(payload)];
95
+ case 1:
96
+ data = (_f.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
+ steps = (_e = tax.data.verify.responseBody) === null || _e === void 0 ? void 0 : _e.steps;
100
+ hasTaxCompleted = Object.keys(steps).find(function (key) { return key === TAX_STEP_NAMES.TAX_SUCCESS; });
101
+ if (hasTaxCompleted) {
102
+ thunkApi.dispatch(handleNextScreenStep('TAX_DETAILS_SUCCESS_STEP'));
103
+ }
104
+ else {
105
+ thunkApi.dispatch(handleNextScreenStep('TAX_TAX_DETAILS_STEP'));
106
+ }
107
+ }
108
+ return [2, { data: data, formData: params }];
109
+ }
110
+ });
111
+ }); });
112
+ export var updateTaxInfo = createAsyncThunk('updateTaxInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
113
+ var _a, settings, tax, requestBody, data;
114
+ var _b, _c, _d, _e;
115
+ return __generator(this, function (_f) {
116
+ switch (_f.label) {
117
+ case 0:
118
+ _a = thunkApi.getState(), settings = _a.settings, tax = _a.tax;
119
+ requestBody = {
120
+ id: (_c = (_b = tax.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.id,
121
+ vat_id: params.vatId,
122
+ step_name: TAX_STEP_NAMES.TAX_INFO
123
+ };
124
+ return [4, API.entityService.updateEntityInfo(requestBody)];
125
+ case 1:
126
+ data = (_f.sent()).data;
127
+ if (!data.errors) {
128
+ thunkApi.dispatch(handleNextScreenStep());
129
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, requestBody);
130
+ }
131
+ return [2, { data: data, formData: params }];
132
+ }
133
+ });
134
+ }); });
135
+ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
136
+ var _a, settings, tax, response, payload;
137
+ var _b, _c, _d, _e, _f, _g;
138
+ return __generator(this, function (_h) {
139
+ switch (_h.label) {
140
+ case 0:
141
+ _a = thunkApi.getState(), settings = _a.settings, tax = _a.tax;
142
+ response = undefined;
143
+ if (!!!((_b = tax.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id)) return [3, 2];
144
+ payload = {
145
+ step_name: TAX_STEP_NAMES.TAX_SUCCESS,
146
+ id: ((_c = tax.data.otpData.responseBody) === null || _c === void 0 ? void 0 : _c.id) || '',
147
+ encryption_contract: []
148
+ };
149
+ return [4, API.leadService.updateLead(payload)];
150
+ case 1:
151
+ response = _h.sent();
152
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, params);
153
+ (_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 });
154
+ _h.label = 2;
155
+ case 2: return [2, { response: response === null || response === void 0 ? void 0 : response.data, formData: params }];
156
+ }
157
+ });
158
+ }); });
159
+ var initialState = {
160
+ error: null,
161
+ loading: false,
162
+ data: {
163
+ verify: {
164
+ token: ''
165
+ },
166
+ otpData: {
167
+ otp: ''
168
+ },
169
+ taxData: {
170
+ vatId: ''
171
+ }
172
+ }
173
+ };
174
+ export var taxSlice = createSlice({
175
+ name: 'tax/store',
176
+ initialState: initialState,
177
+ reducers: {
178
+ clearError: function (state) {
179
+ state.error = null;
180
+ },
181
+ stopLoader: function (state) {
182
+ state.loading = false;
183
+ },
184
+ resetOTPScreen: function (state) {
185
+ state.data.otpData.otp = '';
186
+ }
187
+ },
188
+ extraReducers: function (builder) {
189
+ builder
190
+ .addCase(verifyLeadToken.fulfilled, function (state, action) {
191
+ var _a;
192
+ state.error = null;
193
+ var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
194
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
195
+ if (description) {
196
+ state.error = description;
197
+ return;
198
+ }
199
+ state.data.verify.responseBody = __assign(__assign({}, data), leadData);
200
+ state.data.verify.token = token;
201
+ })
202
+ .addCase(verifyLeadToken.rejected, function (state, action) {
203
+ state.error = action.error.message;
204
+ })
205
+ .addCase(verifyTaxLeadOTP.pending, function (state) {
206
+ state.loading = true;
207
+ state.error = null;
208
+ })
209
+ .addCase(verifyTaxLeadOTP.fulfilled, function (state, action) {
210
+ var _a;
211
+ state.loading = false;
212
+ state.error = null;
213
+ var _b = action.payload, data = _b.data, formData = _b.formData;
214
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
215
+ if (description) {
216
+ state.error = description;
217
+ return;
218
+ }
219
+ state.data.otpData = formData;
220
+ state.data.otpData.responseBody = data;
221
+ })
222
+ .addCase(verifyTaxLeadOTP.rejected, function (state, action) {
223
+ state.loading = false;
224
+ state.error = action.error.message;
225
+ })
226
+ .addCase(updateTaxInfo.pending, function (state) {
227
+ state.loading = true;
228
+ state.error = null;
229
+ })
230
+ .addCase(updateTaxInfo.fulfilled, function (state, action) {
231
+ var _a;
232
+ state.loading = false;
233
+ state.error = null;
234
+ var _b = action.payload, data = _b.data, formData = _b.formData;
235
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
236
+ if (description) {
237
+ state.error = description;
238
+ return;
239
+ }
240
+ state.data.taxData = formData;
241
+ state.data.taxData.responseBody = data;
242
+ })
243
+ .addCase(updateTaxInfo.rejected, function (state, action) {
244
+ state.loading = false;
245
+ state.error = action.error.message;
246
+ })
247
+ .addCase(updateLeadSuccess.fulfilled, function (state, action) {
248
+ var _a;
249
+ state.loading = false;
250
+ state.error = null;
251
+ var response = action.payload.response;
252
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
253
+ if (description) {
254
+ state.error = description;
255
+ return;
256
+ }
257
+ removeRequestHeaders();
258
+ })
259
+ .addCase(updateLeadSuccess.pending, function (state) {
260
+ state.loading = true;
261
+ state.error = null;
262
+ })
263
+ .addCase(updateLeadSuccess.rejected, function (state, action) {
264
+ state.loading = false;
265
+ state.error = action.error.message;
266
+ });
267
+ }
268
+ });
269
+ export var clearError = (_a = taxSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen;
270
+ export default taxSlice.reducer;
271
+ export var taxSelector = function (state) { return state.tax; };
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- export interface BankLibProps {
2
+ import { LibConfig } from '../../@types';
3
+ export interface BankLibProps extends LibConfig {
3
4
  }
4
5
  export declare function BankLib(props: BankLibProps): JSX.Element;
5
6
  export declare function renderBankLib(config: BankLibProps, elementId: string): void;
@@ -11,27 +11,37 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import React, { memo, useEffect } from 'react';
14
- import { useAppTheme, useAppDispatch, useAppSelector } from '../../hooks';
15
- import { handleActiveFlowScreens, settingsSelector } from '../../app/settings';
14
+ import { useAppTheme, useAppDispatch, useAppSelector, useErrorListener, useAppConfig } from '../../hooks';
15
+ import { settingsSelector } from '../../app/settings';
16
16
  import AnimationFlow from '../../components/AnimationFlow';
17
17
  import { store } from '../../app/store';
18
18
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
19
19
  import Collapse from '../../components/Collapse';
20
- import { reactElement } from '../../utils';
20
+ import { getParameterByName, reactElement } from '../../utils';
21
21
  import { FeatureContainer } from '../shared/Containers';
22
22
  import { BANK_SCREENS_NAVIGATION } from '../../constants';
23
23
  import { bankFeatureScreens } from '../featuresScreens';
24
24
  import CustomFooter from '../shared/Footer';
25
+ import { verifyLeadToken } from '../app/bank/bankStore';
25
26
  var Bank = memo(function (props) {
26
27
  var open = React.useState(true)[0];
27
28
  var theme = useAppTheme().theme;
28
29
  var dispatch = useAppDispatch();
29
- var data = useAppSelector(settingsSelector).data;
30
+ var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
31
+ var loading = useAppConfig(__assign({ navigation: BANK_SCREENS_NAVIGATION }, props)).loading;
32
+ useErrorListener();
30
33
  var activeScreen = data.activeScreen;
34
+ var verifyToken = function () {
35
+ var token = getParameterByName('token');
36
+ if (!token)
37
+ throw new Error('Auth token is not found!');
38
+ dispatch(verifyLeadToken(token));
39
+ };
31
40
  useEffect(function () {
32
- dispatch(handleActiveFlowScreens(BANK_SCREENS_NAVIGATION));
33
- }, []);
34
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: bankFeatureScreens.map(function (_a, index) {
41
+ if (!loading)
42
+ verifyToken();
43
+ }, [loading]);
44
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ loading: settingLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: bankFeatureScreens.map(function (_a, index) {
35
45
  var Element = _a.element, name = _a.name;
36
46
  var isActive = activeScreen.name === name;
37
47
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
@@ -46,8 +46,7 @@ var BankDetails = function () {
46
46
  },
47
47
  mode: 'onChange'
48
48
  });
49
- var onSubmit = function (data) {
50
- console.log('data', data);
49
+ var onSubmit = function () {
51
50
  dispatch(handleNextScreenStep());
52
51
  };
53
52
  var t = useTranslation().t;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,42 @@
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 } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box/Box';
15
+ import { styled } from '@mui/material/styles';
16
+ import OTPField from '../../../shared/OTP';
17
+ import { useController, useFormContext } from 'react-hook-form';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
+ var BoxStyled = styled(Box)(function (_a) {
21
+ var theme = _a.theme;
22
+ return ({
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ fontFamily: theme.typography.fontFamily
26
+ });
27
+ });
28
+ var OTPInput = function (_a) {
29
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
30
+ var t = useTranslation().t;
31
+ var otpControl = useController({ name: 'otp', control: control });
32
+ var handleOnOTPChange = function (otp) {
33
+ otpControl.field.onChange(otp);
34
+ };
35
+ var handleOnResendOTP = function () {
36
+ if (otpControl.field.value)
37
+ setValue('otp', '', { shouldValidate: true });
38
+ };
39
+ var otpValue = otpControl.field.value;
40
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
41
+ };
42
+ export default React.memo(OTPInput);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,78 @@
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 { useAppDispatch } from '../../../../hooks';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useSelector } from 'react-redux';
17
+ import { useForm, FormProvider } from 'react-hook-form';
18
+ import { yupResolver } from '@hookform/resolvers/yup';
19
+ import Box from '@mui/material/Box/Box';
20
+ import { styled } from '@mui/material/styles';
21
+ import { handlePrevScreenStep } from '../../../../app/settings';
22
+ import { useLanguage } from '../../../../hooks';
23
+ import { maskPhone } from '../../../../utils';
24
+ import Form from '../../../../components/Form';
25
+ import Text from '../../../../components/Text';
26
+ import { ScreenContainer } from '../../../shared/Containers';
27
+ import { bankSelector, clearError, resetOTPScreen, verifyBankLeadOTP } from '../../../app/bank/bankStore';
28
+ import Button from '../../../shared/Button';
29
+ import { OTPValidation } from './validation';
30
+ import OTPInput from './OTPInput';
31
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ background: theme.palette.common.white,
35
+ border: '1px solid',
36
+ borderColor: theme.palette.divider,
37
+ direction: theme.direction,
38
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
39
+ marginBottom: theme.spacing(5.75)
40
+ });
41
+ });
42
+ var OTPTitleStyled = styled(Text)(function (_a) {
43
+ var theme = _a.theme;
44
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInlineStart: theme.spacing(2.5), lineHeight: 1.75 }));
45
+ });
46
+ var FormStyled = styled(Form)(function () { return ({
47
+ display: 'flex',
48
+ flexDirection: 'column'
49
+ }); });
50
+ var VerifyNumber = function (_a) {
51
+ var _b, _c, _d;
52
+ var dispatch = useAppDispatch();
53
+ var _e = useSelector(bankSelector), data = _e.data, loading = _e.loading, error = _e.error;
54
+ var methods = useForm({
55
+ resolver: yupResolver(OTPValidation),
56
+ defaultValues: data.otpData,
57
+ mode: 'onChange'
58
+ });
59
+ var t = useTranslation().t;
60
+ var isAr = useLanguage().isAr;
61
+ React.useEffect(function () {
62
+ if (error)
63
+ dispatch(clearError());
64
+ return function () {
65
+ dispatch(resetOTPScreen());
66
+ };
67
+ }, [methods.formState.isValid]);
68
+ var onSubmit = function (formData) {
69
+ dispatch(verifyBankLeadOTP(formData));
70
+ };
71
+ var onBack = function () {
72
+ dispatch(handlePrevScreenStep());
73
+ };
74
+ var phone = (_d = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.contact) === null || _c === void 0 ? void 0 : _c.phone) === null || _d === void 0 ? void 0 : _d.number;
75
+ var disabled = !methods.formState.isValid || !!error || !phone;
76
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), !loading && phone && _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(maskPhone(phone || '')) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, type: 'submit', isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
77
+ };
78
+ export default React.memo(VerifyNumber);
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ otp: 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
+ otp: 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
+ otp: 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 OTPValidation = yup.object().shape({
3
+ otp: yup.string().min(6, 'otp_min_length').required('otp_required')
4
+ });
@@ -27,7 +27,7 @@ var Business = memo(function (props) {
27
27
  var open = React.useState(true)[0];
28
28
  var theme = useAppTheme().theme;
29
29
  var dispatch = useAppDispatch();
30
- var data = useAppSelector(settingsSelector).data;
30
+ var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
31
31
  var loading = useAppConfig(__assign({ navigation: BUSINESS_SCREENS_NAVIGATION }, props)).loading;
32
32
  useErrorListener();
33
33
  var activeScreen = data.activeScreen;
@@ -44,7 +44,7 @@ var Business = memo(function (props) {
44
44
  useEffect(function () {
45
45
  dispatch(getCountries());
46
46
  }, []);
47
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: businessFeatureScreens.map(function (_a, index) {
47
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ loading: settingLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: businessFeatureScreens.map(function (_a, index) {
48
48
  var Element = _a.element, name = _a.name;
49
49
  var isActive = activeScreen.name === name;
50
50
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
@@ -32,14 +32,12 @@ var FormStyled = styled(Form)(function () { return ({
32
32
  flexDirection: 'column'
33
33
  }); });
34
34
  var Activities = function () {
35
- var _a;
36
- var _b = React.useState(false), anchorEl = _b[0], setAnchorEl = _b[1];
37
- var _c = React.useState(false), collapse = _c[0], setCollapse = _c[1];
35
+ var _a = React.useState(false), anchorEl = _a[0], setAnchorEl = _a[1];
36
+ var _b = React.useState(false), collapse = _b[0], setCollapse = _b[1];
38
37
  var dispatch = useAppDispatch();
39
38
  var isAr = useLanguage().isAr;
40
39
  var t = useTranslation().t;
41
- var _d = useSelector(businessSelector), data = _d.data, loading = _d.loading, error = _d.error;
42
- var businessTypeResponse = data.businessTypeData.responseBody;
40
+ var _c = useSelector(businessSelector), data = _c.data, loading = _c.loading, error = _c.error;
43
41
  var activitiesData = data.activitiesData;
44
42
  var methods = useForm({
45
43
  resolver: yupResolver(ActivitiesValidationSchema),
@@ -50,7 +48,6 @@ var Activities = function () {
50
48
  dispatch(updateActivitiesInfo(__assign({}, data)));
51
49
  };
52
50
  var handleCollapseOpenClose = function (flag) {
53
- console.log('flag', flag);
54
51
  setCollapse(flag);
55
52
  };
56
53
  var onBack = function () {
@@ -60,6 +57,10 @@ var Activities = function () {
60
57
  var salesChannels = activitiesData.salesChannels;
61
58
  methods.setValue('salesChannels', salesChannels);
62
59
  }, [activitiesData.salesChannels]);
60
+ React.useEffect(function () {
61
+ var activities = activitiesData.activities;
62
+ methods.setValue('activities', activities);
63
+ }, [activitiesData === null || activitiesData === void 0 ? void 0 : activitiesData.activities]);
63
64
  React.useEffect(function () {
64
65
  if (error)
65
66
  dispatch(clearError());
@@ -67,8 +68,7 @@ var Activities = function () {
67
68
  var handleMenuClick = function () {
68
69
  anchorEl ? setAnchorEl(false) : setAnchorEl(true);
69
70
  };
70
- var activities_list = ((_a = businessTypeResponse === null || businessTypeResponse === void 0 ? void 0 : businessTypeResponse.activities) === null || _a === void 0 ? void 0 : _a.length) > 0;
71
71
  var disabled = !methods.formState.isValid || !!error;
72
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse }, { children: [!!activities_list && (_jsx(ActivitiesList, { onListOpen: function () { return handleMenuClick(); }, onListClose: function () { return handleMenuClick(); } })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(SalesChannels, {}) }))] })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
72
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(ActivitiesList, { onListOpen: function () { return handleMenuClick(); }, onListClose: function () { return handleMenuClick(); } }), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(SalesChannels, {}) }))] })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
73
73
  };
74
74
  export default Activities;
@@ -106,9 +106,9 @@ var ActivitiesList = function (_a) {
106
106
  (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
107
107
  };
108
108
  var onSelectItem = function (item) {
109
- var isActivityExists = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === (item === null || item === void 0 ? void 0 : item.id); });
109
+ var isActivityExists = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.en === (item === null || item === void 0 ? void 0 : item.en); });
110
110
  if (isActivityExists) {
111
- var updatedIdList = controlValue === null || controlValue === void 0 ? void 0 : controlValue.filter(function (activity) { return activity.id !== (item === null || item === void 0 ? void 0 : item.id); });
111
+ var updatedIdList = controlValue === null || controlValue === void 0 ? void 0 : controlValue.filter(function (activity) { return activity.en !== (item === null || item === void 0 ? void 0 : item.en); });
112
112
  if (updatedIdList.length >= 1)
113
113
  activitiesControl.field.onChange(updatedIdList);
114
114
  return;
@@ -120,13 +120,13 @@ var ActivitiesList = function (_a) {
120
120
  if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > 1) {
121
121
  return (controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) + ' ' + t('activities_selected');
122
122
  }
123
- return isAr ? (_a = controlValue[0]) === null || _a === void 0 ? void 0 : _a.name : (_b = controlValue[0]) === null || _b === void 0 ? void 0 : _b.nameEn;
123
+ return isAr ? (_a = controlValue[0]) === null || _a === void 0 ? void 0 : _a.ar : (_b = controlValue[0]) === null || _b === void 0 ? void 0 : _b.en;
124
124
  };
125
125
  var getSelectedActivityFlag = function (item) {
126
- return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === (item === null || item === void 0 ? void 0 : item.id); });
126
+ return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.en === (item === null || item === void 0 ? void 0 : item.en); });
127
127
  };
128
- return (_jsxs(ScreenContainer, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
129
- return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === getSelectedActivityFlag(item) }, { children: isAr ? item === null || item === void 0 ? void 0 : item.name : item === null || item === void 0 ? void 0 : item.nameEn })) })), getSelectedActivityFlag(item) && _jsx(CheckIconStyled, {})] }));
130
- } }) }))] })] }));
128
+ return (_jsx(Collapse, __assign({ in: (activitiesMenuList === null || activitiesMenuList === void 0 ? void 0 : activitiesMenuList.length) > 0 }, { children: _jsxs(ScreenContainer, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
129
+ return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.en) === getSelectedActivityFlag(item) }, { children: isAr ? item === null || item === void 0 ? void 0 : item.ar : item === null || item === void 0 ? void 0 : item.en })) })), getSelectedActivityFlag(item) && _jsx(CheckIconStyled, {})] }));
130
+ } }) }))] })] }) })));
131
131
  };
132
132
  export default ActivitiesList;
@@ -84,7 +84,7 @@ var SalesChannels = function () {
84
84
  var channelsChecked = channelsControl.field.value;
85
85
  var warningMessage = (_a = channelsControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
86
86
  var data = useSelector(businessSelector).data;
87
- var response = data.businessInfo.responseBody;
87
+ var response = data.businessTypeData.responseBody;
88
88
  React.useEffect(function () {
89
89
  var _a;
90
90
  if (((_a = response === null || response === void 0 ? void 0 : response.channelList) === null || _a === void 0 ? void 0 : _a.length) > 0) {