@capillarytech/creatives-library 7.18.0-beta.0 → 8.0.0

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 (334) hide show
  1. package/app.js +27 -54
  2. package/assets/Line_Preview_English.svg +24 -0
  3. package/assets/Line_Preview_Japanese.svg +24 -0
  4. package/components/CapTagList/index.js +2 -2
  5. package/components/CapTagList/messages.js +8 -0
  6. package/components/Ckeditor/index.js +4 -2
  7. package/components/Ckeditor/style.scss +3 -0
  8. package/components/FormBuilder/_formBuilder.scss +4 -16
  9. package/components/FormBuilder/index.js +4 -3
  10. package/components/FormBuilder/messages.js +4 -0
  11. package/components/Sidebar/index.js +4 -4
  12. package/config/path.js +1 -1
  13. package/containers/App/constants.js +95 -0
  14. package/containers/App/index.js +52 -0
  15. package/containers/App/sagas.js +8 -3
  16. package/containers/Assets/Gallery/index.js +17 -3
  17. package/containers/Assets/Gallery/messages.js +4 -0
  18. package/containers/Assets/Gallery/sagas.js +14 -14
  19. package/containers/Cap/index.js +84 -50
  20. package/containers/Cap/sagas.js +20 -12
  21. package/containers/Cap/selectors.js +13 -13
  22. package/containers/Cap/tests/__snapshots__/index.test.js.snap +1 -1
  23. package/containers/Cap/tests/saga.test.js +81 -1
  24. package/containers/Dashboard/index.js +34 -17
  25. package/containers/Dashboard/sagas.js +7 -1
  26. package/containers/Ebill/index.js +16 -3
  27. package/containers/Ebill/sagas.js +18 -11
  28. package/containers/Email/index.js +20 -3
  29. package/containers/Email/sagas.js +34 -23
  30. package/containers/LanguageProvider/index.js +49 -31
  31. package/containers/LanguageProvider/tests/index.test.js +5 -3
  32. package/containers/Line/Create/index.js +15 -2
  33. package/containers/Line/Create/sagas.js +26 -17
  34. package/containers/Line/Edit/sagas.js +12 -13
  35. package/containers/Login/index.js +36 -11
  36. package/containers/MobilePush/Create/index.js +17 -2
  37. package/containers/MobilePush/Create/sagas.js +18 -12
  38. package/containers/MobilePush/Edit/index.js +20 -3
  39. package/containers/MobilePush/Edit/sagas.js +30 -20
  40. package/containers/Sms/Create/index.js +15 -2
  41. package/containers/Sms/Create/sagas.js +8 -6
  42. package/containers/Sms/Edit/index.js +15 -3
  43. package/containers/Sms/Edit/sagas.js +14 -8
  44. package/containers/TagList/constants.js +23 -0
  45. package/containers/Templates/actions.js +0 -5
  46. package/containers/Templates/index.js +47 -14
  47. package/containers/Templates/sagas.js +20 -23
  48. package/containers/WeChat/MapTemplates/index.js +19 -2
  49. package/containers/WeChat/MapTemplates/sagas.js +17 -17
  50. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -2
  51. package/containers/WeChat/RichmediaTemplates/Create/sagas.js +11 -8
  52. package/containers/WeChat/RichmediaTemplates/Edit/index.js +21 -2
  53. package/containers/WeChat/RichmediaTemplates/Edit/sagas.js +9 -5
  54. package/entry.js +2 -0
  55. package/global-styles.js +2 -2
  56. package/gtm/eventDefinitionsMap.js +1 -1
  57. package/helpers/intl-enzym-test-helpers.js +1 -1
  58. package/hoc/withReactRouterV3Compatibility.js +66 -0
  59. package/index.js +12 -0
  60. package/initialReducer.js +32 -0
  61. package/initialState.js +1 -0
  62. package/mfe-exposed-components.js +8 -0
  63. package/package.json +16 -11
  64. package/routes.js +206 -749
  65. package/services/api.js +62 -17
  66. package/services/tests/api.test.js +248 -1
  67. package/styles/components/navigation/_leftnav.scss +13 -0
  68. package/styles/containers/layout/_layoutPage.scss +14 -0
  69. package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +21 -16
  70. package/tests/store.test.js +5 -3
  71. package/translations/en.json +1 -9
  72. package/translations/ja-JP.json +0 -8
  73. package/translations/zh.json +0 -8
  74. package/utils/authWrapper.js +43 -17
  75. package/utils/cdnTransformation.js +73 -44
  76. package/utils/checkStore.js +21 -0
  77. package/utils/common.js +198 -8
  78. package/utils/commonUtils.js +17 -1
  79. package/utils/customAuthWrapper.js +62 -0
  80. package/utils/customConnectedAuthWrapper.js +26 -0
  81. package/utils/history.js +8 -0
  82. package/utils/injectReducer.js +2 -0
  83. package/utils/injectSaga.js +2 -0
  84. package/utils/tagValidations.js +2 -2
  85. package/utils/tests/cdnTransformation.test.js +6 -4
  86. package/utils/tests/common.mockdata.js +623 -0
  87. package/utils/tests/common.test.js +273 -0
  88. package/utils/tests/commonUtil.test.js +79 -0
  89. package/v2Components/CapDeviceContent/index.js +330 -0
  90. package/v2Components/CapDeviceContent/index.scss +115 -0
  91. package/v2Components/CapDeviceContent/messages.js +94 -0
  92. package/v2Components/CapDeviceContent/tests/index.test.js +89 -0
  93. package/v2Components/CapImageUpload/constants.js +6 -0
  94. package/v2Components/CapImageUpload/index.js +23 -15
  95. package/v2Components/CapImageUpload/index.scss +6 -0
  96. package/v2Components/CapImageUpload/messages.js +7 -7
  97. package/v2Components/CapInAppCTA/constants.js +25 -0
  98. package/v2Components/CapInAppCTA/index.js +279 -0
  99. package/v2Components/CapInAppCTA/index.scss +99 -0
  100. package/v2Components/CapInAppCTA/messages.js +85 -0
  101. package/v2Components/CapTagList/index.js +149 -26
  102. package/v2Components/CapTagList/messages.js +12 -0
  103. package/v2Components/CapTagList/style.scss +26 -0
  104. package/v2Components/CapVideoUpload/constants.js +6 -0
  105. package/v2Components/CapVideoUpload/index.js +48 -22
  106. package/v2Components/CapVideoUpload/index.scss +4 -2
  107. package/v2Components/CapVideoUpload/messages.js +10 -6
  108. package/v2Components/CapWhatsappQuickReply/index.js +255 -0
  109. package/v2Components/CapWhatsappQuickReply/index.scss +54 -0
  110. package/v2Components/CapWhatsappQuickReply/messages.js +32 -0
  111. package/v2Components/Ckeditor/index.js +56 -22
  112. package/v2Components/Ckeditor/style.scss +3 -0
  113. package/v2Components/Ckeditor/tests/index.test.js +44 -0
  114. package/v2Components/CmsTemplatesComponent/index.js +1 -0
  115. package/v2Components/CmsTemplatesComponent/messages.js +4 -0
  116. package/v2Components/EmailMobilePreview/index.js +4 -2
  117. package/v2Components/EmailPreviewV2/index.js +6 -4
  118. package/v2Components/EmailPreviewV2/tests/__snapshots__/index.test.js.snap +0 -3
  119. package/v2Components/FormBuilder/_formBuilder.scss +1 -0
  120. package/v2Components/FormBuilder/constants.js +1 -1
  121. package/v2Components/FormBuilder/index.js +111 -29
  122. package/v2Components/FormBuilder/messages.js +4 -0
  123. package/v2Components/FormBuilder/tests/index.test.js +5 -2
  124. package/v2Components/MobilePushPreviewV2/index.js +57 -22
  125. package/v2Components/NavigationBar/constants.js +1 -0
  126. package/v2Components/NavigationBar/index.js +84 -113
  127. package/v2Components/NavigationBar/messages.js +8 -0
  128. package/v2Components/NavigationBar/style.js +9 -0
  129. package/v2Components/NavigationBar/tests/index.test.js +32 -9
  130. package/v2Components/NavigationBar/tests/mockData.js +1 -0
  131. package/v2Components/NewCallTask/tests/index.test.js +5 -3
  132. package/v2Components/Pagination/index.js +2 -1
  133. package/v2Components/RenderRoute/RenderRoute.js +11 -0
  134. package/v2Components/RenderRoute/index.js +1 -0
  135. package/v2Components/TemplatePreview/_templatePreview.scss +535 -0
  136. package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_bottom.svg +11 -0
  137. package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_full.svg +11 -0
  138. package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_modal.svg +11 -0
  139. package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_top.svg +11 -0
  140. package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_bottom.svg +6 -0
  141. package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_full.svg +18 -0
  142. package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_modal.svg +7 -0
  143. package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_top.svg +13 -0
  144. package/v2Components/TemplatePreview/index.js +745 -362
  145. package/v2Components/TemplatePreview/messages.js +8 -0
  146. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +47 -14
  147. package/v2Components/TemplatePreview/tests/index.test.js +9 -0
  148. package/v2Components/WhatsappStatusContainer/_whatsappStatusContainer.scss +8 -1
  149. package/v2Containers/App/constants.js +12 -6
  150. package/v2Containers/App/sagas.js +0 -1
  151. package/v2Containers/Assets/Gallery/index.js +1 -0
  152. package/v2Containers/Assets/Gallery/sagas.js +15 -14
  153. package/v2Containers/BeeEditor/index.js +3 -1
  154. package/v2Containers/BeeEditor/sagas.js +8 -5
  155. package/v2Containers/CallTask/sagas.js +7 -1
  156. package/v2Containers/Cap/actions.js +4 -0
  157. package/v2Containers/Cap/constants.js +20 -1
  158. package/v2Containers/Cap/index.js +116 -17
  159. package/v2Containers/Cap/messages.js +8 -0
  160. package/v2Containers/Cap/reducer.js +18 -3
  161. package/v2Containers/Cap/sagas.js +64 -9
  162. package/v2Containers/Cap/selectors.js +27 -13
  163. package/v2Containers/Cap/tests/Cap.test.js +164 -0
  164. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +2 -1
  165. package/v2Containers/Cap/tests/actions.test.js +11 -0
  166. package/v2Containers/Cap/tests/reducer.test.js +59 -0
  167. package/v2Containers/Cap/tests/saga.test.js +181 -2
  168. package/v2Containers/Cap/tests/selectors.test.js +42 -18
  169. package/v2Containers/CapFacebookPreview/sagas.js +7 -5
  170. package/v2Containers/CreativesContainer/SlideBoxContent.js +86 -4
  171. package/v2Containers/CreativesContainer/SlideBoxFooter.js +4 -3
  172. package/v2Containers/CreativesContainer/SlideBoxHeader.js +30 -14
  173. package/v2Containers/CreativesContainer/constants.js +5 -0
  174. package/v2Containers/CreativesContainer/index.js +157 -38
  175. package/v2Containers/CreativesContainer/index.scss +12 -0
  176. package/v2Containers/CreativesContainer/messages.js +33 -1
  177. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +11 -0
  178. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +5 -2
  179. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +7 -1
  180. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +227 -0
  181. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +73 -0
  182. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +80 -0
  183. package/v2Containers/CreativesContainer/tests/index.test.js +16 -0
  184. package/v2Containers/Ebill/sagas.js +3 -10
  185. package/v2Containers/Email/index.js +38 -19
  186. package/v2Containers/Email/initialSchema.js +1 -1
  187. package/v2Containers/Email/sagas.js +22 -26
  188. package/v2Containers/EmailWrapper/index.js +18 -8
  189. package/v2Containers/FTP/index.js +2 -2
  190. package/v2Containers/FTP/sagas.js +3 -4
  191. package/v2Containers/Facebook/sagas.js +26 -17
  192. package/v2Containers/InApp/actions.js +64 -0
  193. package/v2Containers/InApp/constants.js +160 -0
  194. package/v2Containers/InApp/index.js +792 -0
  195. package/v2Containers/InApp/index.scss +50 -0
  196. package/v2Containers/InApp/messages.js +114 -0
  197. package/v2Containers/InApp/reducer.js +109 -0
  198. package/v2Containers/InApp/sagas.js +151 -0
  199. package/v2Containers/InApp/selectors.js +12 -0
  200. package/v2Containers/InApp/tests/action.test.js +53 -0
  201. package/v2Containers/InApp/tests/index.test.js +165 -0
  202. package/v2Containers/InApp/tests/mockData.js +898 -0
  203. package/v2Containers/InApp/tests/reducer.test.js +177 -0
  204. package/v2Containers/InApp/tests/sagas.test.js +391 -0
  205. package/v2Containers/InApp/utils.js +12 -0
  206. package/v2Containers/LanguageProvider/index.js +17 -5
  207. package/v2Containers/LanguageProvider/reducer.js +3 -2
  208. package/v2Containers/LanguageProvider/sagas.js +7 -8
  209. package/v2Containers/LanguageProvider/selectors.js +2 -1
  210. package/v2Containers/LanguageProvider/tests/index.test.js +5 -2
  211. package/v2Containers/LanguageProvider/tests/reducer.test.js +6 -3
  212. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +28 -16
  213. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -2
  214. package/v2Containers/Line/Container/ImageCarousel/tests/content.test.js +5 -3
  215. package/v2Containers/Line/Container/ImageCarousel/tests/index.test.js +5 -3
  216. package/v2Containers/Line/Container/ImageMap/index.js +1 -1
  217. package/v2Containers/Line/Container/Text/index.js +16 -1
  218. package/v2Containers/Line/Container/Video/index.js +2 -1
  219. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +18134 -107
  220. package/v2Containers/Line/Container/Wrapper/tests/index.test.js +5 -3
  221. package/v2Containers/Line/Container/Wrapper/utils.js +1 -1
  222. package/v2Containers/Line/Container/index.js +4 -0
  223. package/v2Containers/Line/Container/sagas.js +30 -20
  224. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +123 -81
  225. package/v2Containers/Line/Container/tests/index.test.js +5 -2
  226. package/v2Containers/Login/index.js +1 -2
  227. package/v2Containers/MobilePush/Create/index.js +40 -17
  228. package/v2Containers/MobilePush/Create/sagas.js +18 -12
  229. package/v2Containers/MobilePush/Edit/index.js +16 -7
  230. package/v2Containers/MobilePush/Edit/sagas.js +30 -20
  231. package/v2Containers/MobilepushWrapper/index.js +3 -0
  232. package/v2Containers/Rcs/sagas.js +14 -14
  233. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +123 -87
  234. package/v2Containers/Rcs/tests/index.test.js +5 -3
  235. package/v2Containers/Sms/Create/sagas.js +10 -6
  236. package/v2Containers/Sms/Edit/sagas.js +14 -8
  237. package/v2Containers/SmsTrai/Create/sagas.js +9 -10
  238. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -4
  239. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +12 -8
  240. package/v2Containers/SmsTrai/Edit/tests/index.test.js +5 -3
  241. package/v2Containers/TagList/_tagList.scss +18 -0
  242. package/v2Containers/TagList/index.js +81 -42
  243. package/v2Containers/TagList/tests/TagList.test.js +6 -7
  244. package/v2Containers/TagList/tests/mockdata.js +10 -166
  245. package/v2Containers/TagList/tests/utils.test.js +17 -0
  246. package/v2Containers/TagList/utils.js +15 -0
  247. package/v2Containers/Templates/_templates.scss +60 -5
  248. package/v2Containers/Templates/actions.js +6 -5
  249. package/v2Containers/Templates/constants.js +2 -1
  250. package/v2Containers/Templates/index.js +576 -181
  251. package/v2Containers/Templates/messages.js +52 -8
  252. package/v2Containers/Templates/reducer.js +3 -1
  253. package/v2Containers/Templates/sagas.js +54 -38
  254. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +669 -43
  255. package/v2Containers/Templates/tests/actions.test.js +19 -0
  256. package/v2Containers/Templates/tests/index.test.js +53 -1
  257. package/v2Containers/Templates/tests/mockData.js +45 -1
  258. package/v2Containers/Templates/tests/reducer.test.js +50 -0
  259. package/v2Containers/Templates/tests/sagas.test.js +116 -3
  260. package/v2Containers/Templates/tests/selector.test.js +17 -0
  261. package/v2Containers/TemplatesV2/index.js +180 -8
  262. package/v2Containers/TemplatesV2/messages.js +8 -0
  263. package/v2Containers/TemplatesV2/tests/index.test.js +104 -0
  264. package/v2Containers/TemplatesV2/tests/mockData.js +685 -0
  265. package/v2Containers/Viber/constants.js +58 -0
  266. package/v2Containers/Viber/index.js +404 -421
  267. package/v2Containers/Viber/index.scss +107 -0
  268. package/v2Containers/Viber/messages.js +70 -2
  269. package/v2Containers/Viber/sagas.js +22 -14
  270. package/v2Containers/Viber/style.js +20 -0
  271. package/v2Containers/Viber/tests/index.test.js +299 -0
  272. package/v2Containers/Viber/tests/mockData.js +134 -0
  273. package/v2Containers/WeChat/MapTemplates/sagas.js +22 -14
  274. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +12 -11
  275. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +9 -5
  276. package/v2Containers/Whatsapp/actions.js +16 -0
  277. package/v2Containers/Whatsapp/constants.js +24 -0
  278. package/v2Containers/Whatsapp/index.js +892 -222
  279. package/v2Containers/Whatsapp/index.scss +91 -1
  280. package/v2Containers/Whatsapp/messages.js +98 -1
  281. package/v2Containers/Whatsapp/reducer.js +19 -0
  282. package/v2Containers/Whatsapp/sagas.js +67 -12
  283. package/v2Containers/Whatsapp/styles.scss +35 -0
  284. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34983 -24886
  285. package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +12 -0
  286. package/v2Containers/Whatsapp/tests/actions.test.js +21 -0
  287. package/v2Containers/Whatsapp/tests/index.test.js +17 -4
  288. package/v2Containers/Whatsapp/tests/mockData.js +77 -0
  289. package/v2Containers/Whatsapp/tests/reducer.test.js +67 -0
  290. package/v2Containers/Whatsapp/tests/saga.test.js +201 -0
  291. package/v2Containers/Whatsapp/tests/utils.test.js +18 -0
  292. package/v2Containers/Whatsapp/utils.js +65 -4
  293. package/v2Containers/Zalo/actions.js +24 -0
  294. package/v2Containers/Zalo/constants.js +59 -0
  295. package/v2Containers/Zalo/index.js +548 -0
  296. package/v2Containers/Zalo/index.scss +75 -0
  297. package/v2Containers/Zalo/messages.js +86 -0
  298. package/v2Containers/Zalo/reducer.js +63 -0
  299. package/v2Containers/Zalo/saga.js +45 -0
  300. package/v2Containers/Zalo/selectors.js +19 -0
  301. package/v2Containers/Zalo/tests/actions.test.js +26 -0
  302. package/v2Containers/Zalo/tests/index.test.js +149 -0
  303. package/v2Containers/Zalo/tests/mockData.js +11527 -0
  304. package/v2Containers/Zalo/tests/reducer.test.js +96 -0
  305. package/v2Containers/Zalo/tests/saga.test.js +118 -0
  306. package/v2Containers/Zalo/tests/selector.test.js +51 -0
  307. package/v2Containers/mockdata.js +1531 -680
  308. package/containers/TestPage/constants.js +0 -7
  309. package/containers/TestPage/index.js +0 -31
  310. package/containers/TestPage/messages.js +0 -13
  311. package/containers/TestPage/reducer.js +0 -21
  312. package/containers/TestPage/sagas.js +0 -11
  313. package/containers/Testv2/actions.js +0 -15
  314. package/containers/Testv2/constants.js +0 -7
  315. package/containers/Testv2/index.js +0 -47
  316. package/containers/Testv2/messages.js +0 -21
  317. package/containers/Testv2/reducer.js +0 -23
  318. package/containers/Testv2/sagas.js +0 -11
  319. package/containers/Testv2/selectors.js +0 -25
  320. package/reducers.js +0 -73
  321. package/store.js +0 -61
  322. package/utils/tests/asyncInjectors.test.js +0 -173
  323. package/v2Containers/TestPage/constants.js +0 -7
  324. package/v2Containers/TestPage/index.js +0 -31
  325. package/v2Containers/TestPage/messages.js +0 -13
  326. package/v2Containers/TestPage/reducer.js +0 -21
  327. package/v2Containers/TestPage/sagas.js +0 -11
  328. package/v2Containers/Testv2/actions.js +0 -15
  329. package/v2Containers/Testv2/constants.js +0 -7
  330. package/v2Containers/Testv2/index.js +0 -47
  331. package/v2Containers/Testv2/messages.js +0 -21
  332. package/v2Containers/Testv2/reducer.js +0 -23
  333. package/v2Containers/Testv2/sagas.js +0 -11
  334. package/v2Containers/Testv2/selectors.js +0 -25
