@tap-payments/auth-jsconnect 2.8.62-beta → 2.8.62-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.
Files changed (46) hide show
  1. package/build/@types/redux.d.ts +1 -0
  2. package/build/api/entity.d.ts +2 -2
  3. package/build/api/entity.js +12 -4
  4. package/build/api/index.d.ts +2 -2
  5. package/build/components/Tooltip/Tooltip.js +1 -1
  6. package/build/constants/api.d.ts +0 -1
  7. package/build/constants/api.js +0 -2
  8. package/build/constants/app.d.ts +0 -2
  9. package/build/constants/app.js +0 -2
  10. package/build/features/app/bank/bankStore.d.ts +13 -19
  11. package/build/features/app/bank/bankStore.js +183 -165
  12. package/build/features/app/board/boardStore.js +16 -10
  13. package/build/features/app/brand/brandStore.d.ts +16 -31
  14. package/build/features/app/brand/brandStore.js +243 -239
  15. package/build/features/app/business/businessStore.js +7 -1
  16. package/build/features/app/entity/entityStore.d.ts +20 -34
  17. package/build/features/app/entity/entityStore.js +204 -249
  18. package/build/features/app/individual/individualStore.d.ts +17 -36
  19. package/build/features/app/individual/individualStore.js +221 -270
  20. package/build/features/app/password/passwordStore.d.ts +19 -25
  21. package/build/features/app/password/passwordStore.js +170 -216
  22. package/build/features/app/tax/taxStore.d.ts +13 -7
  23. package/build/features/app/tax/taxStore.js +168 -147
  24. package/build/features/bank/screens/BankDetails/BankDetails.js +17 -4
  25. package/build/features/brand/screens/BrandActivities/BrandActivities.js +48 -11
  26. package/build/features/brand/screens/BrandInfo/BrandInfo.js +22 -4
  27. package/build/features/brand/screens/BrandSegmentInfo/BrandSegmentInfo.js +22 -6
  28. package/build/features/business/screens/Activities/Activities.js +9 -1
  29. package/build/features/business/screens/Customers/Customers.js +9 -1
  30. package/build/features/connect/screens/BusinessCountry/BusinessCountry.js +7 -1
  31. package/build/features/entity/screens/EntityCapital/EntityCapital.js +33 -9
  32. package/build/features/entity/screens/EntityName/EntityName.js +31 -14
  33. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +43 -10
  34. package/build/features/individual/screens/IndividualList/IndividualList.js +7 -0
  35. package/build/features/individual/screens/IndividualList/UserList.js +3 -3
  36. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +73 -18
  37. package/build/features/password/Password.js +1 -1
  38. package/build/features/shared/Button/FlowsButtons.js +7 -1
  39. package/build/features/signIn/SignIn.js +10 -2
  40. package/build/features/tax/screens/TaxDetails/TaxDetails.js +7 -2
  41. package/build/hooks/index.d.ts +1 -0
  42. package/build/hooks/index.js +1 -0
  43. package/build/hooks/useFormDirtyCheck.d.ts +10 -0
  44. package/build/hooks/useFormDirtyCheck.js +66 -0
  45. package/build/utils/common.js +4 -4
  46. package/package.json +2 -2
