@tap-payments/auth-jsconnect 2.10.17-development → 2.10.19-development

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.
@@ -234,6 +234,9 @@ export declare const OTHER_FL_LICENSE: {
234
234
  };
235
235
  license: {
236
236
  number: string;
237
+ additional_info: {
238
+ unified_number: string;
239
+ };
237
240
  };
238
241
  type: BusinessType;
239
242
  };
@@ -245,6 +248,9 @@ export declare const OTHER_ENTITY_LICENSE: {
245
248
  };
246
249
  license: {
247
250
  number: string;
251
+ additional_info: {
252
+ unified_number: string;
253
+ };
248
254
  };
249
255
  type: BusinessType;
250
256
  };
@@ -255,6 +261,9 @@ export declare const OTHER_CR_LICENSE: {
255
261
  };
256
262
  license: {
257
263
  number: string;
264
+ additional_info: {
265
+ unified_number: string;
266
+ };
258
267
  };
259
268
  type: BusinessType;
260
269
  };
@@ -1241,7 +1241,8 @@ export var OTHER_FL_LICENSE = {
1241
1241
  en: 'add_other_fl'
1242
1242
  },
1243
1243
  license: {
1244
- number: 'other_fl'
1244
+ number: 'other_fl',
1245
+ additional_info: { unified_number: 'other_fl' }
1245
1246
  },
1246
1247
  type: BusinessType.FL
1247
1248
  };
@@ -1252,7 +1253,8 @@ export var OTHER_ENTITY_LICENSE = {
1252
1253
  en: 'add_other'
1253
1254
  },
1254
1255
  license: {
1255
- number: 'other_entity'
1256
+ number: 'other_entity',
1257
+ additional_info: { unified_number: 'other_entity' }
1256
1258
  },
1257
1259
  type: BusinessType.CR
1258
1260
  };
@@ -1262,7 +1264,8 @@ export var OTHER_CR_LICENSE = {
1262
1264
  en: 'add_other_cr'
1263
1265
  },
1264
1266
  license: {
1265
- number: 'other_cr'
1267
+ number: 'other_cr',
1268
+ additional_info: { unified_number: 'other_cr' }
1266
1269
  },
1267
1270
  type: BusinessType.CR
1268
1271
  };
@@ -1265,7 +1265,7 @@ export var businessSlice = createSlice({
1265
1265
  state.loading = true;
1266
1266
  })
