@tap-payments/auth-jsconnect 2.3.64-test → 2.3.67-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.
@@ -4,14 +4,16 @@ import { ListItemProps } from '@mui/material/ListItem';
4
4
  import { SxProps, Theme } from '@mui/material/styles';
5
5
  export interface SimpleListProps<T> extends ListProps {
6
6
  list: Array<T>;
7
+ selectedItems?: Array<T>;
7
8
  listItemProps?: ListItemProps;
8
9
  onSelectItem: (item: T) => void;
9
10
  renderItem: (item: T, idx: number) => React.ReactElement;
10
11
  searchKeyPath?: string;
11
12
  searchValuePath?: string[];
13
+ getSelectedItemCondition?: (a: T, b: T) => boolean;
12
14
  sx?: SxProps<Theme>;
13
15
  }
14
- declare function SimpleList<T>({ list, listItemProps, onSelectItem, renderItem, children, searchKeyPath, searchValuePath, ...rest }: SimpleListProps<T>): JSX.Element;
16
+ declare function SimpleList<T>({ list, listItemProps, onSelectItem, renderItem, children, searchKeyPath, searchValuePath, selectedItems, getSelectedItemCondition, ...rest }: SimpleListProps<T>): JSX.Element;
15
17
  declare namespace SimpleList {
16
18
  var defaultProps: {
17
19
  searchKeyPath: string;
@@ -20,6 +20,15 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
+ if (ar || !(i in from)) {
26
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
+ ar[i] = from[i];
28
+ }
29
+ }
30
+ return to.concat(ar || Array.prototype.slice.call(from));
31
+ };
23
32
  import { createElement as _createElement } from "react";
24
33
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
25
34
  import * as React from 'react';
@@ -69,11 +78,18 @@ var ListItemStyled = styled(ListItem)(function (_a) {
69
78
  });
70
79
  });