@@ -90,7 +90,7 @@ var UserList = function (_a) {
90
90
  var _l = data.individualCollectData, email = _l.email, mobile = _l.mobile, responseBody = _l.responseBody;
91
91
  var is_available = (responseBody || {}).is_available;
92
92
  var verify = data.verify;
93
- var _m = verify.responseBody || {}, userList = _m.userList, notification = _m.notification, userRes = _m.user;
93
+ var _m = verify.responseBody || {}, userList = _m.userList, recipient = _m.recipient, userRes = _m.user;
94
94
  var methods = useForm({
95
95
  resolver: yupResolver(IndividualCollectInfoValidationSchema(activeUser)),
96
96
  defaultValues: {
@@ -159,10 +159,10 @@ var UserList = function (_a) {
159
159
  return (activeUser === null || activeUser === void 0 ? void 0 : activeUser.id) === user.id;
160
160
  };
161
161
  var isSameUserRequestedBefore = function (user) {
162
- var _a, _b;
162
+ var _a;
163
163
  if (!(userRes === null || userRes === void 0 ? void 0 : userRes.is_authorized) && !isKWOrSA(settingsData.businessCountry.iso2))
164
164
  return false;
165
- return (_a = user === null || user === void 0 ? void 0 : user.ids) === null || _a === void 0 ? void 0 : _a.includes((_b = notification === null || notification === void 0 ? void 0 : notification.recipient) === null || _b === void 0 ? void 0 : _b.id);
165
+ return (_a = user === null || user === void 0 ? void 0 : user.ids) === null || _a === void 0 ? void 0 : _a.includes(recipient === null || recipient === void 0 ? void 0 : recipient.id);
166
166
  };
167
167
  var getUserStatus = function (user) {
168
168
  return user === null || user === void 0 ? void 0 : user.individual_data_state;
@@ -17,8 +17,8 @@ import { useTranslation } from 'react-i18next';
17
17
  import { handleCurrentActiveScreen, handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
18
18
  import Box from '@mui/material/Box';
19
19
  import { alpha, styled } from '@mui/material/styles';
20
- import { useAppDispatch, useAppSelector, useSetFromDefaultValues, useLanguage, useFormReadOnly, useDataNoneEditable, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified } from '../../../../hooks';
21
- import { convertToEnglishDateFormat, deepCopy, getUserName, isKWOrSA, isOtherThanKWOrSA } from '../../../../utils';
20
+ import { useAppDispatch, useAppSelector, useSetFromDefaultValues, useLanguage, useFormReadOnly, useDataNoneEditable, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified, useFormDirtyCheck } from '../../../../hooks';
21
+ import { convertToEnglishDateFormat, deepCopy, findCountryByIddPrefix, findCountryByIso2, getUserName, isKWOrSA, isOtherThanKWOrSA, sendCustomEventToGTM } from '../../../../utils';
22
22
  import Form from '../../../../components/Form';
23
23
  import Collapse from '../../../../components/Collapse';
24
24
  import Text from '../../../../components/Text';
@@ -50,17 +50,17 @@ var ListType;
50
50
  ListType["NationalityList"] = "NationalityList";
51
51
  })(ListType || (ListType = {}));
52
52
  var IndividualPersonalInfo = function (_a) {
53
- var _b, _c, _d, _e, _f, _g, _h, _j, _k;
53
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
54
54
  var t = useTranslation().t;
55
55
  var isAr = useLanguage().isAr;
56
56
  var dispatch = useAppDispatch();
57
- var _l = useAppSelector(individualSelector), data = _l.data, loading = _l.loading, error = _l.error, cityLoading = _l.cityLoading;
57
+ var _p = useAppSelector(individualSelector), data = _p.data, loading = _p.loading, error = _p.error, cityLoading = _p.cityLoading;
58
58
  var settingsData = useAppSelector(settingsSelector).data;
59
59
  var countries = settingsData.countries;
60
60
  var verify = data.verify, individualPersonalData = data.individualPersonalData;
61
- var _m = verify.responseBody || {}, user = _m.user, flows = _m.flows;
61
+ var _q = verify.responseBody || {}, user = _q.user, flows = _q.flows;
62
62
  var name = individualPersonalData.name, email = individualPersonalData.email, mobile = individualPersonalData.mobile, countryCode = individualPersonalData.countryCode, gender = individualPersonalData.gender, nid = individualPersonalData.nid, issuedCountry = individualPersonalData.issuedCountry, expiryDate = individualPersonalData.expiryDate, dob = individualPersonalData.dob, placeOfBirthCountry = individualPersonalData.placeOfBirthCountry, placeOfBirthCity = individualPersonalData.placeOfBirthCity, nationality = individualPersonalData.nationality;
63
- var _o = user || {}, data_status = _o.data_status, is_authorized = _o.is_authorized, data_verification = _o.data_verification, contact = _o.contact, genderRes = _o.gender, identification = _o.identification, birth = _o.birth, nationalityRes = _o.nationality;
63
+ var _r = user || {}, data_status = _r.data_status, is_authorized = _r.is_authorized, data_verification = _r.data_verification, contact = _r.contact, genderRes = _r.gender, identification = _r.identification, birth = _r.birth, nationalityRes = _r.nationality;
64
64
  var isOtherCountry = React.useMemo(function () { return isOtherThanKWOrSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
65
65
  var methods = useForm({
66
66
  resolver: yupResolver(IndividualInfoValidationSchema(isOtherCountry)),
@@ -82,9 +82,51 @@ var IndividualPersonalInfo = function (_a) {
82
82
  });
83
83
  var watch = methods.watch;
84
84
  useSetFromDefaultValues(methods, data.individualPersonalData);
85
- var _p = React.useState(), listActive = _p[0], setListActive = _p[1];
86
- var _q = React.useState(false), dobActive = _q[0], setDobActive = _q[1];
87
- var _r = React.useState(false), expiryDateActive = _r[0], setExpiryDateActive = _r[1];
85
+ var _s = React.useState(), listActive = _s[0], setListActive = _s[1];
86
+ var _t = React.useState(false), dobActive = _t[0], setDobActive = _t[1];
87
+ var _u = React.useState(false), expiryDateActive = _u[0], setExpiryDateActive = _u[1];
88
+ var expDateRes = (identification === null || identification === void 0 ? void 0 : identification.expiry) && convertToEnglishDateFormat(new Date(identification === null || identification === void 0 ? void 0 : identification.expiry));
89
+ var dobDateRes = (birth === null || birth === void 0 ? void 0 : birth.date) && convertToEnglishDateFormat(new Date(birth === null || birth === void 0 ? void 0 : birth.date));
90
+ var resCountryCode = React.useMemo(function () {
91
+ var _a;
92
+ if (!((_a = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _a === void 0 ? void 0 : _a.country_code))
93
+ return {};
94
+ return findCountryByIddPrefix(countries, contact.phone.country_code) || {};
95
+ }, [(_b = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _b === void 0 ? void 0 : _b.country_code]);
96
+ var resIssuedCountry = React.useMemo(function () {
97
+ if (!(identification === null || identification === void 0 ? void 0 : identification.issued_country_code))
98
+ return;
99
+ return findCountryByIso2(countries, identification.issued_country_code);
100
+ }, [identification === null || identification === void 0 ? void 0 : identification.issued_country_code]);
101
+ var resPlaceOfBirthCountry = React.useMemo(function () {
102
+ if (!(birth === null || birth === void 0 ? void 0 : birth.country))
103
+ return;
104
+ return findCountryByIso2(countries, birth.country);
105
+ }, [birth === null || birth === void 0 ? void 0 : birth.country]);
106
+ var resNationality = React.useMemo(function () {
107
+ if (!nationalityRes)
108
+ return;
109
+ return findCountryByIso2(countries, nationalityRes);
110
+ }, [nationalityRes]);
111
+ var isDirty = useFormDirtyCheck(methods, {
112
+ name: getUserName(user, false),
113
+ email: contact === null || contact === void 0 ? void 0 : contact.email,
114
+ mobile: (_c = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _c === void 0 ? void 0 : _c.number,
115
+ countryCode: resCountryCode,
116
+ gender: genderRes === null || genderRes === void 0 ? void 0 : genderRes.toLowerCase(),
117
+ nid: identification === null || identification === void 0 ? void 0 : identification.id,
118
+ issuedCountry: resIssuedCountry,
119
+ expiryDate: expDateRes,
120
+ dob: dobDateRes,
121
+ placeOfBirthCountry: resPlaceOfBirthCountry,
122
+ placeOfBirthCity: ((_d = birth === null || birth === void 0 ? void 0 : birth.city) === null || _d === void 0 ? void 0 : _d.cityId) && { id: birth.city.cityId },
123
+ nationality: resNationality
124
+ }, [
125
+ {
126
+ name: 'placeOfBirthCity',
127
+ keys: ['id']
128
+ }
129
+ ]).isDirty;
88
130
  var originalReadOnly = useFormReadOnly(methods);
89
131
  var noneEditable = useDataNoneEditable(data_status, [
90
132
  'name.en',
@@ -120,30 +162,37 @@ var IndividualPersonalInfo = function (_a) {
120
162
  'nationality',
121
163
  'gender'
122
164
  ]);
123
- var expDateRes = (identification === null || identification === void 0 ? void 0 : identification.expiry) && convertToEnglishDateFormat(new Date(identification === null || identification === void 0 ? void 0 : identification.expiry));
124
- var dobDateRes = (birth === null || birth === void 0 ? void 0 : birth.date) && convertToEnglishDateFormat(new Date(birth === null || birth === void 0 ? void 0 : birth.date));
125
165
  var isNameVerified = dataVerified['name.en'] && dataVerified['name.ar'] && getUserName(user, isAr) === watch('name');
126
166
  var isPhoneNumberVerified = dataVerified['contact.phone.number'] &&
127
167
  dataVerified['contact.phone.country_code'] &&
128
- ((_b = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _b === void 0 ? void 0 : _b.number) === watch('mobile') &&
129
- ((_c = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _c === void 0 ? void 0 : _c.country_code) === ((_e = (_d = watch('countryCode')) === null || _d === void 0 ? void 0 : _d.idd_prefix) === null || _e === void 0 ? void 0 : _e.toString());
168
+ ((_e = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _e === void 0 ? void 0 : _e.number) === watch('mobile') &&
169
+ ((_f = contact === null || contact === void 0 ? void 0 : contact.phone) === null || _f === void 0 ? void 0 : _f.country_code) === ((_h = (_g = watch('countryCode')) === null || _g === void 0 ? void 0 : _g.idd_prefix) === null || _h === void 0 ? void 0 : _h.toString());
130
170
  var isEmailVerified = dataVerified['contact.email'] && (contact === null || contact === void 0 ? void 0 : contact.email) === watch('email');
131
171
  var isGenderVerified = dataVerified['gender'] && genderRes === watch('gender');
132
172
  var isIDVerified = dataVerified['identification.id'] && (identification === null || identification === void 0 ? void 0 : identification.id) === watch('nid');
133
- var isIssuedCountryVerified = dataVerified['identification.issuer_country'] && (identification === null || identification === void 0 ? void 0 : identification.issued_country_code) === ((_f = watch('issuedCountry')) === null || _f === void 0 ? void 0 : _f.iso2);
173
+ var isIssuedCountryVerified = dataVerified['identification.issuer_country'] && (identification === null || identification === void 0 ? void 0 : identification.issued_country_code) === ((_j = watch('issuedCountry')) === null || _j === void 0 ? void 0 : _j.iso2);
134
174
  var isExpiryDateVerified = dataVerified['identification.expiry'] && expDateRes === watch('expiryDate');
135
175
  var isDOBVerified = dataVerified['birth.date'] && dobDateRes === watch('dob');
136
- var isBirthCountryVerified = dataVerified['birth.country'] && (birth === null || birth === void 0 ? void 0 : birth.country) === ((_g = watch('placeOfBirthCountry')) === null || _g === void 0 ? void 0 : _g.iso2);
137
- var isBirthCityVerified = dataVerified['birth.city'] && ((_h = birth === null || birth === void 0 ? void 0 : birth.city) === null || _h === void 0 ? void 0 : _h.cityId) === ((_j = watch('placeOfBirthCity')) === null || _j === void 0 ? void 0 : _j.id);
138
- var isNationalityVerified = dataVerified['nationality'] && nationalityRes === ((_k = watch('nationality')) === null || _k === void 0 ? void 0 : _k.iso2);
176
+ var isBirthCountryVerified = dataVerified['birth.country'] && (birth === null || birth === void 0 ? void 0 : birth.country) === ((_k = watch('placeOfBirthCountry')) === null || _k === void 0 ? void 0 : _k.iso2);
177
+ var isBirthCityVerified = dataVerified['birth.city'] && ((_l = birth === null || birth === void 0 ? void 0 : birth.city) === null || _l === void 0 ? void 0 : _l.cityId) === ((_m = watch('placeOfBirthCity')) === null || _m === void 0 ? void 0 : _m.id);
178
+ var isNationalityVerified = dataVerified['nationality'] && nationalityRes === ((_o = watch('nationality')) === null || _o === void 0 ? void 0 : _o.iso2);
139
179
  var isKWOrSaCountry = React.useMemo(function () { return isKWOrSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
140
180
  var onSubmit = function (data) {
141
- dispatch(updateIndividualPersonalInfo(deepCopy(getFelids(data))));
181
+ var formData = __assign(__assign({}, deepCopy(getFelids(data))), { isDirty: isDirty });
182
+ dispatch(updateIndividualPersonalInfo(formData));
142
183
  };
143
184
  React.useEffect(function () {
144
185
  if (error)
145
186
  dispatch(clearError());
146
187
  }, [methods.formState.isValid]);
188
+ React.useEffect(function () {
189
+ sendCustomEventToGTM({
190
+ event: 'Send Event',
191
+ event_category: 'Board Flows - Individual',
192
+ event_action: 'Update Personal Data Page',
193
+ event_label: settingsData.businessCountry.iso2
194
+ });
195
+ }, []);
147
196
  var onBack = function () {
148
197
  if (error)
149
198
  dispatch(clearError());
@@ -151,6 +200,12 @@ var IndividualPersonalInfo = function (_a) {
151
200
  dispatch(handleCurrentActiveScreen('INDIVIDUAL_LIST_STEP'));
152
201
  return;
153
202
  }
203
+ sendCustomEventToGTM({
204
+ event: 'Send Event',
205
+ event_category: 'Board Flows - Individual',
206
+ event_action: 'Individual Details Back Button',
207
+ event_label: settingsData.businessCountry.iso2
208
+ });
154
209
  if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0) {
155
210
  dispatch(handlePrevScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
156
211
  return;
@@ -96,7 +96,7 @@ var Password = memo(function (_a) {
96
96
  title: 'Password'
97
97
  });
98
98
  if (operationType === PASSWORD_OPERATION_TYPE.RESET_PASSWORD) {
99
- dispatch(verifyOperationToken({ token: token, boardId: boardId, boardInfoId: boardInfoId }));
99
+ dispatch(verifyOperationToken({ token: token, boardId: boardId, boardInfoId: boardInfoId, userId: userId, userType: userType }));
100
100
  return [2];
101
101
  }
102
102
  dispatch(verifyLeadToken({ token: token, isInternally: isInternally }));
@@ -59,7 +59,7 @@ import CheckIcon from '@mui/icons-material/Check';
59
59
  import { useAppDispatch, useAppSelector, useLanguage } from '../../../hooks';
60
60
  import { handleOpen, handleCurrentActiveScreen, handleNextScreenStep, settingsSelector } from '../../../app/settings';
61
61
  import { FlowsTypes } from '../../../@types';
62
- import { dangerousMessage, getScreenNameBasedOnFlow, isKWOrSA } from '../../../utils';
62
+ import { dangerousMessage, getScreenNameBasedOnFlow, isKWOrSA, sendCustomEventToGTM } from '../../../utils';
63
63
  import API from '../../../api';
64
64
  import Text from '../../../components/Text';
65
65
  import Dot from '../Dot';
@@ -163,6 +163,12 @@ export default function FlowsButtons(_a) {
163
163
  if (!item.href)
164
164
  return;
165
165
  var name = flowName === FlowsTypes.BANK ? 'Wallet' : capitalize(flowName);
166
+ sendCustomEventToGTM({
167
+ event: 'Send Event',
168
+ event_category: "Board Flows - ".concat(name),
169
+ event_action: "".concat(name, " Kit Click"),
170
+ event_label: settingsData.businessCountry.iso2
171
+ });
166
172
  if (flowName === item.name && !isResetPassword(item.name, item.status)) {
167
173
  var isOtherThanSAOrKWCountry = !isKWOrSA(settingsData.businessCountry.iso2);
168
174
  dispatch(handleCurrentActiveScreen(getScreenNameBasedOnFlow(item.name, isAuthorizedUser, isOtherThanSAOrKWCountry)));
@@ -10,10 +10,10 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { memo } from 'react';
13
+ import React, { memo } from 'react';
14
14
  import { createRoot } from 'react-dom/client';
15
15
  import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useAppDispatch } from '../../hooks';
16
- import { settingsSelector } from '../../app/settings';
16
+ import { handleCurrentActiveScreen, settingsSelector } from '../../app/settings';
17
17
  import AnimationFlow from '../../components/AnimationFlow';
18
18
  import { store } from '../../app/store';
19
19
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
@@ -33,6 +33,14 @@ var SignIn = memo(function (props) {
33
33
  useErrorListener(signInError || error);
34
34
  useStepStartedListener();
35
35
  var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open, merchant = data.merchant, isMaturityExpress = data.isMaturityExpress, appConfig = data.appConfig;
36
+ React.useEffect(function () {
37
+ if (settingLoading || !props.open)
38
+ return;
39
+ if (!data.isValidOperator) {
40
+ dispatch(handleCurrentActiveScreen('SIGIN_OPERATOR_ERROR_STEP'));
41
+ return;
42
+ }
43
+ }, [data.isValidOperator, settingLoading]);
36
44
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading }, { children: _jsx(AnimationFlow, __assign({ pointerEvents: loading ? 'none' : 'auto', isTapOrigin: isTapOrigin, open: open, error: error, loading: settingLoading, breakpoint: 'sm', screenId: activeScreen.name, merchantInfo: merchant, isMaturityExpress: isMaturityExpress, dialogEdgeFormat: data.appConfig.dialogEdgeFormat, features: appConfig.features }, { children: _jsx(FeatureContainer, __assign({ isMaturityExpress: isMaturityExpress }, { children: signInFeatureScreens.map(function (_a, index) {
37
45
  var Element = _a.element, name = _a.name;
38
46
  var isActive = activeScreen.name === name;
@@ -16,7 +16,7 @@ import { useForm, FormProvider } from 'react-hook-form';
16
16
  import { yupResolver } from '@hookform/resolvers/yup';
17
17
  import { styled } from '@mui/material/styles';
18
18
  import Form from '../../../../components/Form';
19
- import { useAppDispatch, useLanguage, useAppSelector, useSetFromDefaultValues, useFormReadOnly, useDataNoneEditable, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified } from '../../../../hooks';
19
+ import { useAppDispatch, useLanguage, useAppSelector, useSetFromDefaultValues, useFormReadOnly, useDataNoneEditable, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified, useFormDirtyCheck } from '../../../../hooks';
20
20
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
21
21
  import { DocumentPurpose } from '../../../../@types';
22
22
  import { deepCopy, getFileDetailsFromDocument, isSA } from '../../../../utils';
@@ -55,13 +55,18 @@ var TaxDetails = function () {
55
55
  var noneEditable = useDataNoneEditable(data_status, ['tax_number', 'documents', 'is_vat_acknowledged']);
56
56
  var readOnly = useFormErrorAndUpdateReadOnly(methods, originalReadOnly, noneEditable);
57
57
  var dataVerified = useDataVerified(data_verification, ['tax_number']);
58
+ var isDirty = useFormDirtyCheck(methods, {
59
+ vatId: entity === null || entity === void 0 ? void 0 : entity.vat_id,
60
+ confirmPolicy: entity === null || entity === void 0 ? void 0 : entity.is_vat_acknowledged
61
+ }).isDirty;
58
62
  var getFelids = useExcludeReadOnlyFelids(methods, readOnly).getFelids;
59
63
  var isVatIdVerified = dataVerified['tax_number'] && vat_id === methods.watch('vatId');
60
64
  var t = useTranslation().t;
61
65
  var isAr = useLanguage().isAr;
62
66
  var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
63
67
  var onSubmit = function (data) {
64
- dispatch(updateTaxInfo(deepCopy(getFelids(data))));
68
+ var formData = __assign(__assign({}, deepCopy(getFelids(data))), { isDirty: isDirty });
69
+ dispatch(updateTaxInfo(formData));
65
70
  };
66
71
  var onBack = function () {
67
72
  if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0) {
@@ -20,3 +20,4 @@ export * from './useDataNoneEditable';
20
20
  export * from './useFormErrorAndUpdateReadOnly';
21
21
  export * from './useExcludeReadOnlyFelids';
22
22
  export * from './useDataVerified';
23
+ export * from './useFormDirtyCheck';
@@ -20,3 +20,4 @@ export * from './useDataNoneEditable';
20
20
  export * from './useFormErrorAndUpdateReadOnly';
21
21
  export * from './useExcludeReadOnlyFelids';
22
22
  export * from './useDataVerified';
23
+ export * from './useFormDirtyCheck';
@@ -0,0 +1,10 @@
1
+ import { FieldValues, UseFormReturn } from 'react-hook-form';
2
+ type UseFormWithDirtyCheck = {
3
+ isDirty: boolean;
4
+ };
5
+ type CustomAttrProps = {
6
+ name: string;
7
+ keys: string[];
8
+ };
9
+ export declare const useFormDirtyCheck: <TFieldValues extends FieldValues>(method: UseFormReturn<TFieldValues, any, undefined>, backendData: TFieldValues, customAttrs?: CustomAttrProps[]) => UseFormWithDirtyCheck;
10
+ export {};
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import _ from 'lodash';
3
+ export var useFormDirtyCheck = function (method, backendData, customAttrs) {
4
+ var _a = React.useState(false), isDirty = _a[0], setIsDirty = _a[1];
5
+ var data = method.watch();
6
+ var isValidData = function (formValue, backendValue) {
7
+ if (_.isUndefined(formValue))
8
+ return false;
9
+ if (_.isArray(formValue) && formValue.length === 0)
10
+ return false;
11
+ if (_.isObject(formValue) && _.isEmpty(formValue))
12
+ return false;
13
+ if (formValue === '' && !backendValue)
14
+ return false;
15
+ return true;
16
+ };
17
+ var isArray = function (data, backendData) {
18
+ return backendData && data && _.isArray(backendData) && _.isArray(data);
19
+ };
20
+ var isObject = function (data, backendData) {
21
+ return backendData && data && _.isObject(data) && _.isObject(backendData);
22
+ };
23
+ var mapArrayOfObjectWithKeys = function (items, keys) {
24
+ return _.map(items, function (item) { return _.pick(item, keys); });
25
+ };
26
+ var mapObjectWithKeys = function (item, keys) {
27
+ return _.pick(item, keys);
28
+ };
29
+ var deepComparison = function (data, backendData, customAttrs) {
30
+ var _loop_1 = function (key) {
31
+ var formValue = data === null || data === void 0 ? void 0 : data[key];
32
+ var backEndValue = backendData === null || backendData === void 0 ? void 0 : backendData[key];
33
+ if (!isValidData(formValue, backEndValue))
34
+ return "continue";
35
+ var customAttr = customAttrs === null || customAttrs === void 0 ? void 0 : customAttrs.find(function (el) { return el.name === key; });
36
+ if (customAttr) {
37
+ var keys = customAttr.keys;
38
+ if (isArray(formValue, backEndValue)) {
39
+ formValue = mapArrayOfObjectWithKeys(formValue, keys);
40
+ backEndValue = mapArrayOfObjectWithKeys(backEndValue, keys);
41
+ if (formValue.length !== backEndValue.length)
42
+ return { value: true };
43
+ if (_.differenceWith(formValue, backEndValue, _.isEqual).length > 0)
44
+ return { value: true };
45
+ }
46
+ if (isObject(formValue, backEndValue)) {
47
+ formValue = mapObjectWithKeys(formValue, keys);
48
+ backEndValue = mapObjectWithKeys(backEndValue, keys);
49
+ }
50
+ }
51
+ if (!_.isEqual(formValue, backEndValue))
52
+ return { value: true };
53
+ };
54
+ for (var key in backendData) {
55
+ var state_1 = _loop_1(key);
56
+ if (typeof state_1 === "object")
57
+ return state_1.value;
58
+ }
59
+ return false;
60
+ };
61
+ React.useEffect(function () {
62
+ var isDirty = deepComparison(data, backendData, customAttrs);
63
+ setIsDirty(isDirty);
64
+ }, [data, backendData]);
65
+ return { isDirty: isDirty };
66
+ };
@@ -1,5 +1,5 @@
1
1
  import { axiosInstance } from '../api';
2
- import { ENDPOINT_PATHS, CONNECT_SANDBOX_URL, CONNECT_BETA_URL } from '../constants';
2
+ import { ENDPOINT_PATHS, CONNECT_DEV_URL, CONNECT_PROD_URL } from '../constants';
3
3
  export var sleep = function (milliseconds) {
4
4
  if (milliseconds === void 0) { milliseconds = 1000; }
5
5
  return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); });
@@ -13,10 +13,10 @@ export var dangerousMessage = function (message, callBack) {
13
13
  export var setBaseUrl = function (publicKey) {
14
14
  var isProd = publicKey.includes('pk_live');
15
15
  if (isProd) {
16
- axiosInstance.defaults.baseURL = ENDPOINT_PATHS.BETA_BASE_URL;
16
+ axiosInstance.defaults.baseURL = ENDPOINT_PATHS.PRODUCTION_BASE_URL;
17
17
  return;
18
18
  }
19
- axiosInstance.defaults.baseURL = ENDPOINT_PATHS.SANDBOX_BASE_URL;
19
+ axiosInstance.defaults.baseURL = ENDPOINT_PATHS.DEV_BASE_URL;
20
20
  };
21
21
  export var updateLocationUrlWithCountry = function (countryIso2) {
22
22
  var country = countryIso2.toLowerCase();
@@ -35,7 +35,7 @@ export var updateLocationUrlWithCountry = function (countryIso2) {
35
35
  window.history.replaceState({}, '', newUrl);
36
36
  };
37
37
  export var openConnect = function (pk, countryCode) {
38
- var newUrl = new URL(pk.includes('pk_live') ? CONNECT_BETA_URL : CONNECT_SANDBOX_URL);
38
+ var newUrl = new URL(pk.includes('pk_live') ? CONNECT_PROD_URL : CONNECT_DEV_URL);
39
39
  if (countryCode) {
40
40
  newUrl.pathname = "/".concat(countryCode.toLowerCase());
41
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.8.62-beta",
3
+ "version": "2.8.62-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -21,7 +21,7 @@
21
21
  "copy:files": "copyfiles -u 1 src/**/*.css build/",
22
22
  "tsc:alias": "tsc-alias -p tsconfig.json",
23
23
  "ts:build": "rm -rf build && tsc -p tsconfig.json && tsc-alias -p tsconfig.json && yarn copy:files",
24
- "push": "npm publish --access public --tag beta"
24
+ "push": "npm publish --access public --tag development"
25
25
  },
26
26
  "keywords": [],
27
27
  "author": {