@tap-payments/auth-jsconnect 2.0.35-test → 2.0.35

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 (299) hide show
  1. package/build/@types/app.d.ts +52 -21
  2. package/build/@types/app.js +10 -3
  3. package/build/@types/form.d.ts +18 -10
  4. package/build/api/auth.d.ts +24 -2
  5. package/build/api/auth.js +36 -1
  6. package/build/api/axios.js +2 -2
  7. package/build/api/brand.d.ts +2 -1
  8. package/build/api/brand.js +10 -1
  9. package/build/api/country.d.ts +3 -1
  10. package/build/api/country.js +3 -1
  11. package/build/api/data.d.ts +38 -7
  12. package/build/api/data.js +57 -17
  13. package/build/api/entity.d.ts +53 -5
  14. package/build/api/entity.js +39 -9
  15. package/build/api/firebase.d.ts +1 -1
  16. package/build/api/firebase.js +3 -1
  17. package/build/api/index.d.ts +44 -14
  18. package/build/api/individual.d.ts +76 -19
  19. package/build/api/individual.js +29 -2
  20. package/build/api/lead.d.ts +9 -6
  21. package/build/api/lead.js +8 -1
  22. package/build/app/rootReducer.d.ts +1 -1
  23. package/build/app/rootReducer.js +2 -2
  24. package/build/app/settings.d.ts +8 -2
  25. package/build/app/settings.js +29 -12
  26. package/build/app/store.d.ts +3 -3
  27. package/build/assets/locales/ar.json +258 -183
  28. package/build/assets/locales/en.json +190 -108
  29. package/build/components/AnimationFlow/AnimationFlow.d.ts +5 -1
  30. package/build/components/AnimationFlow/AnimationFlow.js +6 -8
  31. package/build/components/AnimationFlow/BottomSheet.d.ts +2 -1
  32. package/build/components/AnimationFlow/BottomSheet.js +4 -3
  33. package/build/components/AnimationFlow/Dialog.d.ts +5 -1
  34. package/build/components/AnimationFlow/Dialog.js +11 -5
  35. package/build/components/ArabicDatePicker/ArabicDatePicker.d.ts +13 -0
  36. package/build/components/ArabicDatePicker/ArabicDatePicker.js +94 -0
  37. package/build/components/ArabicDatePicker/index.d.ts +2 -0
  38. package/build/components/ArabicDatePicker/index.js +2 -0
  39. package/build/components/ArabicDatePicker/style.css +24 -0
  40. package/build/components/FileInput/DragAndDrop.d.ts +10 -1
  41. package/build/components/FileInput/DragAndDrop.js +108 -8
  42. package/build/components/Lottie/Lottie.d.ts +878 -0
  43. package/build/components/Lottie/Lottie.js +58 -0
  44. package/build/components/Lottie/files/pulsating_circle_waves.json +236 -0
  45. package/build/components/Lottie/files/success.json +425 -0
  46. package/build/components/Lottie/index.d.ts +3 -0
  47. package/build/components/Lottie/index.js +3 -0
  48. package/build/components/OTPField/OTPField.d.ts +2 -1
  49. package/build/components/OTPField/OTPField.js +2 -2
  50. package/build/components/OTPTimer/OTPTimer.js +1 -1
  51. package/build/components/ProgressBar/CircularProgressBar.d.ts +14 -0
  52. package/build/components/ProgressBar/CircularProgressBar.js +48 -0
  53. package/build/components/ProgressBar/index.d.ts +2 -0
  54. package/build/components/ProgressBar/index.js +2 -0
  55. package/build/components/RadioLabel/RadioLabel.d.ts +2 -1
  56. package/build/components/RadioLabel/RadioLabel.js +2 -2
  57. package/build/components/SocialMediaGroup/SocialMediaGroup.d.ts +2 -6
  58. package/build/components/SocialMediaGroup/SocialMediaGroup.js +4 -49
  59. package/build/constants/api.d.ts +6 -0
  60. package/build/constants/api.js +14 -1
  61. package/build/constants/app.d.ts +7 -5
  62. package/build/constants/app.js +56 -23
  63. package/build/constants/assets.d.ts +14 -0
  64. package/build/constants/assets.js +16 -2
  65. package/build/constants/dummy.d.ts +1 -1
  66. package/build/constants/dummy.js +2 -2
  67. package/build/constants/validation.d.ts +8 -0
  68. package/build/constants/validation.js +9 -1
  69. package/build/features/app/auth/authStore.d.ts +47 -0
  70. package/build/features/app/auth/authStore.js +260 -0
  71. package/build/features/app/bank/bankStore.d.ts +16 -0
  72. package/build/features/app/bank/bankStore.js +86 -39
  73. package/build/features/app/business/businessStore.d.ts +22 -3
  74. package/build/features/app/business/businessStore.js +432 -291
  75. package/build/features/app/connect/connectStore.d.ts +33 -31
  76. package/build/features/app/connect/connectStore.js +394 -308
  77. package/build/features/app/entity/entityStore.d.ts +30 -5
  78. package/build/features/app/entity/entityStore.js +258 -47
  79. package/build/features/app/individual/individualStore.d.ts +17 -0
  80. package/build/features/app/individual/individualStore.js +170 -84
  81. package/build/features/app/password/passwordStore.js +1 -1
  82. package/build/features/app/tax/taxStore.js +18 -14
  83. package/build/features/auth/Auth.d.ts +10 -0
  84. package/build/features/auth/Auth.js +87 -0
  85. package/build/features/auth/index.d.ts +1 -0
  86. package/build/features/auth/index.js +1 -0
  87. package/build/features/auth/screens/NID/DOB.d.ts +7 -0
  88. package/build/features/auth/screens/NID/DOB.js +47 -0
  89. package/build/features/auth/screens/NID/IDNumber.d.ts +3 -0
  90. package/build/features/auth/screens/NID/IDNumber.js +64 -0
  91. package/build/features/auth/screens/NID/NID.d.ts +5 -0
  92. package/build/features/auth/screens/NID/NID.js +68 -0
  93. package/build/features/auth/screens/NID/TAC.d.ts +3 -0
  94. package/build/features/auth/screens/NID/TAC.js +87 -0
  95. package/build/features/auth/screens/NID/index.d.ts +3 -0
  96. package/build/features/auth/screens/NID/index.js +2 -0
  97. package/build/features/auth/screens/NID/validation.d.ts +27 -0
  98. package/build/features/auth/screens/NID/validation.js +19 -0
  99. package/build/features/auth/screens/OTP/OTP.d.ts +5 -0
  100. package/build/features/auth/screens/OTP/OTP.js +76 -0
  101. package/build/features/{otp/screens/OTPVerify/Verify.d.ts → auth/screens/OTP/OTPInput.d.ts} +0 -0
  102. package/build/features/{otp/screens/OTPVerify → auth/screens/OTP}/OTPInput.js +11 -7
  103. package/build/features/auth/screens/OTP/index.d.ts +3 -0
  104. package/build/features/auth/screens/OTP/index.js +2 -0
  105. package/build/features/{otp/screens/OTPVerify → auth/screens/OTP}/validation.d.ts +0 -0
  106. package/build/features/{otp/screens/OTPVerify → auth/screens/OTP}/validation.js +0 -0
  107. package/build/features/bank/Bank.js +12 -6
  108. package/build/features/bank/screens/BankDetails/BankDetails.js +18 -5
  109. package/build/features/bank/screens/BankDetails/BankName.js +2 -1
  110. package/build/features/bank/screens/BankDetails/BankStatement.js +41 -8
  111. package/build/features/bank/screens/BankDetails/Beneficiary.js +10 -11
  112. package/build/features/bank/screens/BankDetails/validation.js +2 -2
  113. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +12 -8
  114. package/build/features/business/Business.d.ts +1 -1
  115. package/build/features/business/Business.js +14 -7
  116. package/build/features/business/screens/Activities/Activities.js +16 -17
  117. package/build/features/business/screens/Activities/ActivitiesList.d.ts +37 -1
  118. package/build/features/business/screens/Activities/ActivitiesList.js +51 -12
  119. package/build/features/business/screens/Activities/OperationStartDate.d.ts +15 -1
  120. package/build/features/business/screens/Activities/OperationStartDate.js +21 -2
  121. package/build/features/business/screens/Activities/validation.d.ts +0 -51
  122. package/build/features/business/screens/Activities/validation.js +0 -9
  123. package/build/features/business/screens/BusinessType/BusinessType.js +20 -7
  124. package/build/features/business/screens/BusinessType/EntityName.d.ts +6 -0
  125. package/build/features/business/screens/BusinessType/EntityName.js +56 -0
  126. package/build/features/business/screens/BusinessType/LicenseCertificate.d.ts +6 -0
  127. package/build/features/business/screens/BusinessType/LicenseCertificate.js +76 -0
  128. package/build/features/business/screens/BusinessType/LicenseList.js +24 -7
  129. package/build/features/business/screens/BusinessType/LicenseNumber.js +14 -8
  130. package/build/features/business/screens/BusinessType/LicenseType.d.ts +6 -0
  131. package/build/features/business/screens/BusinessType/LicenseType.js +67 -0
  132. package/build/features/business/screens/BusinessType/validation.d.ts +19 -0
  133. package/build/features/business/screens/BusinessType/validation.js +50 -1
  134. package/build/features/business/screens/CivilID/CivilID.d.ts +5 -0
  135. package/build/features/business/screens/CivilID/CivilID.js +67 -0
  136. package/build/features/business/screens/CivilID/IDNumber.d.ts +7 -0
  137. package/build/features/business/screens/CivilID/IDNumber.js +59 -0
  138. package/build/features/business/screens/CivilID/index.d.ts +3 -0
  139. package/build/features/business/screens/CivilID/index.js +2 -0
  140. package/build/features/business/screens/CivilID/validation.d.ts +8 -0
  141. package/build/features/business/screens/CivilID/validation.js +4 -0
  142. package/build/features/business/screens/Customers/CustomerLocations.d.ts +15 -2
  143. package/build/features/business/screens/Customers/CustomerLocations.js +32 -8
  144. package/build/features/business/screens/Customers/Customers.js +15 -9
  145. package/build/features/business/screens/Customers/ExpectedCustomers.js +16 -4
  146. package/build/features/business/screens/Customers/ExpectedSalesRange.js +32 -14
  147. package/build/features/business/screens/Customers/RefundPolicy.js +8 -2
  148. package/build/features/business/screens/Customers/TransactionPolicy.js +8 -2
  149. package/build/features/business/screens/IDBOD/IDBOD.js +15 -2
  150. package/build/features/business/screens/OTP/OTP.js +15 -2
  151. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +10 -7
  152. package/build/features/business/screens/Verify/Verify.js +4 -4
  153. package/build/features/business/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
  154. package/build/features/business/screens/VerifyPACI/VerifyPACI.js +159 -0
  155. package/build/features/business/screens/VerifyPACI/VerifyPACILoading.d.ts +6 -0
  156. package/build/features/business/screens/VerifyPACI/VerifyPACILoading.js +23 -0
  157. package/build/features/business/screens/VerifyPACI/VerifyPACISuccess.d.ts +5 -0
  158. package/build/features/business/screens/VerifyPACI/VerifyPACISuccess.js +8 -0
  159. package/build/features/business/screens/VerifyPACI/index.d.ts +3 -0
  160. package/build/features/business/screens/VerifyPACI/index.js +2 -0
  161. package/build/features/connect/Connect.d.ts +2 -1
  162. package/build/features/connect/Connect.js +47 -12
  163. package/build/features/connect/screens/CivilID/CivilID.d.ts +5 -0
  164. package/build/features/connect/screens/CivilID/CivilID.js +99 -0
  165. package/build/features/connect/screens/CivilID/IDNumber.d.ts +7 -0
  166. package/build/features/connect/screens/CivilID/IDNumber.js +59 -0
  167. package/build/features/connect/screens/CivilID/index.d.ts +3 -0
  168. package/build/features/connect/screens/CivilID/index.js +2 -0
  169. package/build/features/connect/screens/CivilID/validation.d.ts +8 -0
  170. package/build/features/connect/screens/CivilID/validation.js +4 -0
  171. package/build/features/connect/screens/Individual/Email.js +11 -3
  172. package/build/features/connect/screens/Individual/Individual.js +41 -27
  173. package/build/features/connect/screens/Merchant/BrandList.js +15 -7
  174. package/build/features/connect/screens/Merchant/BrandName.js +7 -4
  175. package/build/features/connect/screens/Merchant/Merchant.js +41 -64
  176. package/build/features/connect/screens/Merchant/SalesChannels.d.ts +3 -1
  177. package/build/features/connect/screens/Merchant/SalesChannels.js +30 -31
  178. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +1 -4
  179. package/build/features/connect/screens/Merchant/SocialMedia.js +129 -109
  180. package/build/features/connect/screens/Merchant/TAC.js +8 -2
  181. package/build/features/connect/screens/Merchant/validation.d.ts +13 -123
  182. package/build/features/connect/screens/Merchant/validation.js +108 -173
  183. package/build/features/connect/screens/Mobile/Mobile.js +30 -12
  184. package/build/features/connect/screens/NID/NID.js +2 -1
  185. package/build/features/connect/screens/OTP/OTP.js +20 -6
  186. package/build/features/connect/screens/OTP/OTPInput.js +3 -2
  187. package/build/features/connect/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
  188. package/build/features/connect/screens/VerifyPACI/VerifyPACI.js +159 -0
  189. package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.d.ts +6 -0
  190. package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.js +23 -0
  191. package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.d.ts +5 -0
  192. package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.js +8 -0
  193. package/build/features/connect/screens/VerifyPACI/index.d.ts +3 -0
  194. package/build/features/connect/screens/VerifyPACI/index.js +2 -0
  195. package/build/features/entity/Entity.d.ts +1 -1
  196. package/build/features/entity/Entity.js +16 -9
  197. package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.d.ts +55 -0
  198. package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.js +149 -0
  199. package/build/features/entity/screens/EntityInfoConfirm/Article.d.ts +3 -0
  200. package/build/features/entity/screens/EntityInfoConfirm/Article.js +73 -0
  201. package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +71 -2
  202. package/build/features/entity/screens/EntityInfoConfirm/LicenseName.d.ts +5 -0
  203. package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +32 -0
  204. package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.d.ts +5 -0
  205. package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.js +49 -0
  206. package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.d.ts +6 -0
  207. package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +33 -0
  208. package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +68 -0
  209. package/build/features/entity/screens/EntityInfoConfirm/validation.js +24 -0
  210. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +6 -5
  211. package/build/features/entity/screens/Verify/Verify.js +18 -5
  212. package/build/features/featuresScreens.d.ts +1 -1
  213. package/build/features/featuresScreens.js +31 -6
  214. package/build/features/individual/Individual.d.ts +1 -1
  215. package/build/features/individual/Individual.js +14 -7
  216. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +18 -25
  217. package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +15 -3
  218. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +11 -3
  219. package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +2 -2
  220. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +12 -8
  221. package/build/features/individual/screens/Verify/Verify.js +18 -5
  222. package/build/features/password/Password.d.ts +1 -1
  223. package/build/features/password/Password.js +14 -7
  224. package/build/features/password/screens/CreatePassword/CreatePassword.js +16 -3
  225. package/build/features/password/screens/OTP/OTP.js +15 -2
  226. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +12 -9
  227. package/build/features/password/screens/Verify/Verify.js +16 -3
  228. package/build/features/shared/Background/Background.d.ts +6 -5
  229. package/build/features/shared/Background/Background.js +16 -5
  230. package/build/features/shared/Button/EmailProvidersButtons.d.ts +2 -1
  231. package/build/features/shared/Button/EmailProvidersButtons.js +7 -2
  232. package/build/features/shared/Button/MobileButton.d.ts +2 -1
  233. package/build/features/shared/Button/MobileButton.js +2 -2
  234. package/build/features/shared/Dialog/CloseDialog.d.ts +11 -0
  235. package/build/features/shared/Dialog/CloseDialog.js +71 -0
  236. package/build/features/shared/Dialog/DialogContainer.d.ts +8 -0
  237. package/build/features/shared/Dialog/DialogContainer.js +56 -0
  238. package/build/features/shared/Dialog/index.d.ts +4 -0
  239. package/build/features/shared/Dialog/index.js +4 -0
  240. package/build/features/shared/Input/Input.d.ts +1 -1
  241. package/build/features/shared/Input/Input.js +2 -2
  242. package/build/features/shared/SuccessScreen/SuccessScreen.js +1 -1
  243. package/build/features/shared/UploadFile/UploadFile.d.ts +10 -3
  244. package/build/features/shared/UploadFile/UploadFile.js +24 -9
  245. package/build/features/signIn/SignIn.d.ts +1 -1
  246. package/build/features/signIn/SignIn.js +14 -6
  247. package/build/features/signIn/screens/Email/Email.js +4 -2
  248. package/build/features/signIn/screens/Mobile/Mobile.js +5 -1
  249. package/build/features/signIn/screens/OTP/OTP.js +14 -1
  250. package/build/features/signIn/screens/Password/Password.js +15 -2
  251. package/build/features/tax/Tax.d.ts +1 -1
  252. package/build/features/tax/Tax.js +16 -8
  253. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +11 -7
  254. package/build/features/tax/screens/TaxDetails/TaxDetails.js +16 -3
  255. package/build/features/tax/screens/Verify/Verify.js +16 -3
  256. package/build/hooks/index.d.ts +2 -0
  257. package/build/hooks/index.js +2 -0
  258. package/build/hooks/useAppConfig.d.ts +3 -1
  259. package/build/hooks/useAppConfig.js +4 -2
  260. package/build/hooks/useAppDispatch.d.ts +1 -1
  261. package/build/hooks/useErrorListener.js +0 -6
  262. package/build/hooks/useScreen.d.ts +3 -0
  263. package/build/hooks/useScreen.js +14 -0
  264. package/build/hooks/useSetFromDefaultValues.d.ts +2 -0
  265. package/build/hooks/useSetFromDefaultValues.js +24 -0
  266. package/build/index.d.ts +3 -3
  267. package/build/index.js +5 -5
  268. package/build/utils/array.d.ts +13 -1
  269. package/build/utils/array.js +26 -0
  270. package/build/utils/common.d.ts +1 -0
  271. package/build/utils/common.js +3 -0
  272. package/build/utils/device.d.ts +1 -0
  273. package/build/utils/device.js +13 -0
  274. package/build/utils/html.d.ts +1 -0
  275. package/build/utils/html.js +6 -0
  276. package/build/utils/index.d.ts +1 -0
  277. package/build/utils/index.js +1 -0
  278. package/build/utils/locale.js +1 -1
  279. package/build/utils/object.d.ts +1 -0
  280. package/build/utils/object.js +12 -0
  281. package/build/utils/rsa.d.ts +2 -2
  282. package/build/utils/rsa.js +1 -1
  283. package/build/utils/string.d.ts +33 -20
  284. package/build/utils/string.js +71 -1
  285. package/build/utils/validation.d.ts +2 -0
  286. package/build/utils/validation.js +6 -0
  287. package/package.json +5 -4
  288. package/build/features/app/otp/otpStore.d.ts +0 -28
  289. package/build/features/app/otp/otpStore.js +0 -153
  290. package/build/features/business/screens/Activities/SalesChannels.d.ts +0 -5
  291. package/build/features/business/screens/Activities/SalesChannels.js +0 -112
  292. package/build/features/otp/OTP.d.ts +0 -7
  293. package/build/features/otp/OTP.js +0 -58
  294. package/build/features/otp/index.d.ts +0 -0
  295. package/build/features/otp/index.js +0 -1
  296. package/build/features/otp/screens/OTPVerify/OTPInput.d.ts +0 -6
  297. package/build/features/otp/screens/OTPVerify/Verify.js +0 -49
  298. package/build/features/otp/screens/OTPVerify/index.d.ts +0 -2
  299. package/build/features/otp/screens/OTPVerify/index.js +0 -2
