@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
@@ -16,14 +16,15 @@ import { useTranslation } from 'react-i18next';
16
16
  import Collapse from '@mui/material/Collapse';
17
17
  import { yupResolver } from '@hookform/resolvers/yup';
18
18
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
19
- import { handlePrevScreenStep } from '../../../../app/settings';
19
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
20
20
  import Form from '../../../../components/Form';
21
- import { INSTAGRAM_URL, TWITTER_URL } from '../../../../constants';
22
21
  import { ScreenContainer } from '../../../shared/Containers';
23
22
  import Button from '../../../shared/Button';
24
23
  import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
25
24
  import { useLanguage } from '../../../../hooks';
26
- import { MerchantValidationSchema, ValidationOptions } from './validation';
25
+ import { AuthForType } from '../../../../@types';
26
+ import { isKW, mapSalesChannel } from '../../../../utils';
27
+ import { MerchantValidationSchema } from './validation';
27
28
  import BrandName from './BrandName';
28
29
  import SocialMedia from './SocialMedia';
29
30
  import TAC from './TAC';
@@ -32,37 +33,40 @@ import SalesChannels from './SalesChannels';
32
33
  var Merchant = function (_a) {
33
34
  var _b, _c;
34
35
  var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
35
- var _e = React.useState(ValidationOptions.NEW_USER), userType = _e[0], setUserType = _e[1];
36
- var _f = React.useState(false), listActive = _f[0], setListActive = _f[1];
36
+ var _e = React.useState(false), isBrandListOpen = _e[0], setIsBrandListOpen = _e[1];
37
+ var _f = React.useState(false), isRequiredNewBrand = _f[0], setIsRequiredNewBrand = _f[1];
37
38
  var _g = useAppSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
38
- var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.new_user;
39
- var isAbsher = data.otpData.isAbsher;
40
- var _h = data.brandData.responseBody || {}, brands = _h.brands, channelList = _h.channelList;
41
- var brandList = brands || [];
42
- var _j = data.brandData, brandName = _j.brandName, links = _j.links, selectedBrandItem = _j.selectedBrandItem, termAndConditionChecked = _j.termAndConditionChecked, responseBody = _j.responseBody, salesChannels = _j.salesChannels;
39
+ var settingsData = useAppSelector(settingsSelector).data;
40
+ var isNewIndividual = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.is_new_individual;
41
+ var startWithNID = data.otpData.authFor === AuthForType.NATIONAL_ID;
42
+ var _h = data.brandData, brandName = _h.brandName, selectedBrandItem = _h.selectedBrandItem, termAndConditionChecked = _h.termAndConditionChecked, responseBody = _h.responseBody, salesChannels = _h.salesChannels;
43
+ var brandList = (responseBody || {}).brand_list;
43
44
  var methods = useForm({
44
- resolver: yupResolver(MerchantValidationSchema(userType)),
45
+ resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
45
46
  defaultValues: {
46
47
  brandName: brandName,
47
- links: links,
48
48
  selectedBrandItem: selectedBrandItem,
49
- termAndConditionChecked: termAndConditionChecked
49
+ termAndConditionChecked: termAndConditionChecked,
50
+ salesChannels: salesChannels
50
51
  },
51
52
  mode: 'onChange'
52
53
  });
53
54
  var t = useTranslation().t;
54
55
  var isAr = useLanguage().isAr;
55
56
  var dispatch = useAppDispatch();
56
- var formDataSelectedBrand = methods.getValues('selectedBrandItem');
57
+ var brandListItem = methods.watch('selectedBrandItem');
57
58
  var onSubmit = function (formData) {
58
- dispatch(updateLeadBrand(formData));
59
+ dispatch(updateLeadBrand(__assign(__assign({}, formData), { isNewBrand: isRequiredNewBrand })));
59
60
  };
60
61
  var onBack = function () {
61
- if (isNewUser) {
62
+ var _a;
63
+ if (isNewIndividual) {
62
64
  dispatch(handlePrevScreenStep('CONNECT_INDIVIDUAL_STEP'));
63
65
  return;
64
66
  }
65
- dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
67
+ var code = (_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2;
68
+ var screen = startWithNID ? (isKW(code) ? 'CONNECT_CIVIL_ID_STEP' : 'CONNECT_NID_STEP') : 'CONNECT_MOBILE_STEP';
69
+ dispatch(handlePrevScreenStep(screen));
66
70
  };
67
71
  React.useEffect(function () {
68
72
  if (error)
@@ -70,60 +74,33 @@ var Merchant = function (_a) {
70
74
  }, [methods.formState.isValid]);
71
75
  React.useEffect(function () {
72
76
  if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.response_code) === '5')
73
- methods.setError('brandName', { message: 'Profile Name already exists' });
77
+ methods.setError('brandName', { message: 'brand_name_already_exist' });
74
78
  }, [responseBody]);
75
79
  React.useEffect(function () {
76
- var _a, _b, _c, _d, _e;
77
- if (isNewUser === true) {
78
- setUserType(ValidationOptions.NEW_USER);
80
+ if (selectedBrandItem.id) {
81
+ methods.setValue('selectedBrandItem', selectedBrandItem);
82
+ var sales = mapSalesChannel(selectedBrandItem.channel_services || []);
83
+ methods.setValue('salesChannels', sales, { shouldValidate: true });
79
84
  }
80
- if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) === 'other') {
81
- setUserType(ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND);
82
- methods.clearErrors();
83
- setTimeout(function () {
84
- var sites = { website: '', twitter: '', instagram: '' };
85
- methods.setValue('brandName', '', { shouldValidate: true });
86
- methods.setValue('links', sites);
87
- methods.setValue('salesChannels', []);
88
- }, 100);
89
- }
90
- if (isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0 && (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) !== 'other') {
91
- setUserType(ValidationOptions.EXISTING_USER_WITH_EXIST_BRAND);
92
- methods.clearErrors();
93
- var twitter = ((_b = (_a = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.social) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.includes('twitter.com'); })) === null || _b === void 0 ? void 0 : _b.replaceAll("".concat(TWITTER_URL, "/"), '')) || '';
94
- var instagram = ((_d = (_c = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.social) === null || _c === void 0 ? void 0 : _c.find(function (item) { return item.includes('instagram.com'); })) === null || _d === void 0 ? void 0 : _d.replaceAll("".concat(INSTAGRAM_URL, "/"), '')) || '';
95
- var website = (_e = formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.website) === null || _e === void 0 ? void 0 : _e.replaceAll(/(https|http):\/\//g, '');
96
- var sites_1 = __assign(__assign({}, links), { website: website, twitter: twitter, instagram: instagram });
97
- setTimeout(function () { return methods.setValue('links', sites_1, { shouldValidate: true }); }, 100);
98
- var selectedChannels = (!!(channelList === null || channelList === void 0 ? void 0 : channelList[0]) && [channelList === null || channelList === void 0 ? void 0 : channelList[0]]) || [];
99
- var _f = formDataSelectedBrand || {}, websiteUrl = _f.website, social = _f.social;
100
- var isHasWebsite = (websiteUrl === null || websiteUrl === void 0 ? void 0 : websiteUrl.length) > 0;
101
- var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
102
- var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
103
- var websiteData = channelList === null || channelList === void 0 ? void 0 : channelList.find(function (c) { return c.name_en.toLocaleLowerCase() === 'website'; });
104
- var socialData = channelList === null || channelList === void 0 ? void 0 : channelList.find(function (c) { return c.name_en.toLocaleLowerCase() === 'social'; });
105
- if (isHasWebsite && (isHasTwitter || isHasInstagram))
106
- selectedChannels = [websiteData, socialData];
107
- else if (isHasTwitter || isHasInstagram)
108
- selectedChannels = [socialData];
109
- else if (isHasWebsite)
110
- selectedChannels = [websiteData];
111
- methods.setValue('salesChannels', selectedChannels);
112
- }
113
- }, [formDataSelectedBrand, isNewUser]);
114
- React.useEffect(function () {
115
- if (!(formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) && (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id))
116
- methods.setValue('selectedBrandItem', selectedBrandItem, { shouldValidate: true });
117
85
  }, [selectedBrandItem]);