1267
1267
  .addCase(retrieveEntityList.fulfilled, function (state, action) {
1268
- var _a, _b, _c, _d;
1268
+ var _a, _b, _c, _d, _e, _f;
1269
1269
  state.error = null;
1270
1270
  state.loading = false;
1271
1271
  var data = action.payload;
@@ -1286,7 +1286,7 @@ export var businessSlice = createSlice({
1286
1286
  licenseList = __spreadArray(__spreadArray([], licenseList, true), mappedFL, true);
1287
1287
  licenseList = licenseList.filter(function (_a) {
1288
1288
  var license = _a.license;
1289
- return !(entityLicenseList || []).some(function (e) { return e.license.number === license.number; });
1289
+ return !(entityLicenseList || []).some(function (e) { var _a, _b; return e.license.number === license.number || ((_a = e.license.additional_info) === null || _a === void 0 ? void 0 : _a.unified_number) === ((_b = license.additional_info) === null || _b === void 0 ? void 0 : _b.unified_number); });
1290
1290
  });
1291
1291
  }
1292
1292
  }
@@ -1296,8 +1296,10 @@ export var businessSlice = createSlice({
1296
1296
  var selectedLicense = licenseList === null || licenseList === void 0 ? void 0 : licenseList[0];
1297
1297
  var isOtherLicense_1 = ((_b = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _b === void 0 ? void 0 : _b.number) === 'other_fl' || ((_c = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _c === void 0 ? void 0 : _c.number) === 'other_cr';
1298
1298
  state.data.businessTypeData.selectedLicense = selectedLicense;
1299
- if (!isOtherLicense_1)
1299
+ if (!isOtherLicense_1) {
1300
1300
  state.data.businessTypeData.licenseNumber = ((_d = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _d === void 0 ? void 0 : _d.number) || '';
1301
+ state.data.businessTypeData.unifiedNumber = ((_f = (_e = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _e === void 0 ? void 0 : _e.additional_info) === null || _f === void 0 ? void 0 : _f.unified_number) || '';
1302
+ }
1301
1303
  }
1302
1304
  })
1303
1305
  .addCase(retrieveEntityList.rejected, function (state, action) {
@@ -1309,10 +1311,10 @@ export var businessSlice = createSlice({
1309
1311
  state.loading = true;
1310
1312
  })
1311
1313
  .addCase(retrieveAllEntityList.fulfilled, function (state, action) {
1312
- var _a;
1314
+ var _a, _b, _c;
1313
1315
  state.error = null;
1314
1316
  state.loading = false;
1315
- var _b = action.payload, data = _b.data, businessCountryCode = _b.businessCountryCode, entityId = _b.entityId;
1317
+ var _d = action.payload, data = _d.data, businessCountryCode = _d.businessCountryCode, entityId = _d.entityId;
1316
1318
  var isKWCountry = isKW(businessCountryCode);
1317
1319
  var list = (data === null || data === void 0 ? void 0 : data.entities_info) || [];
1318
1320
  if (isKWCountry) {
@@ -1330,8 +1332,10 @@ export var businessSlice = createSlice({
1330
1332
  var selectedLicense = findEntity ? findEntity : entityLicenseList[0];
1331
1333
  state.data.businessTypeData.selectedEntityLicense = selectedLicense;
1332
1334
  state.data.businessTypeData.selectedLicense = selectedLicense;
1333
- if (!isOtherLicense(selectedLicense))
1335
+ if (!isOtherLicense(selectedLicense)) {
1334
1336
  state.data.businessTypeData.licenseNumber = ((_a = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _a === void 0 ? void 0 : _a.number) || '';
1337
+ state.data.businessTypeData.unifiedNumber = ((_c = (_b = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _b === void 0 ? void 0 : _b.additional_info) === null || _c === void 0 ? void 0 : _c.unified_number) || '';
1338
+ }
1335
1339
  }
1336
1340
  })
1337
1341
  .addCase(retrieveAllEntityList.rejected, function (state, action) {
@@ -1800,7 +1800,7 @@ export var connectSlice = createSlice({
1800
1800
  }
1801
1801
  }
1802
1802
  licenseList = __spreadArray(__spreadArray([], licenseList, true), [OTHER_CR_LICENSE, OTHER_FL_LICENSE], false);
1803
- var _c = ((_b = state.data.responseData) === null || _b === void 0 ? void 0 : _b.leadData) || {}, license_number = _c.license_number, license_type = _c.license_type;
1803
+ var _c = ((_b = state.data.responseData) === null || _b === void 0 ? void 0 : _b.leadData) || {}, license_number = _c.license_number, license_type = _c.license_type, unified_number = _c.unified_number;
1804
1804
  var selectedLicense = undefined;
1805
1805
  if (license_number) {
1806
1806
  var findLicense = licenseList.find(function (_a) {
@@ -1816,6 +1816,18 @@ export var connectSlice = createSlice({
1816
1816
  selectedLicense = __assign(__assign({}, OTHER_CR_LICENSE), { license: { number: license_number } });
1817
1817
  state.data.businessData.licenseNumber = license_number;
1818
1818
  }
1819
+ if (unified_number) {
1820
+ var findLicense = licenseList.find(function (_a) {
1821
+ var _b;
1822
+ var license = _a.license;
1823
+ return ((_b = license === null || license === void 0 ? void 0 : license.additional_info) === null || _b === void 0 ? void 0 : _b.unified_number) === unified_number;
1824
+ });
1825
+ if (findLicense)
1826
+ selectedLicense = findLicense;
1827
+ else
1828
+ selectedLicense = __assign(__assign({}, OTHER_CR_LICENSE), { license: { number: '', additional_info: { unified_number: unified_number } } });
1829
+ state.data.businessData.unifiedNumber = unified_number;
1830
+ }
1819
1831
  state.data.businessData.selectedLicense = selectedLicense;
1820
1832
  state.data.responseData = __assign(__assign({}, state.data.responseData), { licenseList: licenseList });
1821
1833
  })
@@ -104,8 +104,8 @@ var BusinessType = function (_a) {
104
104
  var showLicenseNumber = function () {
105
105
  if (isKWCountry)
106
106
  return !isAnyListActive && isCR;
107
- if (isSACountry && isCR)
108
- return !isAnyListActive && !isOtherLicense(selectedLicenseEntity);
107
+ if (isSACountry)
108
+ return !isAnyListActive && isFL;
109
109
  return !isAnyListActive;
110
110
  };
111
111
  var isLicenseListActive = listActive === ListType.LicenseList;
@@ -114,6 +114,7 @@ var BusinessType = function (_a) {
114
114
  var selected = methods.getValues('selectedLicense');
115
115
  var selectedLicenseEntity = methods.getValues('selectedEntityLicense');
116
116
  var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === Type.CR;
117
+ var isFL = (selected === null || selected === void 0 ? void 0 : selected.type) === Type.FL;
117
118
  var hasEntityList = !!(entityLicenseList === null || entityLicenseList === void 0 ? void 0 : entityLicenseList.length);
118
119
  var showLicenseList = hasEntityList ? (isSACountry || isOtherCountry) && isOtherLicense(selectedLicenseEntity) : isSACountry || isOtherCountry;
119
120
  var showEntityList = isKWCountry ? hasEntityList && !isLicenseListActive && isCR : hasEntityList && !isLicenseListActive;
@@ -36,7 +36,7 @@ import { businessSelector, clearError } from '../../../app/business/businessStor
36
36
  import Text from '../../../../components/Text';
37
37
  import ExpandIcon from '../../../../components/ExpandIcon';
38
38
  import Collapse from '../../../../components/Collapse';
39
- import { isKW, isOtherLicense } from '../../../../utils';
39
+ import { isKW, isOtherLicense, isSA } from '../../../../utils';
40
40
  import { settingsSelector } from '../../../../app/settings';
41
41
  import { OTHER_CR_LICENSE } from '../../../../constants';
42
42
  var InputStyled = styled(InputSelect)(function (_a) {
@@ -67,6 +67,7 @@ var EntityLicenseList = function (_a) {
67
67
  var entityLicenseList = (responseBody || {}).entityLicenseList;
68
68
  var country_code = settingsData.businessCountry.iso2;
69
69
  var isKWCountry = React.useMemo(function () { return isKW(country_code); }, [country_code]);
70
+ var isSACountry = React.useMemo(function () { return isSA(country_code); }, [country_code]);
70
71
  var onOpenLicenseList = function (event) {
71
72
  var _a;
72
73
  setAnchorEl(event.currentTarget);
@@ -90,8 +91,10 @@ var EntityLicenseList = function (_a) {
90
91
  }
91
92
  }, [entityLicenseList, selectedEntityLicense]);
92
93
  var getLicenseNumber = function (item) {
93
- var _a;
94
- return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) || '';
94
+ var _a, _b, _c;
95
+ if ((item === null || item === void 0 ? void 0 : item.type) === BusinessType.CR && isSACountry)
96
+ return ((_b = (_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.additional_info) === null || _b === void 0 ? void 0 : _b.unified_number) || '';
97
+ return ((_c = item === null || item === void 0 ? void 0 : item.license) === null || _c === void 0 ? void 0 : _c.number) || '';
95
98
  };
96
99
  var getLicenseName = function (item) {
97
100
  var _a, _b;
@@ -100,6 +103,7 @@ var EntityLicenseList = function (_a) {
100
103
  return t((isAr ? (_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.legal_name) === null || _b === void 0 ? void 0 : _b.en) || '');
101
104
  };
102
105
  var onSelectItem = function (license) {
106
+ var _a, _b, _c;
103
107
  if (error)
104
108
  dispatch(clearError());
105
109
  selectedEntityLicenseControl.field.onChange(license);
@@ -107,10 +111,12 @@ var EntityLicenseList = function (_a) {
107
111
  var license_1 = isKWCountry ? OTHER_CR_LICENSE : {};
108
112
  setValue('selectedLicense', license_1, { shouldValidate: true });
109
113
  setValue('licenseNumber', '', { shouldValidate: true });
114
+ setValue('unifiedNumber', '', { shouldValidate: true });
110
115
  }
111
116
  else {
112
117
  setValue('selectedLicense', license, { shouldValidate: true });
113
- setValue('licenseNumber', getLicenseNumber(license), { shouldValidate: true });
118
+ setValue('licenseNumber', ((_a = license === null || license === void 0 ? void 0 : license.license) === null || _a === void 0 ? void 0 : _a.number) || '', { shouldValidate: true });
119
+ setValue('unifiedNumber', ((_c = (_b = license === null || license === void 0 ? void 0 : license.license) === null || _b === void 0 ? void 0 : _b.additional_info) === null || _c === void 0 ? void 0 : _c.unified_number) || '', { shouldValidate: true });
114
120
  }
115
121
  onCloseLicenseList();
116
122
  };
@@ -122,7 +128,7 @@ var EntityLicenseList = function (_a) {
122
128
  var selected = selectedEntityLicenseControl.field.value;
123
129
  var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.CR;
124
130
  var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
125
- return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('choose_entity_license'), onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_entity'), value: isCR ? t(getLicenseName(selected)) : flValue }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: entityLicenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
131
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('choose_entity_license'), onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_entity'), value: (isCR ? t(getLicenseName(selected)) : flValue) || '' }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: entityLicenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
126
132
  return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selected) }, { children: isOtherLicense(item) ? t(getLicenseName(item)) : getLicenseFullName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selected) && _jsx(CheckIcon, {})] }));
127
133
  } }) }))] }) })));
128
134
  };
@@ -36,7 +36,7 @@ import { businessSelector, clearError } from '../../../app/business/businessStor
36
36
  import Text from '../../../../components/Text';
37
37
  import ExpandIcon from '../../../../components/ExpandIcon';
38
38
  import Collapse from '../../../../components/Collapse';
39
- import { isKW, isOtherLicense } from '../../../../utils';
39
+ import { isKW, isOtherLicense, isSA } from '../../../../utils';
40
40
  import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
41
41
  import { settingsSelector } from '../../../../app/settings';
42
42
  var InputStyled = styled(InputSelect)(function (_a) {
@@ -66,6 +66,7 @@ var LicenseList = function (_a) {
66
66
  var responseBody = businessTypeData.responseBody, selectedLicense = businessTypeData.selectedLicense, licenseNumber = businessTypeData.licenseNumber, entityLegalName = businessTypeData.entityLegalName;
67
67
  var licenseList = (responseBody || { licenseList: [] }).licenseList;
68
68
  var country_code = settingsData.businessCountry.iso2;
69
+ var isSACountry = React.useMemo(function () { return isSA(country_code); }, [country_code]);
69
70
  var onOpenLicenseList = function (event) {
70
71
  var _a;
71
72
  setAnchorEl(event.currentTarget);
@@ -99,8 +100,10 @@ var LicenseList = function (_a) {
99
100
  }
100
101
  }, [country_code]);
101
102
  var getLicenseNumber = function (item) {
102
- var _a;
103
- return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) || '';
103
+ var _a, _b, _c;
104
+ if ((item === null || item === void 0 ? void 0 : item.type) === BusinessType.CR && isSACountry)
105
+ return ((_b = (_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.additional_info) === null || _b === void 0 ? void 0 : _b.unified_number) || '';
106
+ return ((_c = item === null || item === void 0 ? void 0 : item.license) === null || _c === void 0 ? void 0 : _c.number) || '';
104
107
  };
105
108
  var getLicenseName = function (item) {
106
109
  var _a, _b;
@@ -109,14 +112,18 @@ var LicenseList = function (_a) {
109
112
  return t((isAr ? (_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.legal_name) === null || _b === void 0 ? void 0 : _b.en) || '');
110
113
  };
111
114
  var onSelectItem = function (license) {
115
+ var _a, _b, _c;
112
116
  if (error)
113
117
  dispatch(clearError());
114
118
  selectedLicenseControl.field.onChange(license);
115
- if (isOtherLicense(license))
119
+ if (isOtherLicense(license)) {
116
120
  setValue('licenseNumber', '', { shouldValidate: true });
117
- else
118
- setValue('licenseNumber', getLicenseNumber(license), { shouldValidate: true });
119
- setValue('unifiedNumber', '', { shouldValidate: true });
121
+ setValue('unifiedNumber', '', { shouldValidate: true });
122
+ }
123
+ else {
124
+ setValue('licenseNumber', ((_a = license === null || license === void 0 ? void 0 : license.license) === null || _a === void 0 ? void 0 : _a.number) || '', { shouldValidate: true });
125
+ setValue('unifiedNumber', ((_c = (_b = license === null || license === void 0 ? void 0 : license.license) === null || _b === void 0 ? void 0 : _b.additional_info) === null || _c === void 0 ? void 0 : _c.unified_number) || '', { shouldValidate: true });
126
+ }
120
127
  onCloseLicenseList();
121
128
  };
122
129
  var getLicenseFullName = function (item) {
@@ -127,7 +134,7 @@ var LicenseList = function (_a) {
127
134
  var selected = selectedLicenseControl.field.value;
128
135
  var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.CR;
129
136
  var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
130
- return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('choose_any_license'), onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: isCR ? t(getLicenseName(selected)) : flValue }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
137
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('choose_any_license'), onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: (isCR ? t(getLicenseName(selected)) : flValue) || '' }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
131
138
  return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selected) }, { children: isOtherLicense(item) ? t(getLicenseName(item)) : getLicenseFullName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selected) && _jsx(CheckIcon, {})] }));
