@tap-payments/auth-jsconnect 2.3.78-test → 2.3.80-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.
@@ -271,6 +271,14 @@ export declare type BrandInfo = {
271
271
  };
272
272
  channel_services: SaleChannel[];
273
273
  };
274
+ export declare type BusinessInfo = {
275
+ id: string;
276
+ segment: string;
277
+ name: {
278
+ ar: string;
279
+ en: string;
280
+ };
281
+ };
274
282
  export declare enum FlowsTypes {
275
283
  CONNECT_EXPRESS = "connect_express",
276
284
  CONNECT = "connect",
@@ -1,4 +1,4 @@
1
- import { Activity, BrandInfo, CountryCode, CustomerLocation, ExpectedCustomer, ExpectedSaleRange, License, MonthlyIncome, Occupation, SaleChannel, Segment, SourceOfIncome, TeamSize, City, EntityLicense } from './app';
1
+ import { Activity, BrandInfo, CountryCode, CustomerLocation, ExpectedCustomer, ExpectedSaleRange, License, MonthlyIncome, Occupation, SaleChannel, Segment, SourceOfIncome, TeamSize, City, EntityLicense, BusinessInfo } from './app';
2
2
  export declare type MobileFormValues = {
3
3
  mobile: string;
4
4
  countryCode: CountryCode;
@@ -36,6 +36,7 @@ export declare type BrandFormValues = {
36
36
  salesChannels: Array<SaleChannel>;
37
37
  termAndConditionChecked?: boolean;
38
38
  selectedBrandItem: BrandInfo;
39
+ business?: BusinessInfo | undefined;
39
40
  };
40
41
  export declare type BrandActivitiesFormValues = {
41
42
  activities: Array<Activity>;
@@ -113,6 +113,7 @@ declare const API: {
113
113
  retrieveIndividual: (id: string, type: string) => Promise<any>;
114
114
  updateIndividual: ({ id, type, ...data }: UpdateIndividualBody) => Promise<any>;
115
115
  getIndividualList: (data: GetIndividualListBody) => Promise<any>;
116
+ getBusinessList: (id: string) => Promise<any>;
116
117
  };
117
118
  boardService: {
118
119
  retrieveBoard: (id: string) => Promise<any>;
@@ -141,5 +141,6 @@ declare const individualService: {
141
141
  retrieveIndividual: (id: string, type: string) => Promise<any>;
142
142
  updateIndividual: ({ id, type, ...data }: UpdateIndividualBody) => Promise<any>;
143
143
  getIndividualList: (data: GetIndividualListBody) => Promise<any>;
144
+ getBusinessList: (id: string) => Promise<any>;
144
145
  };
145
146
  export { individualService };
@@ -38,10 +38,24 @@ var getIndividualList = function (data) {
38
38
  data: data
39
39
  });
40
40
  };
41
+ var getBusinessList = function (id) {
42
+ return httpClient({
43
+ method: 'post',
44
+ url: "".concat(ENDPOINT_PATHS.BUSINESS, "/list"),
45
+ data: {
46
+ individual_id: id,
47
+ list: {
48
+ limit: 10,
49
+ page: 1
50
+ }
51
+ }
52
+ });
53
+ };
41
54
  var individualService = {
42
55
  retrieveIndividualInfo: retrieveIndividualInfo,
43
56
  retrieveIndividual: retrieveIndividual,
44
57
  updateIndividual: updateIndividual,
45
- getIndividualList: getIndividualList
58
+ getIndividualList: getIndividualList,
59
+ getBusinessList: getBusinessList
46
60
  };
47
61
  export { individualService };
@@ -38,6 +38,7 @@ declare type BrandInfo = {
38
38
  export declare type UpdateLeadBody = {
39
39
  step_name?: string;
40
40
  id: string;
41
+ business_id?: string;
41
42
  encryption_contract?: Array<string>;
42
43
  entity?: {
43
44
  id: string;
@@ -396,5 +396,9 @@
396
396
  "powered_by": "بواسطة",
397
397
  "add_other": "أخرى",
398
398
  "choose_entity_license": "اختر ترخيص المنشأة",
399
- "choose_license_entity": "- الرجاء الاختيار -"
399
+ "choose_license_entity": "- الرجاء الاختيار -",
400
+ "select_business_label": "اختر الشركة",
401
+ "Choose_business": "الرجاء تحديد شركة",
402
+ "alert_choose_business": "يُرجى اختيار الشركة",
403
+ "other": "اخرى"
400
404
  }
@@ -426,5 +426,9 @@
426
426
  "powered_by": "Powered by",
427
427
  "add_other": "Other",
428
428
  "choose_entity_license": "Choose Entity License",
429
- "choose_license_entity": "- Please select -"
429
+ "choose_license_entity": "- Please select -",
430
+ "select_business_label": "Business",
431
+ "choose_business": "Please select a business",
432
+ "alert_choose_business": "Please select business",
433
+ "other": "other"
430
434
  }
@@ -6,6 +6,14 @@ export declare const OTHER_BRAND: {
6
6
  en: string;
7
7
  };
8
8
  };
9
+ export declare const OTHER_BUSINESS: {
10
+ id: string;
11
+ segment: string;
12
+ name: {
13
+ ar: string;
14
+ en: string;
15
+ };
16
+ };
9
17
  export declare const defaultCountry: {
10
18
  created: number;
11
19
  updated: number;
@@ -6,6 +6,14 @@ export var OTHER_BRAND = {
6
6
  en: 'other'
7
7
  }
8
8
  };
9
+ export var OTHER_BUSINESS = {
10
+ id: 'other',
11
+ segment: 'other',
12
+ name: {
13
+ ar: 'other',
14
+ en: 'other'
15
+ }
16
+ };
9
17
  export var defaultCountry = {
10
18
  created: 1577690965000,
11
19
  updated: 1577691209000,
@@ -68,7 +68,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
68
68
  var _a;
69
69
  import API from '../../../api';
70
70
  import { handleNextScreenStep } from '../../../app/settings';
71
- import { CONNECT_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, OTHER_BRAND } from '../../../constants';
71
+ import { CONNECT_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, OTHER_BRAND, OTHER_BUSINESS } from '../../../constants';
72
72
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
73
73
  import { AuthForType, FlowsTypes } from '../../../@types';
74
74
  import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, isTwitter, getIndividualName, isWebsite, sleep } from '../../../utils';
@@ -228,7 +228,7 @@ export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, t
228
228
  });
