@capillarytech/creatives-library 2.0.69 → 2.0.71

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 (391) hide show
  1. package/app.js +1 -1
  2. package/components/Ckeditor/index.js +2 -1
  3. package/components/FormBuilder/index.js +25 -10
  4. package/components/Header/index.js +3 -1
  5. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +38 -3
  6. package/components/TemplatePreview/index.js +45 -51
  7. package/components/TemplatePreview/messages.js +1 -1
  8. package/containers/Cap/actions.js +0 -5
  9. package/containers/Cap/reducer.js +1 -1
  10. package/containers/Cap/selectors.js +0 -13
  11. package/containers/Ebill/index.js +1 -2
  12. package/containers/Email/_email.scss +1 -0
  13. package/containers/Email/actions.js +3 -8
  14. package/containers/Email/constants.js +0 -1
  15. package/containers/Email/index.js +947 -322
  16. package/containers/Email/reducer.js +0 -3
  17. package/containers/Email/sagas.js +6 -3
  18. package/containers/Email/selectors.js +1 -4
  19. package/containers/Line/Create/index.js +1 -2
  20. package/containers/Line/Edit/_lineEdit.scss +4 -0
  21. package/containers/Line/Edit/index.js +1 -3
  22. package/containers/MobilePush/Create/_mobilePushCreate.scss +3 -12
  23. package/containers/MobilePush/Create/actions.js +0 -6
  24. package/containers/MobilePush/Create/constants.js +0 -1
  25. package/containers/MobilePush/Create/index.js +1133 -628
  26. package/containers/MobilePush/Create/messages.js +1 -5
  27. package/containers/MobilePush/Create/reducer.js +0 -2
  28. package/containers/MobilePush/Create/selectors.js +3 -3
  29. package/containers/MobilePush/Edit/_mobilePushCreate.scss +3 -9
  30. package/containers/MobilePush/Edit/index.js +1127 -393
  31. package/containers/MobilePush/Edit/messages.js +0 -4
  32. package/containers/MobilePush/Edit/reducer.js +1 -2
  33. package/containers/MobilePush/Edit/selectors.js +3 -6
  34. package/containers/Sms/Create/_smsCreate.scss +2 -1
  35. package/containers/Sms/Create/actions.js +4 -4
  36. package/containers/Sms/Create/index.js +570 -102
  37. package/containers/Sms/Create/sagas.js +2 -1
  38. package/containers/Sms/Edit/actions.js +5 -10
  39. package/containers/Sms/Edit/constants.js +0 -1
  40. package/containers/Sms/Edit/index.js +548 -103
  41. package/containers/Sms/Edit/reducer.js +0 -2
  42. package/containers/Sms/Edit/sagas.js +3 -1
  43. package/containers/TagList/index.js +3 -3
  44. package/containers/Templates/actions.js +1 -3
  45. package/containers/Templates/index.js +299 -268
  46. package/containers/Templates/messages.js +90 -122
  47. package/containers/Templates/reducer.js +3 -3
  48. package/containers/Templates/sagas.js +1 -5
  49. package/containers/Templates/selectors.js +1 -41
  50. package/containers/WeChat/MapTemplates/index.js +3 -4
  51. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -4
  52. package/containers/WeChat/RichmediaTemplates/Create/messages.js +4 -0
  53. package/containers/WeChat/RichmediaTemplates/Edit/index.js +3 -1
  54. package/containers/WeChat/RichmediaTemplates/View/index.js +3 -1
  55. package/index.js +31 -31
  56. package/initialState.js +6 -0
  57. package/package.json +3 -3
  58. package/routes.js +24 -19
  59. package/services/api.js +6 -2
  60. package/services/getSchema.js +18 -0
  61. package/v2Containers/App/actions.js +7 -0
  62. package/v2Containers/App/constants.js +3 -0
  63. package/v2Containers/App/reducer.js +19 -0
  64. package/v2Containers/App/sagas.js +26 -0
  65. package/v2Containers/App/selectors.js +25 -0
  66. package/v2Containers/App/tests/actions.test.js +18 -0
  67. package/v2Containers/App/tests/reducer.test.js +9 -0
  68. package/v2Containers/App/tests/sagas.test.js +15 -0
  69. package/v2Containers/App/tests/selectors.test.js +10 -0
  70. package/v2Containers/Assets/Gallery/_gallery.scss +0 -0
  71. package/v2Containers/Assets/Gallery/actions.js +37 -0
  72. package/v2Containers/Assets/Gallery/constants.js +23 -0
  73. package/v2Containers/Assets/Gallery/index.js +479 -0
  74. package/v2Containers/Assets/Gallery/messages.js +97 -0
  75. package/v2Containers/Assets/Gallery/reducer.js +81 -0
  76. package/v2Containers/Assets/Gallery/sagas.js +84 -0
  77. package/v2Containers/Assets/Gallery/selectors.js +25 -0
  78. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +7 -0
  79. package/v2Containers/Assets/Gallery/tests/actions.test.js +26 -0
  80. package/v2Containers/Assets/Gallery/tests/index.test.js +10 -0
  81. package/v2Containers/Assets/Gallery/tests/reducer.test.js +95 -0
  82. package/v2Containers/Assets/Gallery/tests/sagas.test.js +15 -0
  83. package/v2Containers/Assets/Gallery/tests/selectors.test.js +10 -0
  84. package/v2Containers/CallTask/_callTask.scss +5 -0
  85. package/v2Containers/CallTask/actions.js +15 -0
  86. package/v2Containers/CallTask/constants.js +7 -0
  87. package/v2Containers/CallTask/index.js +141 -0
  88. package/v2Containers/CallTask/messages.js +21 -0
  89. package/v2Containers/CallTask/reducer.js +23 -0
  90. package/v2Containers/CallTask/sagas.js +11 -0
  91. package/v2Containers/CallTask/selectors.js +25 -0
  92. package/v2Containers/CallTask/tests/actions.test.js +18 -0
  93. package/v2Containers/CallTask/tests/index.test.js +10 -0
  94. package/v2Containers/CallTask/tests/reducer.test.js +9 -0
  95. package/v2Containers/CallTask/tests/sagas.test.js +15 -0
  96. package/v2Containers/CallTask/tests/selectors.test.js +10 -0
  97. package/v2Containers/Cap/actions.js +64 -0
  98. package/v2Containers/Cap/constants.js +24 -0
  99. package/v2Containers/Cap/index.js +349 -0
  100. package/v2Containers/Cap/messsages.js +63 -0
  101. package/v2Containers/Cap/reducer.js +111 -0
  102. package/v2Containers/Cap/sagas.js +143 -0
  103. package/v2Containers/Cap/selectors.js +85 -0
  104. package/v2Containers/Cap/tests/index.test.js +16 -0
  105. package/v2Containers/Cap/tests/selectors.test.js +28 -0
  106. package/v2Containers/ChannelTemplates/actions.js +20 -0
  107. package/v2Containers/ChannelTemplates/constants.js +8 -0
  108. package/v2Containers/ChannelTemplates/index.js +48 -0
  109. package/v2Containers/ChannelTemplates/messages.js +13 -0
  110. package/v2Containers/ChannelTemplates/reducer.js +34 -0
  111. package/v2Containers/ChannelTemplates/sagas.js +32 -0
  112. package/v2Containers/ChannelTemplates/selectors.js +25 -0
  113. package/v2Containers/ChannelTemplates/tests/actions.test.js +18 -0
  114. package/v2Containers/ChannelTemplates/tests/index.test.js +10 -0
  115. package/v2Containers/ChannelTemplates/tests/reducer.test.js +9 -0
  116. package/v2Containers/ChannelTemplates/tests/sagas.test.js +15 -0
  117. package/v2Containers/ChannelTemplates/tests/selectors.test.js +10 -0
  118. package/v2Containers/CreativesContainer/SlideBoxContent.js +257 -0
  119. package/v2Containers/CreativesContainer/SlideBoxFooter.js +45 -0
  120. package/v2Containers/CreativesContainer/SlideBoxHeader.js +70 -0
  121. package/v2Containers/CreativesContainer/actions.js +27 -0
  122. package/v2Containers/CreativesContainer/constants.js +16 -0
  123. package/v2Containers/CreativesContainer/index.js +483 -0
  124. package/v2Containers/CreativesContainer/index.scss +27 -0
  125. package/v2Containers/CreativesContainer/messages.js +293 -0
  126. package/v2Containers/CreativesContainer/reducer.js +29 -0
  127. package/v2Containers/CreativesContainer/sagas.js +11 -0
  128. package/v2Containers/CreativesContainer/selectors.js +30 -0
  129. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -0
  130. package/v2Containers/CreativesContainer/tests/index.test.js +10 -0
  131. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -0
  132. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -0
  133. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -0
  134. package/v2Containers/Dashboard/actions.js +15 -0
  135. package/v2Containers/Dashboard/constants.js +7 -0
  136. package/v2Containers/Dashboard/index.js +54 -0
  137. package/v2Containers/Dashboard/messages.js +13 -0
  138. package/v2Containers/Dashboard/reducer.js +21 -0
  139. package/v2Containers/Dashboard/sagas.js +11 -0
  140. package/v2Containers/Dashboard/selectors.js +25 -0
  141. package/v2Containers/Dashboard/tests/actions.test.js +18 -0
  142. package/v2Containers/Dashboard/tests/index.test.js +10 -0
  143. package/v2Containers/Dashboard/tests/reducer.test.js +9 -0
  144. package/v2Containers/Dashboard/tests/sagas.test.js +15 -0
  145. package/v2Containers/Dashboard/tests/selectors.test.js +10 -0
  146. package/v2Containers/Ebill/_ebill.scss +5 -0
  147. package/v2Containers/Ebill/actions.js +43 -0
  148. package/v2Containers/Ebill/constants.js +20 -0
  149. package/v2Containers/Ebill/index.js +1261 -0
  150. package/v2Containers/Ebill/messages.js +73 -0
  151. package/v2Containers/Ebill/reducer.js +72 -0
  152. package/v2Containers/Ebill/sagas.js +65 -0
  153. package/v2Containers/Ebill/selectors.js +25 -0
  154. package/v2Containers/Ebill/tests/actions.test.js +18 -0
  155. package/v2Containers/Ebill/tests/index.test.js +10 -0
  156. package/v2Containers/Ebill/tests/reducer.test.js +9 -0
  157. package/v2Containers/Ebill/tests/sagas.test.js +15 -0
  158. package/v2Containers/Ebill/tests/selectors.test.js +10 -0
  159. package/v2Containers/Email/_email.scss +140 -0
  160. package/v2Containers/Email/actions.js +86 -0
  161. package/v2Containers/Email/constants.js +37 -0
  162. package/v2Containers/Email/index.js +2703 -0
  163. package/v2Containers/Email/initialSchema.js +540 -0
  164. package/v2Containers/Email/messages.js +237 -0
  165. package/v2Containers/Email/reducer.js +147 -0
  166. package/v2Containers/Email/sagas.js +133 -0
  167. package/v2Containers/Email/selectors.js +34 -0
  168. package/v2Containers/Email/tests/actions.test.js +18 -0
  169. package/v2Containers/Email/tests/index.test.js +10 -0
  170. package/v2Containers/Email/tests/reducer.test.js +9 -0
  171. package/v2Containers/Email/tests/sagas.test.js +15 -0
  172. package/v2Containers/Email/tests/selectors.test.js +10 -0
  173. package/v2Containers/EmailWrapper/actions.js +15 -0
  174. package/v2Containers/EmailWrapper/constants.js +7 -0
  175. package/v2Containers/EmailWrapper/index.js +258 -0
  176. package/v2Containers/EmailWrapper/messages.js +57 -0
  177. package/v2Containers/EmailWrapper/reducer.js +23 -0
  178. package/v2Containers/EmailWrapper/sagas.js +11 -0
  179. package/v2Containers/EmailWrapper/selectors.js +25 -0
  180. package/v2Containers/EmailWrapper/tests/actions.test.js +18 -0
  181. package/v2Containers/EmailWrapper/tests/index.test.js +10 -0
  182. package/v2Containers/EmailWrapper/tests/reducer.test.js +9 -0
  183. package/v2Containers/EmailWrapper/tests/sagas.test.js +15 -0
  184. package/v2Containers/EmailWrapper/tests/selectors.test.js +10 -0
  185. package/v2Containers/LanguageProvider/actions.js +17 -0
  186. package/v2Containers/LanguageProvider/constants.js +8 -0
  187. package/v2Containers/LanguageProvider/index.js +46 -0
  188. package/v2Containers/LanguageProvider/reducer.js +30 -0
  189. package/v2Containers/LanguageProvider/selectors.js +20 -0
  190. package/v2Containers/LanguageProvider/tests/actions.test.js +19 -0
  191. package/v2Containers/LanguageProvider/tests/index.test.js +49 -0
  192. package/v2Containers/LanguageProvider/tests/reducer.test.js +20 -0
  193. package/v2Containers/LanguageProvider/tests/selectors.test.js +15 -0
  194. package/v2Containers/Line/Create/_lineCreate.scss +43 -0
  195. package/v2Containers/Line/Create/actions.js +90 -0
  196. package/v2Containers/Line/Create/constants.js +39 -0
  197. package/v2Containers/Line/Create/index.js +822 -0
  198. package/v2Containers/Line/Create/messages.js +173 -0
  199. package/v2Containers/Line/Create/reducer.js +99 -0
  200. package/v2Containers/Line/Create/sagas.js +107 -0
  201. package/v2Containers/Line/Create/selectors.js +36 -0
  202. package/v2Containers/Line/Edit/_lineEdit.scss +21 -0
  203. package/v2Containers/Line/Edit/actions.js +79 -0
  204. package/v2Containers/Line/Edit/constants.js +27 -0
  205. package/v2Containers/Line/Edit/index.js +1050 -0
  206. package/v2Containers/Line/Edit/messages.js +157 -0
  207. package/v2Containers/Line/Edit/reducer.js +83 -0
  208. package/v2Containers/Line/Edit/sagas.js +81 -0
  209. package/v2Containers/Line/Edit/selectors.js +29 -0
  210. package/v2Containers/Line/Edit/tests/actions.test.js +18 -0
  211. package/v2Containers/Line/Edit/tests/index.test.js +10 -0
  212. package/v2Containers/Line/Edit/tests/reducer.test.js +9 -0
  213. package/v2Containers/Line/Edit/tests/sagas.test.js +15 -0
  214. package/v2Containers/Line/Edit/tests/selectors.test.js +10 -0
  215. package/v2Containers/Login/assets/images/capillary_logo.png +0 -0
  216. package/v2Containers/Login/components/LoginForm/index.js +59 -0
  217. package/v2Containers/Login/components/LoginForm/messages.js +21 -0
  218. package/v2Containers/Login/components/LoginForm/tests/index.test.js +10 -0
  219. package/v2Containers/Login/index.js +106 -0
  220. package/v2Containers/Login/messages.js +21 -0
  221. package/v2Containers/Login/selectors.js +25 -0
  222. package/v2Containers/Login/tests/index.test.js +10 -0
  223. package/v2Containers/Login/tests/sagas.test.js +15 -0
  224. package/v2Containers/Login/tests/selectors.test.js +10 -0
  225. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +41 -0
  226. package/v2Containers/MobilePush/Create/actions.js +52 -0
  227. package/v2Containers/MobilePush/Create/constants.js +24 -0
  228. package/v2Containers/MobilePush/Create/index.js +1759 -0
  229. package/v2Containers/MobilePush/Create/messages.js +237 -0
  230. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  231. package/v2Containers/MobilePush/Create/sagas.js +60 -0
  232. package/v2Containers/MobilePush/Create/selectors.js +28 -0
  233. package/v2Containers/MobilePush/Create/tests/actions.test.js +18 -0
  234. package/v2Containers/MobilePush/Create/tests/index.test.js +10 -0
  235. package/v2Containers/MobilePush/Create/tests/reducer.test.js +9 -0
  236. package/v2Containers/MobilePush/Create/tests/sagas.test.js +15 -0
  237. package/v2Containers/MobilePush/Create/tests/selectors.test.js +10 -0
  238. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +38 -0
  239. package/v2Containers/MobilePush/Edit/actions.js +91 -0
  240. package/v2Containers/MobilePush/Edit/constants.js +35 -0
  241. package/v2Containers/MobilePush/Edit/index.js +1846 -0
  242. package/v2Containers/MobilePush/Edit/messages.js +253 -0
  243. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  244. package/v2Containers/MobilePush/Edit/sagas.js +119 -0
  245. package/v2Containers/MobilePush/Edit/selectors.js +32 -0
  246. package/v2Containers/MobilePush/Edit/tests/actions.test.js +18 -0
  247. package/v2Containers/MobilePush/Edit/tests/index.test.js +10 -0
  248. package/v2Containers/MobilePush/Edit/tests/reducer.test.js +9 -0
  249. package/v2Containers/MobilePush/Edit/tests/sagas.test.js +15 -0
  250. package/v2Containers/MobilePush/Edit/tests/selectors.test.js +10 -0
  251. package/v2Containers/MobilePush/commonMethods.js +249 -0
  252. package/v2Containers/MobilePush/eventsMap.js +127 -0
  253. package/v2Containers/MobilePush/initialSchema.js +1739 -0
  254. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  255. package/v2Containers/MobilepushWrapper/index.js +136 -0
  256. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  257. package/v2Containers/MobilepushWrapper/tests/index.test.js +10 -0
  258. package/v2Containers/NotFoundPage/index.js +25 -0
  259. package/v2Containers/NotFoundPage/messages.js +13 -0
  260. package/v2Containers/NotFoundPage/tests/index.test.js +17 -0
  261. package/v2Containers/Sms/Create/_smsCreate.scss +58 -0
  262. package/v2Containers/Sms/Create/actions.js +27 -0
  263. package/v2Containers/Sms/Create/constants.js +16 -0
  264. package/v2Containers/Sms/Create/index.js +1017 -0
  265. package/v2Containers/Sms/Create/messages.js +85 -0
  266. package/v2Containers/Sms/Create/reducer.js +41 -0
  267. package/v2Containers/Sms/Create/sagas.js +35 -0
  268. package/v2Containers/Sms/Create/selectors.js +28 -0
  269. package/v2Containers/Sms/Create/tests/actions.test.js +18 -0
  270. package/v2Containers/Sms/Create/tests/index.test.js +10 -0
  271. package/v2Containers/Sms/Create/tests/reducer.test.js +9 -0
  272. package/v2Containers/Sms/Create/tests/sagas.test.js +15 -0
  273. package/v2Containers/Sms/Create/tests/selectors.test.js +10 -0
  274. package/v2Containers/Sms/Edit/actions.js +45 -0
  275. package/v2Containers/Sms/Edit/constants.js +18 -0
  276. package/v2Containers/Sms/Edit/index.js +1018 -0
  277. package/v2Containers/Sms/Edit/messages.js +89 -0
  278. package/v2Containers/Sms/Edit/reducer.js +52 -0
  279. package/v2Containers/Sms/Edit/sagas.js +50 -0
  280. package/v2Containers/Sms/Edit/selectors.js +32 -0
  281. package/v2Containers/Sms/Edit/tests/actions.test.js +18 -0
  282. package/v2Containers/Sms/Edit/tests/index.test.js +10 -0
  283. package/v2Containers/Sms/Edit/tests/reducer.test.js +9 -0
  284. package/v2Containers/Sms/Edit/tests/sagas.test.js +15 -0
  285. package/v2Containers/Sms/Edit/tests/selectors.test.js +10 -0
  286. package/v2Containers/Sms/initialSchema.js +281 -0
  287. package/v2Containers/TagList/_tagList.scss +8 -0
  288. package/v2Containers/TagList/actions.js +15 -0
  289. package/v2Containers/TagList/constants.js +7 -0
  290. package/v2Containers/TagList/index.js +236 -0
  291. package/v2Containers/TagList/messages.js +13 -0
  292. package/v2Containers/TagList/reducer.js +23 -0
  293. package/v2Containers/TagList/sagas.js +11 -0
  294. package/v2Containers/TagList/selectors.js +25 -0
  295. package/v2Containers/TagList/tests/actions.test.js +18 -0
  296. package/v2Containers/TagList/tests/index.test.js +10 -0
  297. package/v2Containers/TagList/tests/reducer.test.js +9 -0
  298. package/v2Containers/TagList/tests/sagas.test.js +15 -0
  299. package/v2Containers/TagList/tests/selectors.test.js +10 -0
  300. package/v2Containers/Templates/_templates.scss +349 -0
  301. package/v2Containers/Templates/actions.js +110 -0
  302. package/v2Containers/Templates/constants.js +45 -0
  303. package/v2Containers/Templates/index.js +1682 -0
  304. package/v2Containers/Templates/messages.js +273 -0
  305. package/v2Containers/Templates/reducer.js +142 -0
  306. package/v2Containers/Templates/sagas.js +180 -0
  307. package/v2Containers/Templates/selectors.js +68 -0
  308. package/v2Containers/Templates/tests/actions.test.js +18 -0
  309. package/v2Containers/Templates/tests/index.test.js +10 -0
  310. package/v2Containers/Templates/tests/reducer.test.js +9 -0
  311. package/v2Containers/Templates/tests/sagas.test.js +15 -0
  312. package/v2Containers/Templates/tests/selectors.test.js +10 -0
  313. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  314. package/v2Containers/TemplatesV2/actions.js +16 -0
  315. package/v2Containers/TemplatesV2/constants.js +10 -0
  316. package/v2Containers/TemplatesV2/index.js +217 -0
  317. package/v2Containers/TemplatesV2/messages.js +29 -0
  318. package/v2Containers/TemplatesV2/selectors.js +25 -0
  319. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -0
  320. package/v2Containers/TemplatesV2/tests/index.test.js +10 -0
  321. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -0
  322. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -0
  323. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -0
  324. package/v2Containers/TestPage/constants.js +7 -0
  325. package/v2Containers/TestPage/index.js +31 -0
  326. package/v2Containers/TestPage/messages.js +13 -0
  327. package/v2Containers/TestPage/reducer.js +21 -0
  328. package/v2Containers/TestPage/sagas.js +11 -0
  329. package/v2Containers/Testv2/actions.js +15 -0
  330. package/v2Containers/Testv2/constants.js +7 -0
  331. package/v2Containers/Testv2/index.js +47 -0
  332. package/v2Containers/Testv2/messages.js +13 -0
  333. package/v2Containers/Testv2/reducer.js +23 -0
  334. package/v2Containers/Testv2/sagas.js +11 -0
  335. package/v2Containers/Testv2/selectors.js +25 -0
  336. package/v2Containers/Testv2/tests/actions.test.js +18 -0
  337. package/v2Containers/Testv2/tests/index.test.js +10 -0
  338. package/v2Containers/Testv2/tests/reducer.test.js +9 -0
  339. package/v2Containers/Testv2/tests/sagas.test.js +15 -0
  340. package/v2Containers/Testv2/tests/selectors.test.js +10 -0
  341. package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
  342. package/v2Containers/WeChat/MapTemplates/actions.js +52 -0
  343. package/v2Containers/WeChat/MapTemplates/constants.js +28 -0
  344. package/v2Containers/WeChat/MapTemplates/index.js +1385 -0
  345. package/v2Containers/WeChat/MapTemplates/messages.js +73 -0
  346. package/v2Containers/WeChat/MapTemplates/reducer.js +74 -0
  347. package/v2Containers/WeChat/MapTemplates/sagas.js +86 -0
  348. package/v2Containers/WeChat/MapTemplates/selectors.js +25 -0
  349. package/v2Containers/WeChat/MapTemplates/tests/actions.test.js +18 -0
  350. package/v2Containers/WeChat/MapTemplates/tests/index.test.js +10 -0
  351. package/v2Containers/WeChat/MapTemplates/tests/reducer.test.js +9 -0
  352. package/v2Containers/WeChat/MapTemplates/tests/sagas.test.js +15 -0
  353. package/v2Containers/WeChat/MapTemplates/tests/selectors.test.js +10 -0
  354. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
  355. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
  356. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
  357. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1053 -0
  358. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +141 -0
  359. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
  360. package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  361. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +48 -0
  362. package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
  363. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/actions.test.js +18 -0
  364. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/index.test.js +10 -0
  365. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/reducer.test.js +9 -0
  366. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/sagas.test.js +15 -0
  367. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/selectors.test.js +10 -0
  368. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
  369. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
  370. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +116 -0
  371. package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
  372. package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
  373. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +32 -0
  374. package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
  375. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/actions.test.js +18 -0
  376. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/index.test.js +10 -0
  377. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/reducer.test.js +9 -0
  378. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/sagas.test.js +15 -0
  379. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/selectors.test.js +10 -0
  380. package/v2Containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
  381. package/v2Containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
  382. package/v2Containers/WeChat/RichmediaTemplates/View/index.js +47 -0
  383. package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +13 -0
  384. package/v2Containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
  385. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
  386. package/v2Containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
  387. package/v2Containers/WeChat/RichmediaTemplates/View/tests/actions.test.js +18 -0
  388. package/v2Containers/WeChat/RichmediaTemplates/View/tests/index.test.js +10 -0
  389. package/v2Containers/WeChat/RichmediaTemplates/View/tests/reducer.test.js +9 -0
  390. package/v2Containers/WeChat/RichmediaTemplates/View/tests/sagas.test.js +15 -0
  391. package/v2Containers/WeChat/RichmediaTemplates/View/tests/selectors.test.js +10 -0
