@tap-payments/auth-jsconnect 2.0.43-test → 2.0.44

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 (308) hide show
  1. package/build/@types/app.d.ts +50 -20
  2. package/build/@types/app.js +9 -3
  3. package/build/@types/form.d.ts +21 -12
  4. package/build/api/auth.d.ts +28 -5
  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 +51 -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 +0 -1
  23. package/build/app/rootReducer.js +0 -2
  24. package/build/app/settings.d.ts +9 -2
  25. package/build/app/settings.js +22 -11
  26. package/build/app/store.d.ts +0 -2
  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 +4 -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 +4 -1
  34. package/build/components/AnimationFlow/Dialog.js +5 -3
  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 +5 -5
  62. package/build/constants/app.js +62 -32
  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 +10 -0
  68. package/build/constants/validation.js +11 -1
  69. package/build/features/app/auth/authStore.d.ts +30 -4
  70. package/build/features/app/auth/authStore.js +182 -20
  71. package/build/features/app/bank/bankStore.d.ts +16 -0
  72. package/build/features/app/bank/bankStore.js +88 -41
  73. package/build/features/app/business/businessStore.d.ts +22 -3
  74. package/build/features/app/business/businessStore.js +445 -296
  75. package/build/features/app/connect/connectStore.d.ts +34 -31
  76. package/build/features/app/connect/connectStore.js +427 -300
  77. package/build/features/app/entity/entityStore.d.ts +40 -8
  78. package/build/features/app/entity/entityStore.js +389 -149
  79. package/build/features/app/individual/individualStore.d.ts +18 -0
  80. package/build/features/app/individual/individualStore.js +178 -85
  81. package/build/features/app/password/passwordStore.d.ts +1 -7
  82. package/build/features/app/password/passwordStore.js +31 -20
  83. package/build/features/app/tax/taxStore.js +23 -16
  84. package/build/features/auth/Auth.d.ts +2 -1
  85. package/build/features/auth/Auth.js +37 -9
  86. package/build/features/auth/screens/NID/DOB.d.ts +7 -0
  87. package/build/features/auth/screens/NID/DOB.js +47 -0
  88. package/build/features/auth/screens/NID/IDNumber.d.ts +3 -0
  89. package/build/features/auth/screens/NID/IDNumber.js +64 -0
  90. package/build/features/auth/screens/NID/NID.d.ts +5 -0
  91. package/build/features/auth/screens/NID/NID.js +68 -0
  92. package/build/features/auth/screens/NID/TAC.d.ts +3 -0
  93. package/build/features/auth/screens/NID/TAC.js +87 -0
  94. package/build/features/auth/screens/NID/index.d.ts +3 -0
  95. package/build/features/auth/screens/NID/index.js +2 -0
  96. package/build/features/auth/screens/NID/validation.d.ts +27 -0
  97. package/build/features/auth/screens/NID/validation.js +19 -0
  98. package/build/features/auth/screens/OTP/OTP.js +8 -4
  99. package/build/features/auth/screens/OTP/OTPInput.js +9 -2
  100. package/build/features/bank/Bank.js +4 -4
  101. package/build/features/bank/screens/BankDetails/BankDetails.js +18 -5
  102. package/build/features/bank/screens/BankDetails/BankName.js +2 -1
  103. package/build/features/bank/screens/BankDetails/BankStatement.js +41 -8
  104. package/build/features/bank/screens/BankDetails/Beneficiary.js +10 -11
  105. package/build/features/bank/screens/BankDetails/validation.js +2 -2
  106. package/build/features/bank/screens/Success/Success.js +7 -3
  107. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +15 -11
  108. package/build/features/business/Business.js +4 -4
  109. package/build/features/business/screens/Activities/Activities.js +16 -17
  110. package/build/features/business/screens/Activities/ActivitiesList.d.ts +37 -1
  111. package/build/features/business/screens/Activities/ActivitiesList.js +51 -12
  112. package/build/features/business/screens/Activities/OperationStartDate.d.ts +15 -1
  113. package/build/features/business/screens/Activities/OperationStartDate.js +21 -2
  114. package/build/features/business/screens/Activities/validation.d.ts +0 -51
  115. package/build/features/business/screens/Activities/validation.js +0 -9
  116. package/build/features/business/screens/BusinessType/BusinessType.js +20 -7
  117. package/build/features/business/screens/BusinessType/EntityName.d.ts +6 -0
  118. package/build/features/business/screens/BusinessType/EntityName.js +56 -0
  119. package/build/features/business/screens/BusinessType/LicenseCertificate.d.ts +6 -0
  120. package/build/features/business/screens/BusinessType/LicenseCertificate.js +76 -0
  121. package/build/features/business/screens/BusinessType/LicenseList.js +26 -7
  122. package/build/features/business/screens/BusinessType/LicenseNumber.js +12 -6
  123. package/build/features/business/screens/BusinessType/LicenseType.d.ts +6 -0
  124. package/build/features/business/screens/BusinessType/LicenseType.js +78 -0
  125. package/build/features/business/screens/BusinessType/validation.d.ts +19 -0
  126. package/build/features/business/screens/BusinessType/validation.js +52 -3
  127. package/build/features/business/screens/CivilID/CivilID.d.ts +5 -0
  128. package/build/features/business/screens/CivilID/CivilID.js +67 -0
  129. package/build/features/business/screens/CivilID/IDNumber.d.ts +7 -0
  130. package/build/features/business/screens/CivilID/IDNumber.js +59 -0
  131. package/build/features/business/screens/CivilID/index.d.ts +3 -0
  132. package/build/features/business/screens/CivilID/index.js +2 -0
  133. package/build/features/business/screens/CivilID/validation.d.ts +8 -0
  134. package/build/features/business/screens/CivilID/validation.js +4 -0
  135. package/build/features/business/screens/Customers/CustomerLocations.d.ts +15 -2
  136. package/build/features/business/screens/Customers/CustomerLocations.js +32 -8
  137. package/build/features/business/screens/Customers/Customers.js +15 -9
  138. package/build/features/business/screens/Customers/ExpectedCustomers.js +16 -4
  139. package/build/features/business/screens/Customers/ExpectedSalesRange.js +32 -14
  140. package/build/features/business/screens/Customers/RefundPolicy.js +8 -2
  141. package/build/features/business/screens/Customers/TransactionPolicy.js +8 -2
  142. package/build/features/business/screens/IDBOD/IDBOD.js +15 -2
  143. package/build/features/business/screens/OTP/OTP.js +15 -2
  144. package/build/features/business/screens/Success/Success.js +10 -3
  145. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +13 -10
  146. package/build/features/business/screens/Verify/Verify.js +4 -4
  147. package/build/features/business/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
  148. package/build/features/business/screens/VerifyPACI/VerifyPACI.js +159 -0
  149. package/build/features/business/screens/VerifyPACI/VerifyPACILoading.d.ts +6 -0
  150. package/build/features/business/screens/VerifyPACI/VerifyPACILoading.js +23 -0
  151. package/build/features/business/screens/VerifyPACI/VerifyPACISuccess.d.ts +5 -0
  152. package/build/features/business/screens/VerifyPACI/VerifyPACISuccess.js +8 -0
  153. package/build/features/business/screens/VerifyPACI/index.d.ts +3 -0
  154. package/build/features/business/screens/VerifyPACI/index.js +2 -0
  155. package/build/features/connect/Connect.d.ts +1 -0
  156. package/build/features/connect/Connect.js +38 -10
  157. package/build/features/connect/screens/CivilID/CivilID.d.ts +5 -0
  158. package/build/features/connect/screens/CivilID/CivilID.js +102 -0
  159. package/build/features/connect/screens/CivilID/IDNumber.d.ts +7 -0
  160. package/build/features/connect/screens/CivilID/IDNumber.js +59 -0
  161. package/build/features/connect/screens/CivilID/index.d.ts +3 -0
  162. package/build/features/connect/screens/CivilID/index.js +2 -0
  163. package/build/features/connect/screens/CivilID/validation.d.ts +8 -0
  164. package/build/features/connect/screens/CivilID/validation.js +4 -0
  165. package/build/features/connect/screens/Individual/Email.js +11 -3
  166. package/build/features/connect/screens/Individual/Individual.js +48 -28
  167. package/build/features/connect/screens/Merchant/BrandList.js +15 -7
  168. package/build/features/connect/screens/Merchant/BrandName.js +7 -4
  169. package/build/features/connect/screens/Merchant/Merchant.js +41 -64
  170. package/build/features/connect/screens/Merchant/SalesChannels.d.ts +3 -1
  171. package/build/features/connect/screens/Merchant/SalesChannels.js +30 -31
  172. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +1 -4
  173. package/build/features/connect/screens/Merchant/SocialMedia.js +129 -109
  174. package/build/features/connect/screens/Merchant/TAC.js +8 -2
  175. package/build/features/connect/screens/Merchant/validation.d.ts +13 -123
  176. package/build/features/connect/screens/Merchant/validation.js +108 -173
  177. package/build/features/connect/screens/Mobile/Mobile.js +33 -12
  178. package/build/features/connect/screens/NID/NID.js +5 -1
  179. package/build/features/connect/screens/OTP/OTP.js +20 -6
  180. package/build/features/connect/screens/OTP/OTPInput.js +3 -2
  181. package/build/features/connect/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
  182. package/build/features/connect/screens/VerifyPACI/VerifyPACI.js +159 -0
  183. package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.d.ts +6 -0
  184. package/build/features/connect/screens/VerifyPACI/VerifyPACILoading.js +23 -0
  185. package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.d.ts +5 -0
  186. package/build/features/connect/screens/VerifyPACI/VerifyPACISuccess.js +8 -0
  187. package/build/features/connect/screens/VerifyPACI/index.d.ts +3 -0
  188. package/build/features/connect/screens/VerifyPACI/index.js +2 -0
  189. package/build/features/entity/Entity.js +6 -6
  190. package/build/features/entity/screens/Customers/CustomerLocations.d.ts +118 -0
  191. package/build/features/entity/screens/Customers/CustomerLocations.js +171 -0
  192. package/build/features/entity/screens/Customers/Customers.d.ts +5 -0
  193. package/build/features/entity/screens/Customers/Customers.js +90 -0
  194. package/build/features/entity/screens/Customers/ExpectedCustomers.d.ts +8 -0
  195. package/build/features/entity/screens/Customers/ExpectedCustomers.js +98 -0
  196. package/build/features/entity/screens/Customers/ExpectedSalesRange.d.ts +8 -0
  197. package/build/features/entity/screens/Customers/ExpectedSalesRange.js +127 -0
  198. package/build/features/entity/screens/Customers/RefundPolicy.d.ts +36 -0
  199. package/build/features/entity/screens/Customers/RefundPolicy.js +84 -0
  200. package/build/features/entity/screens/Customers/TransactionPolicy.d.ts +3 -0
  201. package/build/features/entity/screens/Customers/TransactionPolicy.js +44 -0
  202. package/build/features/entity/screens/Customers/index.d.ts +3 -0
  203. package/build/features/entity/screens/Customers/index.js +2 -0
  204. package/build/features/entity/screens/Customers/validation.d.ts +20 -0
  205. package/build/features/entity/screens/Customers/validation.js +13 -0
  206. package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.d.ts +2 -1
  207. package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.js +25 -15
  208. package/build/features/entity/screens/EntityInfoConfirm/Article.d.ts +3 -0
  209. package/build/features/entity/screens/EntityInfoConfirm/Article.js +73 -0
  210. package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +38 -10
  211. package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +20 -5
  212. package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.d.ts +2 -1
  213. package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.js +34 -5
  214. package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +13 -18
  215. package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +75 -41
  216. package/build/features/entity/screens/EntityInfoConfirm/validation.js +76 -10
  217. package/build/features/entity/screens/Success/Success.js +7 -3
  218. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +9 -8
  219. package/build/features/entity/screens/Verify/Verify.js +18 -5
  220. package/build/features/featuresScreens.d.ts +0 -1
  221. package/build/features/featuresScreens.js +30 -7
  222. package/build/features/individual/Individual.js +4 -4
  223. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +18 -25
  224. package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +15 -3
  225. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +11 -3
  226. package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +2 -2
  227. package/build/features/individual/screens/Success/Success.js +7 -3
  228. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +15 -11
  229. package/build/features/individual/screens/Verify/Verify.js +18 -5
  230. package/build/features/password/Password.js +4 -4
  231. package/build/features/password/screens/CreatePassword/CreatePassword.js +16 -3
  232. package/build/features/password/screens/OTP/OTP.js +15 -2
  233. package/build/features/password/screens/Success/Success.js +7 -3
  234. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +15 -12
  235. package/build/features/password/screens/Verify/Verify.js +16 -3
  236. package/build/features/shared/Background/Background.d.ts +2 -5
  237. package/build/features/shared/Background/Background.js +7 -3
  238. package/build/features/shared/Button/EmailProvidersButtons.d.ts +2 -1
  239. package/build/features/shared/Button/EmailProvidersButtons.js +7 -2
  240. package/build/features/shared/Button/MobileButton.d.ts +2 -1
  241. package/build/features/shared/Button/MobileButton.js +2 -2
  242. package/build/features/shared/Dialog/CloseDialog.d.ts +11 -0
  243. package/build/features/shared/Dialog/CloseDialog.js +71 -0
  244. package/build/features/shared/Dialog/DialogContainer.d.ts +8 -0
  245. package/build/features/shared/Dialog/DialogContainer.js +56 -0
  246. package/build/features/shared/Dialog/index.d.ts +4 -0
  247. package/build/features/shared/Dialog/index.js +4 -0
  248. package/build/features/shared/Input/Input.d.ts +1 -1
  249. package/build/features/shared/Input/Input.js +2 -2
  250. package/build/features/shared/SuccessScreen/SuccessScreen.js +3 -2
  251. package/build/features/shared/UploadFile/UploadFile.d.ts +10 -3
  252. package/build/features/shared/UploadFile/UploadFile.js +24 -9
  253. package/build/features/signIn/SignIn.js +4 -4
  254. package/build/features/signIn/screens/Email/Email.js +4 -2
  255. package/build/features/signIn/screens/Mobile/Mobile.js +5 -1
  256. package/build/features/signIn/screens/OTP/OTP.js +14 -1
  257. package/build/features/signIn/screens/Password/Password.js +15 -2
  258. package/build/features/tax/Tax.js +6 -6
  259. package/build/features/tax/screens/Success/Success.js +9 -3
  260. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +14 -10
  261. package/build/features/tax/screens/TaxDetails/TaxDetails.js +16 -3
  262. package/build/features/tax/screens/Verify/Verify.js +16 -3
  263. package/build/hooks/index.d.ts +2 -0
  264. package/build/hooks/index.js +2 -0
  265. package/build/hooks/useAppConfig.d.ts +3 -1
  266. package/build/hooks/useAppConfig.js +2 -2
  267. package/build/hooks/useAppDispatch.d.ts +0 -1
  268. package/build/hooks/useErrorListener.js +0 -6
  269. package/build/hooks/useScreen.d.ts +3 -0
  270. package/build/hooks/useScreen.js +14 -0
  271. package/build/hooks/useSetFromDefaultValues.d.ts +2 -0
  272. package/build/hooks/useSetFromDefaultValues.js +24 -0
  273. package/build/index.d.ts +2 -3
  274. package/build/index.js +1 -4
  275. package/build/utils/array.d.ts +49 -1
  276. package/build/utils/array.js +58 -0
  277. package/build/utils/common.d.ts +1 -0
  278. package/build/utils/common.js +3 -0
  279. package/build/utils/device.d.ts +1 -0
  280. package/build/utils/device.js +13 -0
  281. package/build/utils/index.d.ts +1 -0
  282. package/build/utils/index.js +1 -0
  283. package/build/utils/locale.js +1 -1
  284. package/build/utils/object.d.ts +1 -0
  285. package/build/utils/object.js +12 -0
  286. package/build/utils/string.d.ts +13 -0
  287. package/build/utils/string.js +71 -1
  288. package/build/utils/validation.d.ts +2 -0
  289. package/build/utils/validation.js +6 -0
  290. package/package.json +4 -3
  291. package/build/features/app/otp/otpStore.d.ts +0 -28
  292. package/build/features/app/otp/otpStore.js +0 -153
  293. package/build/features/business/screens/Activities/SalesChannels.d.ts +0 -5
  294. package/build/features/business/screens/Activities/SalesChannels.js +0 -112
  295. package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.d.ts +0 -5
  296. package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.js +0 -112
  297. package/build/features/otp/OTP.d.ts +0 -7
  298. package/build/features/otp/OTP.js +0 -58
  299. package/build/features/otp/index.d.ts +0 -0
  300. package/build/features/otp/index.js +0 -1
  301. package/build/features/otp/screens/OTPVerify/OTPInput.d.ts +0 -6
  302. package/build/features/otp/screens/OTPVerify/OTPInput.js +0 -47
  303. package/build/features/otp/screens/OTPVerify/Verify.d.ts +0 -5
  304. package/build/features/otp/screens/OTPVerify/Verify.js +0 -49
  305. package/build/features/otp/screens/OTPVerify/index.d.ts +0 -2
  306. package/build/features/otp/screens/OTPVerify/index.js +0 -2
  307. package/build/features/otp/screens/OTPVerify/validation.d.ts +0 -8
  308. package/build/features/otp/screens/OTPVerify/validation.js +0 -4
