@tap-payments/auth-jsconnect 1.0.33 → 1.0.34

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 (34) hide show
  1. package/build/@types/form.d.ts +8 -1
  2. package/build/api/account.d.ts +15 -0
  3. package/build/api/account.js +9 -0
  4. package/build/api/data.d.ts +6 -0
  5. package/build/api/data.js +17 -0
  6. package/build/api/entity.d.ts +4 -4
  7. package/build/api/index.d.ts +10 -1
  8. package/build/api/index.js +5 -1
  9. package/build/components/Input/Input.js +1 -1
  10. package/build/constants/api.d.ts +4 -0
  11. package/build/constants/api.js +9 -1
  12. package/build/constants/app.d.ts +5 -1
  13. package/build/constants/app.js +5 -1
  14. package/build/features/app/business/businessStore.d.ts +23 -4
  15. package/build/features/app/business/businessStore.js +202 -29
  16. package/build/features/app/connect/connectStore.d.ts +8 -2
  17. package/build/features/app/connect/connectStore.js +19 -1
  18. package/build/features/business/screens/Activities/Activities.js +12 -12
  19. package/build/features/business/screens/Activities/ActivitiesList.js +14 -4
  20. package/build/features/business/screens/Activities/SalesChannels.js +11 -2
  21. package/build/features/business/screens/Confirm/Confirm.js +3 -3
  22. package/build/features/business/screens/Customers/Customers.js +3 -2
  23. package/build/features/business/screens/IDBOD/IDBOD.js +1 -1
  24. package/build/features/business/screens/Success/Success.js +6 -0
  25. package/build/features/business/screens/Verify/Verify.js +2 -1
  26. package/build/features/connect/screens/Individual/Individual.js +6 -1
  27. package/build/features/connect/screens/Merchant/Merchant.js +6 -1
  28. package/build/features/connect/screens/Mobile/Mobile.js +6 -1
  29. package/build/features/connect/screens/NID/NID.js +6 -1
  30. package/build/features/connect/screens/OTP/OTP.js +6 -1
  31. package/build/features/connect/screens/OTP/OTPInput.js +0 -3
  32. package/build/features/connect/screens/Password/Password.js +6 -1
  33. package/build/utils/string.js +2 -1
  34. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { Activity, CountryCode, SalesChannel } from './app';