@@ -0,0 +1,24 @@
1
+ export const DEFAULT_LOCALE = 'en';
2
+ export const SWITCH_ORG_REQUEST = 'cap/SWITCH_ORG_REQUEST';
3
+ export const SWITCH_ORG_SUCCESS = 'cap/SWITCH_ORG_SUCCESS';
4
+ export const SWITCH_ORG_FAILURE = 'cap/SWITCH_ORG_FAILURE';
5
+ export const LOGIN_REQUEST = 'cap/LOGIN_REQUEST';
6
+ export const LOGIN_SUCCESS = 'cap/LOGIN_SUCCESS';
7
+ export const LOGIN_FAILURE = 'cap/LOGIN_FAILURE';
8
+
9
+ export const LOGOUT_REQUEST = 'cap/LOGOUT_REQUEST';
10
+ export const LOGOUT_SUCCESS = 'cap/LOGOUT_SUCCESS';
11
+ export const LOGOUT_FAILURE = 'cap/LOGOUT_FAILURE';
12
+ export const ADD_MESSAGE = 'cap/ADD_MESSAGE';
13
+ export const REMOVE_MESSAGE = 'cap/REMOVE_MESSAGE';
14
+ export const GET_USER_DATA_REQUEST = 'cap/GET_USER_DATA_REQUEST';
15
+ export const GET_USER_DATA_SUCCESS = 'cap/GET_USER_DATA_SUCCESS';
16
+ export const GET_USER_DATA_FAILURE = 'cap/GET_USER_DATA_FAILURE';
17
+
18
+ export const GET_SCHEMA_FOR_ENTITY_FAILURE = 'cap/GET_SCHEMA_FOR_ENTITY_FAILURE';
19
+ export const GET_SCHEMA_FOR_ENTITY_REQUEST = 'cap/GET_SCHEMA_FOR_ENTITY_REQUEST';
20
+ export const GET_SCHEMA_FOR_ENTITY_SUCCESS = 'cap/GET_SCHEMA_FOR_ENTITY_SUCCESS';
21
+ export const CLEAR_META_ENTITIES = 'cap/CLEAR_META_ENTITIES';
22
+ export const HIDE_TAGS = 'cap/HIDE_TAGS';
23
+
24
+ export const SET_INJECTED_TAGS = 'cap/SET_INJECTED_TAGS';
@@ -0,0 +1,349 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import Helmet from 'react-helmet';
4
+ import { connect } from 'react-redux';
5
+ // import { Link } from 'react-router';
6
+ // import { Icon } from 'semantic-ui-react';
7
+ import { bindActionCreators } from 'redux';
8
+ import styled from 'styled-components';
9
+ import { createStructuredSelector } from 'reselect';
10
+ import _ from 'lodash';
11
+ import moment from 'moment';
12
+ import 'moment/locale/zh-cn';
13
+ import { injectIntl, intlShape } from 'react-intl';
14
+ import {CapNotification} from '@capillarytech/cap-ui-library';
15
+ import TopBar from '../../components/TopBar';
16
+ // import 'moment/locale/en-us';
17
+ import Sidebar from '../../components/Sidebar';
18
+ import { makeSelectAuthenticated, makeSelectUser } from './selectors';
19
+ import * as actions from './actions';
20
+ import * as locationActions from '../LanguageProvider/actions';
21
+ import * as appActions from '../App/actions';
22
+ import config from '../../config/app';
23
+ import messages from './messsages';
24
+ const gtm = window.dataLayer || [];
25
+
26
+ const CapWrapper = styled.div`
27
+ margin: 0 auto;
28
+ display: flex;
29
+ min-height: 100%;
30
+ padding: 0;
31
+ flex-direction: column;
32
+ `;
33
+
34
+ export class Cap extends React.Component { // eslint-disable-line react/prefer-stateless-function
35
+
36
+ constructor(props) {
37
+ super(props);
38
+ this.state = {
39
+ menuData: [],
40
+ switchedOrg: false,
41
+ };
42
+ this.changeOrg = this.changeOrg.bind(this);
43
+ this.logout = this.logout.bind(this);
44
+ this.handleRemoveMessage = this.handleRemoveMessage.bind(this);
45
+ this.getMappedLocale = this.getMappedLocale.bind(this);
46
+ }
47
+
48
+ componentWillMount() {
49
+ this.props.actions.getUserData();
50
+ if (this.props.Global.user) {
51
+ const userGtmData = this.getUserGtmData(this.props);
52
+ gtm.push(userGtmData);
53
+ }
54
+ if (this.props.Global.orgID !== undefined) {
55
+ gtm.push({orgId: this.props.Global.orgID});
56
+ }
57
+ if (this.props.Global.isLoggedIn) {
58
+ if (this.props.Global.user && Object.keys(this.props.Global.user).length) {
59
+ // gtm.push({userId: this.props.Global.user.id});
60
+ this.props.appActions.getSidebar();
61
+ }
62
+ }
63
+ }
64
+
65
+ componentDidMount() {
66
+ const user = localStorage.getItem('user');
67
+ let locale = 'en';
68
+ if (user) {
69
+ locale = JSON.parse(user).lang;
70
+ }
71
+ locale = this.getMappedLocale(locale);
72
+ //locale = 'zh';
73
+ console.log('Setting final locale as', locale);
74
+ moment.locale(locale);
75
+ this.props.locationActions.changeLocale(locale);
76
+ }
77
+
78
+ componentWillReceiveProps(nextProps) {
79
+ const user = this.props.Global.user;
80
+ const nextPropsUser = nextProps.Global.user;
81
+ if (!nextProps.Global.settingProxyOrg && nextProps.Global.changeProxyOrgSuccess &&
82
+ !_.isEqual(nextProps.Global.changeProxyOrgSuccess, this.props.Global.changeProxyOrgSuccess) && !this.state.switchedOrg) {
83
+ this.navigateToDashboard();
84
+ }
85
+
86
+ const callBack = nextProps.routeParams.callbackUrl ? decodeURIComponent(nextProps.routeParams.callbackUrl) : "";
87
+ if (nextProps.Global.error) {
88
+ const locationValue = `${window.location.origin}${callBack}?flash=${nextProps.Global.error}`;
89
+ window.location.replace(locationValue);
90
+ window.location.reload();
91
+ }
92
+
93
+ if (nextPropsUser && user && nextProps.Global.isLoggedIn && nextProps.Global.isLoggedIn !== this.props.Global.isLoggedIn) {
94
+ this.props.appActions.getSidebar();
95
+ }
96
+
97
+ if (nextProps.Global.user && this.props.Global.user && (nextProps.Global.user.refID !== this.props.Global.user.refID)) {
98
+ const userGtmData = this.getUserGtmData(nextProps);
99
+ gtm.push(userGtmData);
100
+ }
101
+
102
+ if (nextProps.Global.isLoggedIn && nextProps.Global.isLoggedIn !== this.props.Global.isLoggedIn) {
103
+ if (nextProps.Global.orgID !== undefined && !_.isEqual(nextProps.Global.orgID, this.props.Global.orgID)) {
104
+ const userGtmData = this.getUserGtmData(nextProps);
105
+ gtm.push(userGtmData);
106
+ }
107
+ }
108
+ }
109
+
110
+ componentWillUnmount() {
111
+ this.setState({ switchedOrg: false });
112
+ }
113
+
114
+ // getSideBarData(reportData) {
115
+ // const tmpMenuData = [];
116
+ // const categoryId = reportData.categories ? Object.keys(reportData.categories) : [];
117
+ // _.forEach(categoryId, (id) => {
118
+ // const groupReport = {
119
+ // group: reportData.categories[id].name,
120
+ // items: [],
121
+ // };
122
+ // _.forEach(reportData.reportList, (report, reportId) => {
123
+ // if (report.category === id) {
124
+ // groupReport.items.push({
125
+ // link: `/report/${reportId}`,
126
+ // text: report.name,
127
+ // });
128
+ // }
129
+ // });
130
+ // tmpMenuData.push(groupReport);
131
+ // });
132
+ // const menuLibrary = {
133
+ // group: 'Library',
134
+ // items: [
135
+ // {
136
+ // link: '/library/charts',
137
+ // text: 'Charts',
138
+ // },
139
+ // {
140
+ // link: '/library/dimension',
141
+ // text: 'Dimensions',
142
+ // },
143
+ // ],
144
+ // };
145
+ // tmpMenuData.push(menuLibrary);
146
+ // this.setState({ menuData: tmpMenuData });
147
+ // }
148
+
149
+ getUserGtmData = (props) => {
150
+ const { user: userData } = props.Global;
151
+ const userName = userData.attributes.USERNAME;
152
+ const userEmail = userData.attributes.EMAIL;
153
+ const orgObj = find(userData.proxyOrgList, {orgID: props.Global.orgID});
154
+ const gtmData = {
155
+ orgId: props.Global.orgID,
156
+ orgName: orgObj && orgObj.orgName,
157
+ userId: userData.refID,
158
+ userName: userName && userName.value,
159
+ userEmail: userEmail && userEmail.value,
160
+ isCapUser: userData.isCapUser,
161
+ };
162
+ return gtmData;
163
+ }
164
+
165
+ getMappedLocale(locale) {
166
+ const map = {
167
+ 'en': 'en',
168
+ 'zh-cn': 'zh',
169
+ };
170
+ return map[locale];
171
+ }
172
+ handleRemoveMessage(messageIndex) {
173
+ this.props.actions.removeMessageFromQueue(messageIndex);
174
+ }
175
+
176
+ navigateToDashboard() {
177
+ const dashboardUrl = process.env.NODE_ENV === 'production' ? config.production.dashboard_url : config.development.dashboard_url;
178
+ this.props.router.push({ pathname: dashboardUrl, state: {} });
179
+ this.props.router.go(dashboardUrl);
180
+ }
181
+
182
+ logout() {
183
+ this.props.actions.logout();
184
+ }
185
+ changeOrg(orgId) {
186
+ this.props.actions.changeOrg(orgId);
187
+ //this.navigateToDashboard();
188
+ }
189
+
190
+ render() {
191
+ const userData = this.props.Global;
192
+ const type = this.props.location.query.type;
193
+ // const changeOrg = this.props.actions.changeOrg;
194
+ // const logout = this.props.actions.logout;
195
+ console.log('props', this.props);
196
+ const proxyOrgList = [];
197
+ let defaultOrgName = '';
198
+ let defaultOrgId = '';
199
+ let userName = '';
200
+ const navigateToDashboard = this.navigateToDashboard;
201
+ if (userData && userData.user && userData.user !== '') {
202
+ console.log('Org name ', userData.user.orgName, userData.user.orgID);
203
+ defaultOrgName = userData.user.orgName;
204
+ defaultOrgId = userData.user.orgID;
205
+ proxyOrgList.push({ text: defaultOrgName, value: defaultOrgId });
206
+ const orgList = userData.user.proxyOrgList;
207
+ if (!_.isEmpty(orgList)) {
208
+ _.forEach(orgList, (item) => {
209
+ const id = item.orgID;
210
+ let name = item.orgName;
211
+ if (id === 486) {
212
+ name = 'Demo Org';
213
+ }
214
+ proxyOrgList.push({ key: id, text: name, value: id });
215
+ });
216
+ }
217
+ userName = userData.user.firstName;
218
+ }
219
+ const actionComponents = "";
220
+ const toastMessages = this.props.Global.messages;
221
+ const loggedIn = this.props.Global.isLoggedIn;
222
+ const menuData = [
223
+ {
224
+ group: this.props.intl.formatMessage(messages.creativesDashboard),
225
+ items: [
226
+ {
227
+ link: '/sms',
228
+ text: this.props.intl.formatMessage(messages.sms),
229
+ value: 'SMS',
230
+ },
231
+ {
232
+ link: '/wechat',
233
+ text: this.props.intl.formatMessage(messages.wechat),
234
+ value: 'WECHAT',
235
+ },
236
+ {
237
+ link: '/mobilepush',
238
+ text: 'Mobile Push',
239
+ value: 'MOBILEPUSH',
240
+ },
241
+ {
242
+ link: '/assets',
243
+ text: this.props.intl.formatMessage(messages.gallery),
244
+ value: 'GALLERY',
245
+ },
246
+ {
247
+ link: '/email',
248
+ text: this.props.intl.formatMessage(messages.email),
249
+ value: 'EMAIL',
250
+ },
251
+ {
252
+ link: '/ebill',
253
+ text: this.props.intl.formatMessage(messages.ebill),
254
+ value: 'EBILL',
255
+ },
256
+ {
257
+ link: '/line',
258
+ text: 'Line',
259
+ value: 'LINE',
260
+ },
261
+ ],
262
+ },
263
+ {
264
+ group: this.props.intl.formatMessage(messages.campaignsDashboard),
265
+ items: [
266
+ {
267
+ link: '/campaign/index',
268
+ text: this.props.intl.formatMessage(messages.campaignsHome),
269
+ value: 'Campaigns Home',
270
+ external: true,
271
+ },
272
+ ],
273
+ },
274
+ ];
275
+ return (
276
+ <CapWrapper>
277
+ <Helmet
278
+ titleTemplate="Capillary - %s"
279
+ defaultTitle="App Name"
280
+ meta={[
281
+ { name: 'description', content: 'App Name' },
282
+ ]}
283
+ />
284
+ <div className="wrapper">
285
+ {loggedIn && type !== 'embedded' ?
286
+ <TopBar
287
+ proxyOrgList={proxyOrgList}
288
+ userName={userName}
289
+ orgName={defaultOrgName}
290
+ orgID={defaultOrgId}
291
+ changeOrg={this.changeOrg}
292
+ navigateToDashboard={navigateToDashboard}
293
+ logout={this.logout}
294
+ /> : ''}
295
+ <div className="main">
296
+ {loggedIn && type !== 'embedded' && this.props.location.pathname.indexOf('v2') === -1 ? <div id="cap-sidebar" className={'sidebar'}>
297
+ <Sidebar
298
+ menuData={menuData}
299
+ actionComponents={actionComponents}
300
+ router={this.props.router}
301
+ />
302
+ </div> : '' }
303
+ <div className="main-content">
304
+ {React.Children.toArray(this.props.children)}
305
+ </div>
306
+ </div>
307
+ </div>
308
+ {(toastMessages && toastMessages.length > 0) &&
309
+ toastMessages.map((message) => CapNotification[message.type]({message: message.text, key: message.text, duration: message.duration || 5})
310
+ )
311
+ }
312
+ {this.props.Global.fetching_userdata &&
313
+ <div className="cap-loader-box">
314
+ <img
315
+ className="loader-image"
316
+ src="https://s3.amazonaws.com/fileservice.in/intouch_creative_assets/88561f46de9407021cad.gif"
317
+ alt="Capillary"/>
318
+ </div>
319
+ }
320
+ </CapWrapper>
321
+ );
322
+ }
323
+ }
324
+
325
+ Cap.propTypes = {
326
+ children: PropTypes.node,
327
+ actions: PropTypes.object.isRequired,
328
+ Global: PropTypes.object,
329
+ router: PropTypes.object,
330
+ appActions: PropTypes.object,
331
+ locationActions: PropTypes.object,
332
+ location: PropTypes.object,
333
+ intl: intlShape.isRequired,
334
+ };
335
+
336
+ const mapStateToProps = createStructuredSelector({
337
+ Global: makeSelectAuthenticated(),
338
+ User: makeSelectUser(),
339
+ });
340
+
341
+ function mapDispatchToProps(dispatch) {
342
+ return {
343
+ actions: bindActionCreators(actions, dispatch),
344
+ appActions: bindActionCreators(appActions, dispatch),
345
+ locationActions: bindActionCreators(locationActions, dispatch),
346
+ };
347
+ }
348
+
349
+ export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(Cap));
@@ -0,0 +1,63 @@
1
+ import { defineMessages } from 'react-intl';
2
+ export default defineMessages({
3
+ "sms": {
4
+ id: 'reon.components.Cap.sms',
5
+ defaultMessage: 'SMS',
6
+ },
7
+ "wechat": {
8
+ id: 'reon.components.Cap.wechat',
9
+ defaultMessage: 'WeChat',
10
+ },
11
+ "gallery": {
12
+ id: 'reon.components.Cap.gallery',
13
+ defaultMessage: 'Gallery',
14
+ },
15
+ "creativesDashboard": {
16
+ id: 'reon.components.Cap.creativesDashboard',
17
+ defaultMessage: 'Creatives',
18
+ },
19
+ "creatives": {
20
+ id: 'reon.components.Cap.creatives',
21
+ defaultMessage: 'Creatives',
22
+ },
23
+ "campaigns": {
24
+ id: 'reon.components.Cap.campaigns',
25
+ defaultMessage: 'Campaigns',
26
+ },
27
+ "loyalty": {
28
+ id: 'reon.components.Cap.loyalty',
29
+ defaultMessage: 'Loyalty',
30
+ },
31
+ "member care": {
32
+ id: 'reon.components.Cap.memberCare',
33
+ defaultMessage: 'Member Care',
34
+ },
35
+ "workbench": {
36
+ id: 'reon.components.Cap.Workbench',
37
+ defaultMessage: 'WorkBench',
38
+ },
39
+ "store care": {
40
+ id: 'reon.components.Cap.storeCare',
41
+ defaultMessage: 'Store Care',
42
+ },
43
+ "store performance": {
44
+ id: 'reon.components.Cap.storePerformance',
45
+ defaultMessage: 'Store Performance',
46
+ },
47
+ "email": {
48
+ id: 'reon.components.Cap.email',
49
+ defaultMessage: 'Email',
50
+ },
51
+ "ebill": {
52
+ id: 'reon.components.Cap.ebill',
53
+ defaultMessage: 'Ebill',
54
+ },
55
+ "campaignsDashboard": {
56
+ id: 'reon.components.campaignsDashboard',
57
+ defaultMessage: 'Campaigns',
58
+ },
59
+ "campaignsHome": {
60
+ id: 'reon.components.campaignsHome',
61
+ defaultMessage: "Campaigns Home",
62
+ },
63
+ });
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Created by vivek on 22/5/17.
3
+ */
4
+ import { fromJS } from 'immutable';
5
+ import _ from 'lodash';
6
+ import * as types from './constants';
7
+ import initialState from '../../initialState';
8
+
9
+ function capReducer(state = fromJS(initialState.cap), action) {
10
+ switch (action.type) {
11
+ case types.LOGIN_REQUEST:
12
+ return state.set('login_progress', true);
13
+ case types.LOGIN_SUCCESS:
14
+ return state
15
+ .set('login_progress', false)
16
+ .set('token', action.res.token)
17
+ .set('user', fromJS(action.res.user))
18
+ .set('message', '')
19
+ .set('authenticated', true)
20
+ .set('isLoggedIn', true);
21
+ case types.LOGIN_FAILURE:
22
+ return state
23
+ .set('login_progress', false)
24
+ .set('message', action.error.message);
25
+ case types.LOGOUT_REQUEST:
26
+ return state.set('login_progress', false);
27
+ case types.LOGOUT_SUCCESS:
28
+ return state;
29
+ case types.LOGOUT_FAILURE:
30
+ return state;
31
+ case types.SWITCH_ORG_REQUEST:
32
+ return state
33
+ .set('settingProxyOrg', true)
34
+ .set('changeProxyOrgSuccess', false);
35
+ case types.SWITCH_ORG_SUCCESS:
36
+ return state
37
+ .set('orgID', action.orgID)
38
+ .set('settingProxyOrg', false)
39
+ .set('changeProxyOrgSuccess', action.isSuccess);
40
+ case types.SWITCH_ORG_FAILURE:
41
+ return state
42
+ .set('settingProxyOrg', false)
43
+ .set('changeProxyOrgSuccess', false);
44
+ case types.ADD_MESSAGE: {
45
+ const message = {
46
+ messageId: action.message.id,
47
+ title: action.message.title,
48
+ text: action.message.text,
49
+ type: action.message.type,
50
+ hideProgressBar: action.message.hideProgressBar,
51
+ };
52
+ return state
53
+ .set('messages', fromJS(state.get('messages').concat(message)));
54
+ }
55
+ case types.REMOVE_MESSAGE: {
56
+ const messageQueue = state.get('messages').toJS();
57
+ const messageIndex = _.findIndex(messageQueue, { messageId: action.messageIndex });
58
+ messageQueue.splice(messageIndex, 1);
59
+ return state
60
+ .set('messages', fromJS(messageQueue));
61
+ }
62
+ case types.GET_USER_DATA_REQUEST:
63
+ return state
64
+ .set('fetching_userdata', true)
65
+ .set('isLoggedIn', false);
66
+ case types.GET_USER_DATA_SUCCESS:
67
+ return state
68
+ .set('fetching_userdata', false)
69
+ .set('user', fromJS(action.userData))
70
+ .set('currentOrgDetails', fromJS(action.currentOrgDetails))
71
+ .set('isLoggedIn', true)
72
+ .set('orgID', action.currentOrgId);
73
+ case types.GET_USER_DATA_FAILURE:
74
+ return state
75
+ .set('fetching_userdata', false)
76
+ .set('isLoggedIn', false);
77
+ case types.GET_SCHEMA_FOR_ENTITY_REQUEST:
78
+ return state
79
+ .set('fetchingSchema', true);
80
+ case types.GET_SCHEMA_FOR_ENTITY_FAILURE:
81
+ return state
82
+ .set('fetchingSchema', false);
83
+ case types.GET_SCHEMA_FOR_ENTITY_SUCCESS: {
84
+ const stateMeta = state.get('metaEntities');
85
+ console.log('stateMeta', stateMeta);
86
+ return state
87
+ .set('fetchingSchema', false)
88
+ .set('metaEntities', {
89
+ layouts: action.data && action.entityType === 'LAYOUT' ? action.data.metaEntities : stateMeta.layouts,
90
+ tags: action.data && action.entityType === 'TAG' ? action.data.metaEntities : stateMeta.tags,
91
+ });
92
+ }
93
+ case types.CLEAR_META_ENTITIES:
94
+ return state.set('metaEntities', {
95
+ layouts: [],
96
+ tags: [],
97
+ });
98
+ // eslint-disable-next-line no-case-declarations
99
+ case types.HIDE_TAGS:
100
+ const metaEntities = {tags: {}, layouts: state.get('metaEntities').layouts};
101
+ metaEntities.tags.standard = _.filter(state.get('metaEntities').tags.standard, (tag) => action.tagList.indexOf(tag.definition.value) === -1);
102
+ metaEntities.tags.custom = _.filter(state.get('metaEntities').tags.custom, (tag) => action.tagList.indexOf(tag.name) === -1);
103
+ return state.setIn(['metaEntities'], metaEntities);
104
+ case types.SET_INJECTED_TAGS:
105
+ return state.set('injectedTags', action.injectedTags);
106
+ default:
107
+ return state;
108
+ }
109
+ }
110
+
111
+ export default capReducer;
@@ -0,0 +1,143 @@
1
+ import { fork, take, call, put, cancelled, cancel, takeLatest } from 'redux-saga/effects';
2
+ import { LOCATION_CHANGE } from 'react-router-redux';
3
+ // import { normalize } from 'normalizr';
4
+ import * as Api from '../../services/api';
5
+ import * as LocalStorage from '../../services/localStorageApi';
6
+ import * as types from './constants';
7
+ import config from '../../config/app';
8
+ import pathConfig from '../../config/path';
9
+ // import {makeSelectOrgId} from './selectors';
10
+
11
+ function* authorize(user) {
12
+ try {
13
+ const res = yield call(Api.authorize, user);
14
+ yield call(LocalStorage.saveItem, 'token', res.token);
15
+ yield call(LocalStorage.saveItem, 'orgID', res.user.orgID);
16
+ yield call(LocalStorage.saveItem, 'user', res.user);
17
+ // yield call(LocalStorage.saveItem, 'isLoggedIn', true);
18
+ yield put({ type: types.LOGIN_SUCCESS, res });
19
+ } catch (error) {
20
+ yield put({ type: types.LOGIN_FAILURE, error });
21
+ } finally {
22
+ if (yield cancelled()) {
23
+ // reducer will clear out login_progress on logout request
24
+ // So this block is not exactly required
25
+ }
26
+ }
27
+ }
28
+
29
+ function* switchOrg({orgID}) {
30
+ try {
31
+ LocalStorage.saveItem('orgID', orgID);
32
+ const res = yield call(Api.changeProxyOrg, orgID);
33
+ yield [put({ type: types.SWITCH_ORG_SUCCESS, orgID, isSuccess: res.success })];
34
+ } catch (error) {
35
+ yield put({ type: types.SWITCH_ORG_FAILURE, error });
36
+ }
37
+ }
38
+
39
+ function* loginFlow() {
40
+ const condition = true;
41
+ while (condition) {
42
+ const { user } = yield take(types.LOGIN_REQUEST);
43
+ const task = yield fork(authorize, user);
44
+ const action = yield take([types.LOGOUT_REQUEST, types.LOGIN_FAILURE]);
45
+ if (action.type === types.LOGOUT_REQUEST) {
46
+ yield cancel(task);
47
+ }
48
+ // yield call(LocalStorage.clearItem, 'token');
49
+ // yield call(LocalStorage.clearItem, 'orgID');
50
+ // yield call(LocalStorage.clearItem, 'user');
51
+ }
52
+ }
53
+
54
+ function* logoutFlow() {
55
+ try {
56
+ const serverLogout = yield call(Api.logout);
57
+ if (serverLogout.success && serverLogout.success === true) {
58
+ const loginUrl = (process.env.NODE_ENV === 'production') ?
59
+ `${pathConfig.publicPath}${config.production.login_url}` : `${pathConfig.publicPath}${config.development.login_url}`;
60
+ yield [put({type: types.LOGOUT_SUCCESS})];
61
+ yield call(LocalStorage.clearItem, 'token');
62
+ yield call(LocalStorage.clearItem, 'orgID');
63
+ yield call(LocalStorage.clearItem, 'user');
64
+ yield call(LocalStorage.clearItem, 'isLoggedIn');
65
+ window.location.href = loginUrl;
66
+ }
67
+ } catch (error) {
68
+ yield put({ type: types.LOGOUT_FAILURE, error });
69
+ }
70
+ }
71
+
72
+ export function* fetchUserInfo() {
73
+ try {
74
+ const result = yield call(Api.getUserData);
75
+ const userData = result.user;
76
+ // const orgId = yield select(makeSelectOrgId());
77
+ // yield put({type: types.GET_ORG_DETAILS_REQUEST, orgId});
78
+ const currentOrgDetails = result.currentOrgDetails;
79
+ if (!(currentOrgDetails && currentOrgDetails.basic_details && currentOrgDetails.basic_details.base_language && (currentOrgDetails.basic_details.base_language !== "" || currentOrgDetails.basic_details.base_language === null))) {
80
+ currentOrgDetails.basic_details.base_language = 'en';
81
+ }
82
+ if (!(currentOrgDetails && currentOrgDetails.basic_details && currentOrgDetails.basic_details.supported_languages && currentOrgDetails.basic_details.supported_languages.length > 0)) {
83
+ currentOrgDetails.basic_details.supported_languages = [
84
+ {
85
+ lang_id: 69,
86
+ language: "English",
87
+ iso_code: "en",
88
+ },
89
+ ];
90
+ }
91
+ yield call(LocalStorage.saveItem, 'orgID', result.currentOrgId);
92
+ yield call(LocalStorage.saveItem, 'user', userData);
93
+ yield put({type: types.GET_USER_DATA_SUCCESS, userData, currentOrgId: result.currentOrgId, currentOrgDetails});
94
+ } catch (error) {
95
+ yield call(LocalStorage.clearItem, 'user');
96
+ yield put({
97
+ type: types.GET_USER_DATA_FAILURE,
98
+ error,
99
+ });
100
+ }
101
+ }
102
+
103
+ export function* fetchSchemaForEntity(queryParams) {
104
+ try {
105
+ console.log('saga fetch Schema For Entity', queryParams);
106
+ const result = yield call(Api.fetchSchemaForEntity, queryParams);
107
+ console.log('cap saga', result);
108
+ // const sidebar = result.response.sidebar;
109
+ yield put({ type: types.GET_SCHEMA_FOR_ENTITY_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', entityType: queryParams.queryParams.type });
110
+ } catch (error) {
111
+ yield put({ type: types.GET_SCHEMA_FOR_ENTITY_FAILURE, error });
112
+ }
113
+ }
114
+
115
+
116
+ function* watchFetchSchemaForEntity() {
117
+ console.log('inside watch get schema');
118
+ const watcher = yield takeLatest(types.GET_SCHEMA_FOR_ENTITY_REQUEST, fetchSchemaForEntity);
119
+ yield take(LOCATION_CHANGE);
120
+ yield cancel(watcher);
121
+ }
122
+
123
+
124
+ function* watchForOrgChange() {
125
+ yield takeLatest(types.SWITCH_ORG_REQUEST, switchOrg);
126
+ }
127
+
128
+ function* watchForLogoutFlow() {
129
+ yield takeLatest(types.LOGOUT_REQUEST, logoutFlow);
130
+ }
131
+
132
+ function* watchForFetchUserInfo() {
133
+ yield takeLatest(types.GET_USER_DATA_REQUEST, fetchUserInfo);
134
+ }
135
+
136
+
137
+ export default [
138
+ loginFlow,
139
+ watchForOrgChange,
140
+ watchForLogoutFlow,
141
+ watchForFetchUserInfo,
142
+ watchFetchSchemaForEntity,
143
+ ];