@@ -1,38 +1,64 @@
1
1
  /**
2
2
  * Created by vivek on 24/5/17.
3
3
  */
4
- import { routerActions } from 'react-router-redux';
5
- import { UserAuthWrapper } from 'redux-auth-wrapper';
4
+
5
+ import { connectedRouterRedirect } from 'redux-auth-wrapper/history4/redirect';
6
+ import connectedAuthWrapper from 'redux-auth-wrapper/connectedAuthWrapper';
7
+ import { routerActions } from 'connected-react-router';
8
+ // import { routerActions } from 'react-router-redux';
9
+ // import { UserAuthWrapper } from 'redux-auth-wrapper';
10
+ import { createSelector } from 'reselect';
6
11
  import { makeSelectAuthenticated } from '../containers/Cap/selectors';
12
+ // import config from '../config/app';
7
13
  const orginUrl = window.location.origin;
14
+ // const loginUrl = '/auth/login';
8
15
 
9
- const getIsLoggedIn = () => {
16
+ export const getIsLoggedIn = () => {
10
17
  let isLoggedIn = false;
11
- if (process.env.NODE_ENV === "production" && JSON.parse(window.localStorage.getItem('isLoggedIn'))) {
18
+ if (
19
+ process.env.NODE_ENV === 'production' &&
20
+ JSON.parse(window.localStorage.getItem('isLoggedIn'))
21
+ ) {
12
22
  isLoggedIn = true;
13
-
14
- } else if (localStorage.getItem("token")) {
23
+ } else if (localStorage.getItem('token')) {
15
24
  isLoggedIn = true;
16
-
17
25
  }
18
26
  return isLoggedIn;
19
27
  };
20
28
 
29
+ const makeSelectAuthenticatedWithPredicate = state =>
30
+ createSelector(
31
+ makeSelectAuthenticated(state),
32
+ global => global && global.isLoggedIn,
33
+ );
21
34
 
22
- // Take the regular authentication & redirect to login from before
23
- export const UserIsAuthenticated = UserAuthWrapper({
24
- authSelector: makeSelectAuthenticated(),
25
- redirectAction: routerActions.replace,
35
+ export const UserIsAuthenticated = connectedAuthWrapper({
36
+ authenticatedSelector: makeSelectAuthenticatedWithPredicate(),
26
37
  predicate: () => getIsLoggedIn(),
27
38
  wrapperDisplayName: 'UserIsAuthenticated',
28
39
  failureRedirectPath: `${orginUrl}/auth/login`,
40
+ redirectAction: routerActions.replace,
29
41
  });
30
42
 
31
- export const UserIsNotAuthenticated = UserAuthWrapper({
32
- authSelector: makeSelectAuthenticated(),
33
- redirectAction: routerActions.replace,
34
- wrapperDisplayName: 'UserIsNotAuthenticated',
43
+ const makeSelectNotAuthenticatedWithPredicate = state =>
44
+ createSelector(
45
+ makeSelectAuthenticated(state),
46
+ global => !(global && global.isLoggedIn),
47
+ );
48
+
49
+ export const UserIsNotAuthenticated = connectedRouterRedirect({
50
+ authenticatedSelector: makeSelectNotAuthenticatedWithPredicate(),
35
51
  predicate: () => !getIsLoggedIn(),
36
- failureRedirectPath: (state, ownProps) => ownProps.location.query.redirect ? ownProps.location.query.redirect : '/campaign',
52
+ wrapperDisplayName: 'UserIsNotAuthenticated',
53
+ redirectAction: routerActions.replace,
54
+ redirectPath: (state, ownProps) => {
55
+ // console.log('ownProps', ownProps);
56
+ const urlParams = new URLSearchParams(ownProps.location.search);
57
+ const redirectUrl = urlParams.get('redirect')
58
+ ? urlParams.get('redirect')
59
+ : '/';
60
+ return redirectUrl;
61
+ },
62
+ // redirectPath: loginUrl,
37
63
  allowRedirectBack: false,
38
- });
64
+ });
@@ -28,6 +28,7 @@ const CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX_KEY = 'CREATIVES_CDN_TRANSFORMATIO
28
28
  const CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY_KEY = 'CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY';
29
29
  const CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY_MAPPING_KEY = 'CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY_MAPPING';
30
30
  export const CREATIVES_S3_ASSET_FILESIZES = 'CREATIVES_S3_ASSET_FILESIZES';
31
+ export const S3_CDN_MAP_KEY = 'S3_CDN_MAP';
31
32
 
32
33
  const HTTPS_STR = "https://"
33
34
  const ALLOWED_EXTENSIONS_STR = ".*(?:jpg|png|jpeg|gif)$"
@@ -110,6 +111,31 @@ const CHANNEL_CONFIGS = {
110
111
  }
111
112
  };
112
113
 
114
+ /**
115
+ * Retrieves the cluster-specific S3 CDN configuration from the given URL based on S3_CDN_MAP.
116
+ *
117
+ * @param {string} url - The URL to check for cluster-specific S3 CDN configuration.
118
+ * @returns {Object} - An object containing the cluster-specific S3 bucket path and CDN base URL.
119
+ */
120
+ const getClusterSpecificS3CdnConfigFromUrl = (url) => {
121
+ const S3_CDN_MAP = getLocalStorageItem(S3_CDN_MAP_KEY, true);
122
+ let CREATIVES_S3_BUCKET_PATH;
123
+ let CREATIVES_CDN_BASE_URL;
124
+
125
+ Object.entries(S3_CDN_MAP).some(([clusterS3Url, cdnConfigs]) => {
126
+ const {cdn_host, bucket_path} = cdnConfigs;
127
+ const s3UrlRegex = new RegExp(`^https://${clusterS3Url}/${bucket_path}/\.*`);
128
+ const cdnUrlRegex = new RegExp(`^https://${cdn_host}/\.*${bucket_path}/\.*`);
129
+
130
+ if (s3UrlRegex.test(url) || cdnUrlRegex.test(url)) {
131
+ CREATIVES_S3_BUCKET_PATH = bucket_path;
132
+ CREATIVES_CDN_BASE_URL = `https://${cdn_host}`;
133
+ return true;
134
+ }
135
+ });
136
+ return { CREATIVES_S3_BUCKET_PATH, CREATIVES_CDN_BASE_URL };
137
+ }
138
+
113
139
  /**
114
140
  *
115
141
  * @param {string} url : required
@@ -144,88 +170,86 @@ export const getCdnUrl = ({
144
170
  emailOverrideQuality = null,
145
171
  }) => {
146
172
  try{
173
+ let cdnUrl;
147
174
  const channelName = receivedChannelName?.toUpperCase();
148
175
  const channelSubType = receivedChannelSubType?.toUpperCase();
149
-
150
- const CREATIVES_CDN_BASE_URL = getLocalStorageItem(CREATIVES_CDN_BASE_URL_KEY);
176
+
151
177
  const CREATIVES_CDN_QUALITY_CONFIG = getLocalStorageItem(CREATIVES_CDN_QUALITY_CONFIG_KEY, true);
152
178
  const CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX = getLocalStorageItem(CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX_KEY);
153
- let CREATIVES_S3_BUCKET_PATH = getLocalStorageItem(CREATIVES_S3_BUCKET_PATH_KEY);
154
-
155
- //remove all leading and trailing forward slash with empty string, if leading/trailing forward slash is present in node env by mistake then url will not be correct hence removing them.
156
- CREATIVES_S3_BUCKET_PATH = CREATIVES_S3_BUCKET_PATH?.replace(/^\/|\/$/g, '');
179
+
180
+ //Get cluster specific S3 CDN configuration from the given URL based on S3_CDN_MAP
181
+ let { CREATIVES_S3_BUCKET_PATH, CREATIVES_CDN_BASE_URL } = getClusterSpecificS3CdnConfigFromUrl(url);
157
182
 
158
183
  //Basic validations on data stored in local storage.
159
184
  if (
160
185
  typeof CREATIVES_CDN_QUALITY_CONFIG !== "object" ||
161
186
  Array.isArray(CREATIVES_CDN_QUALITY_CONFIG) ||
162
187
  CREATIVES_CDN_QUALITY_CONFIG === null ||
163
- typeof CREATIVES_CDN_BASE_URL !== "string" ||
164
- typeof CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX !== "string" ||
165
- typeof CREATIVES_S3_BUCKET_PATH !== 'string'
188
+ !CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX ||
189
+ !CREATIVES_S3_BUCKET_PATH ||
190
+ !CREATIVES_CDN_BASE_URL
166
191
  )
167
192
  return url;
168
-
193
+
194
+ //remove all leading and trailing forward slash with empty string, if leading/trailing forward slash is present in node env by mistake then url will not be correct hence removing them.
195
+ CREATIVES_S3_BUCKET_PATH = CREATIVES_S3_BUCKET_PATH?.replace(/^\/|\/$/g, '');
196
+
169
197
  const QUALITY = CREATIVES_CDN_QUALITY_CONFIG?.[channelName] || CREATIVES_CDN_QUALITY_CONFIG?.DEFAULT;
198
+ const [_, assetKey] = url.split(CREATIVES_S3_BUCKET_PATH);
170
199
 
171
200
  const regexWithExtension = new RegExp(HTTPS_STR + ANY_STR + CREATIVES_S3_BUCKET_PATH + ANY_STR + ALLOWED_EXTENSIONS_STR)
172
201
  const regexWithoutExtension = new RegExp(HTTPS_STR + ANY_STR + CREATIVES_S3_BUCKET_PATH + ANY_STR);
173
-
174
- let skipTransformations = true;
175
-
202
+
176
203
  if (
177
204
  !regexWithoutExtension.test(url) ||
178
205
  !CHANNEL_CONFIGS?.[channelName] ||
179
206
  (channelSubType && !CHANNEL_CONFIGS?.[channelName]?.[channelSubType]) ||
180
- !CREATIVES_CDN_BASE_URL ||
181
- !CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX ||
182
- !QUALITY
207
+ !QUALITY ||
208
+ !assetKey
183
209
  )
184
210
  return url;
211
+
212
+ let skipTransformations = true;
213
+ let applicableTransformations;
185
214
 
186
215
  //Skip transformations if extensions are not proper. Else consider transformations if available.
187
216
  if(regexWithExtension.test(url)){
188
217
  skipTransformations = false;
189
218
  }
190
-
191
- const [, assetKey] = url.split(CREATIVES_S3_BUCKET_PATH);
192
-
193
- let newUrl = `${CREATIVES_CDN_BASE_URL}`;
194
-
195
- let applicableTransformations;
196
219
 
220
+ //Skip trasformations if transformation properties are not present in channel/subchannel.
197
221
  if (channelSubType) {
198
222
  applicableTransformations =
199
223
  CHANNEL_CONFIGS?.[channelName]?.[channelSubType]?.transformations;
200
224
  } else {
201
225
  applicableTransformations = CHANNEL_CONFIGS?.[channelName]?.transformations;
202
226
  }
227
+
228
+ cdnUrl = `${CREATIVES_CDN_BASE_URL}`;
203
229
 
204
230
  if (!isEmpty(applicableTransformations) && !skipTransformations) {
231
+ cdnUrl += `/${CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX}/`;
205
232
 
206
- newUrl += `/${CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX}/`;
207
-
208
- // Object.keys(applicableTransformations)?.forEach((transformationParam) => {
209
233
  forOwn(applicableTransformations, (transformationParamVal, transformationParam)=>{
210
234
  try {
211
235
  switch (transformationParam) {
212
236
  case "height":
213
237
  if (transformationParamVal === SPECIFIED && height) {
214
- newUrl += `${transformationParam}=${height},`;
238
+ cdnUrl += `${transformationParam}=${height},`;
215
239
  } else if(transformationParamVal !== SPECIFIED && isNumber(transformationParamVal)) {
216
- newUrl += `${transformationParam}=${transformationParamVal},`;
240
+ cdnUrl += `${transformationParam}=${transformationParamVal},`;
217
241
  }
218
242
  break;
219
243
  case "width":
220
244
  if (transformationParamVal === SPECIFIED && width) {
221
- newUrl += `${transformationParam}=${width},`;
245
+ cdnUrl += `${transformationParam}=${width},`;
222
246
  } else if(transformationParamVal !== SPECIFIED && isNumber(transformationParamVal)) {
223
- newUrl += `${transformationParam}=${transformationParamVal},`;
247
+ cdnUrl += `${transformationParam}=${transformationParamVal},`;
224
248
  }
225
249
  break;
226
250
  case "format":
227
251
  if(transformationParamVal){
228
- newUrl += `${transformationParam}=${transformationParamVal},`;
252
+ cdnUrl += `${transformationParam}=${transformationParamVal},`;
229
253
  }
230
254
  break;
231
255
  case "quality":
@@ -234,12 +258,12 @@ export const getCdnUrl = ({
234
258
  emailOverrideQuality &&
235
259
  typeof emailOverrideQuality === "number"
236
260
  ) {
237
- newUrl += `${transformationParam}=${emailOverrideQuality},`;
261
+ cdnUrl += `${transformationParam}=${emailOverrideQuality},`;
238
262
  } else {
239
- newUrl += `${transformationParam}=${QUALITY},`;
263
+ cdnUrl += `${transformationParam}=${QUALITY},`;
240
264
  }
241
265
  } else {
242
- newUrl += `${transformationParam}=100,`;
266
+ cdnUrl += `${transformationParam}=100,`;
243
267
  }
244
268
  break;
245
269
  }
@@ -251,9 +275,8 @@ export const getCdnUrl = ({
251
275
  }
252
276
  })
253
277
  }
254
- newUrl += `/${CREATIVES_S3_BUCKET_PATH}${assetKey}`;
255
- return newUrl;
256
-
278
+ cdnUrl += `/${CREATIVES_S3_BUCKET_PATH}${assetKey}`;
279
+ return cdnUrl;
257
280
  }catch(e){
258
281
  Bugsnag.leaveBreadcrumb("Some exception occurred in getCdnUrl");
259
282
  Bugsnag.notify(e, (event) => {
@@ -389,6 +412,7 @@ export function removeAllCdnLocalStorageItems() {
389
412
  removeLocalStorageItem(CREATIVES_S3_BUCKET_PATH_KEY);
390
413
  removeLocalStorageItem(CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY_KEY);
391
414
  removeLocalStorageItem(CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY_MAPPING_KEY);
415
+ removeLocalStorageItem(S3_CDN_MAP_KEY);
392
416
  }catch(e){
393
417
  Bugsnag.leaveBreadcrumb("some error occured while deleting all keys for cdn");
394
418
  Bugsnag.notify(e, (event) => {
@@ -476,6 +500,13 @@ export function saveCdnConfigs(configsResponse) {
476
500
  CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY_MAPPING_KEY
477
501
  );
478
502
  }
503
+
504
+ if (configsResponse?.s3CdnMap) {
505
+ const strigifiedS3CdnMap = JSON.stringify(configsResponse?.s3CdnMap);
506
+ localStorage.setItem(S3_CDN_MAP_KEY, strigifiedS3CdnMap);
507
+ } else {
508
+ removeLocalStorageItem(S3_CDN_MAP_KEY);
509
+ }
479
510
  } catch (e) {
480
511
  Bugsnag.leaveBreadcrumb("some error while setting localstorage cdn configs");
481
512
  Bugsnag.notify(e, (event) => {
@@ -509,8 +540,8 @@ export function storeS3FileSizeDetails(url, fileSize) {
509
540
  export function getKeyFromS3Url(url) {
510
541
  if (typeof url !== "string") return url;
511
542
 
512
- const bucketPathWithSlash =
513
- getLocalStorageItem(CREATIVES_S3_BUCKET_PATH_KEY) + "/";
543
+ const { CREATIVES_S3_BUCKET_PATH } = getClusterSpecificS3CdnConfigFromUrl(url);
544
+ const bucketPathWithSlash = CREATIVES_S3_BUCKET_PATH + "/";
514
545
  const [, key] = url.split(bucketPathWithSlash);
515
546
  return key;
516
547
  }
@@ -527,22 +558,20 @@ export function getKeyFromS3Url(url) {
527
558
  * 'isCdnUrl' refers that it is cdn url.
528
559
  */
529
560
  export function checkValidUrl(url){
561
+ const { CREATIVES_S3_BUCKET_PATH, CREATIVES_CDN_BASE_URL } = getClusterSpecificS3CdnConfigFromUrl(url);
530
562
 
531
- const CREATIVES_CDN_BASE_URL = getLocalStorageItem(CREATIVES_CDN_BASE_URL_KEY);
532
-
533
- let CREATIVES_S3_BUCKET_PATH = getLocalStorageItem(CREATIVES_S3_BUCKET_PATH_KEY);
534
563
  const regexWithExtension = new RegExp(HTTPS_STR + ANY_STR + CREATIVES_S3_BUCKET_PATH + ANY_STR + ALLOWED_EXTENSIONS_STR)
535
-
564
+
536
565
  //It is S3 url if tests with regex but doesn't contain cdn base url.
537
-
566
+
538
567
  const isValidUrl = regexWithExtension.test(url);
539
568
  const isCdnUrl = url.includes(CREATIVES_CDN_BASE_URL);
540
569
  const isS3Url = isValidUrl && !isCdnUrl;
541
570
 
542
571
  return {
543
572
  isValidUrl,
544
- isCdnUrl,
545
573
  isS3Url,
574
+ isCdnUrl,
546
575
  }
547
576
  }
548
577
 
@@ -0,0 +1,21 @@
1
+ import { conformsTo, isFunction, isObject } from 'lodash';
2
+ import invariant from 'invariant';
3
+
4
+ /**
5
+ * Validate the shape of redux store
6
+ */
7
+ export default function checkStore(store) {
8
+ const shape = {
9
+ dispatch: isFunction,
10
+ subscribe: isFunction,
11
+ getState: isFunction,
12
+ replaceReducer: isFunction,
13
+ runSaga: isFunction,
14
+ injectedReducers: isObject,
15
+ injectedSagas: isObject,
16
+ };
17
+ invariant(
18
+ conformsTo(store, shape),
19
+ '(app/utils...) injectors: Expected a valid redux store',
20
+ );
21
+ }
package/utils/common.js CHANGED
@@ -1,11 +1,28 @@
1
1
  import _ from 'lodash';
2
+ import Bugsnag from '@bugsnag/js';
2
3
  import { Auth } from '@capillarytech/cap-ui-utils';
3
4
  import {
4
5
  STORE2DOOR_PLUS_ENABLED,
5
6
  TRAI_DLT,
6
7
  CARD_RELATED_TAGS,
7
8
  CARD_BASED_SCOPE,
9
+ HOSPITALITY_RELATED_TAGS,
10
+ HOSPITALITY_BASED_SCOPE,
11
+ GIFT_CARDS,
12
+ PROMO_ENGINE,
13
+ EXTENDED_TAG,
14
+ CUSTOMER_EXTENDED_FIELD,
15
+ CUSTOM_TAG,
16
+ REGISTRATION_CUSTOM_FIELD,
17
+ JP_LOCALE_HIDE_FEATURE,
18
+ ENABLE_CUSTOMER_BARCODE_TAG,
19
+ BADGES_UI_ENABLED,
20
+ BADGES_ENROLL,
21
+ EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
22
+ BADGES_ISSUE,
23
+ ENABLE_WECHAT,
8
24
  } from '../containers/App/constants';
25
+ import { apiMessageFormatHandler } from './commonUtils';
9
26
 
10
27
  export function getUserNameById(userId, allUserList) {
11
28
  let userName = "";
@@ -38,6 +55,15 @@ export function removeLinksFromHtmlContent(content) {
38
55
  return copyContent;
39
56
  }
40
57
 
58
+ export function iframePreviewAdjustWidth(content) {
59
+ const doc = document.createElement('html');
60
+ doc.innerHTML = content;
61
+ let copyContent = doc.cloneNode(true).outerHTML;
62
+ copyContent = copyContent.replace(/<img /g, '<img width="310" ');
63
+ doc.remove();
64
+ return copyContent;
65
+ }
66
+
41
67
  export const hasStore2DoorFeature = Auth.hasFeatureAccess.bind(
42
68
  null,
43
69
  STORE2DOOR_PLUS_ENABLED,
@@ -53,16 +79,61 @@ export const hasCardBasedScope = Auth.hasFeatureAccess.bind(
53
79
  CARD_BASED_SCOPE,
54
80
  );
55
81
 
82
+ export const hasHospitalityBasedScope = Auth.hasFeatureAccess.bind(
83
+ null,
84
+ HOSPITALITY_BASED_SCOPE,
85
+ );
86
+ export const hasPromoFeature = Auth.hasFeatureAccess.bind(
87
+ null,
88
+ PROMO_ENGINE,
89
+ );
90
+
91
+ export const hasGiftVoucherFeature = Auth.hasFeatureAccess.bind(
92
+ null,
93
+ GIFT_CARDS,
94
+ );
95
+
96
+ export const hasBadgesFeature = Auth.hasFeatureAccess.bind(
97
+ null,
98
+ BADGES_UI_ENABLED
99
+ );
100
+
101
+ export const hasJPLocaleHideFeatureEnabled = Auth.hasFeatureAccess.bind(
102
+ null,
103
+ JP_LOCALE_HIDE_FEATURE,
104
+ );
105
+
106
+ export const hasWechatFeatureEnabled = Auth.hasFeatureAccess.bind(
107
+ null,
108
+ ENABLE_WECHAT,
109
+ );
110
+
111
+ export const hasCustomerBarcodeFeatureEnabled = Auth.hasFeatureAccess.bind(
112
+ null,
113
+ ENABLE_CUSTOMER_BARCODE_TAG,
114
+ );
115
+
116
+ export const isEmailUnsubscribeTagMandatory = Auth.hasFeatureAccess.bind(
117
+ null,
118
+ EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
119
+ );
120
+ //filtering tags based on scope
121
+ export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
122
+ (tag) => !tagsToFilter?.includes(tag?.definition?.value)
123
+ );
124
+
56
125
  export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails = [], disableTagsDetails = {}}) {
57
- console.log('populating tags', (tagsList || []).length);
58
126
  const mainTags = {};
59
127
  const { disableRelatedTags, childTagsToDisable, parentTagstoDisable} = disableTagsDetails;
60
128
 
61
129
  let clonedTags = tagsList;
62
130
  if (!hasCardBasedScope()) {
63
- clonedTags = _.filter(tagsList, (tag) =>
64
- !CARD_RELATED_TAGS.includes(tag?.definition?.value)
65
- );
131
+ //filtering CARD_RELATED_TAGS if org does not have CARD_BASED_SCOPE feature enabled
132
+ clonedTags = filterTags(CARD_RELATED_TAGS, tagsList);
133
+ }
134
+ if (!hasHospitalityBasedScope()) {
135
+ //filtering HOSPITALITY_RELATED_TAGS if org does not have HOSPITALITY_BASED_SCOPE feature enabled
136
+ clonedTags = filterTags(HOSPITALITY_RELATED_TAGS, tagsList);
66
137
  }
67
138
  _.forEach(clonedTags, (temp) => {
68
139
  const tag = temp.definition;
@@ -118,8 +189,12 @@ export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails
118
189
  }
119
190
  });
120
191
  let combinedTags = result;
121
- if (offerDetails.length) {
122
- combinedTags = transformCouponTags(offerDetails, result);
192
+ if (offerDetails?.length) {
193
+ if ([BADGES_ENROLL, BADGES_ISSUE].includes(offerDetails?.[0]?.type)) {
194
+ combinedTags = transformBadgeTags(offerDetails, result);
195
+ } else {
196
+ combinedTags = transformCouponTags(offerDetails, result);
197
+ }
123
198
  }
124
199
  return getTreeStructureData(combinedTags);
125
200
  }
@@ -145,7 +220,7 @@ function transformCouponTags(offerDetails, allTags) {
145
220
  return {
146
221
  ...obj,
147
222
  ...tempObj,
148
- couponSeriesId: id,
223
+ incentiveSeriesId: id,
149
224
  };
150
225
  };
151
226
  offerDetails.forEach((offer) => {
@@ -168,7 +243,7 @@ function transformCouponTags(offerDetails, allTags) {
168
243
  'tag-header': true,
169
244
  'name': couponNameFinal || couponId,
170
245
  'desc': couponNameFinal || couponId,
171
- 'couponSeriesId': couponId,
246
+ 'incentiveSeriesId': couponId,
172
247
  'subtags': couponSubTags,
173
248
  'resolved': true,
174
249
  'couponTags': true,
@@ -179,6 +254,44 @@ function transformCouponTags(offerDetails, allTags) {
179
254
  return allTags;
180
255
  }
181
256
 
257
+ export function transformBadgeTags(badgeDetails = [], allTags) {
258
+ const badgeTags = {};
259
+ const badgeTagsKeys = Object.keys(_.get(allTags, 'Badge.subtags', []));
260
+ const withBadgeId = (obj, id) => {
261
+ const tempObj = {};
262
+ if (obj?.subtags) {
263
+ tempObj.subtags = _.mapValues(obj.subtags, (tag) => ({
264
+ ...withBadgeId(tag, id),
265
+ }));
266
+ }
267
+ return {
268
+ ...obj,
269
+ ...tempObj,
270
+ incentiveSeriesId: id,
271
+ };
272
+ };
273
+ badgeDetails.forEach((offer) => {
274
+ const { badgesMetaId, badgeName } = offer || {};
275
+ const badgeSubTags = {};
276
+ badgeTagsKeys.forEach((badgeTagKey) => {
277
+ const badgeSubTagsObj = withBadgeId(allTags?.Badge?.subtags?.[badgeTagKey], badgesMetaId);
278
+ badgeSubTags[badgeTagKey] = badgeSubTagsObj;
279
+ });
280
+ badgeTags[badgesMetaId] = {
281
+ 'tag-header': true,
282
+ 'name': badgeName,
283
+ 'desc': badgeName,
284
+ 'incentiveSeriesId': badgesMetaId,
285
+ 'subtags': badgeSubTags,
286
+ 'resolved': true,
287
+ 'couponTags': true,
288
+ };
289
+ });
290
+ // eslint-disable-next-line no-param-reassign
291
+ allTags.Badge.subtags = badgeTags;
292
+ return allTags;
293
+ }
294
+
182
295
  function populateTagForChildren(targetTag, tagsObject, tagValue) {
183
296
  const tag = targetTag;
184
297
  if (tag && tag['tag-header'] && !tag.resolved) {
@@ -262,3 +375,80 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
262
375
  const isTraiDltFeature = isTraiDltFeatureForOrg && isTraiEnableforLib;
263
376
  return isTraiDltFeature;
264
377
  };
378
+
379
+ //Input: " Spaces In Input "---> Output: "spaces_in_input"
380
+ export const intlKeyGenerator = (value = "") => String(value).replace(/[^a-zA-Z0-9_ ]/g, "").replace(/ /g, "_").toLowerCase();
381
+
382
+ export const handleInjectedData = (data, scope) => {
383
+ let tagType;
384
+ for (const tagKey in data) {
385
+ if (data.hasOwnProperty(tagKey)) {
386
+ const tag = data[tagKey];
387
+ if (tag?.name === REGISTRATION_CUSTOM_FIELD) {
388
+ tagType = CUSTOM_TAG;
389
+ } else if (tag?.name === CUSTOMER_EXTENDED_FIELD) {
390
+ tagType = EXTENDED_TAG;
391
+ }
392
+
393
+ if (tag?.name) {
394
+ const name = tag.name;
395
+ const key = intlKeyGenerator(name);
396
+ const id = tagType
397
+ ? `${scope}.${key}_name.${tagType}`
398
+ : `${scope}.${key}`;
399
+
400
+ tag.name = apiMessageFormatHandler(id, name);
401
+ }
402
+
403
+ if (tag?.subtags) {
404
+ for (const subtagKey in tag.subtags) {
405
+ if (tag.subtags.hasOwnProperty(subtagKey)) {
406
+ const subtag = tag.subtags[subtagKey];
407
+ if (subtag?.name) {
408
+ const name = subtag?.name;
409
+ const key = intlKeyGenerator(name);
410
+ const id = tagType
411
+ ? `${scope}.${key}_name.${tagType}`
412
+ : `${scope}.${key}`;
413
+
414
+ subtag.name = apiMessageFormatHandler(id, name);
415
+ }
416
+ if (subtag?.desc) {
417
+ const desc = subtag?.desc;
418
+ const key = intlKeyGenerator(desc);
419
+ const id = tagType
420
+ ? `${scope}.${key}_desc.${tagType}`
421
+ : `${scope}.${key}`;
422
+
423
+ subtag.desc = apiMessageFormatHandler(id, desc);
424
+ }
425
+ }
426
+ }
427
+ }
428
+ tagType = "";
429
+ }
430
+ }
431
+ return data;
432
+ };
433
+
434
+ export const handlePreviewInNewTab = (previewUrl) => {
435
+ window.open(previewUrl, '_blank');
436
+ };
437
+
438
+ export const getDecodedFileName = (templateName = '') => {
439
+ try {
440
+ return decodeURIComponent(templateName);
441
+ } catch (error) {
442
+ // If decoding fails due to URIError, using the original encoded filename
443
+ if (error instanceof URIError) {
444
+ return templateName;
445
+ } else {
446
+ // For other errors, registering the exception in Bugsnag
447
+ Bugsnag.leaveBreadcrumb("Error decoding the string:", error);
448
+ Bugsnag.notify(error, (event) => {
449
+ event.severity = "error";
450
+ });
451
+ }
452
+ }
453
+ return templateName;
454
+ };
@@ -3,4 +3,20 @@ import { FormattedMessage } from 'react-intl';
3
3
 
4
4
  export const apiMessageFormatHandler = (id, fallback) => (
5
5
  <FormattedMessage id={id} defaultMessage={fallback} />
6
- );
6
+ );
7
+
8
+ export const addBaseToTemplate = (template) => {
9
+ const { versions: {
10
+ history = [],
11
+ } = {}} = template || {};
12
+ if (history?.length) {
13
+ return ({
14
+ ...template,
15
+ versions: {
16
+ ...template.versions,
17
+ base: history[0],
18
+ },
19
+ });
20
+ }
21
+ return template;
22
+ };