1
+ import { Activity, CountryCode, CustomerLocation, ExpectedCustomer, ExpectedSaleRange, SalesChannel } from './app';
2
2
  export declare type MobileFormValues = {
3
3
  mobile: string | null;
4
4
  countryCode: CountryCode;
@@ -43,3 +43,10 @@ export declare type ActivitiesFormValues = {
43
43
  salesChannels: Array<SalesChannel>;
44
44
  operationStartDate: string;
45
45
  };
46
+ export declare type CustomersFormValues = {
47
+ customerLocations: Array<CustomerLocation>;
48
+ expectedCustomers: ExpectedCustomer | undefined;
49
+ expectedSalesRange: ExpectedSaleRange | undefined;
50
+ refundPolicy: boolean;
51
+ transactionPolicy: boolean;
52
+ };
@@ -0,0 +1,15 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ export declare type CreateAccountBody = {
3
+ lead_id: string;
4
+ notify: {
5
+ email: boolean;
6
+ phone: boolean;
7
+ };
8
+ skip_legacy: boolean;
9
+ is_acknowledged: boolean;
10
+ step_name: string;
11
+ };
12
+ declare const accountService: {
13
+ createAccount: (data: CreateAccountBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
14
+ };
15
+ export { accountService };
@@ -0,0 +1,9 @@
1
+ import instance from './axios';
2
+ import { ENDPOINT_PATHS } from '../constants';
3
+ var createAccount = function (data, config) {
4
+ return instance.post("".concat(ENDPOINT_PATHS.CREATE_ACCOUNT, "/").concat(data.lead_id), data, config);
5
+ };
6
+ var accountService = {
7
+ createAccount: createAccount
8
+ };
9
+ export { accountService };
@@ -0,0 +1,6 @@
1
+ declare const dataService: {
2
+ getChannelsOfServices: () => Promise<import("axios").AxiosResponse<any, any>>;
3
+ getCustomerBases: () => Promise<import("axios").AxiosResponse<any, any>>;
4
+ getExpectedSales: () => Promise<import("axios").AxiosResponse<any, any>>;
5
+ };
6
+ export { dataService };
@@ -0,0 +1,17 @@
1
+ import instance from './axios';
2
+ import { ENDPOINT_PATHS } from '../constants';
3
+ var getChannelsOfServices = function () {
4
+ return instance.get("".concat(ENDPOINT_PATHS.CHANNEL));
5
+ };
6
+ var getCustomerBases = function () {
7
+ return instance.get("".concat(ENDPOINT_PATHS.CUSTOMER_BASES));
8
+ };
9
+ var getExpectedSales = function () {
10
+ return instance.get("".concat(ENDPOINT_PATHS.SALES));
11
+ };
12
+ var dataService = {
13
+ getChannelsOfServices: getChannelsOfServices,
14
+ getCustomerBases: getCustomerBases,
15
+ getExpectedSales: getExpectedSales
16
+ };
17
+ export { dataService };
@@ -1,13 +1,13 @@
1
- import { Activity, SalesChannel } from '../@types';
1
+ import { Activity, CustomerLocation, ExpectedCustomer, ExpectedSaleRange, SalesChannel } from '../@types';
2
2
  import { AxiosRequestConfig } from 'axios';
3
3
  export declare type EntityInfoUpdateBody = {
4
4
  activities?: Array<Activity>;
5
5
  business_operation_start_at?: string;
6
6
  channel_services?: Array<SalesChannel>;
7
7
  physical_store_available?: boolean;
8
- yearly_sales_range?: string;
9
- customers_served_monthly?: string;
10
- customers_base?: Array<string>;
8
+ yearly_sales_range?: ExpectedSaleRange;
9
+ customers_served_monthly?: ExpectedCustomer;
10
+ customers_base?: Array<CustomerLocation>;
11
11
  vat_id?: string;
12
12
  agree_chargeback?: boolean;
13
13
  agree_refund?: boolean;
@@ -4,6 +4,7 @@ import { CreateAuthBody, VerifyAuthBody } from './auth';
4
4
  import { UpdateLeadBody, LeadVerifyBody, CreateLeadBody, LeadOTPVerifyBody, LeadIdentityUpdateBody } from './lead';
5
5
  import { CheckEmailBody, CheckBrandBody } from './availabilityServices';
6
6
  import { EntityInfoUpdateBody } from './entity';
7
+ import { CreateAccountBody } from './account';
7
8
  declare const API: {
8
9
  ipService: {
9
10
  getIP: () => Promise<import("axios").AxiosResponse<any, any>>;
@@ -39,7 +40,15 @@ declare const API: {
39
40
  firebaseService: {
40
41
  getLocale: () => Promise<import("axios").AxiosResponse<any, any>>;
41
42
  };
43
+ accountService: {
44
+ createAccount: (data: CreateAccountBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
45
+ };
46
+ dataService: {
47
+ getChannelsOfServices: () => Promise<import("axios").AxiosResponse<any, any>>;
48
+ getCustomerBases: () => Promise<import("axios").AxiosResponse<any, any>>;
49
+ getExpectedSales: () => Promise<import("axios").AxiosResponse<any, any>>;
50
+ };
42
51
  };
43
- export type { ValidateOperatorBody, CreateAuthBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoUpdateBody };
52
+ export type { ValidateOperatorBody, CreateAuthBody, VerifyAuthBody, CreateLeadBody, UpdateLeadBody, LeadVerifyBody, LeadOTPVerifyBody, CheckEmailBody, CheckBrandBody, LeadIdentityUpdateBody, EntityInfoUpdateBody, CreateAccountBody };
44
53
  export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders };
45
54
  export default API;
@@ -7,6 +7,8 @@ import { leadService } from './lead';
7
7
  import availabilityServices from './availabilityServices';
8
8
  import { firebaseService } from './firebase';
9
9
  import { entityService } from './entity';
10
+ import { accountService } from './account';
11
+ import { dataService } from './data';
10
12
  var API = {
11
13
  ipService: ipService,
12
14
  operatorService: operatorService,
@@ -15,7 +17,9 @@ var API = {
15
17
  leadService: leadService,
16
18
  entityService: entityService,
17
19
  availabilityServices: availabilityServices,
18
- firebaseService: firebaseService
20
+ firebaseService: firebaseService,
21
+ accountService: accountService,
22
+ dataService: dataService
19
23
  };
20
24
  export { setAxiosGlobalHeaders, removeAxiosGlobalHeaders };
21
25
  export default API;
@@ -65,7 +65,7 @@ var InputStyled = styled(Input)(function (_a) {
65
65
  });
66
66
  var InputField = function (_a) {
67
67
  var onEnterPressed = _a.onEnterPressed, hide = _a.hide, endAdornment = _a.endAdornment, startAdornment = _a.startAdornment, warningType = _a.warningType, warningMessage = _a.warningMessage, rest = __rest(_a, ["onEnterPressed", "hide", "endAdornment", "startAdornment", "warningType", "warningMessage"]);
68
- var _b = React.useState(), warning = _b[0], setWarning = _b[1];
68
+ var _b = React.useState('alert'), warning = _b[0], setWarning = _b[1];
69
69
  var onKeyPress = function (e) {
70
70
  var _a;
71
71
  if (e.key === 'Enter')
@@ -14,4 +14,8 @@ export declare const ENDPOINT_PATHS: {
14
14
  CHECK_EMAIL: string;
15
15
  CHECK_BRAND: string;
16
16
  FIREBASE_URL: string;
17
+ CREATE_ACCOUNT: string;
18
+ CHANNEL: string;
19
+ CUSTOMER_BASES: string;
20
+ SALES: string;
17
21
  };
@@ -12,6 +12,10 @@ var RETRIEVE_FL_PATH = '/lead/fllist';
12
12
  var ENTITY_PATH = '/entity';
13
13
  var CHECK_EMAIL = '/lead/identity/emailcheck';
14
14
  var CHECK_BRAND = 'lead/profile/profile_name';
15
+ var CREATE_ACCOUNT_PATH = '/account/create';
16
+ var CHANNEL_PATH = '/channel';
17
+ var CUSTOMER_BASES_PATH = '/customerBases';
18
+ var SALES_PATH = '/sales';
15
19
  var FIREBASE_URL = 'https://goconnect-195cd-default-rtdb.asia-southeast1.firebasedatabase.app/sandbox/local.json';
16
20
  export var ENDPOINT_PATHS = {
17
21
  BASE_URL: API_BASE_URL,
@@ -28,5 +32,9 @@ export var ENDPOINT_PATHS = {
28
32
  ENTITY: ENTITY_PATH,
29
33
  CHECK_EMAIL: CHECK_EMAIL,
30
34
  CHECK_BRAND: CHECK_BRAND,
31
- FIREBASE_URL: FIREBASE_URL
35
+ FIREBASE_URL: FIREBASE_URL,
36
+ CREATE_ACCOUNT: CREATE_ACCOUNT_PATH,
37
+ CHANNEL: CHANNEL_PATH,
38
+ CUSTOMER_BASES: CUSTOMER_BASES_PATH,
39
+ SALES: SALES_PATH
32
40
  };
@@ -83,7 +83,11 @@ export declare const BUSINESS_STEP_NAMES: {
83
83
  PHONE_AUTH: string;
84
84
  IDENTITY_AUTH: string;
85
85
  IDENTITY_VERIFY_AUTH: string;
86
- BUSINESS_INFO: string;
86
+ BUSINESS_CR_INFO: string;
87
+ BUSINESS_INFO_CONFIRM: string;
88
+ BUSINESS_CR_ACTIVITIES: string;
89
+ BUSINESS_CUSTOMERS: string;
90
+ BUSINESS_SUCCESS: string;
87
91
  };
88
92
  export declare const RSA_FRONTEND_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgC9kH1SQvjbXAUXd0PbrDUG8P\nLhRig9pJNBmdQBZjihuaxfkzYu6ToMbIMAfmYgVgQw338/y7aQ8X3m03CXNIlkxo\nOwxKCA8ymKsZQptXJn9IxlPO7yjoFgTFBrpmTgvcC4XO1uoUYTAPq3szK8kj4zgT\nucWG1hSKsOdRU7sl/wIDAQAB\n-----END PUBLIC KEY-----";
89
93
  export declare const ENCRYPTION_FLAG = "encryption_contract";
@@ -232,7 +232,11 @@ export var BUSINESS_STEP_NAMES = {
232
232
  PHONE_AUTH: 'business_phone_auth',
233
233
  IDENTITY_AUTH: 'business_identity_auth',
234
234
  IDENTITY_VERIFY_AUTH: 'business_identity_auth_verify',
235
- BUSINESS_INFO: 'business_info'
235
+ BUSINESS_CR_INFO: 'business_cr_info',
236
+ BUSINESS_INFO_CONFIRM: 'business_info_confirm',
237
+ BUSINESS_CR_ACTIVITIES: 'business_cr_activities',
238
+ BUSINESS_CUSTOMERS: 'business_customers',
239
+ BUSINESS_SUCCESS: 'business_completed'
236
240
  };
237
241
  export var RSA_FRONTEND_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgC9kH1SQvjbXAUXd0PbrDUG8P\nLhRig9pJNBmdQBZjihuaxfkzYu6ToMbIMAfmYgVgQw338/y7aQ8X3m03CXNIlkxo\nOwxKCA8ymKsZQptXJn9IxlPO7yjoFgTFBrpmTgvcC4XO1uoUYTAPq3szK8kj4zgT\nucWG1hSKsOdRU7sl/wIDAQAB\n-----END PUBLIC KEY-----";
238
242
  export var ENCRYPTION_FLAG = 'encryption_contract';
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { ActivitiesFormValues, BusinessInfoFormValues, BusinessTypeFormValues, CountryCode, CRLicense, FLLicense, NIDFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
2
+ import { ActivitiesFormValues, BusinessInfoFormValues, CustomersFormValues, BusinessTypeFormValues, CountryCode, CRLicense, FLLicense, NIDFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
3
  export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
4
4
  businessCountry: any;
5
5
  countries: any;
@@ -37,17 +37,35 @@ export declare const updateLeadBusinessType: import("@reduxjs/toolkit").AsyncThu
37
37
  data: any;
38
38
  formData: BusinessTypeFormValues;
39
39
  }, BusinessTypeFormValues, {}>;
40
- export declare const updateEntityInfo: import("@reduxjs/toolkit").AsyncThunk<{
40
+ export declare const createAccount: import("@reduxjs/toolkit").AsyncThunk<{
41
+ data: any;
42
+ channelsData: any;
43
+ }, void, {}>;
44
+ export declare const updateActivitiesInfo: import("@reduxjs/toolkit").AsyncThunk<{
41
45
  data: any;
42
46
  formData: {
43
47
  activities: import("../../../@types").Activity[] | undefined;
44
48
  salesChannels: import("../../../@types").SalesChannel[];
45
49
  operationStartDate: string;
50
+ };
51
+ }, ActivitiesFormValues, {}>;
52
+ export declare const updateCustomersInfo: import("@reduxjs/toolkit").AsyncThunk<{
53
+ data: any;
54
+ formData: {
55
+ customerLocations: import("../../../@types").CustomerLocation[];
56
+ expectedCustomers: import("../../../@types").ExpectedCustomer | undefined;
57
+ expectedSalesRange: import("../../../@types").ExpectedSaleRange | undefined;
58
+ refundPolicy: boolean;
59
+ transactionPolicy: boolean;
46
60
  isResend: boolean;
47
61
  };
48
- }, ActivitiesFormValues & {
62
+ }, CustomersFormValues & {
49
63
  isResend: boolean;
50
64
  }, {}>;
65
+ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
66
+ response: any;
67
+ formData: void;
68
+ }, void, {}>;
51
69
  declare type VerifyData = {
52
70
  token: string;
53
71
  };
@@ -62,8 +80,9 @@ export interface BusinessData {
62
80
  businessTypeData: BusinessTypeFormValues & ResponseData;
63
81
  crInfos: Array<CRLicense>;
64
82
  flInfos: Array<FLLicense>;
65
- businessInfo: BusinessInfoFormValues;
83
+ businessInfo: BusinessInfoFormValues & ResponseData;
66
84
  activitiesData: ActivitiesFormValues & ResponseData;
85
+ customersData: CustomersFormValues & ResponseData;
67
86
  }
68
87
  export interface BusinessState extends SharedState<BusinessData> {
69
88
  }
@@ -47,10 +47,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import moment from 'moment';
50
51
  import API from '../../../api';
51
52
  import { BusinessType } from '../../../@types';
52
53
  import { BUSINESS_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE } from '../../../constants';
53
- import { handleNextScreenStep } from '../../../app/settings';
54
+ import i18n from '../../../i18n';
55
+ import { convertNumbers2English, removeRequestHeaders } from '../../../utils';
56
+ import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
54
57
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
55
58
  var settings, countriesBody, list, businessCountry;
56
59
  return __generator(this, function (_a) {
@@ -82,14 +85,14 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
82
85
  data = (_a.sent()).data;
83
86
  leadResponse = undefined;
84
87
  if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
85
- return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.lead_id)];
88
+ return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
86
89
  case 2:
87
90
  leadResponse = _a.sent();
88
91
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH) {
89
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
92
+ thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_IDBOD_STEP'));
90
93
  }
91
- else {
92
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_VERIFY_STEP'));
94
+ if (data.step_name === 'business_info') {
95
+ thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_BUSINESS_TYPE_STEP'));
93
96
  }
94
97
  _a.label = 3;
95
98
  case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
@@ -193,20 +196,21 @@ export var retrieveFLInfos = createAsyncThunk('retrieveFLInfos', function (_a, t
193
196
  });
194
197
  }); });
195
198
  export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
196
- var _a, settings, connect, headers, payload, data;
199
+ var _a, settings, business, headers, payload, data;
197
200
  var _b, _c, _d, _e, _f;
198
201
  return __generator(this, function (_g) {
199
202
  switch (_g.label) {
200
203
  case 0:
201
- _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
204
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
202
205
  headers = {
203
- lead_id: ((_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
206
+ lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
204
207
  device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
205
208
  };
206
209
  payload = {
207
210
  freelancer_number: params.flNumber,
208
211
  business_type: params.businessType,
209
212
  cr_number: params.crNumber,
213
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_INFO,
210
214
  encryption_contract: ['freelancer_number', 'business_type', 'cr_number']
211
215
  };
212
216
  return [4, API.leadService.updateLead(payload, { headers: headers })];
@@ -220,31 +224,114 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
220
224
  }
221
225
  });
222
226
  }); });
223
- export var updateEntityInfo = createAsyncThunk('updateEntityInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
224
- var settings, requestBody, headers, data;
225
- var _a, _b;
226
- return __generator(this, function (_c) {
227
- switch (_c.label) {
227
+ export var createAccount = createAsyncThunk('createAccount', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
228
+ var _a, settings, business, requestBody, data, channels;
229
+ var _b, _c, _d;
230
+ return __generator(this, function (_e) {
231
+ switch (_e.label) {
228
232
  case 0:
229
- settings = thunkApi.getState().settings;
233
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
234
+ requestBody = {
235
+ lead_id: (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id,
236
+ notify: {
237
+ email: false,
238
+ phone: false
239
+ },
240
+ skip_legacy: false,
241
+ is_acknowledged: true,
242
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_INFO_CONFIRM
243
+ };
244
+ return [4, API.accountService.createAccount(requestBody)];
245
+ case 1:
246
+ data = (_e.sent()).data;
247
+ channels = undefined;
248
+ if (!!data.errors) return [3, 3];
249
+ return [4, API.dataService.getChannelsOfServices()];
250
+ case 2:
251
+ channels = _e.sent();
252
+ thunkApi.dispatch(handleNextScreenStep());
253
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
254
+ _e.label = 3;
255
+ case 3: return [2, { data: data, channelsData: channels === null || channels === void 0 ? void 0 : channels.data }];
256
+ }
257
+ });
258
+ }); });
259
+ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
260
+ var _a, settings, business, requestBody, headers, data;
261
+ var _b, _c, _d;
262
+ return __generator(this, function (_e) {
263
+ switch (_e.label) {
264
+ case 0:
265
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
230
266
  requestBody = {
231
267
  activities: params.activities,
232
268
  channel_services: params.salesChannels,
233
269
  business_operation_start_at: params.operationStartDate,
234
- step_name: BUSINESS_STEP_NAMES.BUSINESS_INFO
270
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES
235
271
  };
236
- headers = { entity_id: '123456789' };
272
+ headers = { entity_id: (_b = business.data.businessInfo.responseBody) === null || _b === void 0 ? void 0 : _b.entity_id };
237
273
  return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
238
274
  case 1:
239
- data = (_c.sent()).data;
275
+ data = (_e.sent()).data;
276
+ if (!data.errors) {
277
+ thunkApi.dispatch(handleNextScreenStep());
278
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
279
+ }
280
+ return [2, { data: data, formData: __assign({}, params) }];
281
+ }
282
+ });
283
+ }); });
284
+ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
285
+ var _a, settings, business, requestBody, headers, data;
286
+ var _b, _c, _d;
287
+ return __generator(this, function (_e) {
288
+ switch (_e.label) {
289
+ case 0:
290
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
291
+ requestBody = {
292
+ customers_base: params.customerLocations,
293
+ customers_served_monthly: params.expectedCustomers,
294
+ yearly_sales_range: params.expectedSalesRange,
295
+ agree_refund: params.refundPolicy,
296
+ agree_chargeback: params.transactionPolicy,
297
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS
298
+ };
299
+ headers = { entity_id: (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id };
300
+ return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
301
+ case 1:
302
+ data = (_e.sent()).data;
240
303
  if (!data.errors && !params.isResend) {
241
304
  thunkApi.dispatch(handleNextScreenStep());
242
- (_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody);
305
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
243
306
  }
244
307
  return [2, { data: data, formData: __assign({}, params) }];
245
308
  }
246
309
  });
247
310
  }); });