@@ -9,30 +9,58 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
+ };
12
23
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { memo } from 'react';
24
+ import React, { memo } from 'react';
14
25
  import { FeatureContainer } from '../shared/Containers';
15
- import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener } from '../../hooks';
16
- import { settingsSelector } from '../../app/settings';
26
+ import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useAppDispatch } from '../../hooks';
27
+ import { handleCurrentActiveScreen, settingsSelector, handleOpen } from '../../app/settings';
17
28
  import AnimationFlow from '../../components/AnimationFlow';
18
29
  import { store } from '../../app/store';
19
- import { connectSelector } from '../app/connect/connectStore';
30
+ import { connectSelector, setDefaultCountryCode } from '../app/connect/connectStore';
20
31
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
21
32
  import Collapse from '../../components/Collapse';
22
- import { reactElement, removeElement } from '../../utils';
33
+ import { reactElement, removeElement, isKW } from '../../utils';
23
34
  import { CONNECT_SCREENS_NAVIGATION, DIALOG_ID } from '../../constants';
24
35
  import { connectFeatureScreens } from '../featuresScreens';
25
36
  import CustomFooter from '../shared/Footer';
26
37
  import Background from '../shared/Background';
27
- var Connect = memo(function (props) {
38
+ var Connect = memo(function (_a) {
39
+ var onClose = _a.onClose, props = __rest(_a, ["onClose"]);
28
40
  var theme = useAppTheme().theme;
29
- var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
30
- var connectError = useAppSelector(connectSelector).error;
41
+ var dispatch = useAppDispatch();
42
+ var _b = useAppSelector(settingsSelector), data = _b.data, error = _b.error, settingLoading = _b.loading;
43
+ var _c = useAppSelector(connectSelector), connectError = _c.error, loading = _c.loading;
31
44
  useAppConfig(__assign({ navigation: CONNECT_SCREENS_NAVIGATION }, props));
32
45
  useErrorListener(connectError || error);
33
46
  useStepStartedListener();
34
47
  var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
35
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading, error: error, open: open, footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: connectFeatureScreens.map(function (_a, index) {
48
+ React.useEffect(function () {
49
+ var _a;
50
+ if (!settingLoading) {
51
+ if (isKW((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2))
52
+ dispatch(handleCurrentActiveScreen('CONNECT_MOBILE_STEP'));
53
+ }
54
+ }, [settingLoading]);
55
+ React.useEffect(function () {
56
+ var _a;
57
+ if (!!((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2))
58
+ dispatch(setDefaultCountryCode(data.businessCountry));
59
+ }, [data.businessCountry]);
60
+ var handleDialogClose = function () {
61
+ dispatch(handleOpen(false));
62
+ };
63
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading }, { children: _jsx(AnimationFlow, __assign({ pointerEvents: loading ? 'none' : 'auto', onClose: onClose, onConfirm: handleDialogClose, isTapOrigin: isTapOrigin, loading: settingLoading, error: error, open: open, footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: connectFeatureScreens.map(function (_a, index) {
36
64
  var Element = _a.element, name = _a.name;
37
65
  var isActive = activeScreen.name === name;
38
66
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
@@ -51,6 +79,6 @@ export function unmountConnectLib(elementId, unmountTimeout) {
51
79
  var _a;
52
80
  ((_a = element === null || element === void 0 ? void 0 : element.children) === null || _a === void 0 ? void 0 : _a.length) && element.removeChild(element.children[0]);
53
81
  removeElement(DIALOG_ID);
54
- reactElement(elementId).unmount();
82
+ elementId && reactElement(elementId).unmount();
55
83
  }, unmountTimeout);
56
84
  }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface CivilIDProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: CivilIDProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,102 @@
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import * as React from 'react';
25
+ import { useTranslation } from 'react-i18next';
26
+ import { alpha, styled } from '@mui/material/styles';
27
+ import { useForm, FormProvider } from 'react-hook-form';
28
+ import { yupResolver } from '@hookform/resolvers/yup';
29
+ import { civilIDValidationSchema } from './validation';
30
+ import { useAppDispatch, useLanguage, useAppSelector, useSetFromDefaultValues } from '../../../../hooks';
31
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
32
+ import { clearError, connectSelector, createCivilIdAuth, resetMobileScreen, resetStore } from '../../../app/connect/connectStore';
33
+ import Form from '../../../../components/Form';
34
+ import Button, { MobileButton } from '../../../shared/Button';
35
+ import { ScreenContainer } from '../../../shared/Containers';
36
+ import Collapse from '../../../../components/Collapse';
37
+ import Box from '@mui/material/Box';
38
+ import Divider from '@mui/material/Divider';
39
+ import Text from '../../../../components/Text';
40
+ import IDNumber from './IDNumber';
41
+ var FormStyled = styled(Form)(function () { return ({
42
+ display: 'flex',
43
+ flexDirection: 'column'
44
+ }); });
45
+ var TextStyled = styled(Text)(function (_a) {
46
+ var theme = _a.theme;
47
+ return ({
48
+ color: alpha(theme.palette.primary.dark, 0.4)
49
+ });
50
+ });
51
+ var DividerStyled = styled(Divider)(function (_a) {
52
+ var theme = _a.theme;
53
+ return ({
54
+ width: '45%',
55
+ borderColor: alpha(theme.palette.primary.dark, 0.4),
56
+ marginBlockEnd: theme.spacing(0.62)
57
+ });
58
+ });
59
+ var OrBoxStyled = styled(Box)(function (_a) {
60
+ var theme = _a.theme;
61
+ return ({
62
+ display: 'flex',
63
+ justifyContent: 'space-between',
64
+ marginBlockEnd: theme.spacing(1.62),
65
+ marginBlockStart: theme.spacing(-1.25),
66
+ marginInline: theme.spacing(2.5)
67
+ });
68
+ });
69
+ var CivilID = function (_a) {
70
+ var isAr = useLanguage().isAr;
71
+ var dispatch = useAppDispatch();
72
+ var t = useTranslation().t;
73
+ var _b = useAppSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
74
+ var settingsStore = useAppSelector(settingsSelector);
75
+ var _c = data.civilIdData, responseBody = _c.responseBody, defaultValues = __rest(_c, ["responseBody"]);
76
+ var methods = useForm({
77
+ resolver: yupResolver(civilIDValidationSchema),
78
+ defaultValues: defaultValues,
79
+ mode: 'onChange'
80
+ });
81
+ useSetFromDefaultValues(methods, defaultValues);
82
+ React.useEffect(function () {
83
+ handleClearError();
84
+ }, [methods.formState.isValid]);
85
+ var onSubmit = function (data) {
86
+ dispatch(createCivilIdAuth(data));
87
+ dispatch(resetMobileScreen(settingsStore.data.businessCountry));
88
+ };
89
+ var handleClearError = function () {
90
+ if (error)
91
+ dispatch(clearError());
92
+ };
93
+ var onBack = function () {
94
+ dispatch(handlePrevScreenStep('CONNECT_MOBILE_STEP'));
95
+ };
96
+ React.useEffect(function () {
97
+ dispatch(resetStore());
98
+ }, []);
99
+ var disabled = !methods.formState.isValid || !!error;
100
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, { sx: { mb: methods.formState.isValid ? 7.5 : 0, transition: 'mb 0.3s' } }), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(Collapse, __assign({ in: !methods.formState.isValid }, { children: [_jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(MobileButton, __assign({ onClick: function () { return onBack(); }, disabled: loading || settingsStore.loading }, { children: t('mobile_button_label') }))] }))] })) })) }));
101
+ };
102
+ export default React.memo(CivilID);
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { SxProps, Theme } from '@mui/material/styles';
3
+ interface IDNumberProps {
4
+ sx: SxProps<Theme> | undefined;
5
+ }
6
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<IDNumberProps & React.RefAttributes<unknown>>>;
7
+ export default _default;
@@ -0,0 +1,59 @@
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useController, useFormContext } from 'react-hook-form';
17
+ import { styled, alpha } from '@mui/material/styles';
18
+ import Text from '../../../../components/Text';
19
+ import Input from '../../../shared/Input';
20
+ import ClearIcon from '../../../shared/ClearIcon';
21
+ import CheckIcon from '../../../shared/CheckIcon';
22
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
23
+ import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
24
+ import { CIVIL_ID_NUMBER_LENGTH } from '../../../../constants';
25
+ var LabelContainerStyled = styled(Box)(function (_a) {
26
+ var theme = _a.theme;
27
+ return ({
28
+ display: 'flex',
29
+ justifyContent: 'space-between',
30
+ padding: theme.spacing(0, 2.5, 1.25, 2.5)
31
+ });
32
+ });
33
+ var InputLabelStyled = styled(Text)(function (_a) {
34
+ var theme = _a.theme;
35
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
36
+ });
37
+ var IDNumber = React.forwardRef(function (_a, ref) {
38
+ var _b;
39
+ var sx = _a.sx;
40
+ var t = useTranslation().t;
41
+ var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
42
+ var civilIdControl = useController({ control: control, name: 'civilId' });
43
+ React.useEffect(function () {
44
+ if (civilIdControl.field.value)
45
+ setValue('civilId', civilIdControl.field.value, { shouldValidate: true });
46
+ }, []);
47
+ var handleIdChange = function (_a) {
48
+ var target = _a.target;
49
+ var value = removeAllOtherThanCharsAndNumber(target.value);
50
+ civilIdControl.field.onChange(value);
51
+ };
52
+ var clearIdNumber = function () {
53
+ civilIdControl.field.onChange('');
54
+ };
55
+ var idValue = civilIdControl.field.value;
56
+ var error = (_b = civilIdControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
57
+ return (_jsxs(ScreenContainer, __assign({ ref: ref, sx: sx }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_civil_id') }) }), _jsx(Input, { dir: 'ltr', type: 'text', inputProps: { maxLength: CIVIL_ID_NUMBER_LENGTH }, onChange: handleIdChange, value: idValue, endAdornment: !error && idValue ? _jsx(CheckIcon, {}) : idValue && _jsx(ClearIcon, { onClick: clearIdNumber }), placeholder: t('civil_id_placeholder'), warningType: 'alert', warningMessage: error && t(error), required: true })] })));
58
+ });
59
+ export default React.memo(IDNumber);
@@ -0,0 +1,3 @@
1
+ import CivilID, { CivilIDProps } from './CivilID';
2
+ export type { CivilIDProps };
3
+ export default CivilID;
@@ -0,0 +1,2 @@
1
+ import CivilID from './CivilID';
2
+ export default CivilID;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const civilIDValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var civilIDValidationSchema = yup.object().shape({
3
+ civilId: yup.string().matches(/^\d+$/, 'invalid_civil_id').min(12, 'invalid_civil_id').required('invalid_civil_id')
4
+ });
@@ -54,8 +54,8 @@ import Input from '../../../shared/Input';
54
54
  import { useController, useFormContext } from 'react-hook-form';
55
55
  import ClearIcon from '../../../shared/ClearIcon';
56
56
  import CheckIcon from '../../../shared/CheckIcon';
57
- import { checkEmailAvailability } from '../../../app/connect/connectStore';
58
- import { useAppDispatch } from '../../../../hooks';
57
+ import { checkEmailAvailability, connectSelector } from '../../../app/connect/connectStore';
58
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
59
59
  import { debounce } from 'lodash-es';
60
60
  import Collapse from '../../../../components/Collapse';
61
61
  import { styled } from '@mui/material/styles';
@@ -72,7 +72,9 @@ var cancelToken = null;
72
72
  var Email = function (_a) {
73
73
  var _b;
74
74
  var show = _a.show, fetchingEmail = _a.fetchingEmail, emailChecking = _a.emailChecking;
75
+ var _c = React.useState(''), storedEmail = _c[0], setStoredEmail = _c[1];
75
76
  var dispatch = useAppDispatch();
77
+ var data = useAppSelector(connectSelector).data;
76
78
  var t = useTranslation().t;
77
79
  var control = useFormContext().control;
78
80
  var emailControl = useController({ name: 'email', control: control });
@@ -93,9 +95,15 @@ var Email = function (_a) {
93
95
  var handleEmailChange = function (event) {
94
96
  emailControl.field.onChange(event.target.value);
95
97
  };
98
+ React.useEffect(function () {
99
+ var _a, _b;
100
+ var email = (_b = (_a = data.otpData.responseBody) === null || _a === void 0 ? void 0 : _a.contact) === null || _b === void 0 ? void 0 : _b.email;
101
+ if (!!email)
102
+ setStoredEmail(email);
103
+ }, [data.otpData.responseBody]);
96
104
  React.useEffect(function () {
97
105
  var isValid = emailValue && !error && emailValue.length > 3;
98
- if (isValid) {
106
+ if (isValid && emailValue != storedEmail) {
99
107
  fetchingEmail(true);
100
108
  checkEmail(emailValue);
101
109
  }
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
+ };
12
23
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
24
  import { styled } from '@mui/material/styles';
14
25
  import Email from './Email';
@@ -17,8 +28,8 @@ import * as React from 'react';
17
28
  import { useTranslation } from 'react-i18next';
18
29
  import { useForm, FormProvider } from 'react-hook-form';
19
30
  import { yupResolver } from '@hookform/resolvers/yup';
20
- import { useAppDispatch, useAppSelector } from '../../../../hooks';
21
- import { handlePrevScreenStep } from '../../../../app/settings';
31
+ import { useAppDispatch, useAppSelector, useSetFromDefaultValues } from '../../../../hooks';
32
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
22
33
  import { IndividualValidation, IndividualMobileValidation } from './validation';
23
34
  import Form from '../../../../components/Form';
24
35
  import Button from '../../../shared/Button';
@@ -27,58 +38,67 @@ import { clearError, connectSelector, resetIndividualScreen, updateLeadIndividua
27
38
  import { useLanguage } from '../../../../hooks';
28
39
  import MobileNumber from './MobileNumber';
29
40
  import { countriesCode } from '../../../../constants';
41
+ import { AuthForType } from '../../../../@types';
30
42
  import Collapse from '../../../../components/Collapse';
43
+ import { isKW } from '../../../../utils';
31
44
  var FormStyled = styled(Form)(function () { return ({
32
45
  display: 'flex',
33
- flexDirection: 'column'
46
+ flexDirection: 'column',
47
+ minHeight: '240px',
48
+ justifyContent: 'space-between'
34
49
  }); });
35
50
  var Individual = function (_a) {
36
- var _b, _c, _d;
37
- var _e = React.useState(false), listActive = _e[0], setListActive = _e[1];
38
- var _f = React.useState(false), emailChecking = _f[0], setEmailChecking = _f[1];
39
- var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
51
+ var _b = React.useState(false), listActive = _b[0], setListActive = _b[1];
52
+ var _c = React.useState(false), emailChecking = _c[0], setEmailChecking = _c[1];
53
+ var settingsData = useAppSelector(settingsSelector).data;
54
+ var _d = useAppSelector(connectSelector), data = _d.data, loading = _d.loading, error = _d.error;
40
55
  var dispatch = useAppDispatch();
41
56
  var t = useTranslation().t;
42
57
  var isAr = useLanguage().isAr;
43
- var isAbsher = (_b = data.otpData) === null || _b === void 0 ? void 0 : _b.isAbsher;
44
- var individualData = data.individualData;
58
+ var individualData = data.individualData, otpData = data.otpData, mobileData = data.mobileData;
59
+ var startWithNID = otpData.authFor === AuthForType.NATIONAL_ID;
60
+ var isMobile = mobileData.mobile;
61
+ var _e = otpData.responseBody || {}, contact = _e.contact, name = _e.name, userInfoMissed = _e.userInfoMissed, is_new_individual = _e.is_new_individual;
62
+ var responseBody = individualData.responseBody, defaultValues = __rest(individualData, ["responseBody"]);
63
+ var is_available = (responseBody || {}).is_available;
45
64
  var methods = useForm({
46
- resolver: yupResolver(isAbsher ? IndividualMobileValidation : IndividualValidation),
47
- defaultValues: data.individualData,
65
+ resolver: yupResolver(isMobile ? IndividualValidation : IndividualMobileValidation),
66
+ defaultValues: defaultValues,
48
67
  mode: 'onChange'
49
68
  });
69
+ useSetFromDefaultValues(methods, defaultValues, true);
70
+ React.useEffect(function () {
71
+ if (defaultValues.countryCode.iso2 !== methods.getValues('countryCode.iso2'))
72
+ methods.setValue('countryCode', defaultValues.countryCode);
73
+ }, [defaultValues.countryCode]);
50
74
  var onSubmit = function (formData) {
51
75
  dispatch(updateLeadIndividual(formData));
52
76
  };
53
77
  var onBack = function () {
78
+ var _a;
54
79
  dispatch(resetIndividualScreen());
55
- dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
80
+ var code = (_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2;
81
+ var screen = startWithNID ? (isKW(code) ? 'CONNECT_CIVIL_ID_STEP' : 'CONNECT_NID_STEP') : 'CONNECT_MOBILE_STEP';
82
+ dispatch(handlePrevScreenStep(screen));
56
83
  };
57
84
  React.useEffect(function () {
58
85
  if (error)
59
86
  dispatch(clearError());
60
87
  }, [methods.formState.isValid]);
61
- React.useEffect(function () {
62
- var name = individualData.name, email = individualData.email, mobile = individualData.mobile, countryCode = individualData.countryCode;
63
- if (!!name)
64
- methods.setValue('name', name, { shouldValidate: true });
65
- if (!!email)
66
- methods.setValue('email', email, { shouldValidate: true });
67
- if (!!mobile)
68
- methods.setValue('mobile', mobile, { shouldValidate: true });
69
- if (!!countryCode)
70
- methods.setValue('countryCode', countryCode, { shouldValidate: true });
71
- }, [individualData.name, individualData.email, individualData.mobile, individualData.countryCode]);
72
88
  var handleMenuListClick = function () {
73
89
  listActive ? setListActive(false) : setListActive(true);
74
90
  };
75
91
  React.useEffect(function () {
76
- var _a, _b;
77
- if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) === false)
92
+ if (is_available === false)
78
93
  methods.setError('email', { message: 'tap_js_email_already_exist' });
79
- }, [(_c = data.individualData) === null || _c === void 0 ? void 0 : _c.responseBody]);
94
+ }, [responseBody]);
95
+ var isLeadEmailAvailable = (contact === null || contact === void 0 ? void 0 : contact.email) === methods.watch('email');
96
+ var isEmailValid = typeof is_available === 'undefined' ? isLeadEmailAvailable : is_available;
80
97
  var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email || !!error;
81
- var disabled = emailErrChecks || emailChecking || !((_d = data.individualData.responseBody) === null || _d === void 0 ? void 0 : _d.is_available);
82
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive }), _jsx(MobileNumber, { show: isAbsher, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: countriesCode }), _jsx(Email, { show: !listActive, fetchingEmail: function (v) { return setEmailChecking(v); }, emailChecking: emailChecking }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
98
+ var disabled = emailErrChecks || emailChecking || !isEmailValid;
99
+ var isNameRequired = (userInfoMissed && !name) || is_new_individual;
100
+ var isEmailRequired = (userInfoMissed && !(contact === null || contact === void 0 ? void 0 : contact.email)) || is_new_individual;
101
+ var isMobileRequired = (userInfoMissed && !(contact === null || contact === void 0 ? void 0 : contact.phone)) || is_new_individual;
102
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive && isNameRequired }), _jsx(MobileNumber, { show: !isMobile && isMobileRequired, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: countriesCode }), _jsx(Email, { show: !listActive && isEmailRequired, fetchingEmail: function (v) { return setEmailChecking(v); }, emailChecking: emailChecking }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
83
103
  };
84
104
  export default React.memo(Individual);
@@ -34,6 +34,7 @@ import SimpleList from '../../../../components/SimpleList';
34
34
  import Text from '../../../../components/Text';
35
35
  import ExpandIcon from '../../../../components/ExpandIcon';
36
36
  import Collapse from '../../../../components/Collapse';
37
+ import { mapSalesChannel } from '../../../../utils';
37
38
  var InputStyled = styled(Input)(function () { return ({
38
39
  '& .MuiInputBase-input': {
39
40
  cursor: 'pointer'
@@ -51,7 +52,7 @@ var BrandList = function (_a) {
51
52
  var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
52
53
  var t = useTranslation().t;
53
54
  var isAr = useLanguage().isAr;
54
- var control = useFormContext().control;
55
+ var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
55
56
  var selectedBrandControl = useController({ control: control, name: 'selectedBrandItem' });
56
57
  var selectedBrand = selectedBrandControl.field.value;
57
58
  var onOpenBrandList = function (event) {
@@ -64,22 +65,29 @@ var BrandList = function (_a) {
64
65
  setAnchorEl(null);
65
66
  (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
66
67
  };
67
- var getBrandName = function (item) {
68
- var _a, _b;
69
- return (isAr ? (_a = item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item.name) === null || _b === void 0 ? void 0 : _b.en) || '';
68
+ var getBrandName = function (_a) {
69
+ var name = _a.name;
70
+ return (isAr ? name === null || name === void 0 ? void 0 : name.ar : name === null || name === void 0 ? void 0 : name.en) || '';
70
71
  };
71
72
  var getBrandId = function (item) {
72
73
  return item.id || '';
73
74
  };
74
- var isOtherLicense = function (item) {
75
- return item.id === 'other';
75
+ var isOtherBrand = function (item) {
76
+ return getBrandId(item) === 'other';
76
77
  };
77
78
  var onSelectItem = function (brand) {
78
79
  selectedBrandControl.field.onChange(brand);
80
+ if (!isOtherBrand(brand)) {
81
+ setValue('salesChannels', mapSalesChannel(brand.channel_services || []), { shouldValidate: true });
82
+ }
83
+ if (isOtherBrand(brand)) {
84
+ setValue('salesChannels', [], { shouldValidate: true });
85
+ setValue('brandName', '');
86
+ }
79
87
  onCloseBrandList();
80
88
  };
81
89
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('select_brand_label'), readOnly: true, onClick: !!anchorEl ? onCloseBrandList : onOpenBrandList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_brand'), value: t(getBrandName(selectedBrand)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'id', list: list, onSelectItem: onSelectItem, renderItem: function (item) {
82
- return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children: isOtherLicense(item) ? t(getBrandName(item)) : getBrandName(item) })) }), getBrandId(item) === getBrandId(selectedBrand) && _jsx(CheckIcon, {})] }));
90
+ return (_jsxs(_Fragment, { children: [_jsx(BrandContainer, { children: _jsx(BrandNameText, __assign({ isSelected: getBrandId(item) === getBrandId(selectedBrand) }, { children: isOtherBrand(item) ? t(getBrandName(item)) : getBrandName(item) })) }), getBrandId(item) === getBrandId(selectedBrand) && _jsx(CheckIcon, {})] }));
83
91
  } }) }))] }) })));