@@ -0,0 +1,159 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
+ import * as React from 'react';
50
+ import Box from '@mui/material/Box/Box';
51
+ import { styled } from '@mui/material/styles';
52
+ import { useTranslation } from 'react-i18next';
53
+ import Text from '../../../../components/Text';
54
+ import { connectSelector, verifyPACI as verifyPACIFun } from '../../../app/connect/connectStore';
55
+ import { handlePrevScreenStep } from '../../../../app/settings';
56
+ import { ScreenContainer } from '../../../shared/Containers';
57
+ import { MobileButton } from '../../../shared/Button';
58
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
59
+ import { mobileOS, sleep } from '../../../../utils';
60
+ import Collapse from '../../../../components/Collapse';
61
+ import Warning from '../../../../components/Warning';
62
+ import VerifyPACILoading from './VerifyPACILoading';
63
+ import VerifyPACISuccess from './VerifyPACISuccess';
64
+ var VerifyPACITitleContainerStyled = styled(Box)(function (_a) {
65
+ var theme = _a.theme;
66
+ return ({
67
+ direction: theme.direction,
68
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
69
+ display: 'flex',
70
+ flexDirection: 'column',
71
+ alignItems: 'center',
72
+ marginBottom: theme.spacing(2.5)
73
+ });
74
+ });
75
+ var VerifyPACITitleStyled = styled(Text)(function (_a) {
76
+ var theme = _a.theme;
77
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightBold, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.75, whiteSpace: 'pre-line' }));
78
+ });
79
+ var VerifyPACISubTitleStyled = styled(Text)(function (_a) {
80
+ var theme = _a.theme;
81
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightMedium, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.75, whiteSpace: 'pre-line', textAlign: 'center' }));
82
+ });
83
+ var Container = styled(Box)(function (_a) {
84
+ var theme = _a.theme;
85
+ return ({
86
+ position: 'relative',
87
+ display: 'flex',
88
+ justifyContent: 'center',
89
+ alignItems: 'center',
90
+ maxHeight: '300px'
91
+ });
92
+ });
93
+ var BackButton = styled('button')(function (_a) {
94
+ var theme = _a.theme;
95
+ return ({
96
+ cursor: 'pointer',
97
+ pointerEvents: 'auto',
98
+ height: 44,
99
+ appearance: 'none',
100
+ background: 'none',
101
+ border: 'none',
102
+ color: theme.palette.primary.main,
103
+ fontSize: theme.typography.body1.fontSize,
104
+ fontWeight: theme.typography.fontWeightMedium,
105
+ textTransform: 'capitalize',
106
+ '&:hover': {
107
+ backgroundColor: 'transparent'
108
+ }
109
+ });
110
+ });
111
+ var VerifyPACI = function () {
112
+ var _a = React.useState(false), success = _a[0], setSuccess = _a[1];
113
+ var _b = React.useState(false), isReady = _b[0], setIsReady = _b[1];
114
+ var dispatch = useAppDispatch();
115
+ var _c = useAppSelector(connectSelector), data = _c.data, error = _c.error;
116
+ var responseBody = data.civilIdData.responseBody;
117
+ var t = useTranslation().t;
118
+ var onSuccess = function () { return __awaiter(void 0, void 0, void 0, function () {
119
+ return __generator(this, function (_a) {
120
+ switch (_a.label) {
121
+ case 0:
122
+ setSuccess(true);
123
+ return [4, sleep(2000)];
124
+ case 1:
125
+ _a.sent();
126
+ return [2];
127
+ }
128
+ });
129
+ }); };
130
+ React.useEffect(function () {
131
+ if (responseBody) {
132
+ setIsReady(true);
133
+ }
134
+ }, [responseBody]);
135
+ React.useEffect(function () {
136
+ if (!isReady)
137
+ return;
138
+ var promise = dispatch(verifyPACIFun({ onSuccess: onSuccess }));
139
+ return function () {
140
+ promise === null || promise === void 0 ? void 0 : promise.abort();
141
+ };
142
+ }, [isReady]);
143
+ var onRedirect = React.useCallback(function () {
144
+ if (os === 'Android') {
145
+ window.open(responseBody === null || responseBody === void 0 ? void 0 : responseBody.app_url_android, '_blank');
146
+ }
147
+ if (os === 'iOS') {
148
+ window.open(responseBody === null || responseBody === void 0 ? void 0 : responseBody.app_url_ios, '_blank');
149
+ }
150
+ }, [responseBody]);
151
+ var onBack = React.useCallback(function () {
152
+ dispatch(handlePrevScreenStep());
153
+ }, []);
154
+ var os = React.useMemo(function () { return mobileOS(); }, []);
155
+ var isAndroid = React.useMemo(function () { return os === 'Android' && (responseBody === null || responseBody === void 0 ? void 0 : responseBody.app_url_ios); }, [os, responseBody]);
156
+ var isIOS = React.useMemo(function () { return os === 'iOS' && (responseBody === null || responseBody === void 0 ? void 0 : responseBody.app_url_ios); }, [os, responseBody]);
157
+ return (_jsxs(ScreenContainer, __assign({ sx: { mb: 2.5 } }, { children: [_jsxs(VerifyPACITitleContainerStyled, { children: [_jsx(Container, { children: success ? _jsx(VerifyPACISuccess, {}) : _jsx(VerifyPACILoading, { loop: !error }) }), _jsx(VerifyPACITitleStyled, { children: t('authenticate_kuwait_mobile_title') }), _jsx(VerifyPACISubTitleStyled, { children: t('authenticate_kuwait_mobile_description') })] }), _jsx(Collapse, __assign({ in: !!error, sx: { width: '100%' } }, { children: _jsx(Warning, { children: t(error) }) })), (isAndroid || isIOS) && (_jsx(MobileButton, __assign({ onClick: onRedirect, hideIcon: true }, { children: t('Open Kuwait Mobile ID') }))), _jsx(BackButton, __assign({ onClick: onBack }, { children: t('back') }))] })));
158
+ };
159
+ export default React.memo(VerifyPACI);
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface VerifyPACILoadingProps {
3
+ loop?: boolean;
4
+ }
5
+ declare const _default: React.NamedExoticComponent<VerifyPACILoadingProps>;
6
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import LottieFile, { LottieAnimationFiles } from '../../../../components/Lottie';
5
+ import { ICONS_NAMES } from '../../../../constants';
6
+ import Icon from '../../../../components/Icon';
7
+ var IconStyled = styled(Icon)(function (_a) {
8
+ var theme = _a.theme;
9
+ return ({
10
+ position: 'absolute',
11
+ top: '50%',
12
+ left: '50%',
13
+ transform: 'translate(-50%, -50%)',
14
+ width: 64,
15
+ height: 64
16
+ });
17
+ });
18
+ var VerifyPACILoading = function (_a) {
19
+ var _b = _a.loop, loop = _b === void 0 ? true : _b;
20
+ return (_jsxs(_Fragment, { children: [_jsx(LottieFile, { file: LottieAnimationFiles.pulsating_circle_waves, loop: loop, width: '90%' }), _jsx(IconStyled, { src: ICONS_NAMES.PACI_VERIFY_ICON })] }));
21
+ };
22
+ VerifyPACILoading.defaultProps = {};
23
+ export default memo(VerifyPACILoading);
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface VerifyPACISuccessProps {
3
+ }
4
+ declare const _default: React.NamedExoticComponent<VerifyPACISuccessProps>;
5
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import LottieFile, { LottieAnimationFiles } from '../../../../components/Lottie';
4
+ var VerifyPACISuccess = function () {
5
+ return (_jsx(_Fragment, { children: _jsx(LottieFile, { loop: false, file: LottieAnimationFiles.success, width: '90%' }) }));
6
+ };
7
+ VerifyPACISuccess.defaultProps = {};
8
+ export default memo(VerifyPACISuccess);
@@ -0,0 +1,3 @@
1
+ import VerifyPACI, { VerifyPACIProps } from './VerifyPACI';
2
+ export type { VerifyPACIProps };
3
+ export default VerifyPACI;
@@ -0,0 +1,2 @@
1
+ import VerifyPACI from './VerifyPACI';
2
+ export default VerifyPACI;
@@ -4,4 +4,4 @@ export interface EntityLibProps extends LibConfig {
4
4
  }
