@tap-payments/auth-jsconnect 2.0.45 → 2.0.46

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 (203) hide show
  1. package/build/@types/app.d.ts +47 -2
  2. package/build/@types/app.js +22 -0
  3. package/build/@types/form.d.ts +19 -1
  4. package/build/@types/index.d.ts +1 -0
  5. package/build/@types/index.js +1 -0
  6. package/build/@types/user.d.ts +141 -0
  7. package/build/@types/user.js +1 -0
  8. package/build/api/board.d.ts +16 -0
  9. package/build/api/board.js +10 -1
  10. package/build/api/country.d.ts +4 -0
  11. package/build/api/country.js +9 -1
  12. package/build/api/entity.d.ts +3 -3
  13. package/build/api/index.d.ts +8 -3
  14. package/build/api/individual.d.ts +54 -4
  15. package/build/api/individual.js +9 -1
  16. package/build/api/user.d.ts +6 -0
  17. package/build/api/user.js +9 -1
  18. package/build/app/settings.js +11 -8
  19. package/build/assets/locales/ar.json +28 -2
  20. package/build/assets/locales/en.json +28 -1
  21. package/build/components/SimpleList/SimpleList.d.ts +2 -0
  22. package/build/constants/api.d.ts +1 -0
  23. package/build/constants/api.js +3 -1
  24. package/build/constants/app.d.ts +1 -0
  25. package/build/constants/app.js +20 -7
  26. package/build/constants/assets.d.ts +4 -0
  27. package/build/constants/assets.js +4 -0
  28. package/build/features/app/bank/bankStore.d.ts +1 -0
  29. package/build/features/app/bank/bankStore.js +19 -13
  30. package/build/features/app/brand/brandStore.d.ts +2 -0
  31. package/build/features/app/brand/brandStore.js +69 -49
  32. package/build/features/app/business/businessStore.js +3 -3
  33. package/build/features/app/connect/connectStore.js +6 -6
  34. package/build/features/app/connectExpress/connectExpressStore.js +15 -9
  35. package/build/features/app/entity/entityStore.d.ts +2 -0
  36. package/build/features/app/entity/entityStore.js +5 -3
  37. package/build/features/app/individual/individualStore.d.ts +93 -4
  38. package/build/features/app/individual/individualStore.js +613 -129
  39. package/build/features/app/password/passwordStore.js +2 -2
  40. package/build/features/app/tax/taxStore.js +30 -29
  41. package/build/features/bank/Bank.js +2 -2
  42. package/build/features/bank/screens/BankDetails/BankDetails.js +8 -7
  43. package/build/features/bank/screens/BankDetails/BankName.js +13 -10
  44. package/build/features/bank/screens/BankDetails/BankStatement.js +8 -2
  45. package/build/features/bank/screens/BankDetails/Beneficiary.js +12 -13
  46. package/build/features/bank/screens/BankDetails/IBAN.js +14 -10
  47. package/build/features/bank/screens/BankDetails/validation.d.ts +14 -14
  48. package/build/features/bank/screens/BankDetails/validation.js +34 -15
  49. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  50. package/build/features/brand/Brand.js +2 -2
  51. package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +3 -3
  52. package/build/features/brand/screens/BrandActivities/ActivitiesList.js +8 -6
  53. package/build/features/brand/screens/BrandActivities/BrandActivities.js +12 -2
  54. package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +2 -2
  55. package/build/features/brand/screens/BrandActivities/CustomerBase.js +9 -6
  56. package/build/features/brand/screens/BrandActivities/ExpectedSalesRange.js +10 -7
  57. package/build/features/brand/screens/BrandActivities/validation.d.ts +7 -7
  58. package/build/features/brand/screens/BrandActivities/validation.js +26 -15
  59. package/build/features/brand/screens/BrandInfo/BrandInfo.js +11 -4
  60. package/build/features/brand/screens/BrandInfo/BrandName.js +13 -12
  61. package/build/features/brand/screens/BrandInfo/SalesChannels.js +21 -9
  62. package/build/features/brand/screens/BrandInfo/validation.d.ts +7 -7
  63. package/build/features/brand/screens/BrandInfo/validation.js +46 -36
  64. package/build/features/brand/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  65. package/build/features/business/Business.js +2 -2
  66. package/build/features/business/screens/Activities/ActivitiesList.d.ts +3 -3
  67. package/build/features/business/screens/BusinessType/LicenseCertificate.js +2 -1
  68. package/build/features/business/screens/BusinessType/LicenseType.d.ts +2 -2
  69. package/build/features/business/screens/Customers/CustomerLocations.d.ts +2 -2
  70. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  71. package/build/features/connect/Connect.js +2 -2
  72. package/build/features/connect/screens/Merchant/BrandList.js +4 -4
  73. package/build/features/connect/screens/Merchant/BrandName.js +6 -5
  74. package/build/features/connect/screens/Merchant/validation.js +2 -2
  75. package/build/features/connectExpress/ConnectExpress.js +2 -2
  76. package/build/features/connectExpress/screens/CollectBusinessInfo/BrandName.js +1 -3
  77. package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +2 -2
  78. package/build/features/connectExpress/screens/CollectBusinessInfo/validation.js +5 -5
  79. package/build/features/connectExpress/screens/CreateAccountLoader/CreateAccountLoader.js +23 -3
  80. package/build/features/connectExpress/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +3 -3
  81. package/build/features/entity/Entity.js +2 -2
  82. package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +3 -3
  83. package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +3 -3
  84. package/build/features/entity/screens/EntityName/LicenseCertificate.js +9 -3
  85. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  86. package/build/features/featuresScreens.js +10 -0
  87. package/build/features/individual/Individual.js +2 -2
  88. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.d.ts +13 -0
  89. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +48 -25
  90. package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +6 -1
  91. package/build/features/individual/screens/AdditionalIndividualInfo/InfluencerSwitch.js +9 -2
  92. package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +11 -17
  93. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +12 -16
  94. package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +2 -2
  95. package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.js +9 -2
  96. package/build/features/individual/screens/AdditionalIndividualInfo/ShareCount.d.ts +6 -0
  97. package/build/features/individual/screens/AdditionalIndividualInfo/ShareCount.js +35 -0
  98. package/build/features/individual/screens/AdditionalIndividualInfo/ShareValue.d.ts +6 -0
  99. package/build/features/individual/screens/AdditionalIndividualInfo/ShareValue.js +41 -0
  100. package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +8 -2
  101. package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +9 -6
  102. package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +25 -23
  103. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +19 -25
  104. package/build/features/individual/screens/IndividualList/CollectPhoneEmail.d.ts +10 -0
  105. package/build/features/individual/screens/IndividualList/CollectPhoneEmail.js +31 -0
  106. package/build/features/individual/screens/IndividualList/Email.d.ts +6 -0
  107. package/build/features/individual/screens/IndividualList/Email.js +48 -0
  108. package/build/features/individual/screens/IndividualList/IndividualList.d.ts +31 -0
  109. package/build/features/individual/screens/IndividualList/IndividualList.js +58 -0
  110. package/build/features/individual/screens/IndividualList/MobileNumber.d.ts +12 -0
  111. package/build/features/individual/screens/IndividualList/MobileNumber.js +143 -0
  112. package/build/features/individual/screens/IndividualList/UserList.d.ts +5 -0
  113. package/build/features/individual/screens/IndividualList/UserList.js +186 -0
  114. package/build/features/individual/screens/IndividualList/index.d.ts +3 -0
  115. package/build/features/individual/screens/IndividualList/index.js +2 -0
  116. package/build/features/individual/screens/IndividualList/validation.d.ts +12 -0
  117. package/build/features/individual/screens/IndividualList/validation.js +39 -0
  118. package/build/features/individual/screens/IndividualPersonalInfo/BirthCity.d.ts +8 -0
  119. package/build/features/individual/screens/IndividualPersonalInfo/BirthCity.js +109 -0
  120. package/build/features/individual/screens/{AdditionalIndividualInfo/EmployerLocation.d.ts → IndividualPersonalInfo/BirthCountry.d.ts} +2 -2
  121. package/build/features/individual/screens/{AdditionalIndividualInfo/EmployerLocation.js → IndividualPersonalInfo/BirthCountry.js} +14 -24
  122. package/build/features/individual/screens/IndividualPersonalInfo/DOB.d.ts +7 -0
  123. package/build/features/individual/screens/IndividualPersonalInfo/DOB.js +46 -0
  124. package/build/features/individual/screens/IndividualPersonalInfo/Email.d.ts +6 -0
  125. package/build/features/individual/screens/IndividualPersonalInfo/Email.js +50 -0
  126. package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.d.ts +7 -0
  127. package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.js +50 -0
  128. package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +34 -0
  129. package/build/features/individual/screens/IndividualPersonalInfo/Gender.js +81 -0
  130. package/build/features/individual/screens/IndividualPersonalInfo/ID.d.ts +6 -0
  131. package/build/features/individual/screens/IndividualPersonalInfo/ID.js +48 -0
  132. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.d.ts +21 -0
  133. package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +139 -0
  134. package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.d.ts +10 -0
  135. package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.js +88 -0
  136. package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.d.ts +10 -0
  137. package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.js +145 -0
  138. package/build/features/individual/screens/IndividualPersonalInfo/Name.d.ts +6 -0
  139. package/build/features/individual/screens/IndividualPersonalInfo/Name.js +52 -0
  140. package/build/features/individual/screens/IndividualPersonalInfo/Nationality.d.ts +10 -0
  141. package/build/features/individual/screens/IndividualPersonalInfo/Nationality.js +88 -0
  142. package/build/features/individual/screens/IndividualPersonalInfo/index.d.ts +3 -0
  143. package/build/features/individual/screens/IndividualPersonalInfo/index.js +2 -0
  144. package/build/features/individual/screens/IndividualPersonalInfo/validation.d.ts +38 -0
  145. package/build/features/individual/screens/IndividualPersonalInfo/validation.js +68 -0
  146. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  147. package/build/features/individual/screens/Verify/Verify.js +10 -17
  148. package/build/features/password/Password.js +2 -2
  149. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  150. package/build/features/shared/Address/Address.d.ts +6 -1
  151. package/build/features/shared/Address/Address.js +40 -30
  152. package/build/features/shared/Address/CountryList.d.ts +1 -1
  153. package/build/features/shared/Address/InputSelect.d.ts +1 -1
  154. package/build/features/shared/Address/InputText.d.ts +2 -1
  155. package/build/features/shared/Address/InputText.js +2 -2
  156. package/build/features/shared/Button/Button.js +11 -0
  157. package/build/features/shared/Button/FlowsButtons.d.ts +1 -0
  158. package/build/features/shared/Button/FlowsButtons.js +5 -5
  159. package/build/features/shared/Button/ListButton.d.ts +18 -0
  160. package/build/features/shared/Button/ListButton.js +125 -0
  161. package/build/features/shared/Button/index.d.ts +2 -1
  162. package/build/features/shared/Button/index.js +2 -1
  163. package/build/features/shared/CreateAccountLoading/CreateAccountLoading.d.ts +2 -1
  164. package/build/features/shared/CreateAccountLoading/CreateAccountLoading.js +2 -2
  165. package/build/features/shared/SalesChannels/SalesChannel.d.ts +2 -1
  166. package/build/features/shared/SalesChannels/SalesChannel.js +2 -2
  167. package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.d.ts +2 -1
  168. package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.js +8 -6
  169. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +6 -1
  170. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +33 -11
  171. package/build/features/signIn/SignIn.js +2 -2
  172. package/build/features/tax/Tax.js +2 -2
  173. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  174. package/build/features/tax/screens/TaxDetails/TaxDetails.js +2 -1
  175. package/build/features/tax/screens/TaxDetails/TaxDocument.js +8 -2
  176. package/build/features/tax/screens/TaxDetails/VATId.js +8 -3
  177. package/build/features/tax/screens/TaxDetails/validation.d.ts +4 -4
  178. package/build/features/tax/screens/TaxDetails/validation.js +10 -5
  179. package/build/utils/array.d.ts +1 -0
  180. package/build/utils/array.js +10 -2
  181. package/build/utils/common.d.ts +1 -0
  182. package/build/utils/common.js +6 -0
  183. package/build/utils/date.d.ts +1 -0
  184. package/build/utils/date.js +7 -1
  185. package/build/utils/error.d.ts +1 -0
  186. package/build/utils/error.js +3 -0
  187. package/build/utils/html.d.ts +1 -1
  188. package/build/utils/html.js +4 -1
  189. package/build/utils/index.d.ts +1 -0
  190. package/build/utils/index.js +1 -0
  191. package/build/utils/string.d.ts +15 -2
  192. package/build/utils/string.js +37 -3
  193. package/build/utils/validation.d.ts +1 -0
  194. package/build/utils/validation.js +3 -0
  195. package/package.json +129 -129
  196. package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.d.ts +0 -6
  197. package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.js +0 -46
  198. package/build/features/individual/screens/ShowIndividualInfo/ShowOwnerInfo.d.ts +0 -19
  199. package/build/features/individual/screens/ShowIndividualInfo/ShowOwnerInfo.js +0 -52
  200. package/build/features/individual/screens/ShowIndividualInfo/index.d.ts +0 -3
  201. package/build/features/individual/screens/ShowIndividualInfo/index.js +0 -2
  202. package/build/features/individual/screens/ShowIndividualInfo/info.d.ts +0 -7
  203. package/build/features/individual/screens/ShowIndividualInfo/info.js +0 -28