311
+ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
312
+ var _a, settings, business, headers, payload, data;
313
+ var _b, _c, _d, _e, _f, _g, _h;
314
+ return __generator(this, function (_j) {
315
+ switch (_j.label) {
316
+ case 0:
317
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
318
+ headers = {
319
+ lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
320
+ device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
321
+ };
322
+ payload = {
323
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_SUCCESS,
324
+ encryption_contract: []
325
+ };
326
+ return [4, API.leadService.updateLead(payload, { headers: headers })];
327
+ case 1:
328
+ data = (_j.sent()).data;
329
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
330
+ (_h = (_g = settings.data.appConfig).onFlowCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, { data: data });
331
+ return [2, { response: data, formData: params }];
332
+ }
333
+ });
334
+ }); });
248
335
  var initialState = {
249
336
  error: null,
250
337
  loading: false,
@@ -278,6 +365,13 @@ var initialState = {
278
365
  activities: [],
279
366
  salesChannels: [],
280
367
  operationStartDate: '1998-08-22'
368
+ },
369
+ customersData: {
370
+ customerLocations: [],
371
+ expectedCustomers: undefined,
372
+ expectedSalesRange: undefined,
373
+ refundPolicy: false,
374
+ transactionPolicy: false
281
375
  }
282
376
  }