132
139
  } }) }))] }) })));
133
140
  };
@@ -79,6 +79,6 @@ var UnifiedNumber = function (_a) {
79
79
  var unifiedNumberValue = unifiedNumberControl.field.value;
80
80
  var error = (_b = unifiedNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
81
81
  var readOnly = !isOtherLicense(selectedLicense) || (selectedEntityLicense && !isOtherLicense(selectedEntityLicense));
82
- return (_jsx(Collapse, __assign({ in: show && isOtherLicense(selectedEntityLicense) }, { children: _jsxs(ScreenContainer, __assign({ sx: { mb: 2.5 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('v1_company_unified_number_label') }), _jsx(Tooltip, __assign({ title: t('v1_company_unified_number_description'), onMouseOver: function () { return setHovered(true); }, onMouseLeave: function () { return setHovered(false); }, onTouchStartCapture: function () { return setHovered(true); } }, { children: hovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { readOnly: readOnly, onChange: handleChange, value: unifiedNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } }, placeholder: t('v1_company_unified_number_hint'), warningType: 'alert', warningMessage: error && t(error), endAdornment: _jsx(EndAdornment, { value: unifiedNumberValue, isVerified: isVerified }) })] })) })));
82
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mb: 2.5 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('v1_company_unified_number_label') }), _jsx(Tooltip, __assign({ title: t('v1_company_unified_number_description'), onMouseOver: function () { return setHovered(true); }, onMouseLeave: function () { return setHovered(false); }, onTouchStartCapture: function () { return setHovered(true); } }, { children: hovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { readOnly: readOnly, onChange: handleChange, value: unifiedNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } }, placeholder: t('v1_company_unified_number_hint'), warningType: 'alert', warningMessage: error && t(error), endAdornment: _jsx(EndAdornment, { value: unifiedNumberValue, isVerified: isVerified }) })] })) })));
83
83
  };
