@tap-payments/auth-jsconnect 2.1.40-test → 2.1.41-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.
@@ -225,6 +225,10 @@ export interface LocalProps {
225
225
  };
226
226
  }
227
227
  export declare type BrandInfo = {
228
+ segment?: {
229
+ type: string;
230
+ team: string;
231
+ };
228
232
  id: string;
229
233
  name: {
230
234
  ar: string;
@@ -59,6 +59,10 @@ export declare type UpdateLeadBody = {
59
59
  is_acknowledged?: boolean;
60
60
  terms_conditions_accepted?: boolean;
61
61
  lang?: LanguageMode;
62
+ segment?: {
63
+ type: string;
64
+ team: string;
65
+ };
62
66
  };
63
67
  export declare type LeadVerifyBody = {
64
68
  verify_token: string;
@@ -74,6 +74,8 @@
74
74
  "choose_any_source_of_income": "- Please select -",
75
75
  "choose_atleast_one_activity": "- Please select -",
76
76
  "choose_atleast_one_channel": "Please select at least a channel.",
77
+ "alert_choose_segment": "Please select business segment.",
78
+ "alert_choose_teamSize": "Please select team size.",
77
79
  "choose_brand": "Please select a brand",
78
80
  "choose_channel": "- Please select -",
79
81
  "choose_customer_base": "- Please select -",
@@ -1,5 +1,5 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { ResponseData, MobileFormValues, NIDFormValues, CivilFormValues, OTPFormValues, IndividualFormValues, SharedState, BrandFormValues, FlowsTypes, ActionState, CountryCode, AuthForType } from '../../../@types';
2
+ import { ActionState, AuthForType, BrandFormValues, CivilFormValues, CountryCode, FlowsTypes, IndividualFormValues, MobileFormValues, NIDFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
3
  import { CancelToken } from 'axios';
4
4
  export declare const createMobileAuth: import("@reduxjs/toolkit").AsyncThunk<{
5
5
  response: any;
@@ -66,13 +66,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
66
  return to.concat(ar || Array.prototype.slice.call(from));
67
67
  };
68
68
  var _a;
69
- import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
70
- import { handleNextScreenStep } from '../../../app/settings';
71
- import { FlowsTypes, AuthForType } from '../../../@types';
72
69
  import API from '../../../api';
73
- import { CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_BRAND } from '../../../constants';
74
- import { defaultCountry } from '../../../constants';
75
- import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo, sleep, findCountryByIddPrefix, concatenateObjectValues, isTwitter, isWebsite, fixBrandList } from '../../../utils';
70
+ import { handleNextScreenStep } from '../../../app/settings';
71
+ import { CONNECT_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, OTHER_BRAND } from '../../../constants';
72
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
73
+ import { AuthForType, FlowsTypes } from '../../../@types';
74
+ import { capitalizeTheFirstLetterOfEachWord, concatenateObjectValues, findCountryByIddPrefix, fixBrandList, getEighteenYearsAgo, getIndividualName, isTwitter, isWebsite, sleep } from '../../../utils';
76
75
  export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
77
76
  var settings, requestBody, data;
78
77
  var _a, _b;
@@ -132,7 +131,7 @@ export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (p
132
131
  });
133
132
  }); });
134
133
  export var resendOTPMobile = createAsyncThunk('resendOTPMobile', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
135
- var _a, settings, connect, _b, mobile, countryCode, requestBody, data;
134
+ var _a, settings, connect, _b, mobile, countryCode, requestBody;
136
135
  return __generator(this, function (_c) {
137
136
  switch (_c.label) {
138
137
  case 0:
@@ -152,9 +151,7 @@ export var resendOTPMobile = createAsyncThunk('resendOTPMobile', function (param
152
151
  encryption_contract: ['user_credentail.phone', 'user_credentail.code']
153
152
  };
154
153
  return [4, API.authService.createAuth(requestBody)];
155
- case 1:
156
- data = _c.sent();
157
- return [2, data];
154
+ case 1: return [2, _c.sent()];
158
155
  }
159
156
  });
160
157
  }); });
@@ -360,7 +357,7 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
360
357
  });
361
358
  }); });
362
359
  export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
