@tap-payments/auth-jsconnect 2.0.70-test → 2.0.71-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,14 +271,13 @@ export var verifyAuth = createAsyncThunk('verifyAuth', function (params, thunkAp
271
271
  });
272
272
  }); });
273
273
  export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
274
- var _a, settings, connect, responseBody, leadBody, expiry, interval, maxCalls, response, count, data, isSuccess, leadBody_1, leadBody_2;
274
+ var _a, settings, connect, responseBody, expiry, interval, maxCalls, response, count, data, isSuccess, leadData, leadBody;
275
275
  var _b, _c, _d, _e;
276
276
  return __generator(this, function (_f) {
277
277
  switch (_f.label) {
278
278
  case 0:
279
279
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
280
280
  responseBody = connect.data.civilIdData.responseBody;
281
- leadBody = connect.data.otpData.responseBody;
282
281
  expiry = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.expiry) || 120;
283
282
  interval = 3;
284
283
  maxCalls = Math.floor(expiry / interval);
@@ -286,49 +285,49 @@ export var verifyPACI = createAsyncThunk('verifyPACI', function (params, thunkAp
286
285
  count = 1;
287
286
  _f.label = 1;
288
287
  case 1:
289
- if (!(count <= maxCalls)) return [3, 7];
288
+ if (!(count <= maxCalls)) return [3, 8];
290
289
  if (thunkApi.signal.aborted) {
291
- return [3, 7];
290
+ return [3, 8];
292
291
  }
293
292
  return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
294
293
  case 2:
295
294
  data = _f.sent();
296
295
  response = data;
297
- if (count === 1 && (leadBody === null || leadBody === void 0 ? void 0 : leadBody.is_new_individual) === false) {
298
- thunkApi.dispatch(retrieveBrandList(data === null || data === void 0 ? void 0 : data.individual_id));
299
- thunkApi.dispatch(retrieveChannels());
300
- }
301
296
  isSuccess = ((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
302
- if (!isSuccess) return [3, 4];
297
+ if (!isSuccess) return [3, 5];
303
298
  return [4, ((_c = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _c === void 0 ? void 0 : _c.call(params))];
304
299
  case 3:
305
300
  _f.sent();
306
- if ((leadBody === null || leadBody === void 0 ? void 0 : leadBody.is_new_individual) && (data === null || data === void 0 ? void 0 : data.lead_id)) {
307
- leadBody_1 = {
308
- leadId: data === null || data === void 0 ? void 0 : data.lead_id,
309
- stepName: 'CONNECT_INDIVIDUAL_STEP'
310
- };
311
- thunkApi.dispatch(retrieveLead(leadBody_1));
301
+ return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.lead_id)];
302
+ case 4:
303
+ leadData = (_f.sent()).data;
304
+ response = __assign(__assign({}, response), leadData);
305
+ if (count === 1 && (leadData === null || leadData === void 0 ? void 0 : leadData.is_new_individual) === false) {
306
+ thunkApi.dispatch(retrieveBrandList(data === null || data === void 0 ? void 0 : data.individual_id));
307
+ thunkApi.dispatch(retrieveChannels());
308
+ }
309
+ if ((leadData === null || leadData === void 0 ? void 0 : leadData.is_new_individual) && (data === null || data === void 0 ? void 0 : data.lead_id)) {
310
+ thunkApi.dispatch(handleNextScreenStep('CONNECT_INDIVIDUAL_STEP'));
312
311
  }
313
312
  else if (!(data === null || data === void 0 ? void 0 : data.lead_id) && (data === null || data === void 0 ? void 0 : data.individual_id)) {
314
- leadBody_2 = {
313
+ leadBody = {
315
314
  individualId: data === null || data === void 0 ? void 0 : data.individual_id,
316
315
  stepName: 'CONNECT_MERCHANT_INFO_STEP'
317
316
  };
318
- thunkApi.dispatch(createLead(leadBody_2));
317
+ thunkApi.dispatch(createLead(leadBody));
319
318
  }
320
319
  else
321
320
  thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
322
321
  (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, {});
323
- return [3, 7];
324
- case 4: return [4, sleep(interval * 1000)];
325
- case 5:
326
- _f.sent();
327
- _f.label = 6;
322
+ return [3, 8];
323
+ case 5: return [4, sleep(interval * 1000)];
328
324
  case 6:
325
+ _f.sent();
326
+ _f.label = 7;
327
+ case 7:
329
328
  count++;
330
329
  return [3, 1];
331
- case 7: return [2, { response: response }];
330
+ case 8: return [2, { response: response }];
332
331
  }
333
332
  });
334
333
  }); });
@@ -696,9 +695,27 @@ export var connectSlice = createSlice({
696
695
  state.error = null;
697
696
  })