283
377
  };
@@ -307,12 +401,10 @@ export var businessSlice = createSlice({
307
401
  state.error = action.error.message;
308
402
  })
309
403
  .addCase(verifyLeadToken.pending, function (state) {
310
- state.loading = true;
311
404
  state.error = null;
312
405
  })
313
406
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
314
407
  var _a;
315
- state.loading = false;
316
408
  state.error = null;
317
409
  var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
318
410
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
@@ -320,11 +412,10 @@ export var businessSlice = createSlice({
320
412
  state.error = description;
321
413
  return;
322
414
  }
323
- state.data.verify.responseBody = leadData;
415
+ state.data.verify.responseBody = __assign(__assign({}, data), leadData);
324
416
  state.data.verify.token = token;
325
417
  })
326
418
  .addCase(verifyLeadToken.rejected, function (state, action) {
327
- state.loading = false;
328
419
  state.error = action.error.message;
329
420
  })
330
421
  .addCase(verifyLeadOTP.pending, function (state) {
@@ -399,7 +490,7 @@ export var businessSlice = createSlice({
399
490
  var data = action.payload.data;
400
491
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
401
492
  if (!description) {
402
- state.data.flInfos = data;
493
+ state.data.flInfos = data === null || data === void 0 ? void 0 : data.licenses;
403
494
  state.data.businessTypeData.businessType = BusinessType.FL;
404
495
  }
405
496
  })
@@ -412,27 +503,68 @@ export var businessSlice = createSlice({
412
503
  state.error = null;
413
504
  })
414
505
  .addCase(updateLeadBusinessType.fulfilled, function (state, action) {
415
- var _a;
506
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
416
507
  state.loading = false;
417
508
  state.error = null;
418
- var _b = action.payload, data = _b.data, formData = _b.formData;
509
+ var _m = action.payload, data = _m.data, formData = _m.formData;
419
510
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
420
511
  if (description) {
421
512
  state.error = description;
422
513
  return;
423
514
  }
424
515
  state.data.businessTypeData = formData;
425
- state.data.businessTypeData.responseBody = data;
516
+ state.data.businessInfo.brandName = i18n.dir() === 'rtl' ? (_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;
517
+ state.data.businessInfo.licenseNumber = (data === null || data === void 0 ? void 0 : data.freelancer_number) || (data === null || data === void 0 ? void 0 : data.cr_number);
518
+ if (formData.businessType === BusinessType.CR) {
519
+ state.data.businessInfo.legalName = (_f = data === null || data === void 0 ? void 0 : data.license) === null || _f === void 0 ? void 0 : _f.crName;
520
+ state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_g = data === null || data === void 0 ? void 0 : data.license) === null || _g === void 0 ? void 0 : _g.issueDate, 'iYYYY/iMM/iDD').format('YYYY-MM-DD'));
521
+ var activities = (_j = (_h = data === null || data === void 0 ? void 0 : data.license) === null || _h === void 0 ? void 0 : _h.activities) === null || _j === void 0 ? void 0 : _j.isic;
522
+ var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
523
+ if (!!selectedActivity)
524
+ state.data.activitiesData.activities = [selectedActivity];
525
+ state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: activities || [] });
526
+ return;
527
+ }
528
+ var category = (_l = (_k = data === null || data === void 0 ? void 0 : data.license) === null || _k === void 0 ? void 0 : _k.License) === null || _l === void 0 ? void 0 : _l.Category;
529
+ if (!!category)
530
+ state.data.activitiesData.activities = [category];
531
+ state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: [category] });
426
532
  })
427
533
  .addCase(updateLeadBusinessType.rejected, function (state, action) {
428
534
  state.loading = false;
429
535
  state.error = action.error.message;
430
536
  })