229
229
  }); });
230
230
  export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
231
- var _a, connect, settings, startWithNID, _b, mobileData, nidData, responseBody, stepName, payload, data, lead_id, leadResponse, channels, brands, err_1, countryCode, phone;
231
+ var _a, connect, settings, startWithNID, _b, mobileData, nidData, responseBody, stepName, payload, data, lead_id, leadResponse, channels, businessList, err_1, brands, err_2, countryCode, phone;
232
232
  var _c, _d, _e, _f;
233
233
  return __generator(this, function (_g) {
234
234
  switch (_g.label) {
@@ -269,15 +269,25 @@ export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params,
269
269
  _g.label = 4;
270
270
  case 4:
271
271
  _g.trys.push([4, 6, , 7]);
272
- return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
272
+ return [4, API.individualService.getBusinessList(leadResponse.individual_id)];
273
273
  case 5:
274
- brands = (_g.sent()).brands;
275
- leadResponse.brand_list = fixBrandList(brands, channels);
274
+ businessList = (_g.sent()).list;
275
+ leadResponse.business_list = businessList;
276
276
  return [3, 7];
277
277
  case 6:
278
278
  err_1 = _g.sent();
279
279
  return [3, 7];
280
280
  case 7:
281
+ _g.trys.push([7, 9, , 10]);
282
+ return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
283
+ case 8:
284
+ brands = (_g.sent()).brands;
285
+ leadResponse.brand_list = fixBrandList(brands, channels);
286
+ return [3, 10];
287
+ case 9:
288
+ err_2 = _g.sent();
289
+ return [3, 10];
290
+ case 10:
281
291
  countryCode = settings.data.businessCountry;
282
292
  phone = (leadResponse.contact || {}).phone;
283
293
  if (phone === null || phone === void 0 ? void 0 : phone.country_code)
@@ -289,7 +299,7 @@ export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params,
289
299
  });
290
300
  }); });
291
301
  export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