698
697
  .addCase(verifyPACI.fulfilled, function (state, action) {
698
+ var _a;
699
699
  state.loading = false;
700
700
  state.error = null;
701
701
  state.data.otpData.responseBody = action.payload.response;
702
+ var _b = action.payload.response, name = _b.name, contact = _b.contact, brand = _b.brand;
703
+ var _c = contact || {}, email = _c.email, phone = _c.phone;
704
+ var firstName = (name === null || name === void 0 ? void 0 : name.first) + ' ';
705
+ var middleName = !!(name === null || name === void 0 ? void 0 : name.middle) ? (name === null || name === void 0 ? void 0 : name.middle) + ' ' : '';
706
+ var thirdName = !!(name === null || name === void 0 ? void 0 : name.third) ? (name === null || name === void 0 ? void 0 : name.third) + ' ' : '';
707
+ var lastName = !!(name === null || name === void 0 ? void 0 : name.last) ? name === null || name === void 0 ? void 0 : name.last : '';
708
+ if (!!name) {
709
+ var capitalizedName = capitalizeTheFirstLetterOfEachWord(firstName + middleName + thirdName + lastName);
710
+ state.data.individualData.name = capitalizedName;
711
+ }
712
+ if (!!email)
713
+ state.data.individualData.email = email;
714
+ if (!!(phone === null || phone === void 0 ? void 0 : phone.number))
715
+ state.data.individualData.mobile = phone === null || phone === void 0 ? void 0 : phone.number;
716
+ state.data.brandData.brandName = (_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en;
717
+ state.data.brandData.links.website = brand === null || brand === void 0 ? void 0 : brand.website;
718
+ state.data.otpData.responseBody = action.payload.response;
702
719
  })
703
720
  .addCase(verifyPACI.rejected, function (state, action) {
704
721
  state.loading = false;
@@ -20,9 +20,8 @@ import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
20
20
  import { settingsSelector, handlePrevScreenStep } from '../../../../app/settings';
21
21
  import { clearError, businessSelector, createCivilIdAuth } from '../../../app/business/businessStore';
22
22
  import Form from '../../../../components/Form';
23
- import Button, { MobileButton } from '../../../shared/Button';
23
+ import Button from '../../../shared/Button';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
25
- import Collapse from '../../../../components/Collapse';
26
25
  import Box from '@mui/material/Box';
27
26
  import Divider from '@mui/material/Divider';
28
27
  import Text from '../../../../components/Text';
@@ -80,6 +79,6 @@ var CivilID = function (_a) {
80
79
  dispatch(handlePrevScreenStep('CONNECT_MOBILE_STEP'));
81
80
  };
82
81
  var disabled = !methods.formState.isValid || !!error;
83
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, { sx: { mb: methods.formState.isValid ? 7.5 : 0, transition: 'mb 0.3s' } }), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(Collapse, __assign({ in: !methods.formState.isValid }, { children: [_jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(MobileButton, __assign({ onClick: function () { return onBack(); }, disabled: loading || settingsStore.loading }, { children: t('mobile_button_label') }))] }))] })) })) }));
82
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, { sx: { mb: 7.5, transition: 'mb 0.3s' } }), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
84
83
  };
85
84
  export default React.memo(CivilID);
@@ -130,7 +130,6 @@ var customerLocations = function (_a) {
130
130
  };
131
131
  var customerLocationsValue = customerLocationsControl.field.value;
132
132
  var customerLocationSelected = customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue[0];
133
- console.log(customerLocationSelected, 'sele');
134
133
  return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('select_customer_base') }), _jsx(InputStyled, { readOnly: true, value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.ar : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.name.en, 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', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
135
134
  return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.name.ar : item.name.en })) })), item.id === (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(CheckIconStyled, {}), checkRemainingCondition(item) && item.id != (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(RemainingCheck, {})] }));
136
135
  } })] }))] }) })));
@@ -91,16 +91,16 @@ var ExpectedSalesRange = function (_a) {
91
91
  expectedSaleControl.field.onChange(expectedSalesRange);
92
92
  };
93
93
  var handleSearch = function (value) {
94
- var filteredSubList = expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.filter(function (salesRange) {
95
- var _a;
96
- return (_a = salesRange.sub) === null || _a === void 0 ? void 0 : _a.find(function (obj) { return obj.name.en.toLowerCase().startsWith(value.toLowerCase()); });
97
- });
98
94
  var filteredList = expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales.filter(function (salesRange) {
99
- var _a, _b;
95
+ var _a, _b, _c;
100
96
  return salesRange.name.en.toLowerCase().includes(value.toLowerCase()) ||
97
+ salesRange.name.en.toLowerCase().replace(',', '').includes(value.toLowerCase()) ||
101
98
  salesRange.name.ar.toLowerCase().includes(value.toLowerCase()) ||
102
99
  ((_a = salesRange.sub) === null || _a === void 0 ? void 0 : _a.find(function (obj) { return obj.name.en.toLowerCase().includes(value.toLowerCase()); })) ||
103
- ((_b = salesRange.sub) === null || _b === void 0 ? void 0 : _b.find(function (obj) { return obj.name.ar.toLowerCase().includes(value.toLowerCase()); }));
100
+ ((_b = salesRange.sub) === null || _b === void 0 ? void 0 : _b.find(function (obj) {
101
+ return obj.name.en.toLowerCase().replace(',', '').includes(value.toLowerCase());
102
+ })) ||
103
+ ((_c = salesRange.sub) === null || _c === void 0 ? void 0 : _c.find(function (obj) { return obj.name.ar.toLowerCase().includes(value.toLowerCase()); }));
104
104
  });
105
105
  setExpectedSalesRangeList(filteredList);
106
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.70-test",
3
+ "version": "2.0.71-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",