@tap-payments/auth-jsconnect 2.1.79-test → 2.1.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.
@@ -858,10 +858,20 @@ export var individualSlice = createSlice({
858
858
  state.error = null;
859
859
  })
860
860
  .addCase(getCityList.fulfilled, function (state, action) {
861
+ var _a;
861
862
  state.cityLoading = false;
862
863
  state.error = null;
863
864
  var data = state.data.verify.responseBody;
864
- state.data.verify.responseBody = __assign(__assign({}, data), { cityList: action.payload });
865
+ var cityList = action.payload;
866
+ state.data.verify.responseBody = __assign(__assign({}, data), { cityList: cityList });
867
+ var birth = (((_a = state.data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.user) || {}).birth;
868
+ var city = (birth || {}).city;
869
+ if (city) {
870
+ var selectedCity = cityList === null || cityList === void 0 ? void 0 : cityList.find(function (c) {
871
+ return c.name.en === city;
872
+ });
873
+ state.data.individualPersonalData.placeOfBirthCity = selectedCity;
874
+ }
865
875
  })
866
876
  .addCase(getCityList.rejected, function (state, action) {
867
877
  state.cityLoading = false;
@@ -58,27 +58,30 @@ var BirthCity = React.forwardRef(function (_a, ref) {
58
58
  var dispatch = useAppDispatch();
59
59
  var _e = useFormContext(), control = _e.control, getValues = _e.getValues, setValue = _e.setValue;
60
60
  var _f = useAppSelector(individualSelector), data = _f.data, cityLoading = _f.cityLoading;
61
- var cityList = (data.verify.responseBody || {}).cityList;
61
+ var _g = data.verify.responseBody || {}, cityList = _g.cityList, user = _g.user;
62
62
  var placeOfBirthCityControl = useController({ control: control, name: 'placeOfBirthCity' });
63
63
  var birthCountry = getValues('placeOfBirthCountry');
64
+ var cityValue = placeOfBirthCityControl.field.value;
65
+ var error = (_b = placeOfBirthCityControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
64
66
  React.useEffect(function () {
65
67
  var _a;
66
68
  if ((cityList === null || cityList === void 0 ? void 0 : cityList.length) > 0) {
67
- var listCountry = (_a = cityList[0]) === null || _a === void 0 ? void 0 : _a.country;
68
- if (cityValue && listCountry !== cityValue.country)
69
- setValue('placeOfBirthCity', undefined);
69
+ var city_1 = (_a = cityValue === null || cityValue === void 0 ? void 0 : cityValue.name) === null || _a === void 0 ? void 0 : _a.en;
70
+ var selectedCity = cityList.find(function (c) {
71
+ return c.name.en.toLowerCase() === (city_1 === null || city_1 === void 0 ? void 0 : city_1.toLowerCase());
72
+ }) || {};
73
+ setValue('placeOfBirthCity', selectedCity, { shouldValidate: true });
70
74
  var list = __spreadArray([], cityList, true);
71
75
  setCities(list);
72
76
  }
73
77
  }, [cityList]);
74
78
  React.useEffect(function () {
75
79
  var _a, _b;
76
- var user = (data.verify.responseBody || {}).user;
77
80
  var listCountry = (cityList === null || cityList === void 0 ? void 0 : cityList.length) > 0 ? (_a = cityList[0]) === null || _a === void 0 ? void 0 : _a.country : (_b = user === null || user === void 0 ? void 0 : user.birth) === null || _b === void 0 ? void 0 : _b.country;
78
81
  var iso2 = (birthCountry || {}).iso2;
79
82
  if (!listCountry || !iso2)
80
83
  return;
81
- if (listCountry !== iso2) {
84
+ if ((listCountry === null || listCountry === void 0 ? void 0 : listCountry.toLowerCase()) !== (iso2 === null || iso2 === void 0 ? void 0 : iso2.toLowerCase())) {
82
85
  dispatch(getCityList(iso2));
83
86
  }
84
87
  }, [birthCountry]);
@@ -99,8 +102,6 @@ var BirthCity = React.forwardRef(function (_a, ref) {
99
102
  var _a;
100
103
  return (_a = city === null || city === void 0 ? void 0 : city.name) === null || _a === void 0 ? void 0 : _a.en;
101
104
  };
102
- var cityValue = placeOfBirthCityControl.field.value;
103
- var error = (_b = placeOfBirthCityControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
104
105
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { pt: 2.5 } }, { children: [_jsx(Input, { label: t('place_birth_city_label'), readOnly: true, 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) {
105
106
  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, {})] }));
106
107
  } }) }))] })) })));
@@ -80,7 +80,7 @@ var IndividualPersonalInfo = function (_a) {
80
80
  },
81
81
  mode: 'onChange'
82
82
  });