5
5
  export declare function EntityLib(props: EntityLibProps): JSX.Element;
6
6
  export declare function renderEntityLib(config: EntityLibProps, elementId: string): void;
7
- export declare function unmountEntityLib(elementId: string): void;
7
+ export declare function unmountEntityLib(elementId: string, unmountTimeout?: number): void;
@@ -17,9 +17,9 @@ import AnimationFlow from '../../components/AnimationFlow';
17
17
  import { store } from '../../app/store';
18
18
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
19
19
  import Collapse from '../../components/Collapse';
20
- import { getParameterByName, reactElement } from '../../utils';
20
+ import { getParameterByName, reactElement, removeElement } from '../../utils';
21
21
  import { FeatureContainer } from '../shared/Containers';
22
- import { ENTITY_SCREENS_NAVIGATION } from '../../constants';
22
+ import { DIALOG_ID, ENTITY_SCREENS_NAVIGATION } from '../../constants';
23
23
  import { entityFeatureScreens } from '../featuresScreens';
24
24
  import CustomFooter from '../shared/Footer';
25
25
  import { entitySelector, verifyLeadToken } from '../app/entity/entityStore';
@@ -27,8 +27,8 @@ import Background from '../shared/Background';
27
27
  var Entity = memo(function (props) {
28
28
  var theme = useAppTheme().theme;
29
29
  var dispatch = useAppDispatch();
30
- var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, loading = _a.loading;
31
- var _b = useAppSelector(entitySelector), customLoading = _b.customLoading, entityError = _b.error;
30
+ var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
31
+ var _b = useAppSelector(entitySelector), customLoading = _b.customLoading, entityError = _b.error, loading = _b.loading;
32
32
  useAppConfig(__assign({ navigation: ENTITY_SCREENS_NAVIGATION }, props));
33
33
  useErrorListener(entityError || error);
34
34
  useStepStartedListener();
@@ -43,10 +43,10 @@ var Entity = memo(function (props) {
43
43
  dispatch(verifyLeadToken(token));
44
44
  };
45
45
  useEffect(function () {
46
- if (!loading)
46
+ if (!settingLoading)
47
47
  verifyToken();
48
- }, [loading]);
49
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: loading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, open: open, error: error, loading: loading || customLoading, breakpoint: 'sm', footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: entityFeatureScreens.map(function (_a, index) {
48
+ }, [settingLoading]);
49
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ pointerEvents: loading ? 'none' : 'auto', isTapOrigin: isTapOrigin, open: open, error: error, loading: settingLoading || customLoading, breakpoint: 'sm', footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: entityFeatureScreens.map(function (_a, index) {
50
50
  var Element = _a.element, name = _a.name;
51
51
  var isActive = activeScreen.name === name;
52
52
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
@@ -58,6 +58,13 @@ export function EntityLib(props) {
58
58
  export function renderEntityLib(config, elementId) {
59
59
  reactElement(elementId).render(_jsx(EntityLib, __assign({}, config)));
60
60
  }
61
- export function unmountEntityLib(elementId) {
62
- reactElement(elementId).unmount();
61
+ export function unmountEntityLib(elementId, unmountTimeout) {
62
+ if (unmountTimeout === void 0) { unmountTimeout = 1000; }
63
+ var element = document.getElementById(elementId);
64
+ setTimeout(function () {
65
+ var _a;
66
+ ((_a = element === null || element === void 0 ? void 0 : element.children) === null || _a === void 0 ? void 0 : _a.length) && element.removeChild(element.children[0]);
67
+ removeElement(DIALOG_ID);
68
+ elementId && reactElement(elementId).unmount();
69
+ }, unmountTimeout);
63
70
  }
@@ -0,0 +1,55 @@
1
+ import * as React from 'react';
2
+ export declare const InputLabelStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
3
+ align?: "right" | "left" | "inherit" | "center" | "justify" | undefined;
4
+ children?: React.ReactNode;
5
+ classes?: Partial<import("@mui/material").TypographyClasses> | undefined;
6
+ gutterBottom?: boolean | undefined;
7
+ noWrap?: boolean | undefined;
8
+ paragraph?: boolean | undefined;
9
+ sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
10
+ variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "overline" | "subtitle1" | "subtitle2" | "body1" | "body2" | undefined;
11
+ variantMapping?: Partial<Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "overline" | "subtitle1" | "subtitle2" | "body1" | "body2", string>> | undefined;
12
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
13
+ ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
14
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "children" | "sx" | "variant" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
15
+ export declare const InputStyled: import("@emotion/styled").StyledComponent<Pick<import("../../../../components/Input").InputProps, "name" | "type" | "className" | "style" | "classes" | "color" | "margin" | "translate" | "slot" | "title" | "ref" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "size" | "disabled" | "error" | "components" | "componentsProps" | "value" | "autoFocus" | "fullWidth" | "required" | "rows" | "inputProps" | "inputRef" | "readOnly" | "autoComplete" | "disableInjectingGlobalStyles" | "endAdornment" | "inputComponent" | "multiline" | "renderSuffix" | "maxRows" | "minRows" | "startAdornment" | "disableUnderline" | "onEnterPressed" | "warningMessage"> & {
16
+ placeholder?: string | undefined;
17
+ hide?: boolean | undefined;
18
+ warningType?: "alert" | "error" | "hint" | undefined;
19
+ } & {} & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
20
+ export declare const MandatoryStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
21
+ export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<{
22
+ children?: React.ReactNode;
23
+ classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
24
+ color?: "inherit" | "disabled" | "error" | "success" | "info" | "primary" | "secondary" | "action" | "warning" | undefined;
25
+ fontSize?: "small" | "inherit" | "medium" | "large" | undefined;
26
+ htmlColor?: string | undefined;
27
+ inheritViewBox?: boolean | undefined;
28
+ shapeRendering?: string | undefined;
29
+ sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
30
+ titleAccess?: string | undefined;
31
+ viewBox?: string | undefined;
32
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.SVGProps<SVGSVGElement>, "string" | "name" | "type" | "version" | "className" | "style" | "display" | "overflow" | "visibility" | "order" | "color" | "width" | "height" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "clipPath" | "cursor" | "direction" | "filter" | "fontSizeAdjust" | "fontStretch" | "fontVariant" | "imageRendering" | "opacity" | "paintOrder" | "pointerEvents" | "rotate" | "scale" | "textRendering" | "transform" | "unicodeBidi" | "wordSpacing" | "writingMode" | "mask" | "offset" | "textDecoration" | "azimuth" | "clip" | "alignmentBaseline" | "baselineShift" | "clipRule" | "colorInterpolation" | "colorRendering" | "dominantBaseline" | "fill" | "fillOpacity" | "fillRule" | "floodColor" | "floodOpacity" | "glyphOrientationVertical" | "lightingColor" | "markerEnd" | "markerMid" | "markerStart" | "shapeRendering" | "stopColor" | "stopOpacity" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "textAnchor" | "vectorEffect" | "path" | "key" | "id" | "lang" | "tabIndex" | "role" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "end" | "values" | "local" | "x" | "y" | "alphabetic" | "hanging" | "ideographic" | "mathematical" | "origin" | "method" | "spacing" | "elevation" | "in" | "max" | "href" | "orientation" | "media" | "target" | "min" | "viewBox" | "crossOrigin" | "accentHeight" | "accumulate" | "additive" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "baseFrequency" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clipPathUnits" | "colorInterpolationFilters" | "colorProfile" | "contentScriptType" | "contentStyleType" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "divisor" | "dur" | "dx" | "dy" | "edgeMode" | "enableBackground" | "exponent" | "externalResourcesRequired" | "filterRes" | "filterUnits" | "focusable" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "in2" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "limitingConeAngle" | "markerHeight" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mode" | "numOctaves" | "operator" | "orient" | "overlinePosition" | "overlineThickness" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rx" | "ry" | "seed" | "slope" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "strikethroughPosition" | "strikethroughThickness" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textLength" | "to" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewTarget" | "vMathematical" | "widths" | "x1" | "x2" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "yChannelSelector" | "z" | "zoomAndPan"> & {
33
+ ref?: ((instance: SVGSVGElement | null) => void) | React.RefObject<SVGSVGElement> | null | undefined;
34
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "color" | "fontSize" | "shapeRendering" | "children" | "sx" | "htmlColor" | "inheritViewBox" | "titleAccess" | "viewBox"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
35
+ export declare const NameContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
36
+ align?: "right" | "left" | "inherit" | "center" | "justify" | undefined;
37
+ children?: React.ReactNode;
38
+ classes?: Partial<import("@mui/material").TypographyClasses> | undefined;
39
+ gutterBottom?: boolean | undefined;
40
+ noWrap?: boolean | undefined;
41
+ paragraph?: boolean | undefined;
42
+ sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
43
+ variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "overline" | "subtitle1" | "subtitle2" | "body1" | "body2" | undefined;
44
+ variantMapping?: Partial<Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "overline" | "subtitle1" | "subtitle2" | "body1" | "body2", string>> | undefined;
45
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
46
+ ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
47
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "children" | "sx" | "variant" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
48
+ isSelected: boolean;
49
+ }, {}, {}>;
50
+ export interface ActivitiesListProps {
51
+ onListOpen?: () => void;
52
+ onListClose?: () => void;
53
+ }
54
+ declare const ActivitiesList: ({ ...rest }: ActivitiesListProps) => JSX.Element;
55
+ export default ActivitiesList;
@@ -0,0 +1,149 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
+ if (ar || !(i in from)) {
26
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
+ ar[i] = from[i];
28
+ }
29
+ }
30
+ return to.concat(ar || Array.prototype.slice.call(from));
31
+ };
32
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
33
+ import * as React from 'react';
34
+ import Box from '@mui/material/Box';
35
+ import { alpha, styled } from '@mui/material/styles';
36
+ import Text from '../../../../components/Text';
37
+ import Input from '../../../../components/Input';
38
+ import { useTranslation } from 'react-i18next';
39
+ import { useController, useFormContext } from 'react-hook-form';
40
+ import { useLanguage, useAppSelector } from '../../../../hooks';
41
+ import { BusinessType } from '../../../../@types';
42
+ import Collapse from '../../../../components/Collapse';
43
+ import SimpleList from '../../../../components/SimpleList';
44
+ import ExpandIcon from '../../../../components/ExpandIcon';
45
+ import { ScreenContainer } from '../../../shared/Containers';
46
+ import { entitySelector } from '../../../app/entity/entityStore';
47
+ import CheckIcon from '@mui/icons-material/Check';
48
+ export var InputLabelStyled = styled(Text)(function (_a) {
49
+ var theme = _a.theme;
50
+ return (__assign({ margin: theme.spacing(2.5, 2.5, 1.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
51
+ });
52
+ export var InputStyled = styled(Input)(function (_a) {
53
+ var theme = _a.theme;
54
+ return ({
55
+ paddingInlineEnd: theme.spacing(2.5),
56
+ '& .MuiInputBase-input': {
57
+ cursor: 'pointer'
58
+ }
59
+ });
60
+ });
61
+ export var MandatoryStyled = styled('span')(function (_a) {
62
+ var theme = _a.theme;
63
+ return (__assign(__assign({ color: alpha(theme.palette.error.light, 0.4) }, theme.typography.h6), { fontWeight: theme.typography.fontWeightLight, verticalAlign: 'sub' }));
64
+ });
65
+ var SimpleListStyled = styled((SimpleList))(function () { return ({
66
+ height: 'fit-content'
67
+ }); });
68
+ export var CheckIconStyled = styled(CheckIcon)(function (_a) {
69
+ var theme = _a.theme;
70
+ return ({
71
+ color: theme.palette.primary.main,
72
+ display: 'flex',
73
+ alignItems: 'flex-end'
74
+ });
75
+ });
76
+ export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
77
+ var theme = _a.theme, isSelected = _a.isSelected;
78
+ return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25) }));
79
+ });
80
+ var ActivitiesList = function (_a) {
81
+ var _b;
82
+ var rest = __rest(_a, []);
83
+ var _c = React.useState([]), activitiesMenuList = _c[0], setActivitiesMenuList = _c[1];
84
+ var _d = React.useState([]), storedActivities = _d[0], setStoredActivities = _d[1];
85
+ var _e = React.useState(null), anchorEl = _e[0], setAnchorEl = _e[1];
86
+ var t = useTranslation().t;
87
+ var isAr = useLanguage().isAr;
88
+ var _f = useFormContext(), control = _f.control, setValue = _f.setValue;
89
+ var data = useAppSelector(entitySelector).data;
90
+ var activitiesControl = useController({ name: 'activities', control: control });
91
+ var controlValue = activitiesControl.field.value;
92
+ var verify = data.verify, entityData = data.entityData;
93
+ var _g = entityData.responseBody || {}, activities = _g.activities, selectedActivities = _g.selectedActivities;
94
+ var entity = (verify.responseBody || {}).entity;
95
+ var licenseType = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.type;
96
+ var businessType = licenseType === 'freelance' ? BusinessType.FL : BusinessType.CR;
97
+ var isCR = businessType === BusinessType.CR;
98
+ React.useEffect(function () {
99
+ if ((activities === null || activities === void 0 ? void 0 : activities.length) > 0) {
100
+ setActivitiesMenuList(activities);
101
+ }
102
+ }, [activities]);
103
+ React.useEffect(function () {
104
+ if ((selectedActivities === null || selectedActivities === void 0 ? void 0 : selectedActivities.length) > 0) {
105
+ setStoredActivities(selectedActivities);
106
+ if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) === 0) {
107
+ setValue('activities', selectedActivities);
108
+ }
109
+ }
110
+ }, [selectedActivities]);
111
+ var onOpenList = function (event) {
112
+ var _a;
113
+ setAnchorEl(event.currentTarget);
114
+ (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
115
+ };
116
+ var onCloseList = function () {
117
+ var _a;
118
+ setAnchorEl(null);
119
+ (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
120
+ };
121
+ var onSelectItem = function (item) {
122
+ var isActivityExists = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === (item === null || item === void 0 ? void 0 : item.id); });
123
+ var storedActivity = storedActivities === null || storedActivities === void 0 ? void 0 : storedActivities.find(function (activity) { return activity.id === (item === null || item === void 0 ? void 0 : item.id); });
124
+ if (isActivityExists && !storedActivity) {
125
+ var updatedIdList = controlValue === null || controlValue === void 0 ? void 0 : controlValue.filter(function (activity) { return activity.id !== (item === null || item === void 0 ? void 0 : item.id); });
126
+ if (updatedIdList.length >= 1)
127
+ activitiesControl.field.onChange(updatedIdList);
128
+ return;
129
+ }
130
+ if (!storedActivity)
131
+ activitiesControl.field.onChange(__spreadArray(__spreadArray([], controlValue, true), [item], false));
132
+ };
133
+ var getSelectedActivities = function () {
134
+ var _a, _b;
135
+ if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > 1) {
136
+ return (controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) + ' ' + t('activities_selected');
137
+ }
138
+ var item = controlValue[0];
139
+ return isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en;
140
+ };
141
+ var getSelectedActivityFlag = function (item) {
142
+ return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return (activity === null || activity === void 0 ? void 0 : activity.id) === (item === null || item === void 0 ? void 0 : item.id); });
143
+ };
144
+ return (_jsx(Collapse, __assign({ in: (activitiesMenuList === null || activitiesMenuList === void 0 ? void 0 : activitiesMenuList.length) > 0 }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t(isCR ? 'activities' : 'category') }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
145
+ var _a;
146
+ return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === ((_a = getSelectedActivityFlag(item)) === null || _a === void 0 ? void 0 : _a.id) }, { children: isAr ? item === null || item === void 0 ? void 0 : item.name.ar : item === null || item === void 0 ? void 0 : item.name.en })) })), getSelectedActivityFlag(item) && _jsx(CheckIconStyled, {})] }));
147
+ } }) }))] })] }) })));
148
+ };
149
+ export default ActivitiesList;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const Article: () => JSX.Element;
3
+ export default Article;
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import { ScreenContainer } from '../../../shared/Containers';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { useController, useFormContext } from 'react-hook-form';
7
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
8
+ import { entitySelector, uploadArticle } from '../../../app/entity/entityStore';
9
+ import UploadFile from '../../../shared/UploadFile';
10
+ import { MAX_FILE_SIZE, VALID_FILE_FORMATS } from '../../../../constants';
11
+ import { maskFileName } from '../../../../utils';
12
+ var FeatureStyled = styled(ScreenContainer)(function (_a) {
13
+ var theme = _a.theme;
14
+ return ({
15
+ marginBlockStart: theme.spacing(3)
16
+ });
17
+ });
18
+ var Article = function () {
19
+ var _a, _b;
20
+ var _c = React.useState(0), progress = _c[0], setProgress = _c[1];
21
+ var t = useTranslation().t;
22
+ var _d = useFormContext(), control = _d.control, setError = _d.setError, clearErrors = _d.clearErrors, setValue = _d.setValue;
23
+ var articleFileControl = useController({ name: 'articleFile', control: control });
24
+ var articleIdControl = useController({ name: 'articleId', control: control });
25
+ var _e = useAppSelector(entitySelector), loading = _e.loading, uploading = _e.uploading, sysError = _e.error, data = _e.data;
26
+ var dispatch = useAppDispatch();
27
+ var articleValue = articleFileControl.field.value;
28
+ var error = ((_a = articleFileControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || ((_b = articleIdControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message);
29
+ var entityData = data.entityData;
30
+ var articleFile = entityData.articleFile, articleId = entityData.articleId;
31
+ React.useEffect(function () {
32
+ if (!articleValue) {
33
+ setValue('articleFile', articleFile);
34
+ setValue('articleId', articleId);
35
+ }
36
+ }, [articleFile, articleId]);
37
+ var handleArticleChange = function (file) {
38
+ if (!VALID_FILE_FORMATS.includes(file === null || file === void 0 ? void 0 : file.type)) {
39
+ setError('articleFile', { message: 'file_not_supported_alert' });
40
+ }
41
+ else if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
42
+ setError('articleFile', { message: 'file_size_alert' });
43
+ }
44
+ else {
45
+ articleFileControl.field.onChange(file);
46
+ dispatch(uploadArticle({
47
+ file: file,
48
+ onProgress: function (value) {
49
+ setProgress(value);
50
+ }
51
+ }));
52
+ }
53
+ };
54
+ var handleReset = function () {
55
+ articleFileControl.field.onChange(null);
56
+ articleIdControl.field.onChange('');
57
+ setProgress(0);
58
+ };
59
+ React.useEffect(function () {
60
+ if (sysError === 'file_upload_error') {
61
+ setError('articleId', { message: sysError });
62
+ articleFileControl.field.onChange(null);
63
+ setProgress(0);
64
+ }
65
+ }, [sysError]);
66
+ React.useEffect(function () {
67
+ if ((articleFileControl.formState.isValid || !!articleValue) && error != 'file_upload_error')
68
+ clearErrors();
69
+ }, [articleFileControl.formState.isValid, articleValue]);
70
+ var fileName = articleValue ? maskFileName(articleValue === null || articleValue === void 0 ? void 0 : articleValue.name) : '';
71
+ return (_jsx(FeatureStyled, { children: _jsx(UploadFile, { label: t('title_article'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('article_of_association'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleArticleChange, isFileUploaded: !uploading && !!articleValue, isSubmitting: loading, isUploading: uploading, progress: progress, onReset: handleReset, error: error && t(error), initialFileName: fileName }) }));
72
+ };
73
+ export default Article;