@tap-payments/auth-jsconnect 2.1.5-test → 2.1.7-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/build/api/entity.d.ts +1 -1
  2. package/build/app/settings.d.ts +1 -0
  3. package/build/app/settings.js +1 -1
  4. package/build/constants/app.d.ts +1 -0
  5. package/build/constants/app.js +11 -4
  6. package/build/features/app/business/businessStore.js +1 -1
  7. package/build/features/app/entity/entityStore.d.ts +11 -1
  8. package/build/features/app/entity/entityStore.js +139 -4
  9. package/build/features/app/password/passwordStore.d.ts +1 -7
  10. package/build/features/app/password/passwordStore.js +27 -16
  11. package/build/features/bank/screens/BankDetails/IBAN.js +4 -1
  12. package/build/features/connect/screens/Merchant/Merchant.js +10 -4
  13. package/build/features/connect/screens/Merchant/SalesChannels.d.ts +2 -1
  14. package/build/features/connect/screens/Merchant/SalesChannels.js +4 -6
  15. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +3 -1
  16. package/build/features/connect/screens/Merchant/SocialMedia.js +7 -33
  17. package/build/features/connect/screens/Merchant/validation.js +3 -5
  18. package/build/features/entity/screens/Customers/CustomerLocations.d.ts +118 -0
  19. package/build/features/entity/screens/Customers/CustomerLocations.js +171 -0
  20. package/build/features/entity/screens/Customers/Customers.d.ts +5 -0
  21. package/build/features/entity/screens/Customers/Customers.js +90 -0
  22. package/build/features/entity/screens/Customers/ExpectedCustomers.d.ts +8 -0
  23. package/build/features/entity/screens/Customers/ExpectedCustomers.js +98 -0
  24. package/build/features/entity/screens/Customers/ExpectedSalesRange.d.ts +8 -0
  25. package/build/features/entity/screens/Customers/ExpectedSalesRange.js +127 -0
  26. package/build/features/entity/screens/Customers/RefundPolicy.d.ts +36 -0
  27. package/build/features/entity/screens/Customers/RefundPolicy.js +84 -0
  28. package/build/features/entity/screens/Customers/TransactionPolicy.d.ts +3 -0
  29. package/build/features/entity/screens/Customers/TransactionPolicy.js +44 -0
  30. package/build/features/entity/screens/Customers/index.d.ts +3 -0
  31. package/build/features/entity/screens/Customers/index.js +2 -0
  32. package/build/features/entity/screens/Customers/validation.d.ts +20 -0
  33. package/build/features/entity/screens/Customers/validation.js +13 -0
  34. package/build/features/featuresScreens.js +5 -0
  35. package/build/features/password/screens/Success/Success.js +7 -3
  36. package/build/hooks/useAppConfig.js +1 -1
  37. package/build/utils/array.d.ts +1 -0
  38. package/build/utils/array.js +8 -0
  39. package/package.json +129 -129
@@ -56,7 +56,7 @@ export declare type UploadFileBody = {
56
56
  };