84
84
  export default React.memo(UnifiedNumber);
@@ -1,5 +1,5 @@
1
1
  import * as yup from 'yup';
2
- import { REGEX_BRAND_NAME, KW_MIN_LICENSE_LENGTH, MAX_FILE_SIZE, VALID_FILE_FORMATS, FL_MIN_LICENSE_LENGTH, CR_MIN_LICENSE_LENGTH, UNIFIED_NUMBER_MIN_LENGTH } from '../../../../constants';
2
+ import { REGEX_BRAND_NAME, KW_MIN_LICENSE_LENGTH, MAX_FILE_SIZE, VALID_FILE_FORMATS, FL_MIN_LICENSE_LENGTH, UNIFIED_NUMBER_MIN_LENGTH } from '../../../../constants';
3
3
  import { BusinessType } from '../../../../@types';
4
4
  import { isOtherLicense } from '../../../../utils';
5
5
  var objectElements = {
@@ -8,7 +8,7 @@ var objectElements = {
8
8
  en: yup.string()
9
9
  }),
10
10
  license: yup.object().shape({
11
- number: yup.string()
11
+ number: yup.string().nullable()
12
12
  }),
13
13
  type: yup.string()
14
14
  };
@@ -43,11 +43,8 @@ export var LicenseValidationSchema = yup.object().shape({
43
43
  var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
44
44
  if (!((_a = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === null || _a === void 0 ? void 0 : _a.length))
45
45
  return false;
46
- if (isCR) {
47
- if (isOtherLicense(selectedEntityLicense))
48
- return true;
49
- return length >= CR_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_max_length' });
50
- }
46
+ if (isCR || !isOtherLicense(selectedEntityLicense))
47
+ return true;
51
48
  if (length === 0)
52
49
  return this.createError({ message: '' });
53
50
  return length >= FL_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'fl_max_length' });
@@ -105,8 +105,10 @@ var LicenseList = function (_a) {
105
105
  }
106
106
  }, [country_code]);