@@ -29,6 +29,8 @@ import { InputLabelStyled } from '../../shared/Input/Input';
29
29
  import { ScreenContainer } from '../../shared/Containers';
30
30
  import Mandatory from '../../shared/Mandatory';
31
31
  import UploadFile, { FileStatus } from './UploadFile';
32
+ import { useController } from 'react-hook-form';
33
+ import { getFileType } from '../../../utils';
32
34
  var FeatureStyled = styled(ScreenContainer)(function (_a) {
33
35
  var theme = _a.theme;
34
36
  return ({
@@ -59,12 +61,31 @@ var UploadCountBox = styled(Box)(function (_a) {
59
61
  });
60
62
  });
61
63
  var UploadMultipleFile = function (_a) {
62
- var label = _a.label, required = _a.required, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, onFileUploaded = _a.onFileUploaded, fileUploadingStatus = _a.fileUploadingStatus, onDeleteFile = _a.onDeleteFile, maxLimit = _a.maxLimit, purpose = _a.purpose, fileTitle = _a.fileTitle;
64
+ var id = _a.id, label = _a.label, control = _a.control, required = _a.required, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, onFileUploaded = _a.onFileUploaded, fileUploadingStatus = _a.fileUploadingStatus, onDeleteFile = _a.onDeleteFile, maxLimit = _a.maxLimit, purpose = _a.purpose, fileTitle = _a.fileTitle, defaultFiles = _a.defaultFiles;
63
65
  var t = useTranslation().t;
64
66
  var theme = useTheme();
65
67
  var _b = React.useState(''), error = _b[0], setError = _b[1];
66
- var _c = React.useState([]), fileArray = _c[0], setFileArray = _c[1];
67
- var _d = React.useState([]), fileInfoArray = _d[0], setFileInfoArray = _d[1];
68
+ var fileControl = useController({ name: "".concat(id, "File"), control: control });
69
+ var fileInfoControl = useController({ name: "".concat(id, "FileInfo"), control: control });
70
+ var fileArray = fileControl.field.value || [];
71
+ var fileInfoArray = fileInfoControl.field.value || [];
72
+ React.useEffect(function () {
73
+ var files = defaultFiles || [];
74
+ if (fileArray.length === 0 && files.length > 0) {
75
+ files.forEach(function (file) {
76
+ fileArray.push({ name: file.title, size: file.size, type: getFileType(file.type) });
77
+ fileInfoArray.push({
78
+ fileId: file.id,
79
+ status: FileStatus.SUCCESS,
80
+ progress: 100,
81
+ error: '',
82
+ name: file.title || ''
83
+ });
84
+ });
85
+ fileControl.field.onChange(__spreadArray([], fileArray, true));
86
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
87
+ }
88
+ }, [defaultFiles]);
68
89
  var uploadedFileCount = React.useMemo(function () { return (fileInfoArray || []).filter(function (file) { return file.fileId; }).length; }, [fileInfoArray]);
69
90
  var handleFileChange = function (files) {
70
91
  if (!isSubmitting) {
@@ -96,8 +117,8 @@ var UploadMultipleFile = function (_a) {
96
117
  fileInfoArray.push({ fileId: '', status: FileStatus.INIT, progress: 0, error: '', name: file.name });
97
118
  }
98
119
  });
99
- setFileArray(__spreadArray([], fileArray, true));
100
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
120
+ fileControl.field.onChange(__spreadArray([], fileArray, true));
121
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
101
122
  }
102
123
  }
103
124
  };