431
- .addCase(updateEntityInfo.pending, function (state) {
537
+ .addCase(createAccount.pending, function (state) {
538
+ state.loading = true;
539
+ state.error = null;
540
+ })
541
+ .addCase(createAccount.fulfilled, function (state, action) {
542
+ var _a, _b;
543
+ state.error = null;
544
+ var _c = action.payload, data = _c.data, channelsData = _c.channelsData;
545
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = channelsData === null || channelsData === void 0 ? void 0 : channelsData.errors) === null || _b === void 0 ? void 0 : _b[0]) || {}).description;
546
+ if (description) {
547
+ state.error = description;
548
+ return;
549
+ }
550
+ if ((data === null || data === void 0 ? void 0 : data.status) === 'ALREADY_TAKEN') {
551
+ state.error = 'signup_user_exists_error';
552
+ return;
553
+ }
554
+ state.data.businessInfo.responseBody = __assign(__assign({}, data), { channelList: channelsData || [] });
555
+ var selectedChannel = channelsData === null || channelsData === void 0 ? void 0 : channelsData[0];
556
+ if (!!selectedChannel)
557
+ state.data.activitiesData.salesChannels = [selectedChannel];
558
+ })
559
+ .addCase(createAccount.rejected, function (state, action) {
560
+ state.loading = false;
561
+ state.error = action.error.message;
562
+ })
563
+ .addCase(updateActivitiesInfo.pending, function (state) {
432
564
  state.loading = true;
433
565
  state.error = null;
434
566
  })
435
- .addCase(updateEntityInfo.fulfilled, function (state, action) {
567
+ .addCase(updateActivitiesInfo.fulfilled, function (state, action) {
436
568
  var _a;
437
569
  state.error = null;
438
570
  var _b = action.payload, data = _b.data, formData = _b.formData;
@@ -444,7 +576,48 @@ export var businessSlice = createSlice({
444
576
  state.data.activitiesData = formData;
445
577
  state.data.activitiesData.responseBody = data;
446
578
  })
447
- .addCase(updateEntityInfo.rejected, function (state, action) {
579
+ .addCase(updateActivitiesInfo.rejected, function (state, action) {
580
+ state.loading = false;
581
+ state.error = action.error.message;
582
+ })
583
+ .addCase(updateCustomersInfo.pending, function (state) {
584
+ state.loading = true;
585
+ state.error = null;
586
+ })
587
+ .addCase(updateCustomersInfo.fulfilled, function (state, action) {
588
+ var _a;
589
+ state.loading = false;
590
+ state.error = null;
591
+ var _b = action.payload, data = _b.data, formData = _b.formData;
592
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
593
+ if (description) {
594
+ state.error = description;
595
+ return;
596
+ }
597
+ state.data.customersData = formData;
598
+ state.data.customersData.responseBody = data;
599
+ })
600
+ .addCase(updateCustomersInfo.rejected, function (state, action) {
601
+ state.loading = false;
602
+ state.error = action.error.message;
603
+ })
604
+ .addCase(updateLeadSuccess.fulfilled, function (state, action) {
605
+ var _a;
606
+ state.loading = false;
607
+ state.error = null;
608
+ var response = action.payload.response;
609
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
610
+ if (description) {
611
+ state.error = description;
612
+ return;
613
+ }
614
+ removeRequestHeaders();
615
+ })
616
+ .addCase(updateLeadSuccess.pending, function (state) {
617
+ state.loading = true;
618
+ state.error = null;
619
+ })
620
+ .addCase(updateLeadSuccess.rejected, function (state, action) {
448
621
  state.loading = false;
449
622
  state.error = action.error.message;
450
623
  });
@@ -57,7 +57,7 @@ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
57
57
  export interface ConnectData {
58
58
  countries: Array<CountryCode>;
59
59
  businessCountry: CountryCode;
60
- mobileData: MobileFormValues & ResponseData;
60
+ mobileData: (MobileFormValues | undefined) & ResponseData;
61
61
  nidData: NIDFormValues & ResponseData & {
62
62
  type: string;
63
63
  };
@@ -73,8 +73,14 @@ export interface ConnectState extends SharedState<ConnectData> {
73
73
  export declare const connectSlice: import("@reduxjs/toolkit").Slice<ConnectState, {
74
74
  clearError: (state: ConnectState) => void;
75
75
  stopLoader: (state: ConnectState) => void;
76
+ resetMobileScreen: (state: ConnectState) => void;
77
+ resetNIDScreen: (state: ConnectState) => void;
78
+ resetOTPScreen: (state: ConnectState) => void;
79
+ resetPasswordScreen: (state: ConnectState) => void;
80
+ resetIndividualScreen: (state: ConnectState) => void;
81
+ resetMerchantScreen: (state: ConnectState) => void;
76
82
  }, "connect/store">;
77
- export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
83
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetIndividualScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMerchantScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetPasswordScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
78
84
  declare const _default: import("redux").Reducer<ConnectState, import("redux").AnyAction>;
79
85
  export default _default;
80
86
  export declare const connectSelector: (state: RootState) => ConnectState;
@@ -435,6 +435,24 @@ export var connectSlice = createSlice({
435
435
  },
436
436
  stopLoader: function (state) {
437
437
  state.loading = false;
438
+ },
439
+ resetMobileScreen: function (state) {
440
+ state.data.mobileData = __assign(__assign({}, state.data.mobileData), initialState.data.mobileData);
441
+ },
442
+ resetNIDScreen: function (state) {
443
+ state.data.nidData = __assign(__assign({}, state.data.nidData), initialState.data.nidData);
444
+ },
445
+ resetOTPScreen: function (state) {
446
+ state.data.otpData = __assign(__assign({}, state.data.otpData), initialState.data.otpData);
447
+ },
448
+ resetPasswordScreen: function (state) {
449
+ state.data.passwordData = initialState.data.passwordData;
450
+ },
451
+ resetIndividualScreen: function (state) {
452
+ state.data.individualData = initialState.data.individualData;
453
+ },
454
+ resetMerchantScreen: function (state) {
455
+ state.data.brandData = initialState.data.brandData;
438
456
  }
439
457
  },
440
458
  extraReducers: function (builder) {
@@ -643,6 +661,6 @@ export var connectSlice = createSlice({
643
661
  });
644
662
  }
645
663
  });
646
- export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader;
664
+ export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetMobileScreen = _a.resetMobileScreen, resetOTPScreen = _a.resetOTPScreen, resetIndividualScreen = _a.resetIndividualScreen, resetMerchantScreen = _a.resetMerchantScreen, resetNIDScreen = _a.resetNIDScreen, resetPasswordScreen = _a.resetPasswordScreen;
647
665
  export default connectSlice.reducer;
648
666
  export var connectSelector = function (state) { return state.connect; };
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import * as React from 'react';
14
+ import { useSelector } from 'react-redux';
14
15
  import { styled } from '@mui/material/styles';
15
16
  import ActivitiesList from './ActivitiesList';
16
17
  import { useForm, FormProvider } from 'react-hook-form';
@@ -18,36 +19,34 @@ import { useAppDispatch, useLanguage } from '../../../../hooks';
18
19
  import Form from '../../../../components/Form';
19
20
  import { yupResolver } from '@hookform/resolvers/yup';
20
21
  import { useTranslation } from 'react-i18next';
21
- import { ActivitiesValidationSchema } from './validation';
22
22
  import { handlePrevScreenStep } from '../../../../app/settings';
23
- import { ACTIVITIES, SALES_CHANNELS } from '../../../../constants';
24
23
  import Button from '../../../shared/Button';
25
24
  import SalesChannels from './SalesChannels';
26
25
  import { ScreenContainer } from '../../../shared/Containers';
27
26
  import Collapse from '../../../../components/Collapse';
28
27
  import OperationStartDate from './OperationStartDate';
29
- import { updateEntityInfo } from '../../../app/business/businessStore';
28
+ import { businessSelector, updateActivitiesInfo } from '../../../app/business/businessStore';
29
+ import { ActivitiesValidationSchema } from './validation';
30
30
  var FormStyled = styled(Form)(function () { return ({
31
31
  display: 'flex',
32
32
  flexDirection: 'column'
33
33
  }); });
34
34
  var Activities = function () {
35
- var _a = React.useState(false), anchorEl = _a[0], setAnchorEl = _a[1];
36
- var _b = React.useState(false), collapse = _b[0], setCollapse = _b[1];
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];
37
38
  var dispatch = useAppDispatch();
38
39
  var isAr = useLanguage().isAr;
39
40
  var t = useTranslation().t;
41
+ var data = useSelector(businessSelector).data;
42
+ var response = data.businessInfo.responseBody;
40
43
  var methods = useForm({
41
44
  resolver: yupResolver(ActivitiesValidationSchema),
42
- defaultValues: {
43
- activities: [ACTIVITIES[0]],
44
- salesChannels: [SALES_CHANNELS[0]],
45
- operationStartDate: '2000-01-01'
46
- },
45
+ defaultValues: data.activitiesData,
47
46
  mode: 'onChange'
48
47
  });
49
48
  var onSubmit = function (data) {
50
- dispatch(updateEntityInfo(__assign(__assign({}, data), { isResend: false })));
49
+ dispatch(updateActivitiesInfo(__assign({}, data)));
51
50
  };
52
51
  var handleCollapseOpenClose = function (flag) {
53
52
  console.log('flag', flag);
@@ -59,6 +58,7 @@ var Activities = function () {
59
58
  var handleMenuClick = function () {
60
59
  anchorEl ? setAnchorEl(false) : setAnchorEl(true);
61
60
  };
62
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse }, { children: [!!ACTIVITIES && (_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: !methods.formState.isValid }, { children: t('next') })) }))] })) })) }));
61
+ var activities_list = ((_a = response === null || response === void 0 ? void 0 : response.activities) === null || _a === void 0 ? void 0 : _a.length) > 0;
62
+ 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: !methods.formState.isValid }, { children: t('next') })) }))] })) })) }));
63
63
  };