118
86
  React.useEffect(function () {
119
- methods.setValue('salesChannels', salesChannels);
87
+ if (salesChannels.length > 0) {
88
+ var sales = mapSalesChannel(salesChannels);
89
+ methods.setValue('salesChannels', sales, { shouldValidate: true });
90
+ }
120
91
  }, [salesChannels]);
92
+ React.useEffect(function () {
93
+ if (termAndConditionChecked === true)
94
+ methods.setValue('termAndConditionChecked', termAndConditionChecked);
95
+ }, [termAndConditionChecked]);
121
96
  var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
122
97
  var disabled = brandErrChecks || brandNameChecking || ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.response_code) === '5';
123
- var isBrandListAvailable = userType !== ValidationOptions.NEW_USER && brandList.length > 0;
124
- var askingForBrandInfo = userType === ValidationOptions.NEW_USER ||
125
- brandList.length === 0 ||
126
- userType === ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND;
127
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: isBrandListAvailable, list: brandList, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(BrandName, { show: !listActive && askingForBrandInfo, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(SalesChannels, {}) })), _jsx(SocialMedia, { show: !listActive, isNewUser: isNewUser }), _jsx(TAC, { show: !listActive && askingForBrandInfo }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
98
+ var hasBrandList = (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0;
99
+ var isOtherBrand = (brandListItem === null || brandListItem === void 0 ? void 0 : brandListItem.id) === 'other' && hasBrandList;
100
+ var isNewBrand = (brandList === null || brandList === void 0 ? void 0 : brandList.length) === 0 || BrandList === undefined;
101
+ React.useEffect(function () {
102
+ setIsRequiredNewBrand(isOtherBrand || isNewBrand);
103
+ }, [isOtherBrand, isNewBrand]);
104
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: !(isOtherBrand || isNewBrand), list: brandList, onListOpen: function () { return setIsBrandListOpen(true); }, onListClose: function () { return setIsBrandListOpen(false); } }), _jsx(BrandName, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(Collapse, __assign({ in: !isBrandListOpen }, { children: _jsx(SalesChannels, {}) })), _jsx(SocialMedia, { show: !isBrandListOpen }), _jsx(TAC, { show: (isNewBrand || isOtherBrand) && !isBrandListOpen }), _jsx(Collapse, __assign({ in: !isBrandListOpen, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
128
105
  };
129
106
  export default React.memo(Merchant);
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export declare const MandatoryStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
3
3
  export declare const CollapseStyled: import("@emotion/styled").StyledComponent<import("../../../../components/Collapse").CollapseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
4
- declare const SalesChannels: () => JSX.Element;
4
+ interface SalesChannelsProps {
5
+ }
6
+ declare const SalesChannels: ({}: SalesChannelsProps) => JSX.Element;
5
7
  export default SalesChannels;
@@ -19,7 +19,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
19
  return to.concat(ar || Array.prototype.slice.call(from));
20
20
  };
21
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- import * as React from 'react';
23
22
  import Box from '@mui/material/Box';
24
23
  import { alpha, styled } from '@mui/material/styles';
25
24
  import { useTranslation } from 'react-i18next';
@@ -30,7 +29,6 @@ import { connectSelector, clearError } from '../../../app/connect/connectStore';
30
29
  import CheckBox from '../../../../components/CheckBox';
31
30
  import Warning from '../../../../components/Warning';
32
31
  import Collapse from '../../../../components/Collapse';
33
- import { ScreenContainer } from '../../../shared/Containers';
34
32
  var InputLabelStyled = styled(Text)(function (_a) {
35
33
  var theme = _a.theme;
36
34
  return (__assign({ margin: theme.spacing(2.5, 2.5, 0.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
@@ -53,6 +51,7 @@ var TextStyled = styled(Text)(function (_a) {
53
51
  var CheckBoxStyled = styled(CheckBox)(function (_a) {
54
52
  var theme = _a.theme;
55
53
  return ({
54
+ paddingInline: '15px',
56
55
  marginInlineEnd: theme.spacing(-1),
57
56
  '& .MuiSvgIcon-root': {
58
57
  fontSize: 30
@@ -73,42 +72,42 @@ export var CollapseStyled = styled(Collapse)(function (_a) {
73
72
  marginBlockStart: theme.spacing(2)
74
73
  });
75
74
  });
76
- var SalesChannels = function () {
77
- var _a;
78
- var _b = React.useState([]), channelsMenuList = _b[0], setChannelsMenuList = _b[1];
75
+ var SalesChannels = function (_a) {
76
+ var _b;
79
77
  var t = useTranslation().t;
80
78
  var isAr = useLanguage().isAr;
81
79
  var _c = useFormContext(), control = _c.control, getValues = _c.getValues;
82
80
  var dispatch = useAppDispatch();
83
- var channelsControl = useController({ name: 'salesChannels', control: control });
84
- var channelsChecked = channelsControl.field.value;
85
- var warningMessage = (_a = channelsControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
81
+ var channelsControl = useController({ control: control, name: 'salesChannels' });
86
82
  var _d = useAppSelector(connectSelector), data = _d.data, error = _d.error;
87
- var channelList = (data.brandData.responseBody || {}).channelList;
88
- var salesChannels = (data.brandData || {}).salesChannels;
89
- var formDataSelectedBrand = getValues('selectedBrandItem');
90
- React.useEffect(function () {
91
- if ((channelList === null || channelList === void 0 ? void 0 : channelList.length) > 0) {
92
- setChannelsMenuList(channelList);
93
- }
94
- }, [channelList]);
95
- var handleSalesChannelChange = function (event) {
96
- var selected = channelsMenuList.find(function (channel) { return channel.id === event.target.id; });
97
- var isExists = channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.find(function (channel) { return channel.id === (selected === null || selected === void 0 ? void 0 : selected.id); });
98
- if (isExists) {
99
- var updatedIdList = channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.filter(function (channel) { return channel.id !== (selected === null || selected === void 0 ? void 0 : selected.id); });
100
- channelsControl.field.onChange(updatedIdList);
101
- return;
102
- }
103
- channelsControl.field.onChange(__spreadArray(__spreadArray([], channelsChecked, true), [selected], false));
83
+ var channelList = (data.brandData.responseBody || {}).channel_list;
84
+ var isChecked = function (id) {
85
+ var item = channelsControl.field.value.find(function (item) { return item.id === id; });
86
+ return !!item;
87
+ };
88
+ var onChange = function (channel) {
104
89
  if (error)
105
90
  dispatch(clearError());
91
+ if (isChecked(channel.id)) {
92
+ var filterChannels = channelsControl.field.value.filter(function (item) { return item.id !== channel.id; });
93
+ channelsControl.field.onChange(filterChannels);
94
+ }
95
+ else {
96
+ var brandName = getValues('brandName');
97
+ var newChannel = __assign({}, channel);
98
+ if (newChannel.code === 'website' && brandName) {
99
+ var brandValue = brandName.replaceAll(' ', '-').toLowerCase();
100
+ var address = (brandValue[brandValue.length - 1] === '-' ? brandValue.slice(0, -1) : brandValue) + '.com';
101
+ newChannel.address = 'www.' + address;
102
+ }
103
+ channelsControl.field.onChange(__spreadArray(__spreadArray([], channelsControl.field.value, true), [newChannel], false));
104
+ }
106
105
  };
107
- var getSelectedChannelsFlag = function (item) {
108
- if (channelsChecked)
109
- return !!(channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.find(function (channel) { return channel.id === (item === null || item === void 0 ? void 0 : item.id); }));
110
- };
111
- var selectedBrandIsOther = (formDataSelectedBrand === null || formDataSelectedBrand === void 0 ? void 0 : formDataSelectedBrand.id) === 'other';
112
- return (_jsxs(ScreenContainer, { children: [_jsxs(InputLabelStyled, { children: [t('channel_of_service'), " ", _jsx(MandatoryStyled, { children: "*" })] }), (channelsMenuList || []).map(function (channel) { return (_jsxs(ContainerStyled, { children: [_jsx(CheckBoxStyled, { id: channel.id, disableRipple: true, disableFocusRipple: true, focusRipple: false, disabled: !selectedBrandIsOther && (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.find(function (c) { return c.id === (channel === null || channel === void 0 ? void 0 : channel.id); })) ? true : false, checked: getSelectedChannelsFlag(channel), onChange: handleSalesChannelChange }), _jsxs(TextStyled, { children: [isAr ? channel.name_ar : channel.name_en, " "] })] }, channel.id)); }), _jsx(CollapseStyled, __assign({ in: !!warningMessage }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: t(warningMessage) })) }))] }));
106
+ var warningMessage = (_b = channelsControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
107
+ var isSalesChannelError = warningMessage === 'choose_atleast_one_channel';
108
+ return (_jsxs(Box, __assign({ sx: { mb: 3 } }, { children: [_jsxs(InputLabelStyled, { children: [t('channel_of_service'), " ", _jsx(MandatoryStyled, { children: "*" })] }), (channelList || []).map(function (channel, index) {
109
+ var _a, _b;
110
+ return (_jsxs(ContainerStyled, { children: [_jsx(CheckBoxStyled, { id: channel.id, disableRipple: true, disableFocusRipple: true, focusRipple: false, checked: isChecked(channel.id), onChange: function () { return onChange(channel); } }), _jsxs(TextStyled, { children: [isAr ? (_a = channel === null || channel === void 0 ? void 0 : channel.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = channel === null || channel === void 0 ? void 0 : channel.name) === null || _b === void 0 ? void 0 : _b.en, " "] })] }, channel.id));
111
+ }), _jsx(CollapseStyled, __assign({ in: isSalesChannelError }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: t(warningMessage) })) }))] })));
113
112
  };
114
113
  export default SalesChannels;
@@ -1,9 +1,6 @@
1
1
  import * as React from 'react';
2
- import { Theme, SxProps } from '@mui/material/styles';
3
2
  interface SocialMediaProps {
4
3
  show: boolean;
5
- sx?: SxProps<Theme>;
6
- isNewUser: boolean;
7
4
  }
8
- declare const _default: React.MemoExoticComponent<({ show, sx, isNewUser }: SocialMediaProps) => JSX.Element>;
5
+ declare const _default: React.MemoExoticComponent<({ show }: SocialMediaProps) => JSX.Element>;
9
6
  export default _default;
@@ -9,26 +9,36 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
22
  import * as React from 'react';
14
23
  import { useTranslation } from 'react-i18next';
15
- import { useController, useFormContext } from 'react-hook-form';
24
+ import { useFormContext } from 'react-hook-form';
16
25
  import { styled, alpha } from '@mui/material/styles';
17
- import ClearIcon from '@mui/icons-material/Clear';
18
- import { SocialMediaTypes } from '../../../../@types';
26
+ import Box from '@mui/material/Box';
19
27
  import Input from '../../../../components/Input';
28
+ import Warning from '../../../../components/Warning';
20
29
  import Text from '../../../../components/Text';
21
30
  import Collapse from '../../../../components/Collapse';
22
31
  import SocialMediaGroup from '../../../../components/SocialMediaGroup';
23
- import { ScreenContainer } from '../../../shared/Containers';
24
- import CheckIcon from '../../../shared/CheckIcon';
25
- import { useAppSelector } from '../../../../hooks';
26
- import { connectSelector } from '../../../app/connect/connectStore';
32
+ import ToggleButton from '../../../../components/ToggleButton';
33
+ import Icon from '../../../../components/Icon';
34
+ import { useLanguage } from '../../../../hooks';
35
+ import { isWebsite, isTwitter } from '../../../../utils';
27
36
  var SocialMediaGroupStyled = styled(SocialMediaGroup)(function (_a) {
28
37
  var theme = _a.theme, defaultValue = _a.defaultValue;
29
38
  return ({
30
39
  borderTop: "1px solid ".concat(alpha(theme.palette.divider, 0.8)),
31
- borderBottom: !defaultValue ? "1px solid ".concat(alpha(theme.palette.divider, 0.8)) : ''
40
+ borderBottom: !defaultValue ? "1px solid ".concat(alpha(theme.palette.divider, 0.8)) : '',
41
+ width: '100%'
32
42
  });
33
43
  });
34
44
  var InputStyled = styled(Input)(function (_a) {
@@ -47,116 +57,126 @@ var TextStyled = styled(Text)(function (_a) {
47
57
  padding: theme.spacing(0, 0, 0, 1.5)
48
58
  });
49
59
  });
50
- var ClearIconStyled = styled(ClearIcon)(function (_a) {
51
- var theme = _a.theme;
60
+ var ToggleIconStyled = styled(Icon, {
61
+ shouldForwardProp: function (prop) { return prop !== 'isActive'; }
62
+ })(function (_a) {
63
+ var theme = _a.theme, isActive = _a.isActive;
64
+ return ({
65
+ width: theme.spacing(3),
66
+ height: theme.spacing(3),
67
+ filter: isActive ? 'invert(1) sepia(1) saturate(5) hue-rotate(175deg)' : ''
68
+ });
69
+ });
70
+ var SocialMediaButtonStyled = styled(ToggleButton, {
71
+ shouldForwardProp: function (prop) { return prop !== 'isActive' && prop !== 'isShow'; }
72
+ })(function (_a) {
73
+ var theme = _a.theme, isActive = _a.isActive, isShow = _a.isShow;
52
74
  return ({
53
- width: theme.spacing(2),
54
- height: theme.spacing(2),
55
- cursor: 'pointer',
56
- color: alpha(theme.palette.text.primary, 0.4)
75
+ borderBottom: isActive ? "".concat(theme.spacing(0.1875), " solid #3478F6") : 'none',
76
+ display: isShow ? 'inherit' : 'none',
77
+ transition: 'display 0.3s'
57
78
  });
58
79
  });
59
80
  var SocialMedia = function (_a) {
60
- var _b, _c, _d, _e, _f, _g, _h, _j;
61
- var show = _a.show, sx = _a.sx, isNewUser = _a.isNewUser;
62
- var _k = React.useState(SocialMediaTypes.WEB), socialMediaType = _k[0], setSocialMediaType = _k[1];
63
- var _l = React.useState([SocialMediaTypes.WEB]), selectedSocialMediaTypes = _l[0], setSelectedSocialMediaTypes = _l[1];
81
+ var _b;
82
+ var show = _a.show;
83
+ var _c = React.useState(''), activeSocialId = _c[0], setActiveSocialId = _c[1];
64
84
  var t = useTranslation().t;
65
- var _m = useFormContext(), control = _m.control, setValue = _m.setValue, watch = _m.watch;
66
- var linksControl = useController({ control: control, name: 'links' });
67
- var links = linksControl.field.value;
68
- var brandName = watch('brandName');
85
+ var isAr = useLanguage().isAr;
86
+ var _d = useFormContext(), setValue = _d.setValue, watch = _d.watch, getFieldState = _d.getFieldState;
69
87
  var selectedChannels = watch('salesChannels');
70
- var data = useAppSelector(connectSelector).data;
71
- var brandList = ((_b = data.brandData.responseBody) === null || _b === void 0 ? void 0 : _b.brands) || [];
72
- var handleChange = function (_a) {
73
- var _b;
74
- var target = _a.target;
75
- linksControl.field.onChange(__assign(__assign({}, links), (_b = {}, _b[socialMediaType.replace(' ', '_')] = target.value, _b)));
88
+ var salesChannelsState = getFieldState('salesChannels');
89
+ var onChangeIcons = function (id) {
90
+ setActiveSocialId(id);
76
91
  };
77
- var handleClear = function (e) {
78
- var _a;
79
- e.stopPropagation();
80
- linksControl.field.onChange(__assign(__assign({}, links), (_a = {}, _a[socialMediaType] = '', _a)));
81
- };
82
- var handleBlueWebsite = function () {
83
- if (!!links.website) {
84
- var website = links.website;
85
- var isWebHasPrefix = !!website.includes('www.');
86
- var isWebHasSuffix = !!website.includes('.com');
87
- if (!isWebHasPrefix)
88
- website = "www.".concat(website);
89
- if (!isWebHasSuffix)
90
- website = "".concat(website, ".com");
91
- setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
92
- }
92
+ var onChangeInput = function (value, id) {
93
+ if (selectedChannels.length <= 0)
94
+ return;
95
+ var updatedChannels = selectedChannels.map(function (channel) {
96
+ var _a;
97
+ if (channel.id === id) {
98
+ return {
99
+ code: channel.code,
100
+ address: value,
101
+ logo: channel.logo,
102
+ id: channel.id,
103
+ name: channel.name,
104
+ sub: channel.sub
105
+ };
106
+ }
107
+ if ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) {
108
+ var updatedSub = channel.sub.map(function (subChannel) {
109
+ if (subChannel.id === id) {
110
+ return {
111
+ code: subChannel.code,
112
+ address: value,
113
+ logo: subChannel.logo,
114
+ id: subChannel.id,
115
+ name: subChannel.name
116
+ };
117
+ }
118
+ return subChannel;
119
+ });
120
+ return __assign(__assign({}, channel), { sub: updatedSub });
121
+ }
122
+ return channel;
123
+ });
124
+ setValue('salesChannels', __spreadArray([], updatedChannels, true), { shouldValidate: true });
93
125
  };
94
- React.useEffect(function () {
95
- if (!!brandName) {
96
- var website = "www.".concat(brandName.replaceAll(' ', '-'), ".com");
97
- setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
98
- }
99
- if (!brandName && isNewUser === false && (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0) {
100
- var website = "other.com";
101
- setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
102
- }
103
- if (!brandName && isNewUser === true) {
104
- var website = '';
105
- setValue('links', __assign(__assign({}, links), { website: website }));
106
- }
107
- }, [brandName]);
108
- React.useEffect(function () {
109
- var _a, _b;
110
- if ((selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.length) > 0) {
111
- setSelectedSocialMediaTypes(selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.map(function (_a) {
112
- var name_en = _a.name_en;
113
- return name_en.toLocaleLowerCase();
114
- }));
115
- var hasSelectedMediaTypeAvailable = !!(selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.find(function (_a) {
116
- var name_en = _a.name_en;
117
- if (socialMediaType === SocialMediaTypes.TWITTER || socialMediaType === SocialMediaTypes.INSTAGRAM)
118
- return name_en.toLocaleLowerCase() === SocialMediaTypes.SOCIAL;
119
- if (socialMediaType === SocialMediaTypes.APPLE_STORE || socialMediaType === SocialMediaTypes.PLAY_STORE)
120
- return name_en.toLocaleLowerCase() === SocialMediaTypes.APP;
121
- return name_en.toLocaleLowerCase() === socialMediaType;
122
- }));
123
- if (!hasSelectedMediaTypeAvailable) {
124
- var type = (_b = (_a = selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels[0]) === null || _a === void 0 ? void 0 : _a.name_en) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase();
125
- if (type === SocialMediaTypes.SOCIAL)
126
- setSocialMediaType(SocialMediaTypes.TWITTER);
127
- else if (type === SocialMediaTypes.APP)
128
- setSocialMediaType(SocialMediaTypes.APPLE_STORE);
129
- else
130
- setSocialMediaType(type);
126
+ var setDefaultActiveSocialId = React.useCallback(function () {
127
+ var _a;
128
+ var idExist = selectedChannels.find(function (channel) {
129
+ var _a;
130
+ if ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) {
131
+ return channel.sub.find(function (subChannel) { return subChannel.id === activeSocialId; });
132
+ }
133
+ return channel.id === activeSocialId;
134
+ });
135
+ if (selectedChannels.length >= 1 && !idExist) {
136
+ var firstChannel = selectedChannels[0];
137
+ if ((_a = firstChannel.sub) === null || _a === void 0 ? void 0 : _a.length) {
138
+ setActiveSocialId(firstChannel.sub[0].id);
139
+ }
140
+ else {
141
+ setActiveSocialId(firstChannel.id);
131
142
  }
132
143
  }
133
144
  }, [selectedChannels]);
134
- var websiteValue = links.website || '';
135
- var twitterValue = links.twitter || '';
136
- var instagramValue = links.instagram || '';
137
- var appleStoreValue = links.apple_store || '';
138
- var playStoreValue = links.play_store || '';
139
- var callCenterValue = links.call_center || '';
140
- var physicalStoreValue = links.physical_store || '';
141
- var errors = linksControl.fieldState.error;
142
- var websiteError = (_c = errors === null || errors === void 0 ? void 0 : errors.website) === null || _c === void 0 ? void 0 : _c.message;
143
- var twitterError = (_d = errors === null || errors === void 0 ? void 0 : errors.twitter) === null || _d === void 0 ? void 0 : _d.message;
144
- var instagramError = (_e = errors === null || errors === void 0 ? void 0 : errors.instagram) === null || _e === void 0 ? void 0 : _e.message;
145
- var appleStoreError = (_f = errors === null || errors === void 0 ? void 0 : errors.apple_store) === null || _f === void 0 ? void 0 : _f.message;
146
- var playStoreError = (_g = errors === null || errors === void 0 ? void 0 : errors.play_store) === null || _g === void 0 ? void 0 : _g.message;
147
- var callCenterError = (_h = errors === null || errors === void 0 ? void 0 : errors.call_center) === null || _h === void 0 ? void 0 : _h.message;
148
- var physicalStoreError = (_j = errors === null || errors === void 0 ? void 0 : errors.physical_store) === null || _j === void 0 ? void 0 : _j.message;
149
- var hasWebsite = !!(selectedSocialMediaTypes === null || selectedSocialMediaTypes === void 0 ? void 0 : selectedSocialMediaTypes.find(function (s) { return s === SocialMediaTypes.WEB; }));
150
- var hasSocial = !!(selectedSocialMediaTypes === null || selectedSocialMediaTypes === void 0 ? void 0 : selectedSocialMediaTypes.find(function (s) {
151
- return s === SocialMediaTypes.TWITTER || s === SocialMediaTypes.INSTAGRAM || s === SocialMediaTypes.SOCIAL;
152
- }));
153
- var hasApp = !!(selectedSocialMediaTypes === null || selectedSocialMediaTypes === void 0 ? void 0 : selectedSocialMediaTypes.find(function (s) {
154
- return s === SocialMediaTypes.APPLE_STORE || s === SocialMediaTypes.PLAY_STORE || s === SocialMediaTypes.APP;
155
- }));
156
- var hasCallCenter = !!(selectedSocialMediaTypes === null || selectedSocialMediaTypes === void 0 ? void 0 : selectedSocialMediaTypes.find(function (s) { return s === SocialMediaTypes.CALL_CENTER; }));
157
- var hasPhysicalStore = !!(selectedSocialMediaTypes === null || selectedSocialMediaTypes === void 0 ? void 0 : selectedSocialMediaTypes.find(function (s) { return s === SocialMediaTypes.PHYSICAL_STORE; }));
158
- return (_jsx(ScreenContainer, __assign({ sx: { mb: show && (selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.length) === 0 ? 3 : 0 } }, { children: _jsx(Collapse, __assign({ in: show && (selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.length) > 0, sx: { mb: (selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.length) === 0 ? 3 : 0 } }, { children: _jsxs(ScreenContainer, __assign({ sx: __assign({ mt: 3, mb: 3, direction: 'ltr' }, sx) }, { children: [_jsx(SocialMediaGroupStyled, { defaultValue: socialMediaType, showSocialMediaTypes: selectedSocialMediaTypes, exclusive: true, onChange: function (e, value) {
159
- setSocialMediaType(value);
160
- } }), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.WEB && hasWebsite, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: websiteValue, onBlur: function () { return handleBlueWebsite(); }, startAdornment: _jsx(TextStyled, {}), placeholder: t('signup_website_placeholder'), warningType: 'alert', warningMessage: websiteError && t(websiteError), endAdornment: !websiteError && websiteValue ? _jsx(CheckIcon, {}) : websiteValue && _jsx(_Fragment, {}) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.APPLE_STORE && hasApp, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: appleStoreValue, startAdornment: _jsx(TextStyled, {}), placeholder: t('apple_store_placeholder'), warningType: 'alert', warningMessage: appleStoreError && t(appleStoreError), endAdornment: !appleStoreError && appleStoreValue ? (_jsx(CheckIcon, {})) : (appleStoreValue && _jsx(ClearIconStyled, { onClick: handleClear })) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.PLAY_STORE && hasApp, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: playStoreValue, startAdornment: _jsx(TextStyled, {}), placeholder: t('play_store_placeholder'), warningType: 'alert', warningMessage: playStoreError && t(playStoreError), endAdornment: !playStoreError && playStoreValue ? (_jsx(CheckIcon, {})) : (playStoreValue && _jsx(ClearIconStyled, { onClick: handleClear })) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.PHYSICAL_STORE && hasPhysicalStore, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: physicalStoreValue, startAdornment: _jsx(TextStyled, {}), placeholder: t('physical_store_placeholder'), warningType: 'alert', warningMessage: physicalStoreError && t(physicalStoreError), endAdornment: !physicalStoreError && physicalStoreValue ? (_jsx(CheckIcon, {})) : (physicalStoreValue && _jsx(ClearIconStyled, { onClick: handleClear })) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.TWITTER && hasSocial, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: twitterValue, startAdornment: _jsx(TextStyled, {}), placeholder: t('signup_twitter_placeholder'), warningType: 'alert', warningMessage: twitterError && t(twitterError), endAdornment: !twitterError && twitterValue ? (_jsx(CheckIcon, {})) : (twitterValue && _jsx(ClearIconStyled, { onClick: handleClear })) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.INSTAGRAM && hasSocial, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: instagramValue, startAdornment: _jsx(TextStyled, {}), placeholder: t('signup_instagram_placeholder'), warningType: 'alert', warningMessage: instagramError && t(instagramError), endAdornment: !instagramError && instagramValue ? (_jsx(CheckIcon, {})) : (instagramValue && _jsx(ClearIconStyled, { onClick: handleClear })) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.CALL_CENTER && hasCallCenter, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: callCenterValue, startAdornment: _jsx(TextStyled, {}), placeholder: t('call_center_placeholder'), warningType: 'alert', warningMessage: callCenterError && t(callCenterError), endAdornment: !callCenterError && callCenterValue ? (_jsx(CheckIcon, {})) : (callCenterValue && _jsx(ClearIconStyled, { onClick: handleClear })) }) }))] })) })) })));
145
+ React.useEffect(function () {
146
+ setDefaultActiveSocialId();
147
+ }, [setDefaultActiveSocialId]);
148
+ var getPlaceHolder = function (item) {
149
+ var _a, _b;
150
+ if (isAr)
151
+ return ((_a = item.name) === null || _a === void 0 ? void 0 : _a.ar) || '';
152
+ return ((_b = item.name) === null || _b === void 0 ? void 0 : _b.en) || '';
153
+ };
154
+ var hasError = React.useMemo(function () {
155
+ var _a;
156
+ var error = salesChannelsState.error;
157
+ return (error === null || error === void 0 ? void 0 : error.message) && 'choose_atleast_one_channel' !== ((_a = salesChannelsState.error) === null || _a === void 0 ? void 0 : _a.message);
158
+ }, [salesChannelsState]);
159
+ var linksErrorMsg = (_b = salesChannelsState.error) === null || _b === void 0 ? void 0 : _b.message;
160
+ return (_jsx(Box, { children: _jsx(Collapse, __assign({ in: show && selectedChannels.length > 0 }, { children: _jsxs(Box, __assign({ sx: { mb: 3, direction: 'ltr' } }, { children: [_jsx(SocialMediaGroupStyled, __assign({ exclusive: true, onChange: function (e, value) {
161
+ onChangeIcons(value);
162
+ } }, { children: selectedChannels.map(function (channel, index) {
163
+ var _a;
164
+ var isActive = activeSocialId === channel.id;
165
+ return ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) ? (channel.sub.map(function (sub, subIndex) {
166
+ var isSubActive = activeSocialId === sub.id;
167
+ return (_jsx(SocialMediaButtonStyled, __assign({ isShow: true, isActive: isSubActive, value: sub.id }, { children: _jsx(ToggleIconStyled, { isActive: isSubActive, src: (sub === null || sub === void 0 ? void 0 : sub.logo) || '' }) }), "sub_".concat(subIndex)));
168
+ })) : (_jsx(SocialMediaButtonStyled, __assign({ isShow: true, isActive: isActive, value: channel.id || '' }, { children: _jsx(ToggleIconStyled, { isActive: isActive, src: (channel === null || channel === void 0 ? void 0 : channel.logo) || '' }) }), index));
169
+ }) })), selectedChannels.map(function (channel, index) {
170
+ var _a;
171
+ var isActive = activeSocialId === channel.id;
172
+ return ((_a = channel.sub) === null || _a === void 0 ? void 0 : _a.length) ? (channel.sub.map(function (sub, subIndex) {
173
+ var isSubActive = activeSocialId === sub.id;
174
+ return (_jsx(Collapse, __assign({ in: isSubActive, timeout: 300 }, { children: _jsx(InputStyled, { onChange: function (e) {
175
+ onChangeInput(e.target.value, sub.id);
176
+ }, value: sub.address || '', startAdornment: _jsx(TextStyled, __assign({ sx: __assign({}, (isTwitter(sub.code) && { fontSize: '20px' })) }, { children: isWebsite(sub.code) ? "https://" : isTwitter(sub.code) ? "@" : '' })), placeholder: t(getPlaceHolder(sub)) }) }), "sub_".concat(subIndex)));
177
+ })) : (_jsx(Collapse, __assign({ in: isActive, timeout: 300 }, { children: _jsx(InputStyled, { onChange: function (e) {
178
+ onChangeInput(e.target.value, channel.id);
179
+ }, value: channel.address || '', startAdornment: _jsx(TextStyled, __assign({ sx: __assign({}, (isTwitter(channel.code) && { fontSize: '20px' })) }, { children: isWebsite(channel.code) ? "https://" : isTwitter(channel.code) ? "@" : '' })), placeholder: t(getPlaceHolder(channel)) }) }), index));
180
+ }), _jsx(Collapse, __assign({ in: !!hasError }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: t(linksErrorMsg) })) }))] })) })) }));
161
181
  };
162
182
  export default React.memo(SocialMedia);
@@ -22,7 +22,9 @@ import Text from '../../../../components/Text';
22
22
  import Warning from '../../../../components/Warning';
23
23
  import { useLanguage } from '../../../../hooks';
24
24
  import Collapse from '../../../../components/Collapse';
25
- import { EXTERNAL_LINKS } from '../../../../constants';
25
+ import { EXTERNAL_LINKS, TAP_WEBSITE } from '../../../../constants';
26
+ import { settingsSelector } from '../../../../app/settings';
27
+ import { useAppSelector } from '../../../../hooks';
26
28
  var TACContainerStyled = styled(Box)(function (_a) {
27
29
  var theme = _a.theme;
28
30
  return ({
@@ -69,12 +71,16 @@ var TAC = function (_a) {
69
71
  var t = useTranslation().t;
70
72
  var isAr = useLanguage().isAr;
71
73
  var control = useFormContext().control;
74
+ var settingsData = useAppSelector(settingsSelector).data;
72
75
  var tacControl = useController({ control: control, name: 'termAndConditionChecked' });
73
76
  var tacChecked = tacControl.field.value;
74
77
  var warningMessage = (_b = tacControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
78
+ var countryCode = settingsData.businessCountry.iso2.toLowerCase();
75
79
  var handleTACCheckedChange = function (event, checked) {
76
80
  tacControl.field.onChange(checked);
77
81
  };
78
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(TACContainerStyled, { children: [_jsx(CheckboxStyled, { disableRipple: true, disableFocusRipple: true, focusRipple: false, checked: tacChecked, onChange: handleTACCheckedChange }), _jsxs(TextStyled, { children: [t('read_agree_terms_and_conditions_message'), _jsx(LinkStyled, __assign({ href: isAr ? EXTERNAL_LINKS.TOS_AR : EXTERNAL_LINKS.TOS_EN, target: '_blank', underline: 'always' }, { children: t('terms_and_conditions_link_title') }))] })] }), _jsx(CollapseStyled, __assign({ in: !!warningMessage }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: warningMessage && t(warningMessage) })) }))] }) })));
82
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(TACContainerStyled, { children: [_jsx(CheckboxStyled, { disableRipple: true, disableFocusRipple: true, focusRipple: false, checked: tacChecked, onChange: handleTACCheckedChange }), _jsxs(TextStyled, { children: [t('read_agree_terms_and_conditions_message'), _jsx(LinkStyled, __assign({ href: isAr
83
+ ? TAP_WEBSITE + countryCode + EXTERNAL_LINKS.TOS_AR
84
+ : TAP_WEBSITE + countryCode + EXTERNAL_LINKS.TOS_EN, target: '_blank', underline: 'always' }, { children: t('terms_and_conditions_link_title') }))] })] }), _jsx(CollapseStyled, __assign({ in: !!warningMessage }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: warningMessage && t(warningMessage) })) }))] }) })));
79
85
  };
80
86
  export default React.memo(TAC);