71
80
  function SimpleList(_a) {
72
- var list = _a.list, listItemProps = _a.listItemProps, onSelectItem = _a.onSelectItem, renderItem = _a.renderItem, children = _a.children, searchKeyPath = _a.searchKeyPath, searchValuePath = _a.searchValuePath, rest = __rest(_a, ["list", "listItemProps", "onSelectItem", "renderItem", "children", "searchKeyPath", "searchValuePath"]);
81
+ var list = _a.list, listItemProps = _a.listItemProps, onSelectItem = _a.onSelectItem, renderItem = _a.renderItem, children = _a.children, searchKeyPath = _a.searchKeyPath, searchValuePath = _a.searchValuePath, selectedItems = _a.selectedItems, getSelectedItemCondition = _a.getSelectedItemCondition, rest = __rest(_a, ["list", "listItemProps", "onSelectItem", "renderItem", "children", "searchKeyPath", "searchValuePath", "selectedItems", "getSelectedItemCondition"]);
73
82
  var _b = React.useState(list), items = _b[0], setItems = _b[1];
74
83
  React.useEffect(function () {
75
84
  setItems(list);
76
85
  }, [list]);
86
+ var mapSelectedItemBeginning = React.useMemo(function () {
87
+ if (getSelectedItemCondition && (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length)) {
88
+ var mapSelectedListFirst = __spreadArray(__spreadArray([], items.filter(function (a) { return selectedItems.some(function (c) { return getSelectedItemCondition(a, c); }); }), true), items.filter(function (a) { return !selectedItems.some(function (c) { return getSelectedItemCondition(a, c); }); }), true);
89
+ return mapSelectedListFirst;
90
+ }
91
+ return items;
92
+ }, [items, selectedItems]);
77
93
  var filterItemsByKey = function (arr, searchKey) {
78
94
  return arr.filter(function (item) {
79
95
  var searchValue = get(item, searchKeyPath || '') || '';
@@ -104,7 +120,7 @@ function SimpleList(_a) {
104
120
  setItems(list);
105
121
  };
106
122
  return (_jsxs(_Fragment, { children: [(searchValuePath === null || searchValuePath === void 0 ? void 0 : searchValuePath.length) && _jsx(Search, { onSearchValue: onSearch }), _jsx(ListStyled, __assign({}, rest, { children: children ||
107
- items.map(function (item, idx) {
123
+ mapSelectedItemBeginning.map(function (item, idx) {
108
124
  return (_createElement(ListItemStyled, __assign({}, listItemProps, { onClick: function () {
109
125
  onSelectItem(item);
110
126
  }, disableGutters: true, key: idx }), renderItem(item, idx)));
@@ -117,7 +117,7 @@ var ActivitiesList = function (_a) {
117
117
  var controlValue = activitiesControl.field.value;
118
118
  var _g = React.useState(false), isHovered = _g[0], setIsHovered = _g[1];
119
119
  var verify = data.verify;
120
- var activities = (verify.responseBody || {}).activities;
120
+ var _h = verify.responseBody || {}, activities = _h.activities, brand = _h.brand;
121
121
  var isCR = ((_d = (_c = (_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.license) === null || _d === void 0 ? void 0 : _d.type) === 'commercial_registration';
122
122
  var disabled = false;
123
123
  var setSelectedActivitiesBeginning = function (list) {
@@ -132,15 +132,15 @@ var ActivitiesList = function (_a) {
132
132
  }
133
133
  }, [activities]);
134
134
  var onOpenList = function (event) {
135
- var _a;
135
+ var _a, _b;
136
136
  if (readOnly)
137
137
  return;
138
- if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > (activities === null || activities === void 0 ? void 0 : activities.length)) {
138
+ if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > ((_a = brand === null || brand === void 0 ? void 0 : brand.activities) === null || _a === void 0 ? void 0 : _a.length)) {
139
139
  var list = __spreadArray([], activitiesMenuList, true);
140
140
  setSelectedActivitiesBeginning(list);
141
141
  }
142
142
  setAnchorEl(event.currentTarget);
143
- (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
143
+ (_b = rest.onListOpen) === null || _b === void 0 ? void 0 : _b.call(rest);
144
144
  };
145
145
  var onCloseList = function () {
146
146
  var _a;
@@ -103,7 +103,7 @@ var ExpectedCustomers = function (_a) {
103
103
  };
104
104
  var expectedCustomersValue = expectedCustomerControl.field.value;
105
105
  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', list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
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
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
108
  } })] }))] }) })));
109
109
  };
@@ -118,16 +118,21 @@ var ActivitiesList = function (_a) {
118
118
  var activities = (businessTypeData.responseBody || {}).activities;
119
119
  var businessType = (_b = businessTypeData.selectedLicense) === null || _b === void 0 ? void 0 : _b.type;
120
120
  var isCR = businessType === BusinessType.CR;
121
+ var setSelectedActivitiesBeginning = function (list) {
122
+ var mapSelectedListFirst = __spreadArray(__spreadArray([], list.filter(function (a) { return (controlValue || []).some(function (c) { return a.id === c.id; }); }), true), list.filter(function (a) { return !(controlValue || []).some(function (c) { return a.id === c.id; }); }), true);
123
+ setActivitiesMenuList(mapSelectedListFirst);
124
+ };
121
125
  React.useEffect(function () {
122
126
  if ((activities === null || activities === void 0 ? void 0 : activities.length) > 0) {
123
127
  var list = __spreadArray([], activities, true);
124
128
  var sortedList = sortActivitiesByName(list, isAr ? 'name.ar' : 'name.en');
125
- setActivitiesMenuList(sortedList);
129
+ setSelectedActivitiesBeginning(sortedList);
126
130
  }
127
131
  }, [activities]);
128
132
  var onOpenList = function (event) {
129
133
  var _a;
130
134
  setAnchorEl(event.currentTarget);
135
+ setSelectedActivitiesBeginning(activitiesMenuList);
131
136
  (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
132
137
  };
133
138
  var onCloseList = function () {
@@ -21,14 +21,16 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { useEffect } from 'react';
24
- import { handleActiveFlowScreens, handleSetAppConfig, handleLanguage, handleOpen, handleIsTapOrigin, fetchAppSettingsSync, handelBoardMaturity } from '../app/settings';
24
+ import { handleActiveFlowScreens, handleSetAppConfig, handleLanguage, handleOpen, handleIsTapOrigin, fetchAppSettingsSync, handelBoardMaturity, settingsSelector } from '../app/settings';
25
25
  import { useAppDispatch } from './useAppDispatch';
26
+ import { useAppSelector } from './useAppSelector';
26
27
  import { axiosInstance } from '../api';
27
28
  import { isTapDomain, removeRequestHeaders } from '../utils';
28
29
  import { ENDPOINT_PATHS } from '../constants';
29
30
  export var useAppConfig = function (_a) {
30
31
  var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, disableCountries = _a.disableCountries, disableLocale = _a.disableLocale, disableSettingFetching = _a.disableSettingFetching, maturity = _a.maturity, boardMaturity = _a.boardMaturity, rest = __rest(_a, ["appInfo", "navigation", "publicKey", "disableCountries", "disableLocale", "disableSettingFetching", "maturity", "boardMaturity"]);
31
32
  var dispatch = useAppDispatch();
33
+ var data = useAppSelector(settingsSelector).data;
32
34
  var setBaseUrl = function () {
33
35
  var isProd = publicKey.includes('pk_live');
34
36
  if (isProd) {
@@ -58,7 +60,8 @@ export var useAppConfig = function (_a) {
58
60
  setAppConfig();
59
61
  if (typeof boardMaturity === 'boolean')
60
62
  dispatch(handelBoardMaturity(boardMaturity));
61
- dispatch(handleLanguage(rest.language));
63
+ if (!data.isMaturityExpress)
64
+ dispatch(handleLanguage(rest.language));
62
65
  if (!disableSettingFetching)
63
66
  dispatch(fetchAppSettingsSync({ disableCountries: disableCountries, disableLocale: disableLocale, mdn: rest.merchantDomain, maturity: maturity }));
64
67
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.3.64-test",
3
+ "version": "2.3.67-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",