@tap-payments/auth-jsconnect 2.3.59-test → 2.3.62-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.
@@ -32,6 +32,7 @@ export interface City {
32
32
  name: {
33
33
  id: string;
34
34
  en: string;
35
+ ar: string;
35
36
  };
36
37
  state: string;
37
38
  un_locode: string;
@@ -981,7 +981,8 @@ export var individualSlice = createSlice({
981
981
  }
982
982
  if (birth === null || birth === void 0 ? void 0 : birth.city) {
983
983
  var selectedCity = cityList === null || cityList === void 0 ? void 0 : cityList.find(function (city) {
984
- return city.name.en === (birth === null || birth === void 0 ? void 0 : birth.city);
984
+ var _a;
985
+ return city.id === ((_a = birth === null || birth === void 0 ? void 0 : birth.city) === null || _a === void 0 ? void 0 : _a.cityId);
985
986
  });
986
987
  state.data.individualPersonalData.placeOfBirthCity = selectedCity;
987
988
  }
@@ -120,17 +120,25 @@ var ActivitiesList = function (_a) {
120
120
  var activities = (verify.responseBody || {}).activities;
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
+ var setSelectedActivitiesBeginning = function (list) {
124
+ 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);
125
+ setActivitiesMenuList(mapSelectedListFirst);
126
+ };
123
127
  React.useEffect(function () {
124
128
  if ((activities === null || activities === void 0 ? void 0 : activities.length) > 0) {
125
129
  var list = __spreadArray([], activities, true);
126
130
  var sortedList = sortActivitiesByName(list, isAr ? 'name.ar' : 'name.en');
127
- setActivitiesMenuList(sortedList);
131
+ setSelectedActivitiesBeginning(sortedList);
128
132
  }
129
133
  }, [activities]);
130
134
  var onOpenList = function (event) {
131
135
  var _a;
132
136
  if (readOnly)
133
137
  return;
138
+ if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > (activities === null || activities === void 0 ? void 0 : activities.length)) {
139
+ var list = __spreadArray([], activitiesMenuList, true);
140
+ setSelectedActivitiesBeginning(list);
141
+ }
134
142
  setAnchorEl(event.currentTarget);
135
143
  (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
136
144
  };
@@ -60,19 +60,15 @@ import { debounce } from 'lodash-es';
60
60
  import Collapse from '../../../../components/Collapse';
61
61
  import { styled } from '@mui/material/styles';
62
62
  import CircularProgress from '@mui/material/CircularProgress';
63
- var InputStyled = styled(Input)(function (_a) {
64
- var theme = _a.theme;
65
- return ({
66
- input: {
67
- textTransform: 'lowercase'
68
- }
69
- });
70
- });
63
+ var InputStyled = styled(Input)(function () { return ({
64
+ input: {
65
+ textTransform: 'lowercase'
66
+ }
67
+ }); });
71
68
  var cancelToken = null;
72
69
  var Email = function (_a) {
73
70
  var _b, _c, _d;
74
71
  var show = _a.show, fetchingEmail = _a.fetchingEmail, emailChecking = _a.emailChecking;
75
- var _e = React.useState(''), storedEmail = _e[0], setStoredEmail = _e[1];
76
72
  var dispatch = useAppDispatch();
77
73
  var data = useAppSelector(connectSelector).data;
78
74
  var t = useTranslation().t;
@@ -97,15 +93,9 @@ var Email = function (_a) {
97
93
  var handleEmailChange = function (event) {
98
94
  emailControl.field.onChange(event.target.value);
99
95
  };
100
- React.useEffect(function () {
101
- var _a, _b;
102
- var email = (_b = (_a = data.otpData.responseBody) === null || _a === void 0 ? void 0 : _a.contact) === null || _b === void 0 ? void 0 : _b.email;
103
- if (!!email)
104
- setStoredEmail(email);
105
- }, [data.otpData.responseBody]);
106
96
  React.useEffect(function () {
107
97
  var isValid = emailValue && !error && emailValue.length > 3;
108
- if (isValid && emailValue != storedEmail) {
98
+ if (isValid && emailValue != email) {
109
99
  fetchingEmail(true);
110
100
  checkEmail(emailValue);
111
101
  }
@@ -108,12 +108,15 @@ var ActivitiesList = function (props) {
108
108
  var type = licenseType === 'freelance' ? BusinessType.FL : BusinessType.CR;
109
109
  var isCR = type === BusinessType.CR;
110
110
  var disabled = false;
111
+ var setSelectedActivitiesBeginning = function (list) {
112
+ 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);
113
+ setActivitiesMenuList(mapSelectedListFirst);
114
+ };
111
115
  React.useEffect(function () {
112
116
  if ((activityList === null || activityList === void 0 ? void 0 : activityList.length) > 0) {
113
117
  var list = __spreadArray([], activityList, true);
114
118
  var sortedList = sortActivitiesByName(list, isAr ? 'name.ar' : 'name.en');
115
- var mapSelectedListFirst = __spreadArray(__spreadArray([], sortedList.filter(function (a) { return (controlValue || []).some(function (c) { return a.id === c.id; }); }), true), sortedList.filter(function (a) { return !(controlValue || []).some(function (c) { return a.id === c.id; }); }), true);
116
- setActivitiesMenuList(mapSelectedListFirst);
119
+ setSelectedActivitiesBeginning(sortedList);
117
120
  }
118
121
  }, [activityList]);
119
122
  var onOpenList = function (event) {
@@ -122,8 +125,7 @@ var ActivitiesList = function (props) {
122
125
  return;
123
126
  if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > ((_a = entity === null || entity === void 0 ? void 0 : entity.activities) === null || _a === void 0 ? void 0 : _a.length)) {
124
127
  var list = __spreadArray([], activitiesMenuList, true);
125
- 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);
126
- setActivitiesMenuList(mapSelectedListFirst);
128
+ setSelectedActivitiesBeginning(list);
127
129
  }
128
130
  setAnchorEl(event.currentTarget);
129
131
  (_b = props.onListOpen) === null || _b === void 0 ? void 0 : _b.call(props);
@@ -26,7 +26,7 @@ import { useController, useFormContext } from 'react-hook-form';
26
26
  import { styled } from '@mui/material/styles';
27
27
  import CheckIcon from '@mui/icons-material/Check';
28
28
  import CircularProgress from '@mui/material/CircularProgress';
29
- import { useAppDispatch, useAppSelector } from '../../../../hooks';
29
+ import { useAppDispatch, useAppSelector, useLanguage } from '../../../../hooks';
30
30
  import Collapse from '../../../../components/Collapse';
31
31
  import ExpandIcon from '../../../../components/ExpandIcon';
32
32
  import Text from '../../../../components/Text';
@@ -64,6 +64,7 @@ var BirthCity = React.forwardRef(function (_a, ref) {
64
64
  var _d = React.useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
65
65
  var t = useTranslation().t;
66
66
  var dispatch = useAppDispatch();
67
+ var isAr = useLanguage().isAr;
67
68
  var _e = useFormContext(), control = _e.control, getValues = _e.getValues, setValue = _e.setValue;
68
69
  var _f = useAppSelector(individualSelector), data = _f.data, cityLoading = _f.cityLoading;
69
70
  var _g = data.verify.responseBody || {}, cityList = _g.cityList, user = _g.user;
@@ -72,11 +73,10 @@ var BirthCity = React.forwardRef(function (_a, ref) {
72
73
  var cityValue = placeOfBirthCityControl.field.value;
73
74
  var error = (_b = placeOfBirthCityControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
74
75
  React.useEffect(function () {
75
- var _a;
76
76
  if ((cityList === null || cityList === void 0 ? void 0 : cityList.length) > 0) {
77
- var city_1 = (_a = cityValue === null || cityValue === void 0 ? void 0 : cityValue.name) === null || _a === void 0 ? void 0 : _a.en;
77
+ var cityId_1 = cityValue === null || cityValue === void 0 ? void 0 : cityValue.id;
78
78
  var selectedCity = cityList.find(function (c) {
79
- return c.name.en.toLowerCase() === (city_1 === null || city_1 === void 0 ? void 0 : city_1.toLowerCase());
79
+ return c.id === cityId_1;
80
80
  }) || {};
81
81
  setValue('placeOfBirthCity', selectedCity, { shouldValidate: true });
82
82
  var list = __spreadArray([], cityList, true);
@@ -109,8 +109,8 @@ var BirthCity = React.forwardRef(function (_a, ref) {
109
109
  placeOfBirthCityControl.field.onChange(city);
110
110
  };
111
111
  var getName = function (city) {
112
- var _a;
113
- return (_a = city === null || city === void 0 ? void 0 : city.name) === null || _a === void 0 ? void 0 : _a.en;
112
+ var _a, _b;
113
+ return isAr ? (_a = city === null || city === void 0 ? void 0 : city.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = city === null || city === void 0 ? void 0 : city.name) === null || _b === void 0 ? void 0 : _b.en;
114
114
  };
115
115
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { pt: 2.5 } }, { children: [_jsx(InputStyled, { label: t('place_birth_city_label'), readOnly: readOnly, placeholder: t('choose_place_birth_city'), value: getName(cityValue) || '', warningMessage: error && t(error), onClick: cityLoading ? undefined : !!anchorEl ? function () { return onCloseCitySelect(); } : onOpenCitySelect, endAdornment: cityLoading ? _jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } }) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.en', searchValuePath: ['name.en'], list: locationCities, onSelectItem: onSelectItem, renderItem: function (item) {
116
116
  return (_jsxs(_Fragment, { children: [_jsx(CountryItemContainer, { children: _jsx(CountryNameText, __assign({ isSelected: item.id === (cityValue === null || cityValue === void 0 ? void 0 : cityValue.id) }, { children: getName(item) })) }), item.id === (cityValue === null || cityValue === void 0 ? void 0 : cityValue.id) && _jsx(CheckIconStyled, {})] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.3.59-test",
3
+ "version": "2.3.62-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",