@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
@@ -0,0 +1,177 @@
1
+ import { fromJS } from "immutable";
2
+ import inAppReducer from "../reducer";
3
+ import * as actions from "../actions";
4
+ import * as types from "../constants";
5
+ // import { editData } from "./mockData";
6
+
7
+
8
+ describe("zalo reducer", () => {
9
+ let state;
10
+ const action = {};
11
+ beforeEach(() => {
12
+ state = fromJS({
13
+ uploadedAssetData: {},
14
+ createTemplateInProgress: false,
15
+ editTemplateInProgress: false,
16
+ });
17
+ });
18
+
19
+ describe("Reducer : INAPP_TEMPLATE_CREATE_REQUEST", () => {
20
+ it("should handle INAPP_TEMPLATE_CREATE_REQUEST action", () => {
21
+ state = state
22
+ .set("createTemplateInProgress", true)
23
+ .set("createTemplateError", false)
24
+ .set("createTemplateErrorMessage", "");
25
+ const expectedResult = state;
26
+ expect(inAppReducer(state, actions.createInAppTemplate({}))).toEqual(
27
+ expectedResult
28
+ );
29
+ });
30
+ it("should handle INAPP_TEMPLATE_CREATE_SUCCESS action", () => {
31
+ action.type = types.INAPP_TEMPLATE_CREATE_SUCCESS;
32
+ action.data = 'data';
33
+ state = state
34
+ .set("createTemplateInProgress", false)
35
+ .set("createTemplateError", false)
36
+ .set("createTemplateErrorMessage", undefined)
37
+ .set('response', 'data');
38
+ const expectedResult = state;
39
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
40
+ });
41
+ it("should handle INAPP_TEMPLATE_CREATE_FAILURE action", () => {
42
+ action.type = types.INAPP_TEMPLATE_CREATE_FAILURE;
43
+ action.errorMsg = 'error';
44
+ state = state
45
+ .set("createTemplateInProgress", false)
46
+ .set('createTemplateError', true)
47
+ .set('createTemplateErrorMessage', fromJS(action.errorMsg));
48
+ const expectedResult = state;
49
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
50
+ });
51
+ });
52
+ describe("Reducer : INAPP_EDIT_TEMPLATE_REQUEST", () => {
53
+ it("should handle INAPP_EDIT_TEMPLATE_REQUEST action", () => {
54
+ state = state
55
+ .set("editTemplateInProgress", true)
56
+ .set("editTemplateError", false)
57
+ .set("editTemplateErrorMessage", "");
58
+ const expectedResult = state;
59
+ expect(inAppReducer(state, actions.editTemplate({}))).toEqual(
60
+ expectedResult
61
+ );
62
+ });
63
+ it("should handle INAPP_EDIT_TEMPLATE_SUCCESS action", () => {
64
+ action.type = types.INAPP_EDIT_TEMPLATE_SUCCESS;
65
+ action.data = 'data';
66
+ action.statusCode = 200;
67
+ state = state
68
+ .set("editTemplateInProgress", false)
69
+ .set("editTemplateError", false)
70
+ .set("editTemplateErrorMessage", 'error')
71
+ .set('editResponse', 'data');
72
+ const expectedResult = state;
73
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
74
+ });
75
+ it("should handle INAPP_EDIT_TEMPLATE_FAILURE action", () => {
76
+ action.type = types.INAPP_EDIT_TEMPLATE_FAILURE;
77
+ action.errorMsg = 'error';
78
+ state = state
79
+ .set("editTemplateInProgress", false)
80
+ .set('editTemplateError', true)
81
+ .set('editTemplateErrorMessage', fromJS(action.errorMsg));
82
+ const expectedResult = state;
83
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
84
+ });
85
+
86
+ it("should handle default action", () => {
87
+ action.type = "deafult_action";
88
+ const expectedResult = state;
89
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
90
+ });
91
+ });
92
+ describe("Reducer : GET_TEMPLATE_DETAILS_REQUEST", () => {
93
+ it("should handle GET_TEMPLATE_DETAILS_REQUEST action", () => {
94
+ state = state
95
+ .set("getTemplateDetailsInProgress", true);
96
+ const expectedResult = state;
97
+ expect(inAppReducer(state, actions.getTemplateDetails({}))).toEqual(
98
+ expectedResult
99
+ );
100
+ });
101
+ it("should handle INAPP_EDIT_TEMPLATE_SUCCESS action", () => {
102
+ action.type = types.GET_INAPP_TEMPLATE_DETAILS_SUCCESS;
103
+ action.data = 'data';
104
+ action.statusCode = 200;
105
+ state = state
106
+ .set("getTemplateDetailsInProgress", false)
107
+ .set('templateDetails', 'data');
108
+ const expectedResult = state;
109
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
110
+ });
111
+ it("should handle GET_TEMPLATE_DETAILS_FAILURE action", () => {
112
+ action.type = types.GET_INAPP_TEMPLATE_DETAILS_FAILURE;
113
+ action.errorMsg = 'error';
114
+ state = state
115
+ .set("getTemplateDetailsInProgress", false);
116
+ const expectedResult = state;
117
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
118
+ });
119
+ it("should handle CLEAR_CREATE_RESPONSE_REQUEST action", () => {
120
+ action.type = types.CLEAR_CREATE_RESPONSE_REQUEST;
121
+ state = state
122
+ .set("response", {});
123
+ const expectedResult = state;
124
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
125
+ });
126
+ it("should handle RESET_EDIT_TEMPLATE action", () => {
127
+ action.type = types.RESET_EDIT_TEMPLATE;
128
+ state = state
129
+ .set("templateDetails", {});
130
+ const expectedResult = state;
131
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
132
+ });
133
+ });
134
+ describe("Reducer : UPLOAD_INAPP_ASSET_REQUEST", () => {
135
+ it("should handle UPLOAD_INAPP_ASSET_REQUEST action", () => {
136
+ state = state
137
+ .set("uploadAssetSuccess", false)
138
+ .set("assetUploading", true);
139
+ const expectedResult = state;
140
+ expect(inAppReducer(state, actions.uploadInAppAsset({}))).toEqual(
141
+ expectedResult
142
+ );
143
+ });
144
+ it("should handle UPLOAD_INAPP_ASSET_SUCCESS action", () => {
145
+ action.type = types.UPLOAD_INAPP_ASSET_SUCCESS;
146
+ action.data = 'data';
147
+ action.statusCode = 200;
148
+ state = state
149
+ .set("getTemplateDetailsInProgress", false)
150
+ .set('assetUploading', false)
151
+ .set('uploadAssetSuccess', true)
152
+ .set('uploadedAssetData', 'data');
153
+ const expectedResult = state;
154
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
155
+ });
156
+ it("should handle UPLOAD_INAPP_ASSET_FAILURE action", () => {
157
+ action.type = types.UPLOAD_INAPP_ASSET_FAILURE;
158
+ action.errorMsg = 'error';
159
+ state = state
160
+ .set("assetUploading", false)
161
+ .set('uploadAssetSuccess', false);
162
+ const expectedResult = state;
163
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
164
+ });
165
+ it("should handle CLEAR_INAPP_ASSET action", () => {
166
+ action.type = types.CLEAR_INAPP_ASSET;
167
+ action.errorMsg = 'error';
168
+ action.data = 'data';
169
+ state = state
170
+ .set("assetUploading", false)
171
+ .delete('uploadedAssetData', {})
172
+ .set('uploadAssetSuccess', false);
173
+ const expectedResult = state;
174
+ expect(inAppReducer(state, action)).toEqual(expectedResult);
175
+ });
176
+ });
177
+ });
@@ -0,0 +1,391 @@
1
+ import { call, cancel, put, takeLatest } from 'redux-saga/effects';
2
+ import { createMockTask } from 'redux-saga/utils';
3
+ import * as sagas from '../sagas';
4
+ import * as Api from '../../../services/api';
5
+ import * as types from '../constants';
6
+ import { INAPP } from '../../CreativesContainer/constants';
7
+
8
+ describe('test for uploadInAppAsset function', () => {
9
+ it('should dispatch UPLOAD_INAPP_ASSET_SUCCESS action with asset data, status code, and template type', () => {
10
+ // Mock the necessary dependencies
11
+ const params = {
12
+ file: new File([""], "filename"),
13
+ assetType: 'image',
14
+ fileParams: {
15
+ name: 'image.jpg',
16
+ size: 1024,
17
+ },
18
+ mode: 'create',
19
+ wechatParams: {
20
+ source: 'wechat',
21
+ appId: '123456',
22
+ appSecret: 'abcdef',
23
+ },
24
+ whatsappParams: {
25
+ source: 'whatsapp',
26
+ wabaId: '987654',
27
+ accessToken: 'xyz123',
28
+ hostName: 'whatsapp.com',
29
+ },
30
+ };
31
+
32
+ // Mock the API.uploadFile function
33
+ const uploadFileMock = jest.spyOn(Api, 'uploadFile').mockImplementation(() => Promise.resolve({
34
+ response: {
35
+ asset: { id: 1, name: 'image.jpg' },
36
+ },
37
+ status: {
38
+ code: 200,
39
+ },
40
+ }));
41
+
42
+ const result = { response: { asset: { id: 1, name: 'image.jpg' } }, status: { code: 200 } };
43
+
44
+ // Invoke the function
45
+ const generator = sagas.uploadInAppAsset(params);
46
+ generator.next();
47
+ const actual = generator.next(result).value;
48
+
49
+ // Assert the dispatched action
50
+ expect(actual).toEqual(
51
+ put({
52
+ type: types.UPLOAD_INAPP_ASSET_SUCCESS,
53
+ data: { id: 1, name: 'image.jpg' },
54
+ statusCode: 200,
55
+ templateType: params.templateType,
56
+ })
57
+ );
58
+
59
+ // Restore the mocks
60
+ uploadFileMock.mockRestore();
61
+ });
62
+
63
+ it('should dispatch UPLOAD_INAPP_ASSET_FAILURE action with error', () => {
64
+ // Mock the necessary dependencies
65
+ const params = {
66
+ file: new File([""], "filename"),
67
+ assetType: 'image',
68
+ fileParams: {
69
+ name: 'image.jpg',
70
+ size: 1024,
71
+ },
72
+ mode: 'create',
73
+ wechatParams: {
74
+ source: 'wechat',
75
+ appId: '123456',
76
+ appSecret: 'abcdef',
77
+ },
78
+ whatsappParams: {
79
+ source: 'whatsapp',
80
+ wabaId: '987654',
81
+ accessToken: 'xyz123',
82
+ hostName: 'whatsapp.com',
83
+ },
84
+ };
85
+
86
+ // Mock the API.uploadFile function
87
+ const uploadFileMock = jest.spyOn(Api, 'uploadFile').mockImplementation(() => Promise.reject(new Error('Upload failed')));
88
+ // Invoke the function
89
+ const generator = sagas.uploadInAppAsset(params);
90
+ generator.next();
91
+
92
+ // Assert the dispatched action
93
+ expect(generator.throw(new Error('Upload failed')).value).toEqual(
94
+ put({ type: types.UPLOAD_INAPP_ASSET_FAILURE, error: new Error('Upload failed') })
95
+ );
96
+
97
+ // Restore the mocks
98
+ uploadFileMock.mockRestore();
99
+ });
100
+ it('should call uploadInAppAsset when UPLOAD_INAPP_ASSET_REQUEST action is dispatched', () => {
101
+ const watcher = sagas.watchUploadInAppAsset();
102
+ const uploadInAppAssetGenerator = watcher.next().value;
103
+ expect(uploadInAppAssetGenerator).toEqual(takeLatest(types.UPLOAD_INAPP_ASSET_REQUEST, sagas.uploadInAppAsset));
104
+ });
105
+ it('should cancel the watcher watchUploadInAppAsset', () => {
106
+ const gen = sagas.watchUploadInAppAsset();
107
+ const mockTask = createMockTask();
108
+
109
+ // Advance the generator to the takeLatest effect
110
+ expect(gen.next().value).toEqual(
111
+ takeLatest(types.UPLOAD_INAPP_ASSET_REQUEST, sagas.uploadInAppAsset),
112
+ );
113
+
114
+ // Pass the mock task to the takeLatest effect
115
+ expect(gen.next(mockTask).done).toBe(false);
116
+
117
+ // Call the cancel function on the mock task to simulate cancellation
118
+ expect(mockTask.isRunning()).toBe(true); // the task is running
119
+ expect(gen.next().value).toEqual(cancel(mockTask));
120
+ });
121
+ });
122
+
123
+ describe('test for inAppTemplateCreate function', () => {
124
+ it('should handle TEMPLATE_CREATE_SUCCESS', () => {
125
+ const payload = {}; // Add your payload for testing
126
+ const mockResult = {
127
+ status: {
128
+ code: 200,
129
+ },
130
+ response: { /* mock response */ },
131
+ };
132
+
133
+ const iterator = sagas.inAppTemplateCreate({ payload, callback: jest.fn() });
134
+
135
+ // Test the yield call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload })
136
+ expect(iterator.next().value).toEqual(call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload }));
137
+
138
+ // Test the result
139
+ expect(iterator.next(mockResult).value).toEqual(
140
+ put({
141
+ type: types.INAPP_TEMPLATE_CREATE_SUCCESS,
142
+ data: mockResult.response,
143
+ statusCode: mockResult.status.code,
144
+ errorMsg: undefined, // No error message expected
145
+ })
146
+ );
147
+
148
+ // Ensure the saga completes
149
+ expect(iterator.next().done).toBe(true);
150
+ });
151
+
152
+ it('should handle error case', () => {
153
+ const payload = {}; // Add your payload for testing
154
+ const mockResult = {
155
+ status: {
156
+ code: 400,
157
+ },
158
+ // message: 'error',
159
+ response: { /* mock response */ },
160
+ };
161
+
162
+ const iterator = sagas.inAppTemplateCreate({ payload, callback: jest.fn() });
163
+
164
+ // Test the yield call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload })
165
+ expect(iterator.next().value).toEqual(call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload }));
166
+
167
+ // Test the result
168
+ expect(iterator.next(mockResult).value).toEqual(
169
+ put({
170
+ type: types.INAPP_TEMPLATE_CREATE_FAILURE,
171
+ error: 400,
172
+ errorMsg: 400, // No error message expected
173
+ })
174
+ );
175
+
176
+ // Ensure the saga completes
177
+ expect(iterator.next().done).toBe(true);
178
+ });
179
+
180
+ it('should handle INAPP_TEMPLATE_CREATE_FAILURE', () => {
181
+ const payload = {}; // Add your payload for testing
182
+ const error = new Error('Test error');
183
+ const iterator = sagas.inAppTemplateCreate({ payload });
184
+
185
+ // Test the yield call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload })
186
+ expect(iterator.next().value).toEqual(call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload }));
187
+
188
+ // Test the error handling path
189
+ expect(iterator.throw(error).value).toEqual(
190
+ put({
191
+ type: types.INAPP_TEMPLATE_CREATE_FAILURE,
192
+ error,
193
+ errorMsg: undefined, // No error message expected
194
+ })
195
+ );
196
+
197
+ // Ensure the saga completes
198
+ expect(iterator.next().done).toBe(true);
199
+ });
200
+ it('should call inAppTemplateCreate when INAPP_TEMPLATE_CREATE_REQUEST action is dispatched', () => {
201
+ const watcher = sagas.watchCreateTemplate();
202
+ const gen = watcher.next().value;
203
+ expect(gen).toEqual(takeLatest(types.INAPP_TEMPLATE_CREATE_REQUEST, sagas.inAppTemplateCreate));
204
+ });
205
+ it('should cancel the watcher watchCreateTemplate', () => {
206
+ const gen = sagas.watchCreateTemplate();
207
+ const mockTask = createMockTask();
208
+
209
+ // Advance the generator to the takeLatest effect
210
+ expect(gen.next().value).toEqual(
211
+ takeLatest(types.INAPP_TEMPLATE_CREATE_REQUEST, sagas.inAppTemplateCreate),
212
+ );
213
+
214
+ // Pass the mock task to the takeLatest effect
215
+ expect(gen.next(mockTask).done).toBe(false);
216
+
217
+ // Call the cancel function on the mock task to simulate cancellation
218
+ expect(mockTask.isRunning()).toBe(true); // the task is running
219
+ expect(gen.next().value).toEqual(cancel(mockTask));
220
+ });
221
+ });
222
+
223
+ describe('test for editTemplate function', () => {
224
+ it('should handle INAPP_EDIT_TEMPLATE_SUCCESS', () => {
225
+ const payload = {}; // Add your payload for testing
226
+ const mockResult = {
227
+ status: {
228
+ code: 200,
229
+ },
230
+ response: { /* mock response */ },
231
+ };
232
+
233
+ const iterator = sagas.editTemplate({ payload, callback: jest.fn() });
234
+
235
+ // Test the yield call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload })
236
+ expect(iterator.next().value).toEqual(call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload }));
237
+
238
+ // Test the result
239
+ expect(iterator.next(mockResult).value).toEqual(
240
+ put({
241
+ type: types.INAPP_EDIT_TEMPLATE_SUCCESS,
242
+ data: mockResult.response,
243
+ statusCode: mockResult.status.code,
244
+ errorMsg: undefined, // No error message expected
245
+ })
246
+ );
247
+
248
+ // Ensure the saga completes
249
+ expect(iterator.next().done).toBe(true);
250
+ });
251
+
252
+ it('should handle error case', () => {
253
+ const payload = {}; // Add your payload for testing
254
+ const mockResult = {
255
+ status: {
256
+ code: 400,
257
+ },
258
+ // message: 'error',
259
+ response: { /* mock response */ },
260
+ };
261
+
262
+ const iterator = sagas.editTemplate({ payload, callback: jest.fn() });
263
+
264
+ // Test the yield call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload })
265
+ expect(iterator.next().value).toEqual(call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload }));
266
+
267
+ // Test the result
268
+ expect(iterator.next(mockResult).value).toEqual(
269
+ put({
270
+ type: types.INAPP_EDIT_TEMPLATE_FAILURE,
271
+ error: 400,
272
+ errorMsg: 400, // No error message expected
273
+ })
274
+ );
275
+
276
+ // Ensure the saga completes
277
+ expect(iterator.next().done).toBe(true);
278
+ });
279
+
280
+ it('should handle EDIT_TEMPLATE_FAILURE', () => {
281
+ const payload = {}; // Add your payload for testing
282
+ const error = new Error('Test error');
283
+ const iterator = sagas.editTemplate({ payload });
284
+
285
+ // Test the yield call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload })
286
+ expect(iterator.next().value).toEqual(call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload }));
287
+
288
+ // Test the error handling path
289
+ expect(iterator.throw(error).value).toEqual(
290
+ put({
291
+ type: types.INAPP_EDIT_TEMPLATE_FAILURE,
292
+ error,
293
+ errorMsg: undefined, // No error message expected
294
+ })
295
+ );
296
+
297
+ // Ensure the saga completes
298
+ expect(iterator.next().done).toBe(true);
299
+ });
300
+ it('should call editTemplate when INAPP_EDIT_TEMPLATE_REQUEST action is dispatched', () => {
301
+ const watcher = sagas.watchEditTemplate();
302
+ const gen = watcher.next().value;
303
+ expect(gen).toEqual(takeLatest(types.INAPP_EDIT_TEMPLATE_REQUEST, sagas.editTemplate));
304
+ });
305
+ it('should cancel the watcher watchCreateTemplate', () => {
306
+ const gen = sagas.watchEditTemplate();
307
+ const mockTask = createMockTask();
308
+
309
+ // Advance the generator to the takeLatest effect
310
+ expect(gen.next().value).toEqual(
311
+ takeLatest(types.INAPP_EDIT_TEMPLATE_REQUEST, sagas.editTemplate),
312
+ );
313
+
314
+ // Pass the mock task to the takeLatest effect
315
+ expect(gen.next(mockTask).done).toBe(false);
316
+
317
+ // Call the cancel function on the mock task to simulate cancellation
318
+ expect(mockTask.isRunning()).toBe(true); // the task is running
319
+ expect(gen.next().value).toEqual(cancel(mockTask));
320
+ });
321
+ });
322
+
323
+ describe('test for getTemplateDetails', () => {
324
+ it('should handle GET_INAPP_TEMPLATE_DETAILS_SUCCESS', () => {
325
+ const payload = {}; // Add your payload for testing
326
+ const mockResult = {
327
+ status: {
328
+ code: 200,
329
+ },
330
+ response: { /* mock response */ },
331
+ };
332
+
333
+ const iterator = sagas.getTemplateDetails({ payload, callback: jest.fn() });
334
+
335
+ // Test the yield call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload })
336
+ expect(iterator.next().value).toEqual(call(Api.getTemplateDetails, { channel: 'INAPP', id: undefined }));
337
+
338
+ // Test the result
339
+ expect(iterator.next(mockResult).value).toEqual(
340
+ put({
341
+ type: types.GET_INAPP_TEMPLATE_DETAILS_SUCCESS,
342
+ data: mockResult.response,
343
+ })
344
+ );
345
+
346
+ // Ensure the saga completes
347
+ expect(iterator.next().done).toBe(true);
348
+ });
349
+
350
+ it('should handle GET_INAPP_TEMPLATE_DETAILS_FAILURE', () => {
351
+ const payload = {}; // Add your payload for testing
352
+ const error = new Error('Test error');
353
+ const iterator = sagas.getTemplateDetails({ channel: INAPP, template: payload });
354
+
355
+ // Test the yield call(Api.createChannelWiseTemplate, { channel: INAPP, template: payload })
356
+ expect(iterator.next().value).toEqual(call(Api.getTemplateDetails, { channel: 'INAPP', id: undefined }));
357
+
358
+ // Test the error handling path
359
+ expect(iterator.throw(error).value).toEqual(
360
+ put({
361
+ type: types.GET_INAPP_TEMPLATE_DETAILS_FAILURE,
362
+ error,
363
+ errorMsg: undefined, // No error message expected
364
+ })
365
+ );
366
+
367
+ // Ensure the saga completes
368
+ expect(iterator.next().done).toBe(true);
369
+ });
370
+ it('should call getTemplateDetails when GET_INAPP_TEMPLATE_DETAILS_REQUEST action is dispatched', () => {
371
+ const watcher = sagas.watchGetTemplateDetails();
372
+ const gen = watcher.next().value;
373
+ expect(gen).toEqual(takeLatest(types.GET_INAPP_TEMPLATE_DETAILS_REQUEST, sagas.getTemplateDetails));
374
+ });
375
+ it('should cancel the watcher watchGetTemplateDetails', () => {
376
+ const gen = sagas.watchGetTemplateDetails();
377
+ const mockTask = createMockTask();
378
+
379
+ // Advance the generator to the takeLatest effect
380
+ expect(gen.next().value).toEqual(
381
+ takeLatest(types.GET_INAPP_TEMPLATE_DETAILS_REQUEST, sagas.getTemplateDetails),
382
+ );
383
+
384
+ // Pass the mock task to the takeLatest effect
385
+ expect(gen.next(mockTask).done).toBe(false);
386
+
387
+ // Call the cancel function on the mock task to simulate cancellation
388
+ expect(mockTask.isRunning()).toBe(true); // the task is running
389
+ expect(gen.next().value).toEqual(cancel(mockTask));
390
+ });
391
+ });
@@ -0,0 +1,12 @@
1
+ export const getCtaObject = (ctaData) =>
2
+ ctaData?.map((cta, index) => {
3
+ const { type = "", actionText = "", actionLink = "" } = cta;
4
+ const obj = {
5
+ index,
6
+ text: actionText,
7
+ url: actionLink,
8
+ urlType: type,
9
+ isSaved: true,
10
+ };
11
+ return obj;
12
+ });
@@ -17,11 +17,14 @@ import { connect } from 'react-redux';
17
17
  import { createStructuredSelector } from 'reselect';