84
92
  };
85
93
  export default React.memo(BrandList);
@@ -63,8 +63,8 @@ import Tooltip from '../../../../components/Tooltip';
63
63
  import Collapse from '../../../../components/Collapse';
64
64
  import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
65
65
  import CheckIcon from '../../../shared/CheckIcon';
66
- import { checkBrandNameAvailability } from '../../../app/connect/connectStore';
67
- import { useAppDispatch } from '../../../../hooks';
66
+ import { checkBrandNameAvailability, connectSelector } from '../../../app/connect/connectStore';
67
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
68
68
  import { debounce } from 'lodash-es';
69
69
  var LabelContainerStyled = styled(Box)(function (_a) {
70
70
  var theme = _a.theme;
@@ -103,6 +103,7 @@ var BrandName = function (_a) {
103
103
  var dispatch = useAppDispatch();
104
104
  var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
105
105
  var t = useTranslation().t;
106
+ var data = useAppSelector(connectSelector).data;
106
107
  var control = useFormContext().control;
107
108
  var brandControl = useController({ control: control, name: 'brandName' });
108
109
  var brandNameValue = brandControl.field.value;
@@ -125,8 +126,10 @@ var BrandName = function (_a) {
125
126
  brandControl.field.onChange(value);
126
127
  };
127
128
  React.useEffect(function () {
129
+ var _a, _b, _c;
128
130
  var isValid = brandNameValue && !error && brandNameValue.length > 2;
129
- if (isValid) {
131
+ var brand = (_c = (_b = (_a = data.otpData.responseBody) === null || _a === void 0 ? void 0 : _a.brand) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.en;
132
+ if (isValid && (brandNameValue === null || brandNameValue === void 0 ? void 0 : brandNameValue.toLowerCase()) != brand) {
130
133
  fetchingBrandName(true);
131
134
  checkBrand(brandNameValue);
132
135
  }
@@ -134,6 +137,6 @@ var BrandName = function (_a) {
134
137
  var clearBrandName = function () {
135
138
  brandControl.field.onChange('');
136
139
  };
137
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue, placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
140
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue || '', placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
138
141
  };
139
142
  export default React.memo(BrandName);