292
- var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, leadResponse, countryCode, channels, brands, err_2, phone;
302
+ var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, leadResponse, countryCode, channels, businessList, err_3, brands, err_4, phone;
293
303
  var _b, _c, _d, _e, _f;
294
304
  return __generator(this, function (_g) {
295
305
  switch (_g.label) {
@@ -302,15 +312,15 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
302
312
  count = 1;
303
313
  _g.label = 1;
304
314
  case 1:
305
- if (!(count <= maxCalls)) return [3, 13];
315
+ if (!(count <= maxCalls)) return [3, 16];
306
316
  if (thunkApi.signal.aborted) {
307
- return [3, 13];
317
+ return [3, 16];
308
318
  }
309
319
  return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
310
320
  case 2:
311
321
  authResponse = _g.sent();
312
322
  isSuccess = ((_b = authResponse.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
313
- if (!isSuccess) return [3, 10];
323
+ if (!isSuccess) return [3, 13];
314
324
  lead_id = authResponse.lead_id;
315
325
  if (!lead_id)
316
326
  throw new Error('Lead id is missing');
@@ -327,18 +337,28 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
327
337
  _g.label = 5;
328
338
  case 5:
329
339
  _g.trys.push([5, 7, , 8]);
330
- return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
340
+ return [4, API.individualService.getBusinessList(leadResponse.individual_id)];
331
341
  case 6:
332
- brands = (_g.sent()).brands;
333
- leadResponse.brand_list = fixBrandList(brands, channels);
342
+ businessList = (_g.sent()).list;
343
+ leadResponse.business_list = businessList;
334
344
  return [3, 8];
335
345
  case 7:
336
- err_2 = _g.sent();
346
+ err_3 = _g.sent();
337
347
  return [3, 8];
338
348
  case 8:
349
+ _g.trys.push([8, 10, , 11]);
350
+ return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
351
+ case 9:
352
+ brands = (_g.sent()).brands;
353
+ leadResponse.brand_list = fixBrandList(brands, channels);
354
+ return [3, 11];
355
+ case 10:
356
+ err_4 = _g.sent();
357
+ return [3, 11];
358
+ case 11:
339
359
  (_d = params.onSuccess) === null || _d === void 0 ? void 0 : _d.call(params);
340
360
  return [4, sleep(3000)];
341
- case 9:
361
+ case 12:
342
362
  _g.sent();
343
363
  phone = (leadResponse.contact || {}).phone;
344
364
  if (phone === null || phone === void 0 ? void 0 : phone.country_code)
@@ -346,19 +366,19 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
346
366
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, {});
347
367
  thunkApi.dispatch(handleNextScreenStep());
348
368
  return [2, { authResponse: authResponse, leadResponse: leadResponse, countryCode: countryCode }];
349
- case 10: return [4, sleep(interval * 1000)];
350
- case 11:
369
+ case 13: return [4, sleep(interval * 1000)];
370
+ case 14:
351
371
  _g.sent();
352
- _g.label = 12;
353
- case 12:
372
+ _g.label = 15;
373
+ case 15:
354
374
  count++;
355
375
  return [3, 1];
356
- case 13: throw new Error('paci_verification_failed');
376
+ case 16: throw new Error('paci_verification_failed');
357
377
  }
358
378
  });
359
379
  }); });
360
380
  export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
361
- var _a, settings, connect, lead_id, phoneCountry, payload, leadResponse, segments, err_3, teamSize, err_4, brand;
381
+ var _a, settings, connect, lead_id, phoneCountry, payload, leadResponse, segments, err_5, teamSize, err_6, brand;
362
382
  var _b, _c, _d, _e, _f;
363
383
  return __generator(this, function (_g) {
364
384
  switch (_g.label) {
@@ -386,7 +406,7 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
386
406
  leadResponse.segments_list = segments.list;
387
407
  return [3, 5];
388
408
  case 4:
389
- err_3 = _g.sent();
409
+ err_5 = _g.sent();
390
410
  return [3, 5];
391
411
  case 5:
392
412
  _g.trys.push([5, 7, , 8]);
@@ -396,7 +416,7 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
396
416
  leadResponse.team_size_list = teamSize.list;
397
417
  return [3, 8];
398
418
  case 7:
399
- err_4 = _g.sent();
419
+ err_6 = _g.sent();
400
420
  return [3, 8];
401
421
  case 8:
402
422
  if (!leadResponse.brand) return [3, 10];
@@ -413,7 +433,7 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
413
433
  });
414
434
  }); });