18
18
  import { IntlProvider } from 'react-intl';
19
19
  import moment from 'moment';
20
- import { bindActionCreators } from 'redux';
20
+ import { bindActionCreators, compose } from 'redux';
21
21
  import * as actions from './actions';
22
22
  import { makeSelectLocale } from './selectors';
23
23
  import { makeSelectUser } from '../Cap/selectors';
24
-
24
+ import { LanguageProviderRootSaga } from './sagas';
25
+ import injectSaga from '../../utils/injectSaga';
26
+ import injectReducer from '../../utils/injectReducer';
27
+ import reducer from './reducer';
25
28
 
26
29
  export class LanguageProvider extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
27
30
  componentDidUpdate(prevProps) {
@@ -53,7 +56,7 @@ export class LanguageProvider extends React.PureComponent { // eslint-disable-li
53
56
  this.props.actions.getLocizMessage(locale);
54
57
  }
55
58
  render() {
56
- const { locale, messages} = this.props.language;
59
+ const { locale, messages, languageLocale} = this.props.language;
57
60
  const mappedLocale = {
58
61
  'en': enUS,
59
62
  'zh-cn': zhCN,
@@ -65,7 +68,7 @@ export class LanguageProvider extends React.PureComponent { // eslint-disable-li
65
68
  const file = mappedLocale[jLocale];
66
69
  return (
67
70
  <ConfigProvider locale={file}>
68
- <IntlProvider locale={locale} key={locale} messages={messages}>
71
+ <IntlProvider locale={languageLocale} key={locale} messages={messages}>
69
72
  {React.Children.only(this.props.children)}
70
73
  </IntlProvider>
71
74
  </ConfigProvider>
@@ -92,4 +95,13 @@ function mapDispatchToProps(dispatch) {
92
95
  };
93
96
  }
94
97
 
95
- export default connect(mapStateToProps, mapDispatchToProps)(LanguageProvider);
98
+ const withSaga = injectSaga({ key: 'language', saga: LanguageProviderRootSaga });
99
+ const withReducer = injectReducer({ key: 'language', reducer });
100
+
101
+ const withConnect = connect(mapStateToProps, mapDispatchToProps);
102
+
103
+ export default compose(
104
+ withSaga,
105
+ withReducer,
106
+ withConnect,
107
+ )(LanguageProvider);
@@ -10,6 +10,7 @@ import * as types from './constants';
10
10
 
11
11
  const initialState = fromJS({
12
12
  locale: types.DEFAULT_LOCALE,
13
+ languageLocale: types.DEFAULT_LOCALE,
13
14
  messages: {},
14
15
  localeLoading: false,
15
16
  });
@@ -18,11 +19,11 @@ function languageProviderReducer(state = initialState, action) {
18
19
  switch (action.type) {
19
20
  case types.GET_LOCIZ_MESSAGE_REQUEST:
20
21
  return state
21
- .set('localeLoading', true)
22
- .set('locale', action.locale);
22
+ .set('localeLoading', true);
23
23
  case types.GET_LOCIZ_MESSAGE_SUCCESS:
24
24
  return state
25
25
  .set('localeLoading', false)
26
+ .set('languageLocale', action.locale)
26
27
  .set('messages', fromJS(action.data));
27
28
  case types.GET_LOCIZ_MESSAGE_FAILURE:
28
29
  return state.set('localeLoading', false);
@@ -1,17 +1,16 @@
1
1
  import { takeLatest, take, all, cancel, call, put } from 'redux-saga/effects';
2
- import { LOCATION_CHANGE } from 'react-router-redux';
3
2
  import * as Api from '../../services/api';
4
3
  import * as types from './constants';
5
4
 
6
5
  function* getLocizMessage(action) {
7
6
  try {
8
7
  const result = yield call(Api.getLocizMessage, action.locale);
9
- yield [
10
- put({
11
- type: types.GET_LOCIZ_MESSAGE_SUCCESS,
12
- data: result,
13
- }),
14
- ];
8
+ yield put({
9
+ type: types.GET_LOCIZ_MESSAGE_SUCCESS,
10
+ data: result,
11
+ locale: action.locale,
12
+ });
13
+
15
14
  } catch (error) {
16
15
  yield [
17
16
  put({
@@ -22,7 +21,7 @@ function* getLocizMessage(action) {
22
21
  }
23
22
  }
24
23
  export function* watchGetLocizMessage() {
25
- const watcher = yield takeLatest(
24
+ yield takeLatest(
26
25
  types.GET_LOCIZ_MESSAGE_REQUEST,
27
26
  getLocizMessage,
28
27
  );
@@ -14,7 +14,8 @@ const makeSelectLocale = () => createSelector(
14
14
  (languageState) => languageState.toJS()
15
15
  );
16
16
 
17
+
17
18
  export {
18
19
  selectLanguage,
19
- makeSelectLocale,
20
+ makeSelectLocale
20
21
  };