363
- var _a, settings, connect, lead_id, phoneCountry, payload, leadResponse, brand;
360
+ var _a, settings, connect, lead_id, phoneCountry, payload, leadResponse, segments, err_3, teamSize, err_4, brand;
364
361
  var _b, _c, _d, _e, _f;
365
362
  return __generator(this, function (_g) {
366
363
  switch (_g.label) {
@@ -379,13 +376,35 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
379
376
  return [4, API.leadService.updateLead(payload)];
380
377
  case 1:
381
378
  leadResponse = _g.sent();
382
- if (!leadResponse.brand) return [3, 3];
383
- return [4, API.brandService.retrieveBrand(leadResponse.brand.id)];
379
+ _g.label = 2;
384
380
  case 2:
381
+ _g.trys.push([2, 4, , 5]);
382
+ return [4, API.dataService.getSegments({ page: 0 })];
383
+ case 3:
384
+ segments = _g.sent();
385
+ leadResponse.segments_list = segments.list;
386
+ return [3, 5];
387
+ case 4:
388
+ err_3 = _g.sent();
389
+ return [3, 5];
390
+ case 5:
391
+ _g.trys.push([5, 7, , 8]);
392
+ return [4, API.dataService.getTeamSize({ page: 0 })];
393
+ case 6:
394
+ teamSize = _g.sent();
395
+ leadResponse.team_size_list = teamSize.list;
396
+ return [3, 8];
397
+ case 7:
398
+ err_4 = _g.sent();
399
+ return [3, 8];
400
+ case 8:
401
+ if (!leadResponse.brand) return [3, 10];
402
+ return [4, API.brandService.retrieveBrand(leadResponse.brand.id)];
403
+ case 9:
385
404
  brand = (_g.sent()).brand;
386
405
  leadResponse.brand = __assign(__assign({}, leadResponse.brand), brand);
387
- _g.label = 3;
388
- case 3:
406
+ _g.label = 10;
407
+ case 10:
389
408
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
390
409
  thunkApi.dispatch(handleNextScreenStep());
391
410
  return [2, { leadResponse: leadResponse, formData: params }];
@@ -394,9 +413,9 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
394
413
  }); });
395
414
  export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
396
415
  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;