107
107
  var getLicenseNumber = function (item) {
108
- var _a;
109
- return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) || '';
108
+ var _a, _b, _c;
109
+ if ((item === null || item === void 0 ? void 0 : item.type) === BusinessType.CR && isSACountry)
110
+ return ((_b = (_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.additional_info) === null || _b === void 0 ? void 0 : _b.unified_number) || '';
111
+ return ((_c = item === null || item === void 0 ? void 0 : item.license) === null || _c === void 0 ? void 0 : _c.number) || '';
110
112
  };
111
113
  var getLicenseName = function (item) {
112
114
  var _a, _b;
@@ -115,14 +117,18 @@ var LicenseList = function (_a) {
115
117
  return t((isAr ? (_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.legal_name) === null || _b === void 0 ? void 0 : _b.en) || '');
116
118
  };
117
119
  var onSelectItem = function (license) {
120
+ var _a, _b, _c;
118
121
  if (error)
119
122
  dispatch(clearError());
120
123
  selectedLicenseControl.field.onChange(license);
121
- if (isOtherLicense(license))
124
+ if (isOtherLicense(license)) {
122
125
  setValue('licenseNumber', '', { shouldValidate: true });
123
- else
124
- setValue('licenseNumber', getLicenseNumber(license), { shouldValidate: true });
125
- setValue('unifiedNumber', '', { shouldValidate: true });
126
+ setValue('unifiedNumber', '', { shouldValidate: true });
127
+ }
128
+ else {
129
+ setValue('licenseNumber', ((_a = license === null || license === void 0 ? void 0 : license.license) === null || _a === void 0 ? void 0 : _a.number) || '', { shouldValidate: true });
130
+ setValue('unifiedNumber', ((_c = (_b = license === null || license === void 0 ? void 0 : license.license) === null || _b === void 0 ? void 0 : _b.additional_info) === null || _c === void 0 ? void 0 : _c.unified_number) || '', { shouldValidate: true });
131
+ }
126
132
  onCloseLicenseList();
127
133
  };
128
134
  var getLicenseFullName = function (item) {
@@ -143,7 +149,7 @@ var LicenseList = function (_a) {
143
149
  var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.CR;
144
150
  var isFL = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.FL;
145
151
  var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
146
- return (_jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: isSACountry || isOtherThanKWOrSACountry }, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: readOnly, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: isCR ? t(getLicenseName(selected)) : flValue }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
152
+ return (_jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: isSACountry || isOtherThanKWOrSACountry }, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: readOnly, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: (isCR ? t(getLicenseName(selected)) : flValue) || '' }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
147
153
  return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selected) }, { children: isOtherLicense(item) ? t(getLicenseName(item)) : getLicenseFullName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selected) && _jsx(CheckIcon, {})] }));