64
64
  export default Activities;
@@ -31,6 +31,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
31
31
  };
32
32
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
33
33
  import * as React from 'react';
34
+ import { useSelector } from 'react-redux';
34
35
  import Box from '@mui/material/Box';
35
36
  import { alpha, styled } from '@mui/material/styles';
36
37
  import Text from '../../../../components/Text';
@@ -38,12 +39,12 @@ import Input from '../../../../components/Input';
38
39
  import { useTranslation } from 'react-i18next';
39
40
  import { useController, useFormContext } from 'react-hook-form';
40
41
  import { useLanguage } from '../../../../hooks';
41
- import { ACTIVITIES } from '../../../../constants';
42
42
  import { BusinessType } from '../../../../@types';
43
43
  import Collapse from '../../../../components/Collapse';
44
44
  import SimpleList from '../../../../components/SimpleList';
45
45
  import ExpandIcon from '../../../../components/ExpandIcon';
46
46
  import { ScreenContainer } from '../../../shared/Containers';
47
+ import { businessSelector } from '../../../app/business/businessStore';
47
48
  import CheckIcon from '@mui/icons-material/Check';
48
49
  import { MandatoryStyled } from './SalesChannels';
49
50
  export var InputLabelStyled = styled(Text)(function (_a) {
@@ -76,15 +77,24 @@ export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { r
76
77
  });
77
78
  var ActivitiesList = function (_a) {
78
79
  var rest = __rest(_a, []);
79
- var activitiesMenuList = React.useState(ACTIVITIES)[0];
80
- var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
80
+ var _b = React.useState([]), activitiesMenuList = _b[0], setActivitiesMenuList = _b[1];
81
+ var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
81
82
  var t = useTranslation().t;
82
83
  var isAr = useLanguage().isAr;
83
84
  var control = useFormContext().control;
84
85
  var activitiesControl = useController({ name: 'activities', control: control });
85
86
  var controlValue = activitiesControl.field.value;
86
- var businessType = BusinessType.CR;
87
+ var data = useSelector(businessSelector).data;
88
+ var businessTypeData = data.businessTypeData;
89
+ var response = businessTypeData.responseBody;
90
+ var businessType = businessTypeData.businessType;
87
91
  var isCR = businessType === BusinessType.CR;
92
+ React.useEffect(function () {
93
+ var _a;
94
+ if (((_a = response === null || response === void 0 ? void 0 : response.activities) === null || _a === void 0 ? void 0 : _a.length) > 0) {
95
+ setActivitiesMenuList(response === null || response === void 0 ? void 0 : response.activities);
96
+ }
97
+ }, [response === null || response === void 0 ? void 0 : response.activities]);
88
98
  var onOpenList = function (event) {
89
99
  var _a;
90
100
  setAnchorEl(event.currentTarget);
@@ -20,13 +20,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
20
  };
21
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
22
  import * as React from 'react';
23
+ import { useSelector } from 'react-redux';
23
24
  import Box from '@mui/material/Box';
24
25
  import { alpha, styled } from '@mui/material/styles';
25
26
  import { useTranslation } from 'react-i18next';
26
27
  import { useController, useFormContext } from 'react-hook-form';
27
28
  import { useLanguage } from '../../../../hooks';
28
29
  import Text from '../../../../components/Text';
29
- import { SALES_CHANNELS } from '../../../../constants';
30
+ import { businessSelector } from '../../../app/business/businessStore';
30
31
  import CheckBox from '../../../../components/CheckBox';
31
32
  import Warning from '../../../../components/Warning';
32
33
  import Collapse from '../../../../components/Collapse';
@@ -75,13 +76,21 @@ export var CollapseStyled = styled(Collapse)(function (_a) {
75
76
  });
76
77
  var SalesChannels = function () {
77
78
  var _a;
78
- var channelsMenuList = React.useState(SALES_CHANNELS)[0];
79
+ var _b = React.useState([]), channelsMenuList = _b[0], setChannelsMenuList = _b[1];
79
80
  var t = useTranslation().t;
80
81
  var isAr = useLanguage().isAr;
81
82
  var control = useFormContext().control;
82
83
  var channelsControl = useController({ name: 'salesChannels', control: control });
83
84
  var channelsChecked = channelsControl.field.value;
84
85
  var warningMessage = (_a = channelsControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
86
+ var data = useSelector(businessSelector).data;
87
+ var response = data.businessInfo.responseBody;
88
+ React.useEffect(function () {
89
+ var _a;
90
+ if (((_a = response === null || response === void 0 ? void 0 : response.channelList) === null || _a === void 0 ? void 0 : _a.length) > 0) {
91
+ setChannelsMenuList(response === null || response === void 0 ? void 0 : response.channelList);
92
+ }
93
+ }, [response === null || response === void 0 ? void 0 : response.channelList]);
85
94
  var handleSalesChannelChange = function (event, checked) {
86
95
  var selected = channelsMenuList.find(function (channel) { return channel.id.toString() === event.target.id; });
87
96
  var isExists = channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.find(function (channel) { return channel.id === (selected === null || selected === void 0 ? void 0 : selected.id); });
@@ -15,13 +15,13 @@ import { useSelector } from 'react-redux';
15
15
  import { styled } from '@mui/material/styles';
16
16
  import { useAppDispatch, useLanguage } from '../../../../hooks';
17
17
  import { useTranslation } from 'react-i18next';
18
- import { handleNextScreenStep, handlePrevScreenStep } from '../../../../app/settings';
18
+ import { handlePrevScreenStep } from '../../../../app/settings';
19
19
  import { FormProvider, useForm } from 'react-hook-form';
20
20
  import Form from '../../../../components/Form';
21
21
  import Input from '../../../shared/Input';
22
22
  import Button from '../../../shared/Button';
23
23
  import { ScreenContainer } from '../../../shared/Containers';
24
- import { businessSelector } from '../../../app/business/businessStore';
24
+ import { businessSelector, createAccount } from '../../../app/business/businessStore';
25
25
  import { BusinessType as BusinessTypeEnum } from '../../../../@types';
26
26
  var InputStyled = styled(Input)(function (_a) {
27
27
  var theme = _a.theme;
@@ -41,7 +41,7 @@ var Confirm = function () {
41
41
  var _a = data.businessInfo, licenseNumber = _a.licenseNumber, brandName = _a.brandName, legalName = _a.legalName;
42
42
  var isCR = data.businessTypeData.businessType === BusinessTypeEnum.CR;
43
43
  var onSubmit = function () {
44
- dispatch(handleNextScreenStep());
44
+ dispatch(createAccount());
45
45
  };
46
46
  var methods = useForm({
47
47
  defaultValues: data.businessInfo,
@@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next';
17
17
  import { useForm, FormProvider } from 'react-hook-form';
18
18
  import { yupResolver } from '@hookform/resolvers/yup';
19
19
  import { useAppDispatch } from '../../../../hooks';
20
- import { handleNextScreenStep, handlePrevScreenStep } from '../../../../app/settings';
20
+ import { handlePrevScreenStep } from '../../../../app/settings';
21
21
  import { CustomerInfoValidation } from './validation';
22
22
  import Form from '../../../../components/Form';
23
23
  import Button from '../../../shared/Button';
@@ -30,6 +30,7 @@ import RefundPolicy from './RefundPolicy';
30
30
  import TransactionPolicy from './TransactionPolicy';
31
31
  import { ScreenContainer } from '../../../shared/Containers';
32
32
  import Collapse from '../../../../components/Collapse';
33
+ import { updateCustomersInfo } from '../../../app/business/businessStore';
33
34
  var FormStyled = styled(Form)(function () { return ({
34
35
  display: 'flex',
35
36
  flexDirection: 'column'
@@ -56,7 +57,7 @@ var Customers = function (_a) {
56
57
  });
57
58
  var onSubmit = function (data) {
58
59
  console.log('data', data);
59
- dispatch(handleNextScreenStep());
60
+ dispatch(updateCustomersInfo(__assign(__assign({}, data), { isResend: false })));
60
61
  };
61
62
  var onBack = function () {
62
63
  dispatch(handlePrevScreenStep());
@@ -55,6 +55,6 @@ var IDBOD = function (_a) {
55
55
  dispatch(handlePrevScreenStep());
56
56
  };
57
57
  var disabled = !methods.formState.isValid || !!error;
58
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(ID, {}) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(Button, __assign({ loading: loading, sx: { mt: 6 }, isAr: isAr, disabled: disabled, onClick: function () { return onBack(); }, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
58
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(ID, {}) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(Button, __assign({ loading: loading, sx: { mt: 6 }, isAr: isAr, disabled: disabled, onBackClicked: function () { return onBack(); }, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
59
59
  };
60
60
  export default React.memo(IDBOD);
@@ -1,9 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
+ import { useAppDispatch } from '../../../../hooks';
3
4
  import { useTranslation } from 'react-i18next';
4
5
  import SuccessScreen from '../../../shared/SuccessScreen';
6
+ import { updateLeadSuccess } from '../../../app/business/businessStore';
5
7
  var Success = function (_a) {
6
8
  var t = useTranslation().t;
9
+ var dispatch = useAppDispatch();
10
+ React.useEffect(function () {
11
+ dispatch(updateLeadSuccess());
12
+ }, []);
7
13
  var onSuccess = function () {
8
14
  window.open('mailto:');
9
15
  };
@@ -20,6 +20,7 @@ import Box from '@mui/material/Box/Box';
20
20
  import { styled } from '@mui/material/styles';
21
21
  import { handlePrevScreenStep } from '../../../../app/settings';
22
22
  import { useLanguage } from '../../../../hooks';
23
+ import { maskPhone } from '../../../../utils';
23
24
  import Form from '../../../../components/Form';
24
25
  import Text from '../../../../components/Text';
25
26
  import { ScreenContainer } from '../../../shared/Containers';
@@ -69,6 +70,6 @@ var VerifyNumber = function (_a) {
69
70
  };
70
71
  var disabled = !methods.formState.isValid || !!error;
71
72
  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) || '';
72
- 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(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') }))] })) })) }));
73
+ 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') }))] })) })) }));
73
74
  };
74
75
  export default React.memo(VerifyNumber);
@@ -24,7 +24,7 @@ import { IndividualValidation, IndividualMobileValidation } from './validation';
24
24
  import Form from '../../../../components/Form';
25
25
  import Button from '../../../shared/Button';
26
26
  import { ScreenContainer } from '../../../shared/Containers';
27
- import { clearError, connectSelector, updateLeadIndividual } from '../../../app/connect/connectStore';
27
+ import { clearError, connectSelector, resetIndividualScreen, updateLeadIndividual } from '../../../app/connect/connectStore';
28
28
  import { useLanguage } from '../../../../hooks';
29
29
  import MobileNumber from './MobileNumber';
30
30
  import { countriesCode } from '../../../../constants';
@@ -58,6 +58,11 @@ var Individual = function (_a) {
58
58
  if (error)
59
59
  dispatch(clearError());
60
60
  }, [methods.formState.isValid]);
61
+ React.useEffect(function () {
62
+ return function () {
63
+ dispatch(resetIndividualScreen());
64
+ };
65
+ }, []);
61
66
  React.useEffect(function () {
62
67
  var name = individualData.name, email = individualData.email, mobile = individualData.mobile, countryCode = individualData.countryCode;
63
68
  if (!!name)
@@ -20,7 +20,7 @@ import { handlePrevScreenStep } from '../../../../app/settings';
20
20
  import Form from '../../../../components/Form';
21
21
  import { ScreenContainer } from '../../../shared/Containers';
22
22
  import Button from '../../../shared/Button';
23
- import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
23
+ import { clearError, connectSelector, resetMerchantScreen, updateLeadBrand } from '../../../app/connect/connectStore';
24
24
  import { useLanguage } from '../../../../hooks';
25
25
  import { MerchantValidationSchema } from './validation';
26
26
  import BrandName from './BrandName';
@@ -47,6 +47,11 @@ var Merchant = function (_a) {
47
47
  if (error)
48
48
  dispatch(clearError());
49
49
  }, [methods.formState.isValid]);
50
+ React.useEffect(function () {
51
+ return function () {
52
+ dispatch(resetMerchantScreen());
53
+ };
54
+ }, []);
50
55
  React.useEffect(function () {
51
56
  var _a, _b;
52
57
  if (((_b = (_a = data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) === '5')
@@ -23,7 +23,7 @@ import Button, { AbsherButton } from '../../../shared/Button';
23
23
  import { useAppDispatch } from '../../../../hooks';
24
24
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
25
25
  import ScreenContainer from '../../../shared/Containers/ScreenContainer';
26
- import { clearError, connectSelector, createMobileAuth } from '../../../app/connect/connectStore';
26
+ import { clearError, resetMobileScreen, connectSelector, createMobileAuth } from '../../../app/connect/connectStore';
27
27
  import { useLanguage } from '../../../../hooks';
28
28
  import Divider from '@mui/material/Divider';
29
29
  import Text from '../../../../components/Text';
@@ -101,6 +101,11 @@ var Mobile = function (_a) {
101
101
  if (error)
102
102
  dispatch(clearError());
103
103
  }, [methods.formState.isValid]);
104
+ React.useEffect(function () {
105
+ return function () {
106
+ dispatch(resetMobileScreen());
107
+ };
108
+ }, []);
104
109
  var onSubmit = function (formData) {
105
110
  dispatch(createMobileAuth(__assign(__assign({}, formData), { isResend: false })));
106
111
  };
@@ -19,7 +19,7 @@ import { yupResolver } from '@hookform/resolvers/yup';
19
19
  import { NIDValidationSchema } from './validation';
20
20
  import { useAppDispatch, useLanguage } from '../../../../hooks';
21
21
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
22
- import { clearError, connectSelector, createNIDAuth } from '../../../app/connect/connectStore';
22
+ import { clearError, resetNIDScreen, connectSelector, createNIDAuth } from '../../../app/connect/connectStore';
23
23
  import Form from '../../../../components/Form';
24
24
  import Button, { AbsherButton } from '../../../shared/Button';
25
25
  import { ScreenContainer } from '../../../shared/Containers';
@@ -73,6 +73,11 @@ var NID = function (_a) {
73
73
  React.useEffect(function () {
74
74
  handleClearError();
75
75
  }, [methods.formState.isValid]);
76
+ React.useEffect(function () {
77
+ return function () {
78
+ dispatch(resetNIDScreen());
79
+ };
80
+ }, []);
76
81
  var onSubmit = function (data) {
77
82
  dispatch(createNIDAuth(__assign(__assign({}, data), { isResend: false })));
78
83
  };
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
16
16
  import * as React from 'react';
17
17
  import { useTranslation } from 'react-i18next';
18
18
  import Text from '../../../../components/Text';
19
- import { clearError, connectSelector, verifyAuth } from '../../../app/connect/connectStore';
19
+ import { clearError, connectSelector, resetOTPScreen, verifyAuth } from '../../../app/connect/connectStore';
20
20
  import Button from '../../../shared/Button';
21
21
  import { ScreenContainer } from '../../../shared/Containers';
22
22
  import { useAppDispatch } from '../../../../hooks';
@@ -63,6 +63,11 @@ var OTP = function () {
63
63
  if (error)
64
64
  dispatch(clearError());
65
65
  }, [methods.formState.isValid]);
66
+ React.useEffect(function () {
67
+ return function () {
68
+ dispatch(resetOTPScreen());
69
+ };
70
+ }, []);
66
71
  var onSubmit = function (formData) {
67
72
  dispatch(verifyAuth(formData));
68
73
  };
@@ -37,9 +37,6 @@ var OTPInput = function (_a) {
37
37
  var mobileData = data.mobileData;
38
38
  var nidData = data.nidData;
39
39
  var isAbsher = data.otpData.isAbsher;
40
- React.useEffect(function () {
41
- otpControl.field.onChange('');
42
- }, []);
43
40
  var handleOnOTPChange = function (otp) {
44
41
  otpControl.field.onChange(otp);
45
42
  };
@@ -18,7 +18,7 @@ import { useTranslation } from 'react-i18next';
18
18
  import { yupResolver } from '@hookform/resolvers/yup';
19
19
  import { styled } from '@mui/material/styles';
20
20
  import { handlePrevScreenStep } from '../../../../app/settings';
21
- import { clearError, connectSelector, createVerifyAuthPassword } from '../../../app/connect/connectStore';
21
+ import { clearError, connectSelector, createVerifyAuthPassword, resetPasswordScreen } from '../../../app/connect/connectStore';
22
22
  import Form from '../../../../components/Form';
23
23
  import Button from '../../../shared/Button';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
@@ -46,6 +46,11 @@ var Password = function (_a) {
46
46
  if (error)
47
47
  dispatch(clearError());
48
48
  }, [methods.formState.isValid]);
49
+ React.useEffect(function () {
50
+ return function () {
51
+ dispatch(resetPasswordScreen());
52
+ };
53
+ }, []);
49
54
  var onSubmit = function (formData) {
50
55
  dispatch(createVerifyAuthPassword(formData));
51
56
  };
@@ -60,6 +60,7 @@ export var capitalizeTheFirstLetterOfEachWord = function (words) {
60
60
  return separateWord.join(' ');
61
61
  };
62
62
  export var getRequestHeaders = function (deviceInfo) {
63
+ console.log(deviceInfo);
63
64
  var app = deviceInfo.app, browser = deviceInfo.browser, connection = deviceInfo.connection, device = deviceInfo.device, source = deviceInfo.source;
64
65
  return {
65
66
  al: encryptString(app.language || ''),
@@ -78,7 +79,7 @@ export var getRequestHeaders = function (deviceInfo) {
78
79
  bn: encryptString(browser.name || ''),
79
80
  bb: encryptString(''),
80
81
  bv: encryptString(browser.version || ''),
81
- bua: encryptString(browser.user_agent),
82
+ bua: encryptString((browser.user_agent || '').substring(0, 80)),
82
83
  bi: encryptString(browser.browser_id || ''),
83
84
  ci: encryptString(connection.ip || ''),
84
85
  cm: encryptString(connection.mac || ''),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",