397
- var _b, _c, _d, _e, _f;
398
- return __generator(this, function (_g) {
399
- switch (_g.label) {
416
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
417
+ return __generator(this, function (_l) {
418
+ switch (_l.label) {
400
419
  case 0:
401
420
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
402
421
  responseBody = connect.data.otpData.responseBody;
@@ -430,20 +449,21 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
430
449
  };
431
450
  return [4, API.leadService.updateLead(payload_1)];
432
451
  case 1:
433
- _g.sent();
434
- _g.label = 2;
452
+ _l.sent();
453
+ _l.label = 2;
435
454
  case 2:
436
455
  brandReqBody_1 = {
437
456
  id: (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id) || '',
438
457
  channel_services: channel_services,
458
+ segment: { type: ((_b = params.segment) === null || _b === void 0 ? void 0 : _b.id) || '', team: ((_c = params.teamSize) === null || _c === void 0 ? void 0 : _c.id) || '' },
439
459
  step_name: CONNECT_STEP_NAMES.UPDATE_BRAND_INFO
440
460
  };
441
461
  return [4, API.brandService.updateBrandInfo(brandReqBody_1)];
442
462
  case 3:
443
- brand_1 = _g.sent();
463
+ brand_1 = _l.sent();
444
464
  thunkApi.dispatch(updateLeadSuccess());
445
465
  thunkApi.dispatch(handleNextScreenStep());
446
- (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, params);
466
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, params);
447
467
  return [2, { response: brand_1, formData: params }];
448
468
  case 4:
449
469
  brandNameBody = {
@@ -461,23 +481,24 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
461
481
  };
462
482
  return [4, API.leadService.updateLead(payload)];
463
483
  case 5:
464
- lead = _g.sent();
484
+ lead = _l.sent();
465
485
  if (!lead.brand) {
466
486
  console.error('Internal server error: brand is not created');
467
487
  throw new Error('Internal server error');
468
488
  }
469
489
  brandReqBody = {
470
- id: ((_d = lead.brand) === null || _d === void 0 ? void 0 : _d.id) || '',
490
+ id: ((_f = lead.brand) === null || _f === void 0 ? void 0 : _f.id) || '',
471
491
  channel_services: channel_services,
472
492
  term: ['general'],
473
- step_name: CONNECT_STEP_NAMES.UPDATE_BRAND_INFO
493
+ step_name: CONNECT_STEP_NAMES.UPDATE_BRAND_INFO,
494
+ segment: { type: ((_g = params.segment) === null || _g === void 0 ? void 0 : _g.id) || '', team: ((_h = params.teamSize) === null || _h === void 0 ? void 0 : _h.id) || '' }
474
495
  };
475
496
  return [4, API.brandService.updateBrandInfo(brandReqBody)];
476
497
  case 6:
477
- brand = _g.sent();
498
+ brand = _l.sent();
478
499
  thunkApi.dispatch(updateLeadSuccess());
479
500
  thunkApi.dispatch(handleNextScreenStep());
480
- (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
501
+ (_k = (_j = settings.data.appConfig).onStepCompleted) === null || _k === void 0 ? void 0 : _k.call(_j, settings.data.activeScreen.name, params);
481
502
  return [2, { response: brand, formData: params }];
482
503
  }
483
504
  });
@@ -578,11 +599,17 @@ var initialState = {
578
599
  name: '',
579
600
  email: '',
580
601
  mobile: '',
581
- countryCode: defaultCountry
602
+ countryCode: defaultCountry,
603
+ responseBody: {
604
+ segments_list: [],
605
+ team_size_list: []
606
+ }
582
607
  },
583
608
  brandData: {
584
609
  brandName: '',
585
610
  salesChannels: [],
611
+ segment: undefined,
612
+ teamSize: undefined,
586
613
  termAndConditionChecked: false,
587
614
  selectedBrandItem: {},
588
615
  responseBody: {
@@ -790,9 +817,10 @@ export var connectSlice = createSlice({
790
817
  state.error = action.error.message;
791
818
  })
792
819
  .addCase(updateLeadIndividual.fulfilled, function (state, action) {
820
+ var _a, _b;
793
821
  state.loading = false;
794
822
  state.error = null;
795
- var _a = action.payload, formData = _a.formData, leadResponse = _a.leadResponse;
823
+ var _c = action.payload, formData = _c.formData, leadResponse = _c.leadResponse;
796
824
  var brand = leadResponse.brand, rest = __rest(leadResponse, ["brand"]);
797
825
  if (brand) {
798
826
  var channel_services = brand.channel_services, terms = brand.terms;
@@ -803,6 +831,15 @@ export var connectSlice = createSlice({
803
831
  });
804
832
  state.data.brandData.termAndConditionChecked = !!termAndCondition;
805
833
  }
834
+ var firstBrand = (_b = (_a = state.data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.brand_list[0];
835
+ state.data.brandData.segment = rest.segments_list.find(function (_a) {
836
+ var id = _a.id;
837
+ return firstBrand.segment.type === id;
838
+ });
839
+ state.data.brandData.teamSize = rest.team_size_list.find(function (_a) {
840
+ var id = _a.id;
841
+ return firstBrand.segment.team === id;
842
+ });
806
843
  state.data.individualData = formData;
807
844
  state.data.individualData.responseBody = rest;
808
845
  })
@@ -21,12 +21,13 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { connectSelector } from '../../../app/connect/connectStore';
24
25
  import * as React from 'react';
25
26
  import { useTranslation } from 'react-i18next';
26
27
  import { useFormContext, useController } from 'react-hook-form';
27
28
  import Box from '@mui/material/Box';
28
29
  import { styled } from '@mui/material/styles';
29
- import { useLanguage } from '../../../../hooks';
30
+ import { useAppSelector, useLanguage } from '../../../../hooks';
30
31
  import ScreenContainer from '../../../shared/Containers/ScreenContainer';
31
32
  import Input from '../../../shared/Input';
32
33
  import CheckIcon from '../../../shared/CheckIcon';
@@ -52,7 +53,9 @@ var BrandList = function (_a) {
52
53
  var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
53
54
  var t = useTranslation().t;
54
55
  var isAr = useLanguage().isAr;
55
- var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
56
+ var data = useAppSelector(connectSelector).data;
57
+ var _c = data.individualData.responseBody || {}, segments_list = _c.segments_list, team_size_list = _c.team_size_list;
58
+ var _d = useFormContext(), control = _d.control, setValue = _d.setValue;
56
59
  var selectedBrandControl = useController({ control: control, name: 'selectedBrandItem' });
57
60
  var selectedBrand = selectedBrandControl.field.value;
58
61
  var onOpenBrandList = function (event) {
@@ -84,6 +87,16 @@ var BrandList = function (_a) {
84
87
  setValue('salesChannels', [], { shouldValidate: true });
85
88
  setValue('brandName', '');
86
89
  }
90
+ setValue('segment', segments_list.find(function (_a) {
91
+ var _b;
92
+ var id = _a.id;
93
+ return ((_b = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _b === void 0 ? void 0 : _b.type) === id;
94
+ }), { shouldValidate: true });
95
+ setValue('teamSize', team_size_list.find(function (_a) {
96
+ var _b;
97
+ var id = _a.id;
98
+ return ((_b = brand === null || brand === void 0 ? void 0 : brand.segment) === null || _b === void 0 ? void 0 : _b.team) === id;
99
+ }), { shouldValidate: true });
87
100
  onCloseBrandList();
88
101
  };
89
102
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('select_brand_label'), readOnly: true, onClick: !!anchorEl ? onCloseBrandList : onOpenBrandList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_brand'), value: t(getBrandName(selectedBrand)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'id', list: list, onSelectItem: onSelectItem, renderItem: function (item) {
@@ -10,6 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import TeamSize from '../../../connect/screens/Merchant/TeamSize';
13
14
  import * as React from 'react';
14
15
  import { useForm, FormProvider } from 'react-hook-form';
15
16
  import { useTranslation } from 'react-i18next';
@@ -27,34 +28,47 @@ import BrandName from './BrandName';
27
28
  import TAC from './TAC';
28
29
  import BrandList from './BrandList';
29
30
  import SalesChannels from './SalesChannels';
31
+ import Segments from './Segments';
32
+ var ListType;
33
+ (function (ListType) {
34
+ ListType["SegmentsList"] = "SegmentsList";
35
+ ListType["TeamSizeList"] = "TeamSizeList";
36
+ })(ListType || (ListType = {}));
30
37
  var Merchant = function (_a) {
31
38
  var _b;
32
39
  var _c = React.useState(false), brandNameChecking = _c[0], setBrandNameChecking = _c[1];
33
40
  var _d = React.useState(false), isBrandListOpen = _d[0], setIsBrandListOpen = _d[1];
34
41
  var _e = React.useState(false), isRequiredNewBrand = _e[0], setIsRequiredNewBrand = _e[1];
35
42
  var _f = useAppSelector(connectSelector), data = _f.data, loading = _f.loading, error = _f.error;
36
- var _g = data.brandData, brandName = _g.brandName, selectedBrandItem = _g.selectedBrandItem, termAndConditionChecked = _g.termAndConditionChecked, responseBody = _g.responseBody, salesChannels = _g.salesChannels;
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;
37
44
  var brandList = (responseBody || {}).brand_list;
45
+ var _h = React.useState(), listActive = _h[0], setListActive = _h[1];
38
46
  var methods = useForm({
39
47
  resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
40
48
  defaultValues: {
41
49
  brandName: brandName,
42
50
  selectedBrandItem: selectedBrandItem,
43
51
  termAndConditionChecked: termAndConditionChecked,
44
- salesChannels: salesChannels
52
+ salesChannels: salesChannels,
53
+ segment: segment,
54
+ teamSize: teamSize
45
55
  },
46
56
  mode: 'onChange'
47
57
  });
48
58
  var t = useTranslation().t;
49
59
  var isAr = useLanguage().isAr;
50
60
  var dispatch = useAppDispatch();
51
- var brandListItem = methods.watch('selectedBrandItem');
61
+ var brandListItem = methods.getValues('selectedBrandItem');
52
62
  var onSubmit = function (formData) {
53
63
  dispatch(updateLeadBrand(__assign(__assign({}, formData), { isNewBrand: isRequiredNewBrand })));
54
64
  };
55
65
  var onBack = function () {
56
66
  dispatch(handlePrevScreenStep('CONNECT_INDIVIDUAL_STEP'));
57
67
  };
68
+ React.useEffect(function () {
69
+ methods.setValue('segment', segment, { shouldValidate: true });
70
+ methods.setValue('teamSize', teamSize, { shouldValidate: true });
71
+ }, [segment, teamSize]);
58
72
  React.useEffect(function () {
59
73
  if (error)
60
74
  dispatch(clearError());
@@ -67,7 +81,7 @@ var Merchant = function (_a) {
67
81
  if (termAndConditionChecked === true)
68
82
  methods.setValue('termAndConditionChecked', termAndConditionChecked);
69
83
  }, [termAndConditionChecked]);
70
- var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
84
+ var brandErrChecks = !!Object.entries(methods.formState.errors).length || !!error;
71
85
  var disabled = brandErrChecks || brandNameChecking || ((_b = data.brandData.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) === '5';
72
86
  var hasBrandList = (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0;
73
87
  var isOtherBrand = (brandListItem === null || brandListItem === void 0 ? void 0 : brandListItem.id) === 'other' && hasBrandList;
@@ -75,6 +89,11 @@ var Merchant = function (_a) {
75
89
  React.useEffect(function () {
76
90
  setIsRequiredNewBrand(isOtherBrand || isNewBrand);
77
91
  }, [isOtherBrand, isNewBrand]);
78
- 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(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') })) }))] })) })) }));
92
+ var handleMenuClick = function (flag) {
93
+ setListActive(flag);
94
+ };
95
+ var isSegmentsListActive = listActive === ListType.SegmentsList;
96
+ var isTeamSizeListActive = listActive === ListType.TeamSizeList;
97
+ 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(Segments, { show: !isTeamSizeListActive, onListOpen: function () { return handleMenuClick(ListType.SegmentsList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(TeamSize, { show: !isSegmentsListActive, onListOpen: function () { return handleMenuClick(ListType.TeamSizeList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(Collapse, __assign({ in: !isBrandListOpen }, { children: _jsx(SalesChannels, {}) })), _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') })) }))] })) })) }));
79
98
  };
80
99
  export default React.memo(Merchant);
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface SegmentsProps {
3
+ show: boolean;
4
+ onListOpen?: () => void;
5
+ onListClose?: () => void;
6
+ }
7
+ declare const Segments: ({ show, onListOpen, onListClose }: SegmentsProps) => JSX.Element;
8
+ export default Segments;
@@ -0,0 +1,79 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { connectSelector } from '../../../app/connect/connectStore';
14
+ import Collapse from '../../../../components/Collapse';
15
+ import { ScreenContainer } from '../../../../features/shared/Containers';
16
+ import Input from '../../../../features/shared/Input';
17
+ import { useAppSelector, useLanguage } from '../../../../hooks';
18
+ import React from 'react';
19
+ import { useTranslation } from 'react-i18next';
20
+ import { useController, useFormContext } from 'react-hook-form';
21
+ import Search from '../../../../features/shared/Search';
22
+ import SimpleList from '../../../../components/SimpleList';
23
+ import ExpandIcon from '../../../../components/ExpandIcon';
24
+ import Container from '@mui/material/Container';
25
+ import { styled } from '@mui/material/styles';
26
+ import Text from '../../../../components/Text';
27
+ import CheckIcon from '@mui/icons-material/Check';
28
+ var IncomeText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
29
+ var theme = _a.theme, isSelected = _a.isSelected;
30
+ return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
31
+ });
32
+ var CheckIconStyled = styled(CheckIcon)(function (_a) {
33
+ var theme = _a.theme;
34
+ return ({
35
+ color: theme.palette.success.main,
36
+ display: 'flex',
37
+ alignItems: 'flex-end'
38
+ });
39
+ });
40
+ var Segments = function (_a) {
41
+ var _b, _c, _d, _e;
42
+ var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose;
43
+ var _f = React.useState([]), segmentList = _f[0], setSegmentList = _f[1];
44
+ var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
45
+ var t = useTranslation().t;
46
+ var isAr = useLanguage().isAr;
47
+ var data = useAppSelector(connectSelector).data;
48
+ var control = useFormContext().control;
49
+ var segmentsList = ((_b = data.individualData.responseBody) === null || _b === void 0 ? void 0 : _b.segments_list) || [];
50
+ var segmentControl = useController({ control: control, name: 'segment' });
51
+ var segment = segmentControl.field.value;
52
+ var error = (_c = segmentControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
53
+ React.useEffect(function () {
54
+ if ((segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.length) > 0) {
55
+ setSegmentList(segmentsList);
56
+ }
57
+ }, [segmentsList]);
58
+ var onOpenList = function (event) {
59
+ setAnchorEl(event.currentTarget);
60
+ onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
61
+ };
62
+ var onCloseList = function () {
63
+ setAnchorEl(null);
64
+ onListClose === null || onListClose === void 0 ? void 0 : onListClose();
65
+ };
66
+ var onSelectItem = function (segment) {
67
+ onCloseList();
68
+ segmentControl.field.onChange(segment);
69
+ };
70
+ var handleSearch = function (value) {
71
+ var filteredList = segmentsList === null || segmentsList === void 0 ? void 0 : segmentsList.filter(function (segment) { var _a, _b; return ((_a = segment === null || segment === void 0 ? void 0 : segment.name) === null || _a === void 0 ? void 0 : _a.en.toLowerCase().includes(value.toLowerCase())) || ((_b = segment === null || segment === void 0 ? void 0 : segment.name) === null || _b === void 0 ? void 0 : _b.ar.toLowerCase().includes(value.toLowerCase())); });
72
+ setSegmentList(filteredList);
73
+ };
74
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(Input, { required: true, label: t('segment_title'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_any_segment'), value: (isAr ? (_d = segment === null || segment === void 0 ? void 0 : segment.name) === null || _d === void 0 ? void 0 : _d.ar : (_e = segment === null || segment === void 0 ? void 0 : segment.name) === null || _e === void 0 ? void 0 : _e.en) || '', warningMessage: error && t(error) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.en', 'name.ar'], list: segmentList, onSelectItem: onSelectItem, renderItem: function (item) {
75
+ var _a, _b;
76
+ return (_jsxs(_Fragment, { children: [_jsx(Container, { children: _jsx(IncomeText, __assign({ isSelected: item.id === (segment === null || segment === void 0 ? void 0 : segment.id) }, { children: isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en })) }), item.id === (segment === null || segment === void 0 ? void 0 : segment.id) && _jsx(CheckIconStyled, {})] }));
77
+ } })] }))] })) })));
78
+ };
79
+ export default Segments;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface TeamSizeProps {
3
+ show: boolean;
4
+ onListOpen?: () => void;
5
+ onListClose?: () => void;
6
+ }
7
+ declare const TeamSize: ({ show, onListOpen, onListClose }: TeamSizeProps) => JSX.Element;
8
+ export default TeamSize;
@@ -0,0 +1,79 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { connectSelector } from '../../../app/connect/connectStore';
14
+ import Collapse from '../../../../components/Collapse';
15
+ import { ScreenContainer } from '../../../../features/shared/Containers';
16
+ import Input from '../../../../features/shared/Input';
17
+ import { useAppSelector, useLanguage } from '../../../../hooks';
18
+ import React from 'react';
19
+ import { useTranslation } from 'react-i18next';
20
+ import { useController, useFormContext } from 'react-hook-form';
21
+ import Search from '../../../../features/shared/Search';
22
+ import SimpleList from '../../../../components/SimpleList';
23
+ import ExpandIcon from '../../../../components/ExpandIcon';
24
+ import Container from '@mui/material/Container';
25
+ import { styled } from '@mui/material/styles';
26
+ import Text from '../../../../components/Text';
27
+ import CheckIcon from '@mui/icons-material/Check';
28
+ var IncomeText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
29
+ var theme = _a.theme, isSelected = _a.isSelected;
30
+ return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
31
+ });
32
+ var CheckIconStyled = styled(CheckIcon)(function (_a) {
33
+ var theme = _a.theme;
34
+ return ({
35
+ color: theme.palette.success.main,
36
+ display: 'flex',
37
+ alignItems: 'flex-end'
38
+ });
39
+ });
40
+ var TeamSize = function (_a) {
41
+ var _b, _c, _d, _e;
42
+ var show = _a.show, onListOpen = _a.onListOpen, onListClose = _a.onListClose;
43
+ var _f = React.useState([]), teamSizeList = _f[0], setTeamSizeList = _f[1];
44
+ var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
45
+ var t = useTranslation().t;
46
+ var isAr = useLanguage().isAr;
47
+ var data = useAppSelector(connectSelector).data;
48
+ var control = useFormContext().control;
49
+ var teamSizesList = ((_b = data.individualData.responseBody) === null || _b === void 0 ? void 0 : _b.team_size_list) || [];
50
+ var teamSizeControl = useController({ control: control, name: 'teamSize' });
51
+ var teamSize = teamSizeControl.field.value;
52
+ var error = (_c = teamSizeControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
53
+ React.useEffect(function () {
54
+ if ((teamSizesList === null || teamSizesList === void 0 ? void 0 : teamSizesList.length) > 0) {
55
+ setTeamSizeList(teamSizesList);
56
+ }
57
+ }, [teamSizesList]);
58
+ var onOpenList = function (event) {
59
+ setAnchorEl(event.currentTarget);
60
+ onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
61
+ };
62
+ var onCloseList = function () {
63
+ setAnchorEl(null);
64
+ onListClose === null || onListClose === void 0 ? void 0 : onListClose();
65
+ };
66
+ var onSelectItem = function (teamSize) {
67
+ onCloseList();
68
+ teamSizeControl.field.onChange(teamSize);
69
+ };
70
+ var handleSearch = function (value) {
71
+ var filteredList = teamSizesList === null || teamSizesList === void 0 ? void 0 : teamSizesList.filter(function (teamSize) { var _a, _b; return ((_a = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _a === void 0 ? void 0 : _a.en.toLowerCase().includes(value.toLowerCase())) || ((_b = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _b === void 0 ? void 0 : _b.ar.toLowerCase().includes(value.toLowerCase())); });
72
+ setTeamSizeList(filteredList);
73
+ };
74
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(Input, { required: true, label: t('team_size_title'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_team_size'), value: (isAr ? (_d = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _d === void 0 ? void 0 : _d.ar : (_e = teamSize === null || teamSize === void 0 ? void 0 : teamSize.name) === null || _e === void 0 ? void 0 : _e.en) || '', warningMessage: error && t(error) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.en', 'name.ar'], list: teamSizeList, onSelectItem: onSelectItem, renderItem: function (item) {
75
+ var _a, _b;
76
+ return (_jsxs(_Fragment, { children: [_jsx(Container, { children: _jsx(IncomeText, __assign({ isSelected: item.id === (teamSize === null || teamSize === void 0 ? void 0 : teamSize.id) }, { children: isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en })) }), item.id === (teamSize === null || teamSize === void 0 ? void 0 : teamSize.id) && _jsx(CheckIconStyled, {})] }));
77
+ } })] }))] })) })));
78
+ };
79
+ export default TeamSize;
@@ -9,6 +9,8 @@ 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
+ 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
+ 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>>;
12
14
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
13
15
  salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