148
154
  } }) }))] })), _jsx(LicenseType, { show: show && isKWCountry, readOnly: readOnly }), _jsx(LicenseNumber, { show: showLicenseNumber(), readOnly: licenseReadonly }), _jsx(UnifiedNumber, { show: isSACountry && isCR && show, readOnly: licenseReadonly })] }));
149
155
  };
@@ -42,12 +42,12 @@ var LicenseNumber = function (_a) {
42
42
  var clearLicenseNumber = function () {
43
43
  licenseNumberControl.field.onChange('');
44
44
  };
45
- var licenseNumberValue = licenseNumberControl.field.value;
45
+ var licenseNumberValue = licenseNumberControl.field.value || '';
46
46
  var error = (_b = licenseNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
47
47
  var length = isKWCountry || isOtherThanKWOrSACountry ? KW_MAX_LICENSE_LENGTH : isCR ? CR_NUMBER_MAX_LENGTH : FL_NUMBER_MAX_LENGTH;
48
48
  var minLength = isKWCountry || isOtherThanKWOrSACountry ? KW_MIN_LICENSE_LENGTH : isCR ? CR_MIN_LICENSE_LENGTH : FL_MIN_LICENSE_LENGTH;
49
49
  var label = isCR ? 'cr_number' : 'fl_number';
50
50
  var showCheckIcon = isKWCountry || isOtherThanKWOrSACountry ? (licenseNumberValue === null || licenseNumberValue === void 0 ? void 0 : licenseNumberValue.length) >= minLength : (licenseNumberValue === null || licenseNumberValue === void 0 ? void 0 : licenseNumberValue.length) === length;
51
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t(label), required: isKWCountry, onChange: handleFLNumberChange, inputProps: { maxLength: length }, value: licenseNumberValue, endAdornment: showCheckIcon || (readOnly && licenseNumberValue) ? _jsx(CheckIcon, {}) : licenseNumberValue && _jsx(ClearIcon, { onClick: clearLicenseNumber }), placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }) }) }) })));
51
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, __assign({ sx: { mb: 2.5 } }, { children: _jsx(Input, { readOnly: readOnly, label: t(label), required: isKWCountry, onChange: handleFLNumberChange, inputProps: { maxLength: length }, value: licenseNumberValue, endAdornment: showCheckIcon || (readOnly && licenseNumberValue) ? _jsx(CheckIcon, {}) : licenseNumberValue && _jsx(ClearIcon, { onClick: clearLicenseNumber }), placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }) }) })) })));
52
52
  };