57
57
  export declare type UpdateEntityBody = {
58
58
  id: string;
59
- license: {
59
+ license?: {
60
60
  type?: string;
61
61
  number?: string;
62
62
  additional_info?: {
@@ -9,6 +9,7 @@ export declare const fetchAppSettingsSync: import("@reduxjs/toolkit").AsyncThunk
9
9
  }, {
10
10
  disableCountries?: boolean | undefined;
11
11
  disableLocale?: boolean | undefined;
12
+ mdn: string;
12
13
  }, {}>;
13
14
  export interface SettingsData {
14
15
  skin: ThemeMode;
@@ -107,7 +107,7 @@ export var fetchAppSettingsSync = createAsyncThunk('fetchAppSettingsSync', funct
107
107
  },
108
108
  source: 'browser'
109
109
  };
110
- setAxiosGlobalHeaders(__assign(__assign({}, getRequestHeaders(deviceInfo)), { authorization: encryptString(appConfig.publicKey), mdn: encryptString(window.location.origin) }));
110
+ setAxiosGlobalHeaders(__assign(__assign({}, getRequestHeaders(deviceInfo)), { authorization: encryptString(appConfig.publicKey), mdn: encryptString(params.mdn || window.location.origin) }));
111
111
  return [4, API.operatorService.validateOperator(operatorData)];
112
112
  case 2:
113
113
  operatorStatus = _e.sent();
@@ -132,6 +132,7 @@ export declare const PASSWORD_STEP_NAMES: {
132
132
  export declare const ENTITY_STEP_NAMES: {
133
133
  PHONE_AUTH: string;
134
134
  ENTITY_INFO: string;
135
+ ENTITY_CUSTOMER: string;
135
136
  ENTITY_SUCCESS: string;
136
137
  };
137
138
  export declare const RSA_FRONTEND_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgC9kH1SQvjbXAUXd0PbrDUG8P\nLhRig9pJNBmdQBZjihuaxfkzYu6ToMbIMAfmYgVgQw338/y7aQ8X3m03CXNIlkxo\nOwxKCA8ymKsZQptXJn9IxlPO7yjoFgTFBrpmTgvcC4XO1uoUYTAPq3szK8kj4zgT\nucWG1hSKsOdRU7sl/wIDAQAB\n-----END PUBLIC KEY-----";
@@ -316,21 +316,27 @@ export var ENTITY_SCREENS_NAVIGATION = [
316
316
  },
317
317
  {
318
318
  name: 'ENTITY_INFO_STEP',
319
- next: 'ENTITY_DETAILS_SUCCESS_STEP',
319
+ next: 'ENTITY_CUSTOMERS_STEP',
320
320
  prev: 'ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
321
321
  order: 2
322
322
  },
323
323
  {
324
- name: 'ENTITY_DETAILS_SUCCESS_STEP',
325
- next: 'ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
324
+ name: 'ENTITY_CUSTOMERS_STEP',
325
+ next: 'ENTITY_DETAILS_SUCCESS_STEP',
326
326
  prev: 'ENTITY_INFO_STEP',
327
327
  order: 3
328
328
  },
329
+ {
330
+ name: 'ENTITY_DETAILS_SUCCESS_STEP',
331
+ next: 'ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
332
+ prev: 'ENTITY_CUSTOMERS_STEP',
333
+ order: 4
334
+ },
329
335
  {
330
336
  name: 'ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
331
337
  next: 'ENTITY_RESET_PASSWORD_SUCCESS',
332
338
  prev: '',
333
- order: 4
339
+ order: 5
334
340
  },
335
341
  {
336
342
  name: 'ENTITY_RESET_PASSWORD_SUCCESS',
@@ -461,6 +467,7 @@ export var PASSWORD_STEP_NAMES = {
461
467
  export var ENTITY_STEP_NAMES = {
462
468
  PHONE_AUTH: 'entity_phone_auth',
463
469
  ENTITY_INFO: 'entity_info',
470
+ ENTITY_CUSTOMER: 'entity_customer',
464
471
  ENTITY_SUCCESS: 'entity_completed'
465
472
  };
466
473
  export var RSA_FRONTEND_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgC9kH1SQvjbXAUXd0PbrDUG8P\nLhRig9pJNBmdQBZjihuaxfkzYu6ToMbIMAfmYgVgQw338/y7aQ8X3m03CXNIlkxo\nOwxKCA8ymKsZQptXJn9IxlPO7yjoFgTFBrpmTgvcC4XO1uoUYTAPq3szK8kj4zgT\nucWG1hSKsOdRU7sl/wIDAQAB\n-----END PUBLIC KEY-----";
@@ -723,7 +723,7 @@ var initialState = {
723
723
  },
724
724
  activitiesData: {
725
725
  activities: [],
726
- operationStartDate: new Date().toString()
726
+ operationStartDate: moment(new Date()).format('YYYY-MM-DD')
727
727
  },
728
728
  customersData: {
729
729
  customerLocations: [],
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { EntityFormValues, FlowsTypes, OTPFormValues, ResponseData, SharedState } from '../../../@types';
2
+ import { CustomersFormValues, EntityFormValues, FlowsTypes, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
3
  export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
4
4
  data: any;
5
5
  boardResponse: {
@@ -47,6 +47,15 @@ interface UploadArticleParams {
47
47
  export declare const uploadArticle: import("@reduxjs/toolkit").AsyncThunk<{
48
48
  data: any;
49
49
  }, UploadArticleParams, {}>;
50
+ export declare const updateCustomersInfo: import("@reduxjs/toolkit").AsyncThunk<{
51
+ data: any;
52
+ formData: CustomersFormValues;
53
+ }, CustomersFormValues, {}>;
54
+ export declare const retrieveDataList: import("@reduxjs/toolkit").AsyncThunk<{
55
+ customerBases: any;
56
+ expectedSales: any;
57
+ expectedCustomerSales: any;
58
+ }, void, {}>;
50
59
  export declare const updateBoardSuccess: import("@reduxjs/toolkit").AsyncThunk<{
51
60
  response: any;
52
61
  formData: void;
@@ -58,6 +67,7 @@ export interface EntityData {
58
67
  verify: ResponseData & VerifyData;
59
68
  otpData: OTPFormValues & ResponseData;
60
69
  entityData: EntityFormValues & ResponseData;
70
+ customersData: CustomersFormValues & ResponseData;
61
71
  flowName: FlowsTypes;
62
72
  }
63
73
  export interface EntityState extends SharedState<EntityData> {
@@ -266,18 +266,20 @@ export var updateEntity = createAsyncThunk('entityUpdateEntity', function (param
266
266
  payload = {
267
267
  id: id,
268
268
  license: {
269
- number: params.licenseNumber
269
+ number: params.licenseNumber && params.licenseNumber,
270
+ type: params.licenseType
270
271
  },
271
272
  legal_name: {
272
273
  ar: params.licenseName,
273
274
  en: params.licenseName
274
275
  },
275
276
  AOA_file_id: articleId,
276
- encryption_contract: ['license.number', 'legal_name.ar', 'legal_name.en']
277
+ encryption_contract: ['license.number', 'legal_name.ar', 'legal_name.en', 'license.type']
277
278
  };
278
279
  return [4, API.entityService.updateEntity(payload)];
279
280
  case 2:
280
281
  data = _j.sent();
282
+ thunkApi.dispatch(retrieveDataList());
281
283
  thunkApi.dispatch(handleNextScreenStep());
282
284
  (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, id);
283
285
  return [2, { data: __assign(__assign({}, data), brandData), formData: params }];
@@ -313,6 +315,66 @@ export var uploadArticle = createAsyncThunk('entityUploadArticle', function (_a)
313
315
  });
314
316
  });
315
317
  });
318
+ export var updateCustomersInfo = createAsyncThunk('entityUpdateCustomersInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
319
+ var _a, settings, entity, id, customerLocation, customerBase, sales, requestBody, data;
320
+ var _b, _c, _d, _e, _f, _g;
321
+ return __generator(this, function (_h) {
322
+ switch (_h.label) {
323
+ case 0:
324
+ _a = thunkApi.getState(), settings = _a.settings, entity = _a.entity;
325
+ id = (_c = (_b = entity.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.id;
326
+ customerLocation = params.customerLocations.map(function (location) { return ({
327
+ id: location === null || location === void 0 ? void 0 : location.id
328
+ }); });
329
+ customerBase = { id: ((_d = params.expectedCustomer) === null || _d === void 0 ? void 0 : _d.id) || '', period: 'monthly', locations: customerLocation };
330
+ sales = { id: ((_e = params.expectedSale) === null || _e === void 0 ? void 0 : _e.id) || '', period: 'monthly' };
331
+ requestBody = {
332
+ operations: {
333
+ customer_base: customerBase,
334
+ sales: sales,
335
+ start_date: entity.data.entityData.operationStartDate
336
+ },
337
+ term: ['refund', 'chargeback'],
338
+ id: id,
339
+ encryption_contract: []
340
+ };
341
+ return [4, API.brandService.updateBrandInfo(requestBody)];
342
+ case 1:
343
+ data = _h.sent();
344
+ thunkApi.dispatch(handleNextScreenStep());
345
+ (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, requestBody);
346
+ return [2, { data: data === null || data === void 0 ? void 0 : data.brand, formData: params }];
347
+ }
348
+ });
349
+ }); });
350
+ export var retrieveDataList = createAsyncThunk('entityRetrieveDataList', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
351
+ var settings, dataBody, salesDataBody, _a, customerBases, expectedSales, expectedCustomerSales;
352
+ return __generator(this, function (_b) {
353
+ switch (_b.label) {
354
+ case 0:
355
+ settings = thunkApi.getState().settings;
356
+ dataBody = {
357
+ page: 0
358
+ };
359
+ salesDataBody = {
360
+ page: 0,
361
+ country_code: [settings.data.businessCountry.iso2]
362
+ };
363
+ return [4, Promise.all([
364
+ API.dataService.getCustomerBases(dataBody),
365
+ API.dataService.getExpectedSales(salesDataBody),
366
+ API.dataService.getExpectedCustomerSales(dataBody)
367
+ ])];
368
+ case 1:
369
+ _a = _b.sent(), customerBases = _a[0], expectedSales = _a[1], expectedCustomerSales = _a[2];
370
+ return [2, {
371
+ customerBases: customerBases,
372
+ expectedSales: expectedSales,
373
+ expectedCustomerSales: expectedCustomerSales
374
+ }];
375
+ }
376
+ });
377
+ }); });
316
378
  export var updateBoardSuccess = createAsyncThunk('updateBoardEntitySuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
317
379
  var _a, settings, entity, _b, id, infoId, payload, data;
318
380
  var _c, _d, _e, _f;
@@ -359,8 +421,15 @@ var initialState = {
359
421
  licenseNumber: '',
360
422
  licenseType: BusinessType.CR,
361
423
  activities: [],
362
- operationStartDate: '',
424
+ operationStartDate: moment(new Date()).format('YYYY-MM-DD'),
363
425
  uploading: false
426
+ },
427
+ customersData: {
428
+ customerLocations: [],
429
+ expectedCustomer: undefined,
430
+ expectedSale: undefined,
431
+ refundPolicy: false,
432
+ transactionPolicy: false
364
433
  }
365
434
  }
366
435
  };
@@ -500,7 +569,7 @@ export var entitySlice = createSlice({
500
569
  return;
501
570
  }
502
571
  state.data.entityData = formData;
503
- state.data.entityData.responseBody = data;
572
+ state.data.entityData.responseBody = __assign(__assign({}, state.data.entityData.responseBody), { data: data });
504
573
  })
505
574
  .addCase(updateEntity.rejected, function (state, action) {
506
575
  state.loading = false;
@@ -519,6 +588,72 @@ export var entitySlice = createSlice({
519
588
  .addCase(retrieveBoardDetails.rejected, function (state, action) {
520
589
  state.error = action.error.message;
521
590
  state.loading = false;
591
+ })
592
+ .addCase(retrieveDataList.pending, function (state) {
593
+ state.loading = true;
594
+ state.error = null;
595
+ })
596
+ .addCase(retrieveDataList.fulfilled, function (state, action) {
597
+ var _a, _b, _c, _d, _e, _f;
598
+ state.loading = false;
599
+ state.error = null;
600
+ var payload = action.payload;
601
+ state.data.customersData.responseBody = payload;
602
+ var brand = (state.data.verify.responseBody || {}).brand;
603
+ var _g = (brand === null || brand === void 0 ? void 0 : brand.operations) || {}, customer_base = _g.customer_base, sales = _g.sales;
604
+ var customerBases = ((_a = payload.customerBases) === null || _a === void 0 ? void 0 : _a.list) || [];
605
+ var customerBase = undefined;
606
+ if ((customerBases === null || customerBases === void 0 ? void 0 : customerBases.length) > 1)
607
+ customerBase = [customerBases === null || customerBases === void 0 ? void 0 : customerBases[1], customerBases[0]];
608
+ else if ((customerBases === null || customerBases === void 0 ? void 0 : customerBases.length) === 1)
609
+ customerBase = [customerBases[0]];
610
+ if (((_b = customer_base === null || customer_base === void 0 ? void 0 : customer_base.locations) === null || _b === void 0 ? void 0 : _b.length) > 0) {
611
+ customerBase = customerBases === null || customerBases === void 0 ? void 0 : customerBases.filter(function (base) {
612
+ var _a;
613
+ return (_a = customer_base === null || customer_base === void 0 ? void 0 : customer_base.locations) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id === base.id; });
614
+ });
615
+ }
616
+ var expectedSales = ((_c = payload.expectedSales) === null || _c === void 0 ? void 0 : _c.list) || [];
617
+ var expectedSale = (_e = (_d = expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales[0]) === null || _d === void 0 ? void 0 : _d.sub) === null || _e === void 0 ? void 0 : _e[4];
618
+ if ((sales === null || sales === void 0 ? void 0 : sales.length) > 0) {
619
+ expectedSale = expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.find(function (sale) {
620
+ var _a;
621
+ return (_a = sales === null || sales === void 0 ? void 0 : sales.sub) === null || _a === void 0 ? void 0 : _a.find(function (s) { return s.id === sale.id; });
622
+ });
623
+ }
624
+ var expectedCustomerSales = ((_f = payload.expectedCustomerSales) === null || _f === void 0 ? void 0 : _f.list) || [];
625
+ var expectedCustomerSale = expectedCustomerSales === null || expectedCustomerSales === void 0 ? void 0 : expectedCustomerSales[3];
626
+ if ((customer_base === null || customer_base === void 0 ? void 0 : customer_base.length) > 0) {
627
+ expectedCustomerSale = expectedCustomerSales === null || expectedCustomerSales === void 0 ? void 0 : expectedCustomerSales.find(function (base) {
628
+ return customer_base.id === base.id;
629
+ });
630
+ }
631
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { customerBases: customerBases, expectedSales: expectedSales, expectedCustomerSales: expectedCustomerSales });
632
+ if (!!customerBase)
633
+ state.data.customersData.customerLocations = customerBase;
634
+ if (!!expectedSale)
635
+ state.data.customersData.expectedSale = expectedSale;
636
+ if (!!expectedCustomerSale)
637
+ state.data.customersData.expectedCustomer = expectedCustomerSale;
638
+ })
639
+ .addCase(retrieveDataList.rejected, function (state, action) {
640
+ state.loading = false;
641
+ state.error = action.error.message;
642
+ })
643
+ .addCase(updateCustomersInfo.pending, function (state) {
644
+ state.loading = true;
645
+ state.error = null;
646
+ })
647
+ .addCase(updateCustomersInfo.fulfilled, function (state, action) {
648
+ state.loading = false;
649
+ state.error = null;
650
+ var _a = action.payload, data = _a.data, formData = _a.formData;
651
+ state.data.customersData = formData;
652
+ state.data.customersData.responseBody = data;
653
+ })
654
+ .addCase(updateCustomersInfo.rejected, function (state, action) {
655
+ state.loading = false;
656
+ state.error = action.error.message;
522
657
  })
523
658
  .addCase(updateBoardSuccess.fulfilled, function (state, action) {
524
659
  var _a;
@@ -2,13 +2,7 @@ import { RootState } from '../../../app/store';
2
2
  import { FlowsTypes, OTPFormValues, PasswordCreateFormValues, ResponseData, SharedState } from '../../../@types';
3
3
  export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
4
4
  data: any;
5
- boardResponse: {
6
- flows: {
7
- name: string;
8
- status: string;
9
- url: string;
10
- }[];
11
- };
5
+ boardResponse: any;
12
6
  token: string;
13
7
  }, string, {}>;
14
8
  export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<{
@@ -49,13 +49,13 @@ var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import API from '../../../api';
51
51
  import { FlowsTypes } from '../../../@types';
52
- import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
52
+ import { handleCurrentActiveScreen, handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
53
53
  import { BUSINESS_FLOW_SUCCESS, PASSWORD_OPERATION_TYPE, PASSWORD_STEP_NAMES } from '../../../constants';
54
54
  export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
55
- var payload, data, boardInfoData, board_id, board_info_id, info, hasPasswordCompleted;
56
- var _a;
57
- return __generator(this, function (_b) {
58
- switch (_b.label) {
55
+ var payload, data, boardInfoData, boardData, board_id, board_info_id, countryIso2, info, hasPasswordCompleted;
56
+ var _a, _b, _c, _d;
57
+ return __generator(this, function (_e) {
58
+ switch (_e.label) {
59
59
  case 0:
60
60
  payload = {
61
61
  service_name: 'tap_email',
@@ -63,21 +63,28 @@ export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', functio
63
63
  };
64
64
  return [4, API.leadService.verifyLeadToken(payload)];
65
65
  case 1:
66
- data = (_b.sent()).data;
67
- boardInfoData = undefined;
68
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 5];
66
+ data = (_e.sent()).data;
67
+ boardData = undefined;
68
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 6];
69
69
  board_id = data === null || data === void 0 ? void 0 : data.id;
70
70
  board_info_id = data === null || data === void 0 ? void 0 : data.board_info_id;
71
- if (!(!!board_id && !!board_info_id)) return [3, 3];
71
+ if (!(board_id && board_info_id)) return [3, 3];
72
72
  return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
73
73
  case 2:
74
- boardInfoData = _b.sent();
75
- _b.label = 3;
76
- case 3: return [4, thunkApi.dispatch(retrieveBoardDetails(board_id))];
74
+ boardInfoData = _e.sent();
75
+ _e.label = 3;
76
+ case 3:
77
+ if (!board_id) return [3, 5];
78
+ return [4, API.boardService.retrieveBoardDetails(board_id)];
77
79
  case 4:
78
- _b.sent();
80
+ boardData = _e.sent();
81
+ _e.label = 5;
82
+ case 5:
83
+ countryIso2 = (_a = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _a === void 0 ? void 0 : _a.country;
84
+ if (countryIso2)
85
+ thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
79
86
  info = (boardInfoData || {}).info;
80
- hasPasswordCompleted = ((_a = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'password'; })) === null || _a === void 0 ? void 0 : _a.status) === 'completed';
87
+ hasPasswordCompleted = ((_b = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'password'; })) === null || _b === void 0 ? void 0 : _b.status) === 'completed';
81
88
  if (data.step_name === PASSWORD_STEP_NAMES.PHONE_AUTH) {
82
89
  thunkApi.dispatch(handleCurrentActiveScreen('PASSWORD_VERIFY_STEP'));
83
90
  }
@@ -87,8 +94,12 @@ export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', functio
87
94
  else if (data.step_name === PASSWORD_STEP_NAMES.PASSWORD_INFO) {
88
95
  thunkApi.dispatch(handleNextScreenStep('PASSWORD_CREATE_PASSWORD_STEP'));
89
96
  }
90
- _b.label = 5;
91
- case 5: return [2, { data: data, boardResponse: { flows: BUSINESS_FLOW_SUCCESS.concat((boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || []) }, token: token }];
97
+ _e.label = 6;
98
+ case 6: return [2, {
99
+ data: data,
100
+ boardResponse: __assign(__assign({}, boardData === null || boardData === void 0 ? void 0 : boardData.business), { flows: BUSINESS_FLOW_SUCCESS.concat((boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || []), user: boardData === null || boardData === void 0 ? void 0 : boardData.user, brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand, bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant, name: (_c = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _c === void 0 ? void 0 : _c.names, contact: (_d = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _d === void 0 ? void 0 : _d.contact }),
101
+ token: token
102
+ }];
92
103
  }
93
104
  });
94
105
  }); });
@@ -50,6 +50,8 @@ import axios from 'axios';
50
50
  import ClearIcon from '../../../shared/ClearIcon';
51
51
  import CheckIcon from '../../../shared/CheckIcon';
52
52
  import CircularProgress from '@mui/material/CircularProgress';
53
+ import { settingsSelector } from '../../../../app/settings';
54
+ import { useAppSelector } from '../../../../hooks';
53
55
  var InputStyled = styled(Input)(function () { return ({
54
56
  input: {
55
57
  textTransform: 'uppercase'
@@ -60,6 +62,7 @@ var IBAN = function (_a) {
60
62
  var _b;
61
63
  var fetchingIban = _a.fetchingIban, ibanChecking = _a.ibanChecking;
62
64
  var dispatch = useAppDispatch();
65
+ var settingsData = useAppSelector(settingsSelector).data;
63
66
  var t = useTranslation().t;
64
67
  var control = useFormContext().control;
65
68
  var ibanControl = useController({ name: 'iban', control: control });
@@ -92,6 +95,6 @@ var IBAN = function (_a) {
92
95
  var clearValue = function () {
93
96
  ibanControl.field.onChange('');
94
97
  };
95
- return (_jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('enter_iban'), inputProps: { maxLength: MAX_IBAN_VALUE }, onChange: handleIbanChange, value: ibanValue, placeholder: t('enter_iban_placeholder'), warningType: 'alert', warningMessage: error && t(error), required: true, endAdornment: ibanChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && ibanValue ? (_jsx(CheckIcon, {})) : (ibanValue && _jsx(ClearIcon, { onClick: clearValue })) }) }));
98
+ return (_jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('enter_iban'), inputProps: { maxLength: MAX_IBAN_VALUE }, onChange: handleIbanChange, value: ibanValue, placeholder: t('iban_input_placeholder', { countrycode: settingsData.businessCountry.iso2.toUpperCase() }), warningType: 'alert', warningMessage: error && t(error), required: true, endAdornment: ibanChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && ibanValue ? (_jsx(CheckIcon, {})) : (ibanValue && _jsx(ClearIcon, { onClick: clearValue })) }) }));
96
99
  };
97
100
  export default IBAN;
@@ -23,7 +23,7 @@ import Button from '../../../shared/Button';
23
23
  import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
24
24
  import { useLanguage } from '../../../../hooks';
25
25
  import { AuthForType } from '../../../../@types';
26
- import { isKW, mapSalesChannel } from '../../../../utils';
26
+ import { findFirstId, isKW, mapSalesChannel } from '../../../../utils';
27
27
  import { MerchantValidationSchema } from './validation';
28
28
  import BrandName from './BrandName';
29
29
  import SocialMedia from './SocialMedia';
@@ -35,11 +35,12 @@ var Merchant = function (_a) {
35
35
  var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
36
36
  var _e = React.useState(false), isBrandListOpen = _e[0], setIsBrandListOpen = _e[1];
37
37
  var _f = React.useState(false), isRequiredNewBrand = _f[0], setIsRequiredNewBrand = _f[1];
38
- var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
38
+ var _g = React.useState(''), activeIconId = _g[0], setActiveIconId = _g[1];
39
+ var _h = useAppSelector(connectSelector), data = _h.data, loading = _h.loading, error = _h.error;
39
40
  var settingsData = useAppSelector(settingsSelector).data;
40
41
  var isNewIndividual = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.is_new_individual;
41
42
  var startWithNID = data.otpData.authFor === AuthForType.NATIONAL_ID;
42
- var _h = data.brandData, brandName = _h.brandName, selectedBrandItem = _h.selectedBrandItem, termAndConditionChecked = _h.termAndConditionChecked, responseBody = _h.responseBody, salesChannels = _h.salesChannels;
43
+ var _j = data.brandData, brandName = _j.brandName, selectedBrandItem = _j.selectedBrandItem, termAndConditionChecked = _j.termAndConditionChecked, responseBody = _j.responseBody, salesChannels = _j.salesChannels;
43
44
  var brandList = (responseBody || {}).brand_list;
44
45
  var methods = useForm({
45
46
  resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
@@ -76,16 +77,21 @@ var Merchant = function (_a) {
76
77
  if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.response_code) === '5')
77
78
  methods.setError('brandName', { message: 'brand_name_already_exist' });
78
79
  }, [responseBody]);
80
+ var onSaleIconChange = function (id) {
81
+ setActiveIconId(id);
82
+ };
79
83
  React.useEffect(function () {
80
84
  if (selectedBrandItem.id) {
81
85
  methods.setValue('selectedBrandItem', selectedBrandItem);
82
86
  var sales = mapSalesChannel(selectedBrandItem.channel_services || []);
87
+ setActiveIconId(findFirstId(sales));
83
88
  methods.setValue('salesChannels', sales, { shouldValidate: true });
84
89
  }
85
90
  }, [selectedBrandItem]);
86
91
  React.useEffect(function () {
87
92
  if (salesChannels.length > 0) {
88
93
  var sales = mapSalesChannel(salesChannels);
94
+ setActiveIconId(findFirstId(sales));
89
95
  methods.setValue('salesChannels', sales, { shouldValidate: true });
90
96
  }
91
97
  }, [salesChannels]);
@@ -101,6 +107,6 @@ var Merchant = function (_a) {
101
107
  React.useEffect(function () {
102
108
  setIsRequiredNewBrand(isOtherBrand || isNewBrand);
103
109
  }, [isOtherBrand, isNewBrand]);
104
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: !(isOtherBrand || isNewBrand), list: brandList, onListOpen: function () { return setIsBrandListOpen(true); }, onListClose: function () { return setIsBrandListOpen(false); } }), _jsx(BrandName, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !isBrandListOpen }, { children: _jsx(SalesChannels, {}) })), _jsx(SocialMedia, { show: !isBrandListOpen }), _jsx(TAC, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen }), _jsx(Collapse, __assign({ in: !isBrandListOpen, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
110
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: !(isOtherBrand || isNewBrand), list: brandList, onListOpen: function () { return setIsBrandListOpen(true); }, onListClose: function () { return setIsBrandListOpen(false); } }), _jsx(BrandName, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !isBrandListOpen }, { children: _jsx(SalesChannels, { onSaleIconChange: onSaleIconChange }) })), _jsx(SocialMedia, { show: !isBrandListOpen, activeIconId: activeIconId, onSaleIconChange: onSaleIconChange }), _jsx(TAC, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen }), _jsx(Collapse, __assign({ in: !isBrandListOpen, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
105
111
  };
106
112
  export default React.memo(Merchant);
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  export declare const MandatoryStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
3
3
  export declare const CollapseStyled: import("@emotion/styled").StyledComponent<import("../../../../components/Collapse").CollapseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
4
4
  interface SalesChannelsProps {
5
+ onSaleIconChange: (id: string) => void;
5
6
  }
6
- declare const SalesChannels: ({}: SalesChannelsProps) => JSX.Element;
7
+ declare const SalesChannels: ({ onSaleIconChange }: SalesChannelsProps) => JSX.Element;
7
8
  export default SalesChannels;
@@ -29,6 +29,7 @@ import { connectSelector, clearError } from '../../../app/connect/connectStore';
29
29
  import CheckBox from '../../../../components/CheckBox';
30
30
  import Warning from '../../../../components/Warning';
31
31
  import Collapse from '../../../../components/Collapse';
32
+ import { findFirstId } from '../../../../utils';
32
33
  var InputLabelStyled = styled(Text)(function (_a) {
33
34
  var theme = _a.theme;
34
35
  return (__assign({ margin: theme.spacing(2.5, 2.5, 0.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
@@ -74,6 +75,7 @@ export var CollapseStyled = styled(Collapse)(function (_a) {
74
75
  });
75
76
  var SalesChannels = function (_a) {
76
77
  var _b;
78
+ var onSaleIconChange = _a.onSaleIconChange;
77
79
  var t = useTranslation().t;
78
80
  var isAr = useLanguage().isAr;
79
81
  var _c = useFormContext(), control = _c.control, getValues = _c.getValues;
@@ -90,16 +92,12 @@ var SalesChannels = function (_a) {
90
92
  dispatch(clearError());
91
93
  if (isChecked(channel.id)) {
92
94
  var filterChannels = channelsControl.field.value.filter(function (item) { return item.id !== channel.id; });
95
+ onSaleIconChange(findFirstId([filterChannels.at(-1)]));
93
96
  channelsControl.field.onChange(filterChannels);
94
97
  }
95
98
  else {
96
- var brandName = getValues('brandName');
99
+ onSaleIconChange(findFirstId([channel]));
97
100
  var newChannel = __assign({}, channel);
98
- if (newChannel.code === 'website' && brandName) {
99
- var brandValue = brandName.replaceAll(' ', '-').toLowerCase();
100
- var address = (brandValue[brandValue.length - 1] === '-' ? brandValue.slice(0, -1) : brandValue) + '.com';
101
- newChannel.address = 'www.' + address;
102
- }
103
101
  channelsControl.field.onChange(__spreadArray(__spreadArray([], channelsControl.field.value, true), [newChannel], false));
104
102
  }
105
103
  };
@@ -1,6 +1,8 @@
1
1
  import * as React from 'react';
2
2
  interface SocialMediaProps {
3
3
  show: boolean;
4
+ activeIconId: string;
5
+ onSaleIconChange: (id: string) => void;
4
6
  }
5
- declare const _default: React.MemoExoticComponent<({ show }: SocialMediaProps) => JSX.Element>;
7
+ declare const _default: React.MemoExoticComponent<({ show, activeIconId, onSaleIconChange }: SocialMediaProps) => JSX.Element>;
6
8
  export default _default;
@@ -79,16 +79,12 @@ var SocialMediaButtonStyled = styled(ToggleButton, {
79
79
  });
80
80
  var SocialMedia = function (_a) {
81
81
  var _b;
82
- var show = _a.show;
83
- var _c = React.useState(''), activeSocialId = _c[0], setActiveSocialId = _c[1];
82
+ var show = _a.show, activeIconId = _a.activeIconId, onSaleIconChange = _a.onSaleIconChange;
84
83
  var t = useTranslation().t;
85
84
  var isAr = useLanguage().isAr;
86
- var _d = useFormContext(), setValue = _d.setValue, watch = _d.watch, getFieldState = _d.getFieldState;
85
+ var _c = useFormContext(), setValue = _c.setValue, watch = _c.watch, getFieldState = _c.getFieldState;
87
86
  var selectedChannels = watch('salesChannels');
88
87
  var salesChannelsState = getFieldState('salesChannels');
89
- var onChangeIcons = function (id) {
90
- setActiveSocialId(id);
91
- };
92
88
  var onChangeInput = function (value, id) {
93
89
  if (selectedChannels.length <= 0)
94
90
  return;
@@ -123,28 +119,6 @@ var SocialMedia = function (_a) {
123
119
  });
124
120
  setValue('salesChannels', __spreadArray([], updatedChannels, true), { shouldValidate: true });
125
121
  };
126
- var setDefaultActiveSocialId = React.useCallback(function () {
127
- var _a;
128
- var idExist = selectedChannels.find(function (channel) {
129
- var _a;
130
- if ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) {
131
- return channel.sub.find(function (subChannel) { return subChannel.id === activeSocialId; });
132
- }
133
- return channel.id === activeSocialId;
134
- });
135
- if (selectedChannels.length >= 1 && !idExist) {
136
- var firstChannel = selectedChannels[0];
137
- if ((_a = firstChannel.sub) === null || _a === void 0 ? void 0 : _a.length) {
138
- setActiveSocialId(firstChannel.sub[0].id);
139
- }
140
- else {
141
- setActiveSocialId(firstChannel.id);
142
- }
143
- }
144
- }, [selectedChannels]);
145
- React.useEffect(function () {
146
- setDefaultActiveSocialId();
147
- }, [setDefaultActiveSocialId]);
148
122
  var getPlaceHolder = function (item) {
149
123
  var _a, _b;
150
124
  if (isAr)
@@ -158,19 +132,19 @@ var SocialMedia = function (_a) {
158
132
  }, [salesChannelsState]);
159
133
  var linksErrorMsg = (_b = salesChannelsState.error) === null || _b === void 0 ? void 0 : _b.message;
160
134
  return (_jsx(Box, { children: _jsx(Collapse, __assign({ in: show && selectedChannels.length > 0 }, { children: _jsxs(Box, __assign({ sx: { mb: 3, direction: 'ltr' } }, { children: [_jsx(SocialMediaGroupStyled, __assign({ exclusive: true, onChange: function (e, value) {
161
- onChangeIcons(value);
135
+ onSaleIconChange(value);
162
136
  } }, { children: selectedChannels.map(function (channel, index) {
163
137
  var _a;
164
- var isActive = activeSocialId === channel.id;
138
+ var isActive = activeIconId === channel.id;
165
139
  return ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) ? (channel.sub.map(function (sub, subIndex) {
166
- var isSubActive = activeSocialId === sub.id;
140
+ var isSubActive = activeIconId === sub.id;
167
141
  return (_jsx(SocialMediaButtonStyled, __assign({ isShow: true, isActive: isSubActive, value: sub.id }, { children: _jsx(ToggleIconStyled, { isActive: isSubActive, src: (sub === null || sub === void 0 ? void 0 : sub.logo) || '' }) }), "sub_".concat(subIndex)));
168
142
  })) : (_jsx(SocialMediaButtonStyled, __assign({ isShow: true, isActive: isActive, value: channel.id || '' }, { children: _jsx(ToggleIconStyled, { isActive: isActive, src: (channel === null || channel === void 0 ? void 0 : channel.logo) || '' }) }), index));
169
143
  }) })), selectedChannels.map(function (channel, index) {
170
144
  var _a;
171
- var isActive = activeSocialId === channel.id;
145
+ var isActive = activeIconId === channel.id;
172
146
  return ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) ? (channel.sub.map(function (sub, subIndex) {
173
- var isSubActive = activeSocialId === sub.id;
147
+ var isSubActive = activeIconId === sub.id;
174
148
  return (_jsx(Collapse, __assign({ in: isSubActive, timeout: 300 }, { children: _jsx(InputStyled, { onChange: function (e) {
175
149
  onChangeInput(e.target.value, sub.id);
176
150
  }, value: sub.address || '', startAdornment: _jsx(TextStyled, __assign({ sx: __assign({}, (isTwitter(sub.code) && { fontSize: '20px' })) }, { children: isWebsite(sub.code) ? "https://" : isTwitter(sub.code) ? "@" : '' })), placeholder: t(getPlaceHolder(sub)) }) }), "sub_".concat(subIndex)));