83
- useSetFromDefaultValues(methods, data.individualPersonalData, true);
83
+ useSetFromDefaultValues(methods, data.individualPersonalData);
84
84
  var _c = React.useState(), listActive = _c[0], setListActive = _c[1];
85
85
  var _d = React.useState(false), dobActive = _d[0], setDobActive = _d[1];
86
86
  var _e = React.useState(false), expiryDateActive = _e[0], setExpiryDateActive = _e[1];
@@ -126,7 +126,7 @@ var IndividualPersonalInfo = function (_a) {
126
126
  var isBirthCountryListActive = listActive === ListType.BirthCountryList;
127
127
  var isBirthCityListActive = listActive === ListType.BirthCityList;
128
128
  var isNationalityListActive = listActive === ListType.NationalityList;
129
- return (_jsxs(ScreenContainer, { children: [_jsx(Collapse, __assign({ in: showField && !!(user === null || user === void 0 ? void 0 : user.is_authorized), timeout: 500 }, { children: _jsxs(TextBoxStyled, { children: [getUserName() || '', _jsx(RoleTextStyled, { children: getUserOccupation() || '' })] }) })), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Box, { children: [_jsx(Name, { show: showField }), _jsx(MobileNumber, { show: showField, countries: countries }), _jsx(Email, { show: showField }), _jsx(Gender, { show: showField }), _jsx(ID, { show: showField }), _jsx(IssuedCountry, { show: !dobActive && !expiryDateActive && !isBirthCountryListActive && !isBirthCityListActive && !isNationalityListActive, countries: countries, onListOpen: function () { return handleMenuClick(ListType.IssuedCountryList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(ExpiryDate, { show: !listActive && !dobActive, onDateClicked: handleExpiryDateActive }), _jsx(DOB, { show: !listActive && !expiryDateActive, onDateClicked: handleDobActive }), _jsx(BirthCountry, { show: !dobActive && !expiryDateActive && !isIssuedCountryListActive && !isBirthCityListActive && !isNationalityListActive, countries: countries, onListOpen: function () { return handleMenuClick(ListType.BirthCountryList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(BirthCity, { show: !dobActive && !expiryDateActive && !isIssuedCountryListActive && !isNationalityListActive, onListOpen: function () { return handleMenuClick(ListType.BirthCityList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(Nationality, { show: !dobActive && !expiryDateActive && !isIssuedCountryListActive && !isBirthCityListActive, countries: countries, onListOpen: function () { return handleMenuClick(ListType.NationalityList); }, onListClose: function () { return handleMenuClick(); } })] }), _jsx(Collapse, __assign({ in: showField, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: !(user === null || user === void 0 ? void 0 : user.is_authorized), disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) }))] }));
129
+ return (_jsxs(ScreenContainer, { children: [_jsx(Collapse, __assign({ in: showField && !!(user === null || user === void 0 ? void 0 : user.is_authorized), timeout: 500 }, { children: _jsxs(TextBoxStyled, { children: [getUserName() || '', _jsx(RoleTextStyled, { children: getUserOccupation() || '' })] }) })), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Box, { children: [_jsx(Name, { show: showField }), _jsx(MobileNumber, { show: showField, countries: countries }), _jsx(Email, { show: showField }), _jsx(Gender, { show: showField }), _jsx(ID, { show: showField }), _jsx(IssuedCountry, { show: !dobActive && !expiryDateActive && !isBirthCountryListActive && !isBirthCityListActive && !isNationalityListActive, countries: countries, onListOpen: function () { return handleMenuClick(ListType.IssuedCountryList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(ExpiryDate, { show: !listActive && !dobActive, onDateClicked: handleExpiryDateActive }), _jsx(DOB, { show: !listActive && !expiryDateActive, onDateClicked: handleDobActive }), _jsx(BirthCountry, { show: !dobActive && !expiryDateActive && !isIssuedCountryListActive && !isBirthCityListActive && !isNationalityListActive, countries: countries, onListOpen: function () { return handleMenuClick(ListType.BirthCountryList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(BirthCity, { show: !dobActive && !expiryDateActive && !isIssuedCountryListActive && !isBirthCountryListActive && !isNationalityListActive, onListOpen: function () { return handleMenuClick(ListType.BirthCityList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(Nationality, { show: !dobActive && !expiryDateActive && !isIssuedCountryListActive && !isBirthCityListActive && !isBirthCountryListActive, countries: countries, onListOpen: function () { return handleMenuClick(ListType.NationalityList); }, onListClose: function () { return handleMenuClick(); } })] }), _jsx(Collapse, __assign({ in: showField, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: !(user === null || user === void 0 ? void 0 : user.is_authorized), disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) }))] }));
130
130
  };
131
131
  export default React.memo(IndividualPersonalInfo);
132
132
  IndividualPersonalInfo.defaultProps = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.1.79-test",
3
+ "version": "2.1.80-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",