53
53
  export default React.memo(LicenseNumber);
@@ -74,7 +74,7 @@ var UnifiedNumber = function (_a) {
74
74
  unifiedNumberControl.field.onChange(value);
75
75
  };
76
76
  var unifiedNumberControl = useController({ control: control, name: 'unifiedNumber' });
77
- var unifiedNumberValue = unifiedNumberControl.field.value;
77
+ var unifiedNumberValue = unifiedNumberControl.field.value || '';
78
78
  var error = (_b = unifiedNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
79
79
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mb: 2.5 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('v1_company_unified_number_label') }), _jsx(Tooltip, __assign({ title: t('v1_company_unified_number_description'), onMouseOver: function () { return setHovered(true); }, onMouseLeave: function () { return setHovered(false); }, onTouchStartCapture: function () { return setHovered(true); } }, { children: hovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { readOnly: readOnly, onChange: handleChange, value: unifiedNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } }, placeholder: t('v1_company_unified_number_hint'), warningType: 'alert', warningMessage: error && t(error), endAdornment: _jsx(EndAdornment, { value: unifiedNumberValue, isVerified: isVerified }) })] })) })));
80
80
  };
@@ -17,34 +17,16 @@ export declare const BusinessDataSchema: (isLeadIdPassed: boolean) => yup.Object
17
17
  selectedLicense: any;