415
435
  export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
416
- var _a, settings, connect, responseBody, leadBrandId, isNewBrand, brandName, salesChannels, selectedBrandItem, termAndConditionChecked, getAddress, channel_services, payload_1, brandReqBody_1, brand_1, brandNameBody, payload, lead, brandReqBody, brand;
436
+ var _a, settings, connect, responseBody, leadBrandId, isNewBrand, brandName, salesChannels, selectedBrandItem, termAndConditionChecked, business, getAddress, channel_services, payload_1, brandReqBody_1, brand_1, brandNameBody, payload, lead, brandReqBody, brand;
417
437
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
418
438
  return __generator(this, function (_l) {
419
439
  switch (_l.label) {
@@ -421,7 +441,7 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
421
441
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
422
442
  responseBody = connect.data.otpData.responseBody;
423
443
  leadBrandId = responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand_id;
424
- isNewBrand = params.isNewBrand, brandName = params.brandName, salesChannels = params.salesChannels, selectedBrandItem = params.selectedBrandItem, termAndConditionChecked = params.termAndConditionChecked;
444
+ isNewBrand = params.isNewBrand, brandName = params.brandName, salesChannels = params.salesChannels, selectedBrandItem = params.selectedBrandItem, termAndConditionChecked = params.termAndConditionChecked, business = params.business;
425
445
  getAddress = function (value, isTwitter, isWeb) {
426
446
  if (isTwitter)
427
447
  return '@' + value;
@@ -475,12 +495,10 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
475
495
  zh: brandName
476
496
  }
477
497
  };
478
- payload = {
479
- brand: brandNameBody,
480
- id: (responseBody === null || responseBody === void 0 ? void 0 : responseBody.lead_id) || '',
481
- step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_BRAND,
482
- encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh']
483
- };
498
+ payload = __assign(__assign({ brand: brandNameBody }, ((business === null || business === void 0 ? void 0 : business.id) &&
499
+ (business === null || business === void 0 ? void 0 : business.id) !== OTHER_BUSINESS.id && {
500
+ business_id: business.id
501
+ })), { id: (responseBody === null || responseBody === void 0 ? void 0 : responseBody.lead_id) || '', step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_BRAND, encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh'] });
484
502
  return [4, API.leadService.updateLead(payload)];
485
503
  case 5:
486
504
  lead = _l.sent();
@@ -615,7 +633,8 @@ var initialState = {
615
633
  termAndConditionChecked: false,
616
634
  selectedBrandItem: {},
617
635
  responseBody: {
618
- brand_list: []
636
+ brand_list: [],
637
+ business_list: []
619
638
  }
620
639
  }
621
640
  }
@@ -710,7 +729,7 @@ export var connectSlice = createSlice({
710
729
  state.loading = false;
711
730
  state.error = null;
712
731
  var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, countryCode = _b.countryCode;
713
- var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id;
732
+ var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id, business_list = leadResponse.business_list, business_id = leadResponse.business_id;
714
733
  var _c = contact || {}, email = _c.email, phone = _c.phone;
715
734
  var fullName = concatenateObjectValues(name, ['first', 'middle', 'last']);
716
735
  if (!!fullName) {
@@ -725,6 +744,11 @@ export var connectSlice = createSlice({
725
744
  state.data.individualData.countryCode = countryCode;
726
745
  if ((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en)
727
746
  state.data.brandData.brandName = brand.name.en;
747
+ var businessList = [];
748
+ if ((business_list === null || business_list === void 0 ? void 0 : business_list.length) > 0) {
749
+ businessList = __spreadArray(__spreadArray([], business_list, true), [OTHER_BUSINESS], false);
750
+ state.data.brandData.business = business_list.find(function (b) { return b.id === business_id; }) || business_list[0];
751
+ }
728
752
  var brandList = [];
729
753
  if ((brand_list === null || brand_list === void 0 ? void 0 : brand_list.length) > 0) {
730
754
  var isBrandExist = brand_list.find(function (item) { return item.id === (brand === null || brand === void 0 ? void 0 : brand.id); });
@@ -736,7 +760,8 @@ export var connectSlice = createSlice({
736
760
  }
737
761
  state.data.brandData.responseBody = {
738
762
  brand_list: brandList,
739
- channel_list: channel_list
763
+ channel_list: channel_list,
764
+ business_list: businessList
740
765
  };
741
766
  state.data.otpData.responseBody = __assign(__assign({}, authResponse), { is_new_individual: is_new_individual, lead_id: id, brand_id: brand === null || brand === void 0 ? void 0 : brand.id, name: name, contact: contact });
742
767
  })
@@ -752,7 +777,7 @@ export var connectSlice = createSlice({
752
777
  state.loading = false;
753
778
  state.error = null;
754
779
  var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, countryCode = _b.countryCode;
755
- var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id;
780
+ var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id, business_list = leadResponse.business_list, business_id = leadResponse.business_id;
756
781
  var _c = contact || {}, email = _c.email, phone = _c.phone;
757
782
  var fullName = concatenateObjectValues(name, ['first', 'middle', 'last']);
758
783
  if (!!fullName) {
@@ -767,6 +792,11 @@ export var connectSlice = createSlice({
767
792
  state.data.individualData.countryCode = countryCode;
768
793
  if ((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en)
769
794
  state.data.brandData.brandName = brand.name.en;
795
+ var businessList = [];
796
+ if ((business_list === null || business_list === void 0 ? void 0 : business_list.length) > 0) {
797
+ businessList = __spreadArray(__spreadArray([], business_list, true), [OTHER_BUSINESS], false);
798
+ state.data.brandData.business = business_list.find(function (b) { return b.id === business_id; }) || business_list[0];
799
+ }
770
800
  var brandList = [];
771
801
  if ((brand_list === null || brand_list === void 0 ? void 0 : brand_list.length) > 0) {
772
802
  var isBrandExist = brand_list.find(function (item) { return item.id === (brand === null || brand === void 0 ? void 0 : brand.id); });
@@ -778,7 +808,8 @@ export var connectSlice = createSlice({
778
808
  }
779
809
  state.data.brandData.responseBody = {
780
810
  brand_list: brandList,
781
- channel_list: channel_list
811
+ channel_list: channel_list,
812
+ business_list: businessList
782
813
  };
783
814
  state.data.otpData.responseBody = __assign(__assign({}, authResponse), { is_new_individual: is_new_individual, lead_id: id, brand_id: brand === null || brand === void 0 ? void 0 : brand.id, name: name, contact: contact });
784
815
  })
@@ -33,7 +33,6 @@ import ExpandIcon from '../../../../components/ExpandIcon';
33
33
  import { ScreenContainer } from '../../../shared/Containers';
34
34
  import { CheckIconStyled, InputLabelStyled, NameContainer } from './CustomerBase';
35
35
  import { brandSelector, clearError } from '../../../app/brand/brandStore';
36
- import Search from '../../../shared/Search';
37
36
  import Input from '../../../shared/Input';
38
37
  var InputStyled = styled(Input)(function (_a) {
39
38
  var theme = _a.theme, readOnly = _a.readOnly;
@@ -94,17 +93,10 @@ var ExpectedCustomers = function (_a) {
94
93
  dispatch(clearError());
95
94
  onCloseList();
96
95
  };
97
- var handleSearch = function (value) {
98
- var _a;
99
- var filteredList = (_a = response === null || response === void 0 ? void 0 : response.expectedCustomerSales) === null || _a === void 0 ? void 0 : _a.filter(function (customer) {
100
- return customer.name.en.toLowerCase().startsWith(value.toLowerCase()) || customer.name.ar.toLowerCase().startsWith(value.toLowerCase());
101
- });
102
- setExpectedCustomersList(filteredList);
103
- };
104
96
  var expectedCustomersValue = expectedCustomerControl.field.value;
105
97
  var expectedCustomersSelected = expectedCustomersValue;
106
- return (_jsx(Collapse, __assign({ in: props.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: readOnly, placeholder: t('choose_expected_sales'), value: isAr ? (_c = (_b = expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name) === null || _b === void 0 ? void 0 : _b.ar) !== null && _c !== void 0 ? _c : '' : (_e = (_d = expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name) === null || _d === void 0 ? void 0 : _d.en) !== null && _e !== void 0 ? _e : '', onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
107
- return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedCustomersValue === null || expectedCustomersValue === void 0 ? void 0 : expectedCustomersValue.id) }, { children: isAr ? item.name.ar : item.name.en })) }), item.id === (expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.id) && _jsx(CheckIconStyled, {})] }));
108
- } })] }))] }) })));
98
+ return (_jsx(Collapse, __assign({ in: props.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: readOnly, placeholder: t('choose_expected_sales'), value: isAr ? (_c = (_b = expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name) === null || _b === void 0 ? void 0 : _b.ar) !== null && _c !== void 0 ? _c : '' : (_e = (_d = expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.name) === null || _d === void 0 ? void 0 : _d.en) !== null && _e !== void 0 ? _e : '', onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
99
+ return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedCustomersValue === null || expectedCustomersValue === void 0 ? void 0 : expectedCustomersValue.id) }, { children: isAr ? item.name.ar : item.name.en })) }), item.id === (expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.id) && _jsx(CheckIconStyled, {})] }));
100
+ } }) }))] }) })));
109
101
  };