14
16
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -19,6 +21,8 @@ export declare const MerchantValidationSchema: (isNewBrand?: boolean) => yup.Obj
19
21
  }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
20
22
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
21
23
  }>>[] | undefined>;
24
+ 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
+ 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>>;
22
26
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
23
27
  salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
24
28
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -29,4 +33,6 @@ export declare const MerchantValidationSchema: (isNewBrand?: boolean) => yup.Obj
29
33
  }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
30
34
  id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
31
35
  }>>[] | undefined>;
36
+ 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
+ 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>>;
32
38
  }>>>;
@@ -86,6 +86,8 @@ export var MerchantValidationSchema = function (isNewBrand) {
86
86
  })
87
87
  .required('enter_brand_name_english_chars_numbers_space'),
88
88
  termAndConditionChecked: yup.boolean().isTrue('check_terms_cond').required('check_terms_cond'),
89
+ segment: yup.object().required('alert_choose_segment'),
90
+ teamSize: yup.object().required('alert_choose_teamSize'),
89
91
  salesChannels: yup
90
92
  .array()
91
93
  .min(1, 'choose_atleast_one_channel')
@@ -125,6 +127,8 @@ export var MerchantValidationSchema = function (isNewBrand) {
125
127
  return this.createError({ message: result });
126
128
  }
127
129
  })
128
- .required('choose_atleast_one_channel')
130
+ .required('choose_atleast_one_channel'),
131
+ segment: yup.object().required('alert_choose_segment'),
132
+ teamSize: yup.object().required('alert_choose_teamSize')
129
133
  });
130
134
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.1.40-test",
3
+ "version": "2.1.41-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",