18
18
  unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
19
19
  licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
20
- termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
21
20
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
22
21
  brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
23
22
  selectedLicense: any;
24
23
  unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
25
24
  licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
26
- termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
27
25
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
28
26
  brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
29
27
  selectedLicense: any;
30
28
  unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
31
29
  licenseNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
32
- termAndConditionChecked: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
33
- }>>> | yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
34
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
35
- selectedLicense: any;
36
- unifiedNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
37
- licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
38
- }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
39
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
40
- selectedLicense: any;
41
- unifiedNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
42
- licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
43
- }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
44
- brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
45
- selectedLicense: any;
46
- unifiedNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
47
- licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
48
30
  }>>>;
49
31
  export declare const KWBusinessDataSchema: (isLeadIdPassed: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
50
32
  brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -7,7 +7,7 @@ var objectElements = {
7
7
  en: yup.string()
8
8
  }),
9
9
  license: yup.object().shape({
10
- number: yup.string()
10
+ number: yup.string().nullable()
11
11
  }),
12
12
  type: yup.string()
13
13
  };
@@ -145,35 +145,40 @@ export var BusinessDataSchema = function (isLeadIdPassed) {
145
145
  })
146
146
  .required('enter_brand_name_english_chars_numbers_space'),
147
147
  selectedLicense: yup.object().shape(objectElements).required(''),
148
- unifiedNumber: yup
149
- .string()
150
- .test({
148
+ unifiedNumber: yup.string().test({
149
+ name: 'unifiedNumber',
150
+ message: '',
151
151
  test: function (value) {
152
+ var _a;
152
153
  var selectedLicense = this.parent.selectedLicense;
153
- var isCR = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR;
154
+ var isFL = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.FL;
154
155
  var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
155
- if (length === 0)
156
+ if (!((_a = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === null || _a === void 0 ? void 0 : _a.length))
157
+ return false;
158
+ if (isFL || length >= UNIFIED_NUMBER_MIN_LENGTH)
156
159
  return true;
157
- if (isCR) {
158
- return length >= UNIFIED_NUMBER_MIN_LENGTH ? true : this.createError({ message: 'unified_number_required' });
159
- }
160
- return true;
160
+ if (length === 0)
161
+ return this.createError({ message: '' });
162
+ return this.createError({ message: 'unified_number_required' });
161
163
  }
162
- })
163
- .required(''),
164
- licenseNumber: yup
165
- .string()
166
- .test({
164
+ }),
165
+ licenseNumber: yup.string().test({
166
+ name: 'licenseNumber',
167
+ message: '',
167
168
  test: function (value) {
169
+ var _a;
168
170
  var selectedLicense = this.parent.selectedLicense;
169
171
  var isCR = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR;
170
172
  var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
171
- if (length === 0 || isCR)
173
+ if (!((_a = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === null || _a === void 0 ? void 0 : _a.length))
174
+ return false;
175
+ if (isCR || length >= FL_MIN_LICENSE_LENGTH)
172
176
  return true;
173
- return length >= FL_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'fl_max_length' });
177
+ if (length === 0)
178
+ return this.createError({ message: '' });
179
+ return this.createError({ message: 'fl_max_length' });
174
180
  }
175
181
  })
176
- .required('')
177
182
  });
178
183
  };
179
184
  export var KWBusinessDataSchema = function (isLeadIdPassed) {
@@ -16,8 +16,8 @@ export var QRCodeImage = styled(Icon)(function (_a) {
16
16
  var spacing = _a.theme.spacing;
17
17
  return ({
18
18
  margin: '0px auto',
19
- width: spacing(21.875),
20
- height: spacing(21.875),
19
+ width: spacing(31.25),
20
+ height: spacing(31.25),
21
21
  marginTop: spacing(2.5),
22
22
  marginBottom: spacing(2.5)
23
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.10.17-development",
3
+ "version": "2.10.19-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",