@@ -108,9 +129,9 @@ var UploadMultipleFile = function (_a) {
108
129
  if (required && fileInfoArray.length === 1)
109
130
  setError(t('file_upload_at_least_one'));
110
131
  fileArray.splice(index, 1);
111
- setFileArray(__spreadArray([], fileArray, true));
132
+ fileControl.field.onChange(__spreadArray([], fileArray, true));
112
133
  fileInfoArray.splice(index, 1);
113
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
134
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
114
135
  var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
115
136
  onDeleteFile(fileIds);
116
137
  }
@@ -119,23 +140,24 @@ var UploadMultipleFile = function (_a) {
119
140
  var handleSuccess = function (index, file) {
120
141
  if (fileInfoArray.length > 0) {
121
142
  fileInfoArray[index] = file;
122
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
143
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
123
144
  var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
124
- onFileUploaded(fileIds);
145
+ var filteredFromDefaultFiles = fileIds.filter(function (id) { return !(defaultFiles || []).some(function (file) { return file.id === id; }); });
146
+ onFileUploaded(filteredFromDefaultFiles);
125
147
  fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
126
148
  }
127
149
  };
128
150
  var handleFailure = function (index, file) {
129
151
  if (fileInfoArray.length > 0) {
130
152
  fileInfoArray[index] = file;
131
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
153
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
132
154
  fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
133
155
  }
134
156
  };
135
157
  var handleProgress = function (index, file) {
136
158
  if (fileInfoArray.length > 0) {
137
159
  fileInfoArray[index] = file;
138
- setFileInfoArray(__spreadArray([], fileInfoArray, true));
160
+ fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
139
161
  fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(true);
140
162
  }
141
163
  };
@@ -18,7 +18,7 @@ import AnimationFlow from '../../components/AnimationFlow';
18
18
  import { store } from '../../app/store';
19
19
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
20
20
  import Collapse from '../../components/Collapse';
21
- import { createElementAndInject } from '../../utils';
21
+ import { findOrCreateElementAndInject } from '../../utils';
22
22
  import { FeatureContainer } from '../shared/Containers';
23
23
  import { SigIn_SCREENS_NAVIGATION } from '../../constants';
24
24
  import { signInFeatureScreens } from '../featuresScreens';
@@ -43,7 +43,7 @@ export function SignInElement(props) {
43
43
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(SignIn, __assign({}, props)) })));
44
44
  }