110
102
  export default ExpectedCustomers;
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { BusinessInfo } from '../../../../@types';
3
+ interface BusinessListProps {
4
+ show: boolean;
5
+ list: Array<BusinessInfo>;
6
+ onListOpen?: () => void;
7
+ onListClose?: () => void;
8
+ }
9
+ declare const _default: React.MemoExoticComponent<({ show, list, ...rest }: BusinessListProps) => JSX.Element>;
10
+ export default _default;
@@ -0,0 +1,82 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import * as React from 'react';
25
+ import { useTranslation } from 'react-i18next';
26
+ import { useFormContext, useController } from 'react-hook-form';
27
+ import Box from '@mui/material/Box';
28
+ import { styled } from '@mui/material/styles';
29
+ import { useLanguage } from '../../../../hooks';
30
+ import SimpleList from '../../../../components/SimpleList';
31
+ import Text from '../../../../components/Text';
32
+ import ExpandIcon from '../../../../components/ExpandIcon';
33
+ import Collapse from '../../../../components/Collapse';
34
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
35
+ import Input from '../../../shared/Input';
36
+ import CheckIcon from '../../../shared/CheckIcon';
37
+ var InputStyled = styled(Input)(function () { return ({
38
+ '& .MuiInputBase-input': {
39
+ cursor: 'pointer'
40
+ }
41
+ }); });
42
+ var BusinessContainer = styled(Box)(function () { return ({
43
+ display: 'flex'
44
+ }); });
45
+ var BusinessNameText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
46
+ var theme = _a.theme, isSelected = _a.isSelected;
47
+ return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight }));
48
+ });
49
+ var BusinessList = function (_a) {
50
+ var show = _a.show, list = _a.list, rest = __rest(_a, ["show", "list"]);
51
+ var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
52
+ var t = useTranslation().t;
53
+ var isAr = useLanguage().isAr;
54
+ var control = useFormContext().control;
55
+ var businessControl = useController({ control: control, name: 'business' });
56
+ var business = businessControl.field.value;
57
+ var onOpenBusinessList = function (event) {
58
+ var _a;
59
+ setAnchorEl(event.currentTarget);
60
+ (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
61
+ };
62
+ var onCloseBusinessList = function () {
63
+ var _a;
64
+ setAnchorEl(null);
65
+ (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
66
+ };
67
+ var getBusinessName = function (business) {
68
+ var _a, _b;
69
+ return (isAr ? (_a = business === null || business === void 0 ? void 0 : business.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = business === null || business === void 0 ? void 0 : business.name) === null || _b === void 0 ? void 0 : _b.en) || '';
70
+ };
71
+ var getBusinessId = function (item) {
72
+ return (item === null || item === void 0 ? void 0 : item.id) || '';
73
+ };
74
+ var onSelectItem = function (business) {
75
+ businessControl.field.onChange(business);
76
+ onCloseBusinessList();
77
+ };
78
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(InputStyled, { label: t('select_business_label'), onClick: !!anchorEl ? onCloseBusinessList : onOpenBusinessList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_business'), value: t(getBusinessName(business)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'id', searchValuePath: ['id', 'name.ar', 'name.en'], list: list, onSelectItem: onSelectItem, renderItem: function (item) {
79
+ return (_jsxs(_Fragment, { children: [_jsx(BusinessContainer, { children: _jsx(BusinessNameText, __assign({ isSelected: getBusinessId(item) === getBusinessId(business) }, { children: t(getBusinessName(item)) })) }), getBusinessId(item) === getBusinessId(business) && _jsx(CheckIcon, {})] }));
80
+ } }) }))] })) })));
81
+ };
82
+ export default React.memo(BusinessList);
@@ -29,29 +29,33 @@ import TAC from './TAC';
29
29
  import BrandList from './BrandList';