45
45
  export function renderSignInLib(config, elementId) {
46
- var element = createElementAndInject(elementId);
46
+ var element = findOrCreateElementAndInject(elementId);
47
47
  var root = createRoot(element);
48
48
  root.render(_jsx(SignInElement, __assign({}, config)));
49
49
  var unmount = function () { return root.unmount(); };
@@ -29,7 +29,7 @@ import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
30
30
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
31
31
  import Collapse from '../../components/Collapse';
32
- import { createElementAndInject } from '../../utils';
32
+ import { findOrCreateElementAndInject } from '../../utils';
33
33
  import { FeatureContainer } from '../shared/Containers';
34
34
  import { TAX_SCREENS_NAVIGATION } from '../../constants';
35
35
  import { taxFeatureScreens } from '../featuresScreens';
@@ -64,7 +64,7 @@ export function TaxElement(props) {
64
64
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Tax, __assign({}, props)) })));
65
65
  }
66
66
  export function renderTaxLib(config, elementId) {
67
- var element = createElementAndInject(elementId);
67
+ var element = findOrCreateElementAndInject(elementId);
68
68
  var root = createRoot(element);
69
69
  root.render(_jsx(TaxElement, __assign({}, config)));
70
70
  var unmount = function () { return root.unmount(); };
@@ -16,7 +16,7 @@ import { taxSelector } from '../../../app/tax/taxStore';
16
16
  import SuccessFlowButtons from '../../../shared/SuccessFlowButtons';
17
17
  var SuccessWithFlowButtons = function () {
18
18
  var data = useAppSelector(taxSelector).data;
19
- var _a = data.verify.responseBody || {}, flows = _a.flows, entity = _a.entity, brand = _a.brand, bank = _a.bank_account, merchant = _a.merchant, user = _a.user, business = _a.business, board_id = _a.board_id, board_info_id = _a.board_info_id, name = _a.name;
20
- return (_jsx(SuccessFlowButtons, { flowName: data.flowName, bank: bank, brand: brand, entity: entity, merchant: merchant, user: __assign({ names: { en: name } }, user), business: business, boardId: board_id, boardInfoId: board_info_id, flows: flows || [] }));
19
+ var _a = data.verify.responseBody || {}, flows = _a.flows, entity = _a.entity, brand = _a.brand, bank = _a.bank_account, merchant = _a.merchant, user = _a.user, business = _a.business, board_id = _a.board_id, board_info_id = _a.board_info_id, name = _a.name, individuals = _a.individuals;
20
+ return (_jsx(SuccessFlowButtons, { flowName: data.flowName, bank: bank, brand: brand, entity: entity, merchant: merchant, user: __assign({ names: { en: name } }, user), business: business, boardId: board_id, boardInfoId: board_info_id, individuals: individuals, flows: flows || [] }));
21
21
  };
22
22
  export default memo(SuccessWithFlowButtons);
@@ -35,10 +35,11 @@ var FormStyled = styled(Form)(function () { return ({
35
35
  var TaxDetails = function () {
36
36
  var dispatch = useAppDispatch();
37
37
  var _a = useAppSelector(taxSelector), data = _a.data, loading = _a.loading, error = _a.error, uploading = _a.uploading;
38
+ var entity = (data.verify.responseBody || {}).entity;
38
39
  var settingsData = useAppSelector(settingsSelector).data;
39
40
  var _b = data.taxData, vatId = _b.vatId, confirmPolicy = _b.confirmPolicy, documentId = _b.documentId;
40
41
  var methods = useForm({
41
- resolver: yupResolver(Validation),
42
+ resolver: yupResolver(Validation(entity)),
42
43
  defaultValues: {
43
44
  vatId: vatId,
44
45
  confirmPolicy: confirmPolicy,
@@ -10,11 +10,14 @@ 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 React from 'react';
13
14
  import { useTranslation } from 'react-i18next';
14
15
  import { useController, useFormContext } from 'react-hook-form';
15
16
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
17
+ import { DocumentPurpose } from '../../../../@types';
16
18
  import { styled } from '@mui/material/styles';
17
19
  import Collapse from '../../../../components/Collapse';
20
+ import { getRecentDocumentFiles } from '../../../../utils';
18
21
  import { ScreenContainer } from '../../../shared/Containers';
19
22
  import { taxSelector, uploadingStatus } from '../../../app/tax/taxStore';
20
23
  import UploadMultipleFile from '../../../shared/UploadMultipleFile';
@@ -25,18 +28,21 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
25
28
  });
26
29
  });
27
30
  var TaxDocument = function (_a) {
31
+ var _b;
28
32
  var show = _a.show;
29
33
  var t = useTranslation().t;
30
34
  var control = useFormContext().control;
31
35
  var dispatch = useAppDispatch();
32
36
  var documentIdControl = useController({ name: 'documentId', control: control });
33
- var loading = useAppSelector(taxSelector).loading;
37
+ var _c = useAppSelector(taxSelector), loading = _c.loading, data = _c.data;
38
+ var documents = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}).documents;
34
39
  var handleTaxDocumentChange = function (ids) {
35
40
  documentIdControl.field.onChange(ids);
36
41
  };
37
42
  var handleReset = function (ids) {
38
43
  documentIdControl.field.onChange(ids);
39
44
  };
40
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(UploadMultipleFile, { label: t('title_tax_document'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_tax_document'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleTaxDocumentChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'tax_document_user_upload', fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) })) })));
45
+ var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.TAX_DOCUMENT); }, [documents]);
46
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(UploadMultipleFile, { id: 'documentId', control: control, label: t('title_tax_document'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_tax_document'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleTaxDocumentChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, defaultFiles: defaultFiles, purpose: DocumentPurpose.TAX_DOCUMENT, fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) })) })));
41
47
  };
42
48
  export default TaxDocument;
@@ -17,26 +17,31 @@ import { useTranslation } from 'react-i18next';
17
17
  import { useController, useFormContext } from 'react-hook-form';
18
18
  import { VAT_ID_LENGTH } from '../../../../constants';
19
19
  import { useAppSelector } from '../../../../hooks';
20
+ import { FieldType } from '../../../../@types';
20
21
  import { isSA, removeAllCharsFromNumber } from '../../../../utils';
21
22
  import { settingsSelector } from '../../../../app/settings';
22
23
  import ClearIcon from '../../../shared/ClearIcon';
23
24
  import CheckIcon from '../../../shared/CheckIcon';
25
+ import { taxSelector } from '../../../app/tax/taxStore';
24
26
  var VATId = function () {
25
- var _a;
27
+ var _a, _b;
26
28
  var t = useTranslation().t;
27
29
  var control = useFormContext().control;
28
30
  var vatControl = useController({ name: 'vatId', control: control });
29
31
  var settingsData = useAppSelector(settingsSelector).data;
30
32
  var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
33
+ var data = useAppSelector(taxSelector).data;
34
+ var entity = (data.verify.responseBody || {}).entity;
35
+ var disabled = ((_a = entity === null || entity === void 0 ? void 0 : entity.data_status) === null || _a === void 0 ? void 0 : _a.tax_number) === FieldType.NON_EDITABLE;
31
36
  var handleOnChange = function (vat) {
32
37
  var value = removeAllCharsFromNumber(vat);
33
38
  vatControl.field.onChange(value);
34
39
  };
35
40
  var vatValue = vatControl.field.value;
36
- var vatError = (_a = vatControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
41
+ var vatError = (_b = vatControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
37
42
  var clearValue = function () {
38
43
  vatControl.field.onChange('');
39
44
  };
40
- return (_jsx(Box, __assign({ sx: isSACountry ? {} : { height: '200px' } }, { children: _jsx(Input, { label: t('vat_id'), inputProps: { maxLength: VAT_ID_LENGTH }, value: vatValue, onChange: function (event) { return handleOnChange(event.target.value); }, placeholder: t('vat_id_placeholder'), warningType: 'alert', warningMessage: vatError && t(vatError), required: true, endAdornment: !vatError && vatValue ? _jsx(CheckIcon, {}) : vatValue && _jsx(ClearIcon, { onClick: clearValue }) }) })));
45
+ return (_jsx(Box, __assign({ sx: isSACountry ? {} : { height: '200px' } }, { children: _jsx(Input, { label: t('vat_id'), disabled: disabled, inputProps: { maxLength: VAT_ID_LENGTH }, value: vatValue, onChange: function (event) { return handleOnChange(event.target.value); }, placeholder: t('vat_id_placeholder'), warningType: 'alert', warningMessage: vatError && t(vatError), required: true, endAdornment: !vatError && vatValue ? _jsx(CheckIcon, {}) : vatValue && _jsx(ClearIcon, { onClick: clearValue }) }) })));
41
46
  };
42
47
  export default VATId;
@@ -1,14 +1,14 @@
1
1
  import * as yup from 'yup';
2
- export declare const Validation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
- vatId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
2
+ export declare const Validation: (entity: any) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ vatId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
4
4
  confirmPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
5
5
  documentId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
6
6
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
- vatId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
7
+ vatId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
8
8
  confirmPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
9
9
  documentId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
10
10
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
11
- vatId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
11
+ vatId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
12
12
  confirmPolicy: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, true>;
13
13
  documentId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
14
14
  }>>>;
@@ -1,6 +1,11 @@
1
1
  import * as yup from 'yup';
2
- export var Validation = yup.object().shape({
3
- vatId: yup.string().min(9, 'alert_vat').max(15, 'alert_vat').required('alert_vat'),
4
- confirmPolicy: yup.boolean().required('alert_tax_confirm').isTrue('alert_tax_confirm'),
5
- documentId: yup.array().optional()
6
- });
2
+ import { FieldType } from '../../../../@types';
3
+ export var Validation = function (entity) {
4
+ var _a = entity || {}, vat_id = _a.vat_id, data_status = _a.data_status;
5
+ var isTaxNumberOptional = !vat_id && (data_status === null || data_status === void 0 ? void 0 : data_status.tax_number) === FieldType.NON_EDITABLE;
6
+ return yup.object().shape({
7
+ vatId: isTaxNumberOptional ? yup.string().optional() : yup.string().min(9, 'alert_vat').max(15, 'alert_vat').required('alert_vat'),
8
+ confirmPolicy: yup.boolean().required('alert_tax_confirm').isTrue('alert_tax_confirm'),
9
+ documentId: yup.array().optional()
10
+ });
11
+ };
@@ -62,3 +62,4 @@ export declare const fixBrandList: (items: Array<{
62
62
  }[];
63
63
  export declare const findFirstId: (items: Array<SaleChannel>) => string;
64
64
  export declare const sortActivitiesByName: (items: Array<Activity>, path: string) => Activity[];
65
+ export declare const getRecentDocumentFiles: (documents: Array<any>, purpose: string) => any;
@@ -90,9 +90,9 @@ export var findCountryByIddPrefix = function (countries, iddPrefix) {
90
90
  export var mapSalesChannel = function (salesChannel) {
91
91
  return salesChannel.map(function (item) {
92
92
  var hasSub = item.sub && item.sub.length > 0;
93
- return __assign(__assign(__assign({}, item), { address: (item.address || '').replaceAll('https://', '').replaceAll('@', '') }), (hasSub && {
93
+ return __assign(__assign(__assign({}, item), { address: (item.address || '').replaceAll('https://', '').replaceAll('www.', '').replaceAll('@', '') }), (hasSub && {
94
94
  sub: item.sub.map(function (subItem) {
95
- return __assign(__assign({}, subItem), { address: (subItem.address || '').replaceAll('https://', '').replaceAll('@', '') });
95
+ return __assign(__assign({}, subItem), { address: (subItem.address || '').replaceAll('https://', '').replaceAll('www.', '').replaceAll('@', '') });
96
96
  })
97
97
  }));
98
98
  });
@@ -142,3 +142,11 @@ export var sortActivitiesByName = function (items, path) {
142
142
  return get(a, path).trim().toLowerCase().localeCompare(get(b, path).trim().toLowerCase().trim().toLowerCase());
143
143
  });
144
144
  };
145
+ export var getRecentDocumentFiles = function (documents, purpose) {
146
+ var _a;
147
+ if ((documents === null || documents === void 0 ? void 0 : documents.length) === 0)
148
+ return [];
149
+ return (((_a = (documents || [])
150
+ .filter(function (doc) { return (doc.file_details || []).find(function (file) { return file.purpose === purpose; }); })
151
+ .sort(function (a, b) { return b.created - a.created; })[0]) === null || _a === void 0 ? void 0 : _a.file_details) || []);
152
+ };
@@ -1 +1,2 @@
1
1
  export declare const sleep: (milliseconds?: number) => Promise<unknown>;
2
+ export declare const dangerousMessage: (message: string, callBack?: Function) => void;
@@ -2,3 +2,9 @@ export var sleep = function (milliseconds) {
2
2
  if (milliseconds === void 0) { milliseconds = 1000; }
3
3
  return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); });
4
4
  };
5
+ export var dangerousMessage = function (message, callBack) {
6
+ if (process.env.NODE_ENV === 'development') {
7
+ return alert(message);
8
+ }
9
+ callBack === null || callBack === void 0 ? void 0 : callBack({ message: message });
10
+ };
@@ -1 +1,2 @@
1
1
  export declare const dateFormat: (date: Date, fmt?: string) => string;
2
+ export declare const getFutureDate: (years?: number) => Date;
@@ -1,5 +1,11 @@
1
1
  import moment from 'moment';
2
2
  export var dateFormat = function (date, fmt) {
3
3
  if (fmt === void 0) { fmt = 'YYYY-MM-DD'; }
4
- return moment(date).format('YYYY-MM-DD');
4
+ return moment(date).format(fmt);
5
+ };
6
+ export var getFutureDate = function (years) {
7
+ var futureY = years || 20;
8
+ var maxDate = new Date();
9
+ maxDate.setFullYear(maxDate.getFullYear() + futureY);
10
+ return maxDate;
5
11
  };
@@ -0,0 +1 @@
1
+ export declare const isNetworkError: (error: string | null) => boolean;
@@ -0,0 +1,3 @@
1
+ export var isNetworkError = function (error) {
2
+ return ['network error', 'network request failed'].includes((error || '').trim().toLowerCase());
3
+ };
@@ -1,4 +1,4 @@
1
- export declare const createElementAndInject: (id: string) => HTMLDivElement;
1
+ export declare const findOrCreateElementAndInject: (id: string) => HTMLElement;
2
2
  export declare const scrollUp: (elementId: string, top?: number) => void;
3
3
  export declare const scrollDown: (elementId: string) => void;
4
4
  export declare const removeElement: (elementId: string) => void;
@@ -1,4 +1,7 @@
1
- export var createElementAndInject = function (id) {
1
+ export var findOrCreateElementAndInject = function (id) {
2
+ var elementExist = document.getElementById(id);
3
+ if (elementExist)
4
+ return elementExist;
2
5
  var element = document.createElement('div');
3
6
  element.setAttribute('id', id || 'tap-connect-sdk-element');
4
7
  document.body.prepend(element);
@@ -9,3 +9,4 @@ export * from './device';
9
9
  export * from './rsa';
10
10
  export * from './common';
11
11
  export * from './date';
12
+ export * from './error';
@@ -9,3 +9,4 @@ export * from './device';
9
9
  export * from './rsa';
10
10
  export * from './common';
11
11
  export * from './date';
12
+ export * from './error';
@@ -1,4 +1,4 @@
1
- import { DeviceInfo } from '../@types';
1
+ import { DeviceInfo, User } from '../@types';
2
2
  export declare const maskPhone: (str?: string) => string;
3
3
  export declare const shortenString: (str: string, length: number) => string;
4
4
  export declare const maskID: (str: string) => string;
@@ -42,7 +42,7 @@ export declare const getRequestHeaders: (deviceInfo: DeviceInfo) => {
42
42
  };
43
43
  export declare const removeRequestHeaders: () => void;
44
44
  export declare const getBaseUrl: () => string;
45
- export declare const getScreenNameBasedOnFlow: (flow: string) => "CONNECT_NID_STEP" | "" | "BUSINESS_BUSINESS_TYPE_STEP" | "INDIVIDUAL_ADDITIONAL_INDIVIDUAL_INFO_STEP" | "BANK_BANK_DETAILS_STEP" | "TAX_TAX_DETAILS_STEP";
45
+ export declare const getScreenNameBasedOnFlow: (flow: string, isAuthorizedUser?: boolean) => "CONNECT_NID_STEP" | "" | "BUSINESS_BUSINESS_TYPE_STEP" | "INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP" | "INDIVIDUAL_LIST_STEP" | "BANK_BANK_DETAILS_STEP" | "TAX_TAX_DETAILS_STEP";
46
46
  export declare const getEighteenYearsAgo: () => string;
47
47
  export declare const isKW: (flag: string) => boolean;
48
48
  export declare const isSA: (flag: string) => boolean;
@@ -56,3 +56,16 @@ export declare const isInstagram: (flag: string) => boolean;
56
56
  export declare const isPhysicalStore: (flag: string) => boolean;
57
57
  export declare const isCallCenter: (flag: string) => boolean;
58
58
  export declare const getChannelIcon: (channel: string) => string;
59
+ export declare const getUserName: (user: User, isAr: boolean) => string;
60
+ export declare const getUserNameObject: (name: string) => {
61
+ first?: undefined;
62
+ middle?: undefined;
63
+ third?: undefined;
64
+ last?: undefined;
65
+ } | {
66
+ first: string;
67
+ middle: string;
68
+ third: string;
69
+ last: string;
70
+ };
71
+ export declare const getFileType: (type: string) => "" | "image/jpeg" | "image/png" | "image/jpg" | "application/pdf";
@@ -1,5 +1,5 @@
1
1
  import { FlowsTypes } from '../@types';
2
- import { encryptString } from '.';
2
+ import { concatenateObjectValues, encryptString } from '.';
3
3
  import { removeAxiosGlobalHeaders } from '../api';
4
4
  import { ENDPOINT_PATHS, ICONS_FULL_PATH } from '../constants';
5
5
  import moment from 'moment';
@@ -172,7 +172,7 @@ export var getBaseUrl = function () {
172
172
  }
173
173
  return ENDPOINT_PATHS.PRODUCTION_BASE_URL;
174
174
  };
175
- export var getScreenNameBasedOnFlow = function (flow) {
175
+ export var getScreenNameBasedOnFlow = function (flow, isAuthorizedUser) {
176
176
  if (flow === FlowsTypes.BANK) {
177
177
  return 'BANK_BANK_DETAILS_STEP';
178
178
  }
@@ -180,7 +180,7 @@ export var getScreenNameBasedOnFlow = function (flow) {
180
180
  return 'BUSINESS_BUSINESS_TYPE_STEP';
181
181
  }
182
182
  if (flow === FlowsTypes.INDIVIDUAL) {
183
- return 'INDIVIDUAL_ADDITIONAL_INDIVIDUAL_INFO_STEP';
183
+ return isAuthorizedUser ? 'INDIVIDUAL_LIST_STEP' : 'INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP';
184
184
  }
185
185
  if (flow === FlowsTypes.CONNECT) {
186
186
  return 'CONNECT_NID_STEP';
@@ -258,3 +258,37 @@ export var getChannelIcon = function (channel) {
258
258
  }
259
259
  return '';
260
260
  };
261
+ export var getUserName = function (user, isAr) {
262
+ var _a, _b;
263
+ var fullNameEn = concatenateObjectValues((_a = user === null || user === void 0 ? void 0 : user.names) === null || _a === void 0 ? void 0 : _a.en, ['first', 'middle', 'last']);
264
+ var fullNameAR = concatenateObjectValues((_b = user === null || user === void 0 ? void 0 : user.names) === null || _b === void 0 ? void 0 : _b.ar, ['first', 'middle', 'last']);
265
+ var nameEN = '';
266
+ var nameAR = '';
267
+ if (fullNameEn)
268
+ nameEN = capitalizeTheFirstLetterOfEachWord(fullNameEn);
269
+ if (fullNameAR)
270
+ nameAR = capitalizeTheFirstLetterOfEachWord(fullNameAR);
271
+ var name = isAr ? nameAR || nameEN : nameEN;
272
+ return name;
273
+ };
274
+ export var getUserNameObject = function (name) {
275
+ if (!name)
276
+ return {};
277
+ var _a = name.split(' '), first = _a[0], middle = _a[1], third = _a[2], rest = _a.slice(3);
278
+ var lastName = rest.join(' ') || '';
279
+ return { first: first, middle: middle || '', third: third || '', last: lastName };
280
+ };
281
+ export var getFileType = function (type) {
282
+ switch (type) {
283
+ case 'jpeg':
284
+ return 'image/jpeg';
285
+ case 'png':
286
+ return 'image/png';
287
+ case 'jpg':
288
+ return 'image/jpg';
289
+ case 'pdf':
290
+ return 'application/pdf';
291
+ default:
292
+ return '';
293
+ }
294
+ };
@@ -15,3 +15,4 @@ export declare const keepLettersAndSpace: (str: string) => string;
15
15
  export declare const isTapDomain: (domain: string) => boolean;
16
16
  export declare const removeArabicWords: (str: string) => string;
17
17
  export declare const removeAllOtherThanArabicWords: (str: string) => string;
18
+ export declare const isValidEmail: (email: string) => boolean;
@@ -49,3 +49,6 @@ export var removeArabicWords = function (str) {
49
49
  export var removeAllOtherThanArabicWords = function (str) {
50
50
  return str.replace(/[^ء-ي]/g, '');
51
51
  };
52
+ export var isValidEmail = function (email) {
53
+ return /.+@.+\..+/.test(email);
54
+ };