30
30
  import SalesChannels from './SalesChannels';
31
31
  import Segments from './Segments';
32
+ import BusinessList from './BusinessList';
32
33
  var ListType;
33
34
  (function (ListType) {
34
35
  ListType["SegmentsList"] = "SegmentsList";
35
36
  ListType["TeamSizeList"] = "TeamSizeList";
36
37
  ListType["BrandList"] = "BrandList";
38
+ ListType["BusinessList"] = "BusinessList";
37
39
  })(ListType || (ListType = {}));
38
40
  var Merchant = function (_a) {
39
41
  var _b, _c;
40
42
  var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
41
43
  var _e = React.useState(false), isRequiredNewBrand = _e[0], setIsRequiredNewBrand = _e[1];
42
44
  var _f = useAppSelector(connectSelector), data = _f.data, loading = _f.loading, error = _f.error;
43
- var _g = data.brandData, brandName = _g.brandName, selectedBrandItem = _g.selectedBrandItem, termAndConditionChecked = _g.termAndConditionChecked, responseBody = _g.responseBody, salesChannels = _g.salesChannels, segment = _g.segment, teamSize = _g.teamSize;
44
- var brandList = (responseBody || {}).brand_list;
45
- var _h = React.useState(), listActive = _h[0], setListActive = _h[1];
45
+ var _g = data.brandData, brandName = _g.brandName, selectedBrandItem = _g.selectedBrandItem, termAndConditionChecked = _g.termAndConditionChecked, responseBody = _g.responseBody, salesChannels = _g.salesChannels, segment = _g.segment, teamSize = _g.teamSize, business = _g.business;
46
+ var _h = responseBody || {}, brandList = _h.brand_list, businessList = _h.business_list;
47
+ var _j = React.useState(), listActive = _j[0], setListActive = _j[1];
48
+ var hasBusinessList = (businessList === null || businessList === void 0 ? void 0 : businessList.length) > 0;
46
49
  var methods = useForm({
47
- resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
50
+ resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand, hasBusinessList)),
48
51
  defaultValues: {
49
52
  brandName: brandName || ((_b = selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.name) === null || _b === void 0 ? void 0 : _b.en),
50
53
  selectedBrandItem: selectedBrandItem,
51
54
  termAndConditionChecked: termAndConditionChecked,
52
55
  salesChannels: salesChannels,
53
56
  segment: segment,
54
- teamSize: teamSize
57
+ teamSize: teamSize,
58
+ business: business
55
59
  },
56
60
  mode: 'onChange'
57
61
  });
@@ -97,6 +101,7 @@ var Merchant = function (_a) {
97
101
  var isSegmentsListActive = listActive === ListType.SegmentsList;
98
102
  var isTeamSizeListActive = listActive === ListType.TeamSizeList;
99
103
  var isBrandListActive = listActive === ListType.BrandList;
100
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && !isTeamSizeListActive && !isSegmentsListActive, list: brandList, onListOpen: function () { return handleMenuClick(ListType.BrandList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(BrandName, { show: (isNewBrand || isOtherBrand) && !listActive, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Segments, { show: !isTeamSizeListActive && !isBrandListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentsList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(TeamSize, { show: !isSegmentsListActive && !isBrandListActive, onListOpen: function () { return handleMenuClick(ListType.TeamSizeList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(SalesChannels, {}) })), _jsx(TAC, { show: (isNewBrand || isOtherBrand) && !listActive }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
104
+ var isBusinessListActive = listActive === ListType.BusinessList;
105
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: hasBrandList && !isTeamSizeListActive && !isSegmentsListActive && !isBusinessListActive, list: brandList, onListOpen: function () { return handleMenuClick(ListType.BrandList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(BusinessList, { show: hasBusinessList && (isOtherBrand || isNewBrand) && !isTeamSizeListActive && !isSegmentsListActive && !isBrandListActive, list: businessList, onListOpen: function () { return handleMenuClick(ListType.BusinessList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(BrandName, { show: (isNewBrand || isOtherBrand) && !listActive, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Segments, { show: !isTeamSizeListActive && !isBrandListActive && !isBusinessListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentsList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(TeamSize, { show: !isSegmentsListActive && !isBrandListActive && !isBusinessListActive, onListOpen: function () { return handleMenuClick(ListType.TeamSizeList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(SalesChannels, {}) })), _jsx(TAC, { show: (isNewBrand || isOtherBrand) && !listActive }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
101
106
  };
102
107
  export default React.memo(Merchant);
@@ -1,5 +1,5 @@
1
1
  import * as yup from 'yup';
2
- export declare const MerchantValidationSchema: (isNewBrand?: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
2
+ export declare const MerchantValidationSchema: (isNewBrand?: boolean, hasBusinessList?: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
3
  salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
4
4
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
5
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
@@ -9,8 +9,10 @@ export declare const MerchantValidationSchema: (isNewBrand?: boolean) => yup.Obj
9
9
  }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
10
10
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
11
11
  }>>[] | undefined>;
12
+ business: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
12
13
  segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
13
14
  teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
15
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
14
16
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
15
17
  salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
16
18
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -21,8 +23,10 @@ export declare const MerchantValidationSchema: (isNewBrand?: boolean) => yup.Obj
21
23
  }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
22
24
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
23
25
  }>>[] | undefined>;
26
+ business: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
24
27
  segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
25
28
  teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
29
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
26
30
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
27
31
  salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
28
32
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -33,6 +37,8 @@ export declare const MerchantValidationSchema: (isNewBrand?: boolean) => yup.Obj
33
37
  }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
34
38
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
35
39
  }>>[] | undefined>;
40
+ business: import("yup/lib/object").OptionalObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
36
41
  segment: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
37
42
  teamSize: import("yup/lib/object").RequiredObjectSchema<import("yup/lib/object").ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").ObjectShape>>;
43
+ brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
38
44
  }>>>;
@@ -69,8 +69,9 @@ var validationSalesChannels = function (channels) {
69
69
  }
70
70
  return true;
71
71
  };
72
- export var MerchantValidationSchema = function (isNewBrand) {
72
+ export var MerchantValidationSchema = function (isNewBrand, hasBusinessList) {
73
73
  if (isNewBrand === void 0) { isNewBrand = true; }
74
+ if (hasBusinessList === void 0) { hasBusinessList = false; }
74
75
  if (isNewBrand)
75
76
  return yup.object().shape({
76
77
  brandName: yup
@@ -88,6 +89,7 @@ export var MerchantValidationSchema = function (isNewBrand) {
88
89
  termAndConditionChecked: yup.boolean().isTrue('check_terms_cond').required('check_terms_cond'),
89
90
  segment: yup.object().required('alert_choose_segment'),
90
91
  teamSize: yup.object().required('alert_choose_teamSize'),
92
+ business: hasBusinessList ? yup.object().required('alert_choose_business') : yup.object().optional(),
91
93
  salesChannels: yup
92
94
  .array()
93
95
  .min(1, 'choose_atleast_one_channel')
@@ -128,7 +130,9 @@ export var MerchantValidationSchema = function (isNewBrand) {
128
130
  }
129
131
  })
130
132
  .required('choose_atleast_one_channel'),
133
+ business: yup.object().optional(),
131
134
  segment: yup.object().required('alert_choose_segment'),
132
- teamSize: yup.object().required('alert_choose_teamSize')
135
+ teamSize: yup.object().required('alert_choose_teamSize'),
136
+ brandName: yup.string().optional()
133
137
  });
134
138
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.3.78-test",
3
+ "version": "2.3.80-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",