@capillarytech/creatives-library 2.0.70 → 2.0.72

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 (395) hide show
  1. package/app.js +1 -1
  2. package/components/Ckeditor/index.js +2 -1
  3. package/components/EmailMobilePreview/index.scss +0 -1
  4. package/components/EmailPreviewV2/_emailPreviewV2.scss +4 -1
  5. package/components/EmailPreviewV2/index.js +1 -1
  6. package/components/FormBuilder/index.js +25 -10
  7. package/components/Header/index.js +3 -1
  8. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +38 -3
  9. package/components/TemplatePreview/index.js +45 -51
  10. package/components/TemplatePreview/messages.js +1 -1
  11. package/config/app.js +1 -0
  12. package/containers/Cap/actions.js +0 -5
  13. package/containers/Cap/reducer.js +1 -1
  14. package/containers/Cap/selectors.js +0 -13
  15. package/containers/Ebill/index.js +1 -2
  16. package/containers/Email/_email.scss +1 -0
  17. package/containers/Email/actions.js +3 -8
  18. package/containers/Email/constants.js +0 -1
  19. package/containers/Email/index.js +947 -322
  20. package/containers/Email/reducer.js +0 -3
  21. package/containers/Email/sagas.js +6 -3
  22. package/containers/Email/selectors.js +1 -4
  23. package/containers/Line/Create/index.js +1 -2
  24. package/containers/Line/Edit/_lineEdit.scss +4 -0
  25. package/containers/Line/Edit/index.js +1 -3
  26. package/containers/MobilePush/Create/_mobilePushCreate.scss +3 -12
  27. package/containers/MobilePush/Create/actions.js +0 -6
  28. package/containers/MobilePush/Create/constants.js +0 -1
  29. package/containers/MobilePush/Create/index.js +1133 -628
  30. package/containers/MobilePush/Create/messages.js +1 -5
  31. package/containers/MobilePush/Create/reducer.js +0 -2
  32. package/containers/MobilePush/Create/selectors.js +3 -3
  33. package/containers/MobilePush/Edit/_mobilePushCreate.scss +3 -9
  34. package/containers/MobilePush/Edit/index.js +1127 -393
  35. package/containers/MobilePush/Edit/messages.js +0 -4
  36. package/containers/MobilePush/Edit/reducer.js +1 -2
  37. package/containers/MobilePush/Edit/selectors.js +3 -6
  38. package/containers/Sms/Create/_smsCreate.scss +2 -1
  39. package/containers/Sms/Create/actions.js +4 -4
  40. package/containers/Sms/Create/index.js +570 -102
  41. package/containers/Sms/Create/sagas.js +2 -1
  42. package/containers/Sms/Edit/actions.js +5 -10
  43. package/containers/Sms/Edit/constants.js +0 -1
  44. package/containers/Sms/Edit/index.js +548 -103
  45. package/containers/Sms/Edit/reducer.js +0 -2
  46. package/containers/Sms/Edit/sagas.js +3 -1
  47. package/containers/TagList/index.js +3 -3
  48. package/containers/Templates/actions.js +1 -3
  49. package/containers/Templates/index.js +299 -268
  50. package/containers/Templates/messages.js +90 -122
  51. package/containers/Templates/reducer.js +3 -3
  52. package/containers/Templates/sagas.js +1 -5
  53. package/containers/Templates/selectors.js +1 -41
  54. package/containers/WeChat/MapTemplates/index.js +3 -4
  55. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -4
  56. package/containers/WeChat/RichmediaTemplates/Create/messages.js +4 -0
  57. package/containers/WeChat/RichmediaTemplates/Edit/index.js +3 -1
  58. package/containers/WeChat/RichmediaTemplates/View/index.js +3 -1
  59. package/index.js +31 -31
  60. package/initialState.js +6 -0
  61. package/package.json +3 -3
  62. package/routes.js +24 -19
  63. package/services/api.js +6 -2
  64. package/services/getSchema.js +18 -0
  65. package/v2Containers/App/actions.js +7 -0
  66. package/v2Containers/App/constants.js +3 -0
  67. package/v2Containers/App/reducer.js +19 -0
  68. package/v2Containers/App/sagas.js +26 -0
  69. package/v2Containers/App/selectors.js +25 -0
  70. package/v2Containers/App/tests/actions.test.js +18 -0
  71. package/v2Containers/App/tests/reducer.test.js +9 -0
  72. package/v2Containers/App/tests/sagas.test.js +15 -0
  73. package/v2Containers/App/tests/selectors.test.js +10 -0
  74. package/v2Containers/Assets/Gallery/_gallery.scss +0 -0
  75. package/v2Containers/Assets/Gallery/actions.js +37 -0
  76. package/v2Containers/Assets/Gallery/constants.js +23 -0
  77. package/v2Containers/Assets/Gallery/index.js +479 -0
  78. package/v2Containers/Assets/Gallery/messages.js +97 -0
  79. package/v2Containers/Assets/Gallery/reducer.js +81 -0
  80. package/v2Containers/Assets/Gallery/sagas.js +84 -0
  81. package/v2Containers/Assets/Gallery/selectors.js +25 -0
  82. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +7 -0
  83. package/v2Containers/Assets/Gallery/tests/actions.test.js +26 -0
  84. package/v2Containers/Assets/Gallery/tests/index.test.js +10 -0
  85. package/v2Containers/Assets/Gallery/tests/reducer.test.js +95 -0
  86. package/v2Containers/Assets/Gallery/tests/sagas.test.js +15 -0
  87. package/v2Containers/Assets/Gallery/tests/selectors.test.js +10 -0
  88. package/v2Containers/CallTask/_callTask.scss +5 -0
  89. package/v2Containers/CallTask/actions.js +15 -0
  90. package/v2Containers/CallTask/constants.js +7 -0
  91. package/v2Containers/CallTask/index.js +141 -0
  92. package/v2Containers/CallTask/messages.js +21 -0
  93. package/v2Containers/CallTask/reducer.js +23 -0
  94. package/v2Containers/CallTask/sagas.js +11 -0
  95. package/v2Containers/CallTask/selectors.js +25 -0
  96. package/v2Containers/CallTask/tests/actions.test.js +18 -0
  97. package/v2Containers/CallTask/tests/index.test.js +10 -0
  98. package/v2Containers/CallTask/tests/reducer.test.js +9 -0
  99. package/v2Containers/CallTask/tests/sagas.test.js +15 -0
  100. package/v2Containers/CallTask/tests/selectors.test.js +10 -0
  101. package/v2Containers/Cap/actions.js +64 -0
  102. package/v2Containers/Cap/constants.js +24 -0
  103. package/v2Containers/Cap/index.js +349 -0
  104. package/v2Containers/Cap/messsages.js +63 -0
  105. package/v2Containers/Cap/reducer.js +111 -0
  106. package/v2Containers/Cap/sagas.js +143 -0
  107. package/v2Containers/Cap/selectors.js +85 -0
  108. package/v2Containers/Cap/tests/index.test.js +16 -0
  109. package/v2Containers/Cap/tests/selectors.test.js +28 -0
  110. package/v2Containers/ChannelTemplates/actions.js +20 -0
  111. package/v2Containers/ChannelTemplates/constants.js +8 -0
  112. package/v2Containers/ChannelTemplates/index.js +48 -0
  113. package/v2Containers/ChannelTemplates/messages.js +13 -0
  114. package/v2Containers/ChannelTemplates/reducer.js +34 -0
  115. package/v2Containers/ChannelTemplates/sagas.js +32 -0
  116. package/v2Containers/ChannelTemplates/selectors.js +25 -0
  117. package/v2Containers/ChannelTemplates/tests/actions.test.js +18 -0
  118. package/v2Containers/ChannelTemplates/tests/index.test.js +10 -0
  119. package/v2Containers/ChannelTemplates/tests/reducer.test.js +9 -0
  120. package/v2Containers/ChannelTemplates/tests/sagas.test.js +15 -0
  121. package/v2Containers/ChannelTemplates/tests/selectors.test.js +10 -0
  122. package/v2Containers/CreativesContainer/SlideBoxContent.js +257 -0
  123. package/v2Containers/CreativesContainer/SlideBoxFooter.js +45 -0
  124. package/v2Containers/CreativesContainer/SlideBoxHeader.js +70 -0
  125. package/v2Containers/CreativesContainer/actions.js +27 -0
  126. package/v2Containers/CreativesContainer/constants.js +16 -0
  127. package/v2Containers/CreativesContainer/index.js +483 -0
  128. package/v2Containers/CreativesContainer/index.scss +27 -0
  129. package/v2Containers/CreativesContainer/messages.js +293 -0
  130. package/v2Containers/CreativesContainer/reducer.js +29 -0
  131. package/v2Containers/CreativesContainer/sagas.js +11 -0
  132. package/v2Containers/CreativesContainer/selectors.js +30 -0
  133. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -0
  134. package/v2Containers/CreativesContainer/tests/index.test.js +10 -0
  135. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -0
  136. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -0
  137. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -0
  138. package/v2Containers/Dashboard/actions.js +15 -0
  139. package/v2Containers/Dashboard/constants.js +7 -0
  140. package/v2Containers/Dashboard/index.js +54 -0
  141. package/v2Containers/Dashboard/messages.js +13 -0
  142. package/v2Containers/Dashboard/reducer.js +21 -0
  143. package/v2Containers/Dashboard/sagas.js +11 -0
  144. package/v2Containers/Dashboard/selectors.js +25 -0
  145. package/v2Containers/Dashboard/tests/actions.test.js +18 -0
  146. package/v2Containers/Dashboard/tests/index.test.js +10 -0
  147. package/v2Containers/Dashboard/tests/reducer.test.js +9 -0
  148. package/v2Containers/Dashboard/tests/sagas.test.js +15 -0
  149. package/v2Containers/Dashboard/tests/selectors.test.js +10 -0
  150. package/v2Containers/Ebill/_ebill.scss +5 -0
  151. package/v2Containers/Ebill/actions.js +43 -0
  152. package/v2Containers/Ebill/constants.js +20 -0
  153. package/v2Containers/Ebill/index.js +1261 -0
  154. package/v2Containers/Ebill/messages.js +73 -0
  155. package/v2Containers/Ebill/reducer.js +72 -0
  156. package/v2Containers/Ebill/sagas.js +65 -0
  157. package/v2Containers/Ebill/selectors.js +25 -0
  158. package/v2Containers/Ebill/tests/actions.test.js +18 -0
  159. package/v2Containers/Ebill/tests/index.test.js +10 -0
  160. package/v2Containers/Ebill/tests/reducer.test.js +9 -0
  161. package/v2Containers/Ebill/tests/sagas.test.js +15 -0
  162. package/v2Containers/Ebill/tests/selectors.test.js +10 -0
  163. package/v2Containers/Email/_email.scss +140 -0
  164. package/v2Containers/Email/actions.js +86 -0
  165. package/v2Containers/Email/constants.js +37 -0
  166. package/v2Containers/Email/index.js +2703 -0
  167. package/v2Containers/Email/initialSchema.js +540 -0
  168. package/v2Containers/Email/messages.js +237 -0
  169. package/v2Containers/Email/reducer.js +147 -0
  170. package/v2Containers/Email/sagas.js +133 -0
  171. package/v2Containers/Email/selectors.js +34 -0
  172. package/v2Containers/Email/tests/actions.test.js +18 -0
  173. package/v2Containers/Email/tests/index.test.js +10 -0
  174. package/v2Containers/Email/tests/reducer.test.js +9 -0
  175. package/v2Containers/Email/tests/sagas.test.js +15 -0
  176. package/v2Containers/Email/tests/selectors.test.js +10 -0
  177. package/v2Containers/EmailWrapper/actions.js +15 -0
  178. package/v2Containers/EmailWrapper/constants.js +7 -0
  179. package/v2Containers/EmailWrapper/index.js +258 -0
  180. package/v2Containers/EmailWrapper/messages.js +57 -0
  181. package/v2Containers/EmailWrapper/reducer.js +23 -0
  182. package/v2Containers/EmailWrapper/sagas.js +11 -0
  183. package/v2Containers/EmailWrapper/selectors.js +25 -0
  184. package/v2Containers/EmailWrapper/tests/actions.test.js +18 -0
  185. package/v2Containers/EmailWrapper/tests/index.test.js +10 -0
  186. package/v2Containers/EmailWrapper/tests/reducer.test.js +9 -0
  187. package/v2Containers/EmailWrapper/tests/sagas.test.js +15 -0
  188. package/v2Containers/EmailWrapper/tests/selectors.test.js +10 -0
  189. package/v2Containers/LanguageProvider/actions.js +17 -0
  190. package/v2Containers/LanguageProvider/constants.js +8 -0
  191. package/v2Containers/LanguageProvider/index.js +46 -0
  192. package/v2Containers/LanguageProvider/reducer.js +30 -0
  193. package/v2Containers/LanguageProvider/selectors.js +20 -0
  194. package/v2Containers/LanguageProvider/tests/actions.test.js +19 -0
  195. package/v2Containers/LanguageProvider/tests/index.test.js +49 -0
  196. package/v2Containers/LanguageProvider/tests/reducer.test.js +20 -0
  197. package/v2Containers/LanguageProvider/tests/selectors.test.js +15 -0
  198. package/v2Containers/Line/Create/_lineCreate.scss +43 -0
  199. package/v2Containers/Line/Create/actions.js +90 -0
  200. package/v2Containers/Line/Create/constants.js +39 -0
  201. package/v2Containers/Line/Create/index.js +822 -0
  202. package/v2Containers/Line/Create/messages.js +173 -0
  203. package/v2Containers/Line/Create/reducer.js +99 -0
  204. package/v2Containers/Line/Create/sagas.js +107 -0
  205. package/v2Containers/Line/Create/selectors.js +36 -0
  206. package/v2Containers/Line/Edit/_lineEdit.scss +21 -0
  207. package/v2Containers/Line/Edit/actions.js +79 -0
  208. package/v2Containers/Line/Edit/constants.js +27 -0
  209. package/v2Containers/Line/Edit/index.js +1050 -0
  210. package/v2Containers/Line/Edit/messages.js +157 -0
  211. package/v2Containers/Line/Edit/reducer.js +83 -0
  212. package/v2Containers/Line/Edit/sagas.js +81 -0
  213. package/v2Containers/Line/Edit/selectors.js +29 -0
  214. package/v2Containers/Line/Edit/tests/actions.test.js +18 -0
  215. package/v2Containers/Line/Edit/tests/index.test.js +10 -0
  216. package/v2Containers/Line/Edit/tests/reducer.test.js +9 -0
  217. package/v2Containers/Line/Edit/tests/sagas.test.js +15 -0
  218. package/v2Containers/Line/Edit/tests/selectors.test.js +10 -0
  219. package/v2Containers/Login/assets/images/capillary_logo.png +0 -0
  220. package/v2Containers/Login/components/LoginForm/index.js +59 -0
  221. package/v2Containers/Login/components/LoginForm/messages.js +21 -0
  222. package/v2Containers/Login/components/LoginForm/tests/index.test.js +10 -0
  223. package/v2Containers/Login/index.js +106 -0
  224. package/v2Containers/Login/messages.js +21 -0
  225. package/v2Containers/Login/selectors.js +25 -0
  226. package/v2Containers/Login/tests/index.test.js +10 -0
  227. package/v2Containers/Login/tests/sagas.test.js +15 -0
  228. package/v2Containers/Login/tests/selectors.test.js +10 -0
  229. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +41 -0
  230. package/v2Containers/MobilePush/Create/actions.js +52 -0
  231. package/v2Containers/MobilePush/Create/constants.js +24 -0
  232. package/v2Containers/MobilePush/Create/index.js +1759 -0
  233. package/v2Containers/MobilePush/Create/messages.js +237 -0
  234. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  235. package/v2Containers/MobilePush/Create/sagas.js +60 -0
  236. package/v2Containers/MobilePush/Create/selectors.js +28 -0
  237. package/v2Containers/MobilePush/Create/tests/actions.test.js +18 -0
  238. package/v2Containers/MobilePush/Create/tests/index.test.js +10 -0
  239. package/v2Containers/MobilePush/Create/tests/reducer.test.js +9 -0
  240. package/v2Containers/MobilePush/Create/tests/sagas.test.js +15 -0
  241. package/v2Containers/MobilePush/Create/tests/selectors.test.js +10 -0
  242. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +38 -0
  243. package/v2Containers/MobilePush/Edit/actions.js +91 -0
  244. package/v2Containers/MobilePush/Edit/constants.js +35 -0
  245. package/v2Containers/MobilePush/Edit/index.js +1851 -0
  246. package/v2Containers/MobilePush/Edit/messages.js +253 -0
  247. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  248. package/v2Containers/MobilePush/Edit/sagas.js +119 -0
  249. package/v2Containers/MobilePush/Edit/selectors.js +32 -0
  250. package/v2Containers/MobilePush/Edit/tests/actions.test.js +18 -0
  251. package/v2Containers/MobilePush/Edit/tests/index.test.js +10 -0
  252. package/v2Containers/MobilePush/Edit/tests/reducer.test.js +9 -0
  253. package/v2Containers/MobilePush/Edit/tests/sagas.test.js +15 -0
  254. package/v2Containers/MobilePush/Edit/tests/selectors.test.js +10 -0
  255. package/v2Containers/MobilePush/commonMethods.js +249 -0
  256. package/v2Containers/MobilePush/eventsMap.js +127 -0
  257. package/v2Containers/MobilePush/initialSchema.js +1739 -0
  258. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  259. package/v2Containers/MobilepushWrapper/index.js +136 -0
  260. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  261. package/v2Containers/MobilepushWrapper/tests/index.test.js +10 -0
  262. package/v2Containers/NotFoundPage/index.js +25 -0
  263. package/v2Containers/NotFoundPage/messages.js +13 -0
  264. package/v2Containers/NotFoundPage/tests/index.test.js +17 -0
  265. package/v2Containers/Sms/Create/_smsCreate.scss +58 -0
  266. package/v2Containers/Sms/Create/actions.js +27 -0
  267. package/v2Containers/Sms/Create/constants.js +16 -0
  268. package/v2Containers/Sms/Create/index.js +1017 -0
  269. package/v2Containers/Sms/Create/messages.js +85 -0
  270. package/v2Containers/Sms/Create/reducer.js +41 -0
  271. package/v2Containers/Sms/Create/sagas.js +35 -0
  272. package/v2Containers/Sms/Create/selectors.js +28 -0
  273. package/v2Containers/Sms/Create/tests/actions.test.js +18 -0
  274. package/v2Containers/Sms/Create/tests/index.test.js +10 -0
  275. package/v2Containers/Sms/Create/tests/reducer.test.js +9 -0
  276. package/v2Containers/Sms/Create/tests/sagas.test.js +15 -0
  277. package/v2Containers/Sms/Create/tests/selectors.test.js +10 -0
  278. package/v2Containers/Sms/Edit/actions.js +45 -0
  279. package/v2Containers/Sms/Edit/constants.js +18 -0
  280. package/v2Containers/Sms/Edit/index.js +1018 -0
  281. package/v2Containers/Sms/Edit/messages.js +89 -0
  282. package/v2Containers/Sms/Edit/reducer.js +52 -0
  283. package/v2Containers/Sms/Edit/sagas.js +50 -0
  284. package/v2Containers/Sms/Edit/selectors.js +32 -0
  285. package/v2Containers/Sms/Edit/tests/actions.test.js +18 -0
  286. package/v2Containers/Sms/Edit/tests/index.test.js +10 -0
  287. package/v2Containers/Sms/Edit/tests/reducer.test.js +9 -0
  288. package/v2Containers/Sms/Edit/tests/sagas.test.js +15 -0
  289. package/v2Containers/Sms/Edit/tests/selectors.test.js +10 -0
  290. package/v2Containers/Sms/initialSchema.js +281 -0
  291. package/v2Containers/TagList/_tagList.scss +8 -0
  292. package/v2Containers/TagList/actions.js +15 -0
  293. package/v2Containers/TagList/constants.js +7 -0
  294. package/v2Containers/TagList/index.js +236 -0
  295. package/v2Containers/TagList/messages.js +13 -0
  296. package/v2Containers/TagList/reducer.js +23 -0
  297. package/v2Containers/TagList/sagas.js +11 -0
  298. package/v2Containers/TagList/selectors.js +25 -0
  299. package/v2Containers/TagList/tests/actions.test.js +18 -0
  300. package/v2Containers/TagList/tests/index.test.js +10 -0
  301. package/v2Containers/TagList/tests/reducer.test.js +9 -0
  302. package/v2Containers/TagList/tests/sagas.test.js +15 -0
  303. package/v2Containers/TagList/tests/selectors.test.js +10 -0
  304. package/v2Containers/Templates/_templates.scss +349 -0
  305. package/v2Containers/Templates/actions.js +110 -0
  306. package/v2Containers/Templates/constants.js +45 -0
  307. package/v2Containers/Templates/index.js +1725 -0
  308. package/v2Containers/Templates/messages.js +278 -0
  309. package/v2Containers/Templates/reducer.js +142 -0
  310. package/v2Containers/Templates/sagas.js +180 -0
  311. package/v2Containers/Templates/selectors.js +68 -0
  312. package/v2Containers/Templates/tests/actions.test.js +18 -0
  313. package/v2Containers/Templates/tests/index.test.js +10 -0
  314. package/v2Containers/Templates/tests/reducer.test.js +9 -0
  315. package/v2Containers/Templates/tests/sagas.test.js +15 -0
  316. package/v2Containers/Templates/tests/selectors.test.js +10 -0
  317. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  318. package/v2Containers/TemplatesV2/actions.js +16 -0
  319. package/v2Containers/TemplatesV2/constants.js +10 -0
  320. package/v2Containers/TemplatesV2/index.js +217 -0
  321. package/v2Containers/TemplatesV2/messages.js +29 -0
  322. package/v2Containers/TemplatesV2/selectors.js +25 -0
  323. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -0
  324. package/v2Containers/TemplatesV2/tests/index.test.js +10 -0
  325. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -0
  326. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -0
  327. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -0
  328. package/v2Containers/TestPage/constants.js +7 -0
  329. package/v2Containers/TestPage/index.js +31 -0
  330. package/v2Containers/TestPage/messages.js +13 -0
  331. package/v2Containers/TestPage/reducer.js +21 -0
  332. package/v2Containers/TestPage/sagas.js +11 -0
  333. package/v2Containers/Testv2/actions.js +15 -0
  334. package/v2Containers/Testv2/constants.js +7 -0
  335. package/v2Containers/Testv2/index.js +47 -0
  336. package/v2Containers/Testv2/messages.js +13 -0
  337. package/v2Containers/Testv2/reducer.js +23 -0
  338. package/v2Containers/Testv2/sagas.js +11 -0
  339. package/v2Containers/Testv2/selectors.js +25 -0
  340. package/v2Containers/Testv2/tests/actions.test.js +18 -0
  341. package/v2Containers/Testv2/tests/index.test.js +10 -0
  342. package/v2Containers/Testv2/tests/reducer.test.js +9 -0
  343. package/v2Containers/Testv2/tests/sagas.test.js +15 -0
  344. package/v2Containers/Testv2/tests/selectors.test.js +10 -0
  345. package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
  346. package/v2Containers/WeChat/MapTemplates/actions.js +52 -0
  347. package/v2Containers/WeChat/MapTemplates/constants.js +28 -0
  348. package/v2Containers/WeChat/MapTemplates/index.js +1385 -0
  349. package/v2Containers/WeChat/MapTemplates/messages.js +73 -0
  350. package/v2Containers/WeChat/MapTemplates/reducer.js +74 -0
  351. package/v2Containers/WeChat/MapTemplates/sagas.js +86 -0
  352. package/v2Containers/WeChat/MapTemplates/selectors.js +25 -0
  353. package/v2Containers/WeChat/MapTemplates/tests/actions.test.js +18 -0
  354. package/v2Containers/WeChat/MapTemplates/tests/index.test.js +10 -0
  355. package/v2Containers/WeChat/MapTemplates/tests/reducer.test.js +9 -0
  356. package/v2Containers/WeChat/MapTemplates/tests/sagas.test.js +15 -0
  357. package/v2Containers/WeChat/MapTemplates/tests/selectors.test.js +10 -0
  358. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
  359. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
  360. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
  361. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1053 -0
  362. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +141 -0
  363. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
  364. package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  365. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +48 -0
  366. package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
  367. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/actions.test.js +18 -0
  368. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/index.test.js +10 -0
  369. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/reducer.test.js +9 -0
  370. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/sagas.test.js +15 -0
  371. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/selectors.test.js +10 -0
  372. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
  373. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
  374. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +116 -0
  375. package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
  376. package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
  377. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +32 -0
  378. package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
  379. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/actions.test.js +18 -0
  380. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/index.test.js +10 -0
  381. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/reducer.test.js +9 -0
  382. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/sagas.test.js +15 -0
  383. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/selectors.test.js +10 -0
  384. package/v2Containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
  385. package/v2Containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
  386. package/v2Containers/WeChat/RichmediaTemplates/View/index.js +47 -0
  387. package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +13 -0
  388. package/v2Containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
  389. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
  390. package/v2Containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
  391. package/v2Containers/WeChat/RichmediaTemplates/View/tests/actions.test.js +18 -0
  392. package/v2Containers/WeChat/RichmediaTemplates/View/tests/index.test.js +10 -0
  393. package/v2Containers/WeChat/RichmediaTemplates/View/tests/reducer.test.js +9 -0
  394. package/v2Containers/WeChat/RichmediaTemplates/View/tests/sagas.test.js +15 -0
  395. package/v2Containers/WeChat/RichmediaTemplates/View/tests/selectors.test.js +10 -0
@@ -0,0 +1,1725 @@
1
+ /*
2
+ *
3
+ * Templates
4
+ *
5
+ */
6
+
7
+ import PropTypes from 'prop-types';
8
+
9
+ import React from 'react';
10
+ import { connect } from 'react-redux';
11
+ import styled from 'styled-components';
12
+ import {injectIntl, intlShape, FormattedMessage } from 'react-intl';
13
+ import { createStructuredSelector } from 'reselect';
14
+ import moment from "moment";
15
+ import _ from 'lodash';
16
+ import { bindActionCreators } from 'redux';
17
+ import { Modal} from 'antd';
18
+ import {CapMenu, CapDropdown, CapButton, CapInput, CapIcon, CapSelect, CapPopover, CapSpin, CapCustomCard, CapRow, CapSlideBox, CapLink, CapHeading} from '@capillarytech/cap-ui-library';
19
+ import { makeSelectTemplates, makeSelectTemplatesResponse } from './selectors';
20
+ import { makeSelectCreate as makeSelectCreateSms} from '../Sms/Create/selectors';
21
+ import { makeSelectCreate as makeSelectCreateMobilePush } from '../MobilePush/Create/selectors';
22
+ import { makeSelectEbill as makeSelectCreateEbill } from '../Ebill/selectors';
23
+ import { makeSelectEmail as makeSelectCreateEmail } from '../Email/selectors';
24
+ import { makeSelectEdit } from '../Sms/Edit/selectors';
25
+ import { makeSelectLine } from '../Line/Create/selectors';
26
+ import { UserIsAuthenticated } from '../../utils/authWrapper';
27
+ import messages from './messages';
28
+ import {checkUnicode} from '../../utils/smsCharCountV2';
29
+ import * as actions from './actions';
30
+ import * as smsActions from '../Sms/Create/actions';
31
+ import * as mobilepushActions from '../MobilePush/Create/actions';
32
+ import * as smsEditActions from '../Sms/Edit/actions';
33
+ import * as ebillActions from '../Ebill/actions';
34
+ import * as emailActions from '../Email/actions';
35
+ import * as lineActions from '../Line/Create/actions';
36
+ import CardGrid from '../../components/CardGrid';
37
+ import config from '../../config/app';
38
+ import './_templates.scss';
39
+ import * as globalActions from '../Cap/actions';
40
+ import { makeSelectAuthenticated } from '../Cap/selectors';
41
+ import {getMessageObject} from '../../utils/messageUtils';
42
+ import * as commonUtil from '../../utils/common';
43
+ import Pagination from '../../components/Pagination';
44
+ import EmailPreview from '../../components/EmailPreview';
45
+ import CreativesContainer from '../CreativesContainer';
46
+ import WechatRichmediaTemplatePreview from '../../components/TemplatePreview/WechatRichmediaTemplatePreview';
47
+ import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE } from '../CreativesContainer/constants';
48
+ const {CapCustomCardList} = CapCustomCard;
49
+ const InlineDiv = styled.div`
50
+ display: inline;
51
+ .ant-anchor.fixed{
52
+ display: inline;
53
+ .ant-anchor-link{
54
+ display: inline;
55
+ }
56
+ }
57
+ `;
58
+ export class Templates extends React.Component { // eslint-disable-line react/prefer-stateless-function
59
+ constructor(props) {
60
+ super(props);
61
+ this.state = {
62
+ channel: '',
63
+ hoveredItem: '',
64
+ clickedItem: '',
65
+ previewOpen: false,
66
+ previewTemplate: {},
67
+ searchText: '',
68
+ sortBy: 'Most Recent',
69
+ selectedAccount: '',
70
+ page: 1,
71
+ perPageLimit: 25,
72
+ templatesCount: 0,
73
+ showEdmEmailTemplates: false,
74
+ showModal: false,
75
+ actionTemplate: {},
76
+ showHtmlPreview: false,
77
+ device: 'desktop',
78
+ searchedTemplates: false,
79
+ defaultAccount: true,
80
+ modeType: null,
81
+ routeParams: null,
82
+ };
83
+ this.handleOnHoverItem = this.handleOnHoverItem.bind(this);
84
+ this.handleOnItemClick = this.handleOnItemClick.bind(this);
85
+ this.handleEditClick = this.handleEditClick.bind(this);
86
+ this.handlePreviewClick = this.handlePreviewClick.bind(this);
87
+ this.createTemplate = this.createTemplate.bind(this);
88
+ this.duplicateTemplate = this.duplicateTemplate.bind(this);
89
+ this.deleteTemplate = this.deleteTemplate.bind(this);
90
+ this.togglePreview = this.togglePreview.bind(this);
91
+ this.searchTemplate = this.searchTemplate.bind(this);
92
+ this.handleSortBy = this.handleSortBy.bind(this);
93
+ this.getCurrentWindow = this.getCurrentWindow.bind(this);
94
+ this.handleFrameTasks = this.handleFrameTasks.bind(this);
95
+ this.startTemplateCreation = this.startTemplateCreation.bind(this);
96
+ this.startLoading = this.startLoading.bind(this);
97
+ this.prepareWeChatPreviewData = this.prepareWeChatPreviewData.bind(this);
98
+ this.prepareWeChatMappedPreviewData = this.prepareWeChatMappedPreviewData.bind(this);
99
+ this.onAccountSelect = this.onAccountSelect.bind(this);
100
+ this.prepareMobilePushPreviewData = this.prepareMobilePushPreviewData.bind(this);
101
+ this.menuOnClickEvent = this.menuOnClickEvent.bind(this);
102
+ }
103
+
104
+ componentWillMount() {
105
+ if (this.state.channel === '') {
106
+ let channel = '';
107
+
108
+ switch (this.props.route.name.toUpperCase()) {
109
+ case SMS:
110
+ channel = 'Sms';
111
+ break;
112
+ case MOBILE_PUSH:
113
+ channel = "MobilePush";
114
+ this.props.actions.getWeCrmAccounts(channel);
115
+ break;
116
+ case WECHAT:
117
+ channel = 'wechat';
118
+ this.props.actions.getWeCrmAccounts();
119
+ break;
120
+ case EMAIL:
121
+ channel = 'Email';
122
+ break;
123
+ case EBILL:
124
+ channel = 'Ebill';
125
+ break;
126
+ case LINE:
127
+ channel = "Line";
128
+ break;
129
+ default:
130
+ channel = '';
131
+ }
132
+ this.setState({ channel });
133
+ if (_.isEmpty(this.props.Templates.userList)) {
134
+ this.props.actions.getUserList();
135
+ }
136
+ }
137
+ }
138
+
139
+ componentDidMount() {
140
+ if (this.props.location.query.type === 'embedded' && this.isEnabledInLibraryModule("setLocale")) {
141
+ this.setLocale();
142
+ }
143
+ if (this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill' || ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && !_.isEmpty(this.props.Templates.selectedWeChatAccount))) {
144
+ const queryParams = {
145
+ // name: this.state.searchText,
146
+ // sortBy: this.state.sortBy,
147
+ };
148
+ if (this.state.channel.toLowerCase() === 'wechat' && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
149
+ queryParams.wecrmId = this.props.Templates.selectedWeChatAccount.configs.wecrm_app_id;
150
+ queryParams.wecrmToken = this.props.Templates.selectedWeChatAccount.configs.wecrm_token;
151
+ queryParams.originalId = this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier;
152
+ }
153
+ if (this.state.channel.toLowerCase() === "mobilepush" && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
154
+ const account = this.props.Templates.selectedWeChatAccount;
155
+ queryParams.accountId = account.id;
156
+ const isAndroidSupported = _.get(account, "configs.android") === '1';
157
+ const isIosSupported = _.get(account, "configs.ios") === '1';
158
+ if (!(isAndroidSupported || isIosSupported)) {
159
+ this.props.actions.resetAccount();
160
+ return;
161
+ }
162
+ }
163
+ queryParams.page = this.state.page;
164
+ queryParams.perPage = this.state.perPageLimit;
165
+ const channel = this.state.channel;
166
+ this.props.actions.getAllTemplates(channel, queryParams);
167
+ //this.getAllTemplates({});
168
+ // if (this.state.channel.toLowerCase() === "email") {
169
+ // this.props.actions.getEdmDefaultTemplates();
170
+ // }
171
+ }
172
+
173
+ window.addEventListener("message", this.handleFrameTasks);
174
+ }
175
+ componentWillReceiveProps(nextProps) {
176
+ const params = {
177
+ name: this.state.searchText,
178
+ sortBy: this.state.sortBy,
179
+ };
180
+ if (!_.isEmpty(this.props.TemplatesList) && !this.props.Templates.getAllTemplatesInProgress && this.props.TemplatesList[0] && this.props.TemplatesList[0].totalCount && this.state.templatesCount === 0) {
181
+ this.setState({templatesCount: this.props.TemplatesList[0].totalCount});
182
+ }
183
+ if (!_.isEqual(nextProps.route.name, this.props.route.name)) {
184
+ let channel = '';
185
+ this.props.actions.resetTemplate();
186
+ this.props.actions.resetAccount();
187
+ if (nextProps.route.name.toLowerCase() === 'sms') {
188
+ channel = 'Sms';
189
+ } else if (nextProps.route.name.toLowerCase() === 'wechat') {
190
+ this.setState({defaultAccount: true});
191
+ channel = 'wechat';
192
+ nextProps.actions.getWeCrmAccounts();
193
+ } else if (nextProps.route.name.toLowerCase() === 'email') {
194
+ channel = 'Email';
195
+ // this.props.actions.getEdmDefaultTemplates();
196
+ } else if (nextProps.route.name.toLowerCase() === "mobilepush") {
197
+ this.setState({defaultAccount: true});
198
+ channel = "mobilepush";
199
+ nextProps.actions.getWeCrmAccounts(channel);
200
+ } else if (nextProps.route.name.toLowerCase() === 'ebill') {
201
+ channel = 'Ebill';
202
+ } else if (nextProps.route.name.toLowerCase() === 'line') {
203
+ channel = 'Line';
204
+ }
205
+ this.setState({ channel }, () => {
206
+ if (this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill' || (this.state.channel.toLowerCase() === 'wechat' && !_.isEmpty(nextProps.Templates.selectedWeChatAccount))) {
207
+ if (this.state.channel.toLowerCase() === 'wechat' && !_.isEmpty(nextProps.Templates.selectedWeChatAccount)) {
208
+ params.wecrmId = nextProps.Templates.selectedWeChatAccount.configs.wecrm_app_id;
209
+ params.wecrmToken = nextProps.Templates.selectedWeChatAccount.configs.wecrm_token;
210
+ params.originalId = nextProps.Templates.selectedWeChatAccount.sourceAccountIdentifier;
211
+ }
212
+ if (this.state.channel.toLowerCase() === "mobilepush" && !_.isEmpty(nextProps.Templates.selectedWeChatAccount)) {
213
+ params.accountId = nextProps.Templates.selectedWeChatAccount.id;
214
+ }
215
+ this.getAllTemplates({params}, true);
216
+ }
217
+ });
218
+ }
219
+ if (this.state.channel.toLowerCase() === 'wechat' && nextProps.Templates.selectedWeChatAccount) {
220
+ params.wecrmId = nextProps.Templates.selectedWeChatAccount.configs.wecrm_app_id;
221
+ params.wecrmToken = nextProps.Templates.selectedWeChatAccount.configs.wecrm_token;
222
+ params.originalId = nextProps.Templates.selectedWeChatAccount.sourceAccountIdentifier;
223
+ }
224
+ if (this.state.channel.toLowerCase() === "mobilepush" && nextProps.Templates.selectedWeChatAccount) {
225
+ params.accountId = nextProps.Templates.selectedWeChatAccount.id;
226
+ }
227
+ if ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && _.isEmpty(nextProps.Templates.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && !this.isEnabledInLibraryModule("showAccountSelection")) {
228
+ let selectedAccount = '';
229
+ if (_.isEmpty(nextProps.Templates.weCrmAccounts)) {
230
+ return;
231
+ }
232
+ if (this.state.channel.toLowerCase() === 'wechat') {
233
+ _.forEach(nextProps.Templates.weCrmAccounts, (account) => {
234
+ if (account.configs && account.configs.is_wecrm_enabled) {
235
+ if (nextProps.location.query.source_account_id && account.sourceAccountIdentifier === nextProps.location.query.source_account_id) {
236
+ selectedAccount = account;
237
+ }
238
+ }
239
+ });
240
+ this.setState({selectedAccount: selectedAccount.name}, () => {
241
+ params.wecrmId = selectedAccount.configs.wecrm_app_id;
242
+ params.wecrmToken = selectedAccount.configs.wecrm_token;
243
+ params.originalId = selectedAccount.sourceAccountIdentifier;
244
+ nextProps.actions.setWeChatAccount(selectedAccount);
245
+ this.getAllTemplates({params});
246
+ });
247
+ } else if (this.state.channel.toLowerCase() === 'mobilepush' && (nextProps.location.query.account_id || nextProps.location.query.source_account_id)) {
248
+ _.forEach(nextProps.Templates.weCrmAccounts, (account) => {
249
+ if ((nextProps.location.query.account_id && account.id === Number(nextProps.location.query.account_id)) || (nextProps.location.query.source_account_id && account.sourceAccountIdentifier && account.sourceAccountIdentifier === nextProps.location.query.source_account_id)) {
250
+ selectedAccount = account;
251
+ }
252
+ });
253
+ this.props.actions.setWeChatAccount(selectedAccount);
254
+ params.accountId = Number(nextProps.location.query.account_id);
255
+ this.getAllTemplates({params});
256
+ }
257
+ }
258
+ if (this.state.channel.toLowerCase() === "mobilepush" && nextProps.CreateMobilePush && nextProps.CreateMobilePush.response && nextProps.CreateMobilePush.response.templateId && nextProps.CreateMobilePush.response.templateId !== '') {
259
+ if (this.state.channel.toLowerCase() === "mobilepush" && !_.isEmpty(nextProps.Templates.selectedWeChatAccount)) {
260
+ params.accountId = nextProps.Templates.selectedWeChatAccount.id;
261
+ }
262
+ const message = getMessageObject('success', `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`, true);
263
+ this.props.globalActions.addMessageToQueue(message);
264
+ this.getAllTemplates({params});
265
+ this.props.mobilepushActions.clearCreateResponse();
266
+ }
267
+
268
+ if (this.state.channel.toLowerCase() === "ebill" && nextProps.CreateEbill && nextProps.CreateEbill.createResponse && nextProps.CreateEbill.createResponse.templateId && nextProps.CreateEbill.createResponse.templateId !== '') {
269
+ const message = getMessageObject('success', `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`, true);
270
+ this.props.globalActions.addMessageToQueue(message);
271
+ this.getAllTemplates({params, resetPage: true});
272
+ this.props.ebillActions.clearStoreValues();
273
+ }
274
+
275
+ if (this.state.channel.toLowerCase() === "email" && nextProps.EmailCreate && nextProps.EmailCreate.duplicateResponse && nextProps.EmailCreate.duplicateResponse.templateId && nextProps.EmailCreate.duplicateResponse.templateId !== '') {
276
+ const message = getMessageObject('success', `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`, true);
277
+ this.props.globalActions.addMessageToQueue(message);
278
+ this.getAllTemplates({params, resetPage: true});
279
+ this.props.emailActions.clearStoreValues();
280
+ }
281
+
282
+ if (this.state.channel.toLowerCase() === "line" && nextProps.Line && nextProps.Line.response && nextProps.Line.response.templateId && nextProps.Line.response.templateId !== '') {
283
+ const message = getMessageObject('success', `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`, true);
284
+ this.props.globalActions.addMessageToQueue(message);
285
+ this.getAllTemplates({params, resetPage: true});
286
+ this.props.lineActions.clearCreateResponse();
287
+ }
288
+
289
+ if (nextProps.Create && this.props.Create && nextProps.Create.createTemplateError && !_.isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
290
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages.somethingWentWrong), true);
291
+ this.props.globalActions.addMessageToQueue(message);
292
+ if (this.state.channel.toLowerCase() === "sms") {
293
+ this.props.smsActions.clearCreateResponse();
294
+ } else if (this.state.channel.toLowerCase() === "mobilepush") {
295
+ this.props.mobilepushActions.clearCreateResponse();
296
+ } else if (this.state.channel.toLowerCase() === "ebill") {
297
+ this.props.ebillActions.clearCreateResponse();
298
+ } else if (this.state.channel.toLowerCase() === "line") {
299
+ this.props.lineActions.clearCreateResponse();
300
+ }
301
+ }
302
+
303
+ if (nextProps.Edit && nextProps.Edit.editResponse && nextProps.Edit.editResponse.templateId && nextProps.Edit.editResponse.templateId !== '') {
304
+ this.props.smsEditActions.clearEditResponse();
305
+ }
306
+ if (!nextProps.Templates.deleteTemplateInProgress && !_.isEqual(nextProps.Templates.deleteTemplateInProgress, this.props.Templates.deleteTemplateInProgress) &&
307
+ nextProps.Templates.deleteResponse) {
308
+ const message = getMessageObject('success', `${this.state.channel.toUpperCase()} ${this.props.intl.formatMessage(messages['Template deleted successfully'])}`, true);
309
+ nextProps.globalActions.addMessageToQueue(message);
310
+ this.getAllTemplates({params, resetPage: true});
311
+ }
312
+
313
+ if (!nextProps.Templates.sendingFile && !_.isEqual(this.props.Templates.sendingFile, nextProps.Templates.sendingFile) && !nextProps.Templates.errorSendingFile) {
314
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
315
+ const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : true;
316
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
317
+ const type = this.props.location.query.type;
318
+ if (this.isEnabledInLibraryModule("callCreateFromProps")) {
319
+ this.props.createNew();
320
+ return;
321
+ }
322
+ this.setState({routeParams: {
323
+ pathname: `/${nextProps.route.name.toLowerCase()}/create`,
324
+ query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module},
325
+ }});
326
+ }
327
+
328
+ if (!nextProps.Templates.sendingFile && !_.isEqual(this.props.Templates.sendingFile, nextProps.Templates.sendingFile) && nextProps.Templates.errorSendingFile) {
329
+ let errorMessage = this.props.intl.formatMessage(messages.zipUploadFailed);
330
+ if (nextProps.Templates.errorMessage && nextProps.Templates.errorMessage !== "") {
331
+ errorMessage = nextProps.Templates.errorMessage;
332
+ }
333
+ const message = getMessageObject('error', errorMessage, true);
334
+ nextProps.globalActions.addMessageToQueue(message);
335
+ }
336
+
337
+ if (!_.isEmpty(nextProps.Templates.templateDetails) && !_.isEqual(nextProps.Templates.templateDetails, this.props.Templates.templateDetails)) {
338
+ this.setState({previewTemplate: nextProps.Templates.templateDetails});
339
+ }
340
+
341
+ if (nextProps.Templates.weCrmAccounts !== undefined && nextProps.Templates.weCrmAccounts.length === 1 && this.state.defaultAccount && (['wechat', 'mobilepush'].indexOf(this.state.channel.toLowerCase()) > -1)) {
342
+ const paramsDefault = {
343
+ name: this.state.searchText,
344
+ sortBy: this.state.sortBy,
345
+ };
346
+ if (this.state.channel.toLowerCase() === 'wechat') {
347
+ paramsDefault.wecrmId = nextProps.Templates.weCrmAccounts[0].configs.wecrm_app_id;
348
+ paramsDefault.wecrmToken = nextProps.Templates.weCrmAccounts[0].configs.wecrm_token;
349
+ paramsDefault.originalId = nextProps.Templates.weCrmAccounts[0].sourceAccountIdentifier;
350
+ nextProps.actions.setWeChatAccount(nextProps.Templates.weCrmAccounts[0]);
351
+ } else if (this.state.channel.toLowerCase() === 'mobilepush') {
352
+ nextProps.actions.setWeChatAccount(nextProps.Templates.weCrmAccounts[0]);
353
+ paramsDefault.accountId = nextProps.Templates.weCrmAccounts[0].id;
354
+ }
355
+ this.setState({defaultAccount: false});
356
+ this.getAllTemplates({params: paramsDefault}, true);
357
+ }
358
+ }
359
+
360
+ componentWillUnmount() {
361
+ window.removeEventListener("message", this.handleFrameTasks);
362
+ this.props.actions.resetTemplateStoreData();
363
+ this.props.globalActions.clearMetaEntities();
364
+ // this.setState({defaultAccount: false});
365
+ }
366
+
367
+ onAccountSelect(value) {
368
+ this.setState({selectedAccount: value}, () => {
369
+ const params = {
370
+ name: this.state.searchText,
371
+ sortBy: this.state.sortBy,
372
+ };
373
+ if (this.state.channel.toLowerCase() === 'wechat') {
374
+ params.wecrmId = this.props.Templates.weCrmAccounts[_.findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_app_id;
375
+ params.wecrmToken = this.props.Templates.weCrmAccounts[_.findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_token;
376
+ this.props.actions.setWeChatAccount(this.props.Templates.weCrmAccounts[_.findIndex(this.props.Templates.weCrmAccounts, { name: value})]);
377
+ params.originalId = this.props.Templates.weCrmAccounts[_.findIndex(this.props.Templates.weCrmAccounts, { name: value})].sourceAccountIdentifier;
378
+ } else if (this.state.channel.toLowerCase() === 'mobilepush') {
379
+ this.props.actions.setWeChatAccount(this.props.Templates.weCrmAccounts[_.findIndex(this.props.Templates.weCrmAccounts, { name: value})]);
380
+ const account = this.props.Templates.weCrmAccounts[_.findIndex(this.props.Templates.weCrmAccounts, { name: value})];
381
+ params.accountId = account.id;
382
+ const isAndroidSupported = _.get(account, "configs.android") === '1';
383
+ const isIosSupported = _.get(account, "configs.ios") === '1';
384
+ if (!(isAndroidSupported || isIosSupported)) {
385
+ this.setState({selectedAccountError: true});
386
+ this.props.actions.resetTemplate();
387
+ return;
388
+ }
389
+ }
390
+
391
+ console.log("getAllTemplates params: ", params);
392
+ this.getAllTemplates({params, resetPage: true});
393
+ });
394
+ }
395
+ onPaginationChange = () => { this.getAllTemplates({getNextPage: true}); }
396
+ onCreateComplete = () => {
397
+ this.setState({routeParams: null});
398
+ }
399
+ getCurrentWindow(e) {
400
+ const response = {
401
+ action: e.action,
402
+ value: 'templates',
403
+ direction: e.value,
404
+ };
405
+ parent.postMessage(JSON.stringify(response), '*');
406
+ }
407
+ getCreativesParams = () => {
408
+ const routeParams = this.state.routeParams;
409
+ let creativesParams = {mode: ''};
410
+ if (!_.isEmpty(routeParams)) {
411
+ if (routeParams.pathname.indexOf('create') > -1) {
412
+ creativesParams.mode = 'create';
413
+ } else if (routeParams.pathname.indexOf('edit') > -1) {
414
+ creativesParams.mode = 'edit';
415
+ creativesParams._id = routeParams.pathname.split('/')[3];
416
+ creativesParams.type = this.state.channel.toUpperCase();
417
+ }
418
+ }
419
+ if (this.state.previewOpen) {
420
+ creativesParams.mode = 'preview';
421
+ creativesParams = {...creativesParams, ...this.state.previewTemplate};
422
+ }
423
+ return creativesParams;
424
+ }
425
+ getMappedLocale = (locale) => {
426
+ const map = {
427
+ 'en': 'en',
428
+ 'zh-cn': 'zh',
429
+ };
430
+ return map[locale];
431
+ };
432
+ setLocale = () => {
433
+ const user = localStorage.getItem('user');
434
+ let locale = 'en';
435
+ if (user) {
436
+ locale = JSON.parse(user).lang;
437
+ }
438
+ locale = this.getMappedLocale(locale);
439
+ //locale = 'zh';
440
+
441
+ moment.locale(locale);
442
+ };
443
+ getAllTemplates = ({params, getNextPage, resetPage}, resetTemplates) => {
444
+ let queryParams = params;
445
+ let page = this.state.page;
446
+ if (resetTemplates) {
447
+ queryParams.name = this.state.searchText;
448
+ queryParams.sortBy = this.state.sortBy;
449
+ queryParams.page = this.state.page;
450
+ queryParams.perPage = this.state.perPageLimit;
451
+ const channel = this.state.channel;
452
+ this.props.actions.getAllTemplates(channel, queryParams);
453
+ } else if ((resetPage || (page === 1 && this.state.templatesCount === 0) || page <= (this.state.templatesCount / this.state.perPageLimit))) {
454
+ if (getNextPage) {
455
+ page += 1;
456
+ }
457
+ let templatesCount = this.state.templatesCount;
458
+ if (resetPage) {
459
+ page = 1;
460
+ templatesCount = 0;
461
+ }
462
+ if (!params || _.isEmpty(params)) {
463
+ queryParams = {
464
+ name: this.state.searchText,
465
+ sortBy: this.state.sortBy,
466
+ };
467
+ if (this.state.channel.toLowerCase() === 'wechat' && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
468
+ queryParams.wecrmId = this.props.Templates.selectedWeChatAccount.configs.wecrm_app_id;
469
+ queryParams.wecrmToken = this.props.Templates.selectedWeChatAccount.configs.wecrm_token;
470
+ queryParams.originalId = this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier;
471
+ }
472
+ if (this.state.channel.toLowerCase() === "mobilepush" && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
473
+ queryParams.accountId = this.props.Templates.selectedWeChatAccount.id;
474
+ if (this.state.mode) {
475
+ queryParams.mode = this.state.mode.toLowerCase();
476
+ }
477
+ }
478
+ }
479
+ this.setState({page, templatesCount}, () => {
480
+ queryParams.page = page;
481
+ queryParams.perPage = this.state.perPageLimit;
482
+ const channel = this.state.channel;
483
+ this.props.actions.getAllTemplates(channel, queryParams);
484
+ });
485
+ }
486
+ };
487
+ getTemplateDataForGrid = ({templates, handlers, filterContent, channel, isLoading, loadingTip}) => {
488
+ const currentChannel = channel.toUpperCase();
489
+ const cardDataList = templates && templates.length ? _.map(templates, (template) => {
490
+ const templateData =
491
+ {
492
+ key: `${currentChannel}-card-${template.name}`,
493
+ title: <span title={template.name} >{template.name}</span>,
494
+ extra: [
495
+ <CapIcon
496
+ style={{marginRight: '16px'}}
497
+ type="eye"
498
+ onClick={() => { if (this.props.isFullMode) { handlers.handlePreviewClick(template); } else { this.props.handlePeviewTemplate(template); } }}
499
+ />,
500
+ ],
501
+ hoverOption: <CapButton onClick={(e) => handlers.handleEditClick(e, template._id)}>{this.props.intl.formatMessage(this.props.isFullMode ? messages.creativesTemplatesEdit : messages.selectButton)}</CapButton>,
502
+ };
503
+ if (this.props.isFullMode) {
504
+ templateData.extra.push(<CapDropdown
505
+ overlay={
506
+ <CapMenu>
507
+ <CapMenu.Item onClick={() => this.duplicateTemplate(template)}>
508
+ <FormattedMessage {...messages.duplicateButton} />
509
+ </CapMenu.Item>
510
+ <CapMenu.Item
511
+ onClick={() => this.deleteTemplate(template)}
512
+ >
513
+ <FormattedMessage {...messages.deleteButton} />
514
+ </CapMenu.Item>
515
+ </CapMenu>
516
+ }
517
+ >
518
+ <CapIcon type="more" />
519
+ </CapDropdown>);
520
+ }
521
+ if (currentChannel === "SMS") {
522
+ templateData.content = template.versions.base['sms-editor'];
523
+ } else if (currentChannel === "EMAIL") {
524
+ templateData.url = template.versions.base.preview_http_url;
525
+ } else if (currentChannel === "MOBILEPUSH" && template.type === "MOBILEPUSH") {
526
+ templateData.content = template;
527
+ }
528
+ return templateData;
529
+ }) : [];
530
+ const accountId = _.get(this.props, 'Templates.selectedWeChatAccount.uuid');
531
+ return (<div>
532
+ {filterContent}
533
+ <CapSpin spinning={isLoading} tip={loadingTip}>
534
+ {!_.isEmpty(templates) && <div className="pagination-container">
535
+ <CapCustomCardList key={`${currentChannel}-card-list`} cardList={cardDataList} type={currentChannel} />
536
+ </div>}
537
+ {(this.state.selectedAccount === '' && _.isEmpty(this.props.Templates.selectedWeChatAccount)) && (this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === "mobilepush") &&
538
+ <div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
539
+ <CapHeading type="h6">{this.props.intl.formatMessage(messages.noAccountMessage)}</CapHeading>
540
+ </div>}
541
+ { !_.isEmpty(this.props.Templates.selectedWeChatAccount) && this.state.channel.toLowerCase() === "mobilepush" && this.state.selectedAccountError &&
542
+ <div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
543
+ <CapHeading type="h6" >
544
+ {this.props.intl.formatMessage(messages.accountConfigError)}
545
+ <InlineDiv>
546
+ <CapLink title="here" style={{display: 'inline'}} onClick={() => { window.open(config.production.accountConfig`${accountId}`); }}/>
547
+ </InlineDiv>
548
+ </CapHeading>
549
+ </div>
550
+ }
551
+ </CapSpin>
552
+
553
+ </div>);
554
+ }
555
+ skipTemplateSelection = (e) => {
556
+ const type = this.props.location.query.type;
557
+ const module = (type === 'embedded') ? this.props.location.query.module : 'default';
558
+ let routeParams = {};
559
+ if (this.state.channel.toLowerCase() === 'email') {
560
+ const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
561
+ routeParams = {
562
+ pathname: `/email/view`,
563
+ query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport} : {},
564
+ };
565
+ } else if (this.state.channel.toLowerCase() === 'sms') {
566
+ routeParams = {
567
+ pathname: `/sms/view`,
568
+ query: type === 'embedded' ? {type: 'embedded', module} : {},
569
+ };
570
+ } else if (this.state.channel.toLowerCase() === 'mobilepush') {
571
+ routeParams = {
572
+ pathname: `/mobilepush/edit/${e.template_id}`,
573
+ query: type === 'embedded' ? {type: 'embedded', module, account_id: e.account_id} : {},
574
+ };
575
+ } else if (this.state.channel.toLowerCase() === 'wechat') {
576
+ if (e.template_type && e.template_type === 'RICHMEDIA_WECHAT_TEMPLATE') {
577
+ this.props.router.push({
578
+ pathname: `/wechat/richmedia/edit/${e.template_id}`,
579
+ query: type === 'embedded' ? {type: 'embedded', module, source_account_id: e.source_account_id} : {},
580
+ });
581
+ } else {
582
+ this.props.router.push({
583
+ pathname: `/wechat/edit/${e.template_id}`,
584
+ query: type === 'embedded' ? {type: 'embedded', module, source_account_id: e.source_account_id} : {},
585
+ });
586
+ }
587
+ } else if (this.state.channel.toLowerCase() === 'line') {
588
+ routeParams = {
589
+ pathname: `/line/view/${e.msg_type}/`,
590
+ query: type === 'embedded' ? {type: 'embedded', module, account_id: e.account_id } : {},
591
+ };
592
+ }
593
+ this.setState({loading: true, routeParams});
594
+ }
595
+
596
+ handleMenuAction = (item) => {
597
+ if (item.key.toLowerCase() === 'uploadfile') {
598
+ document.getElementById('filename').click();
599
+ } else if (item.key.toLowerCase() === 'useeditor') {
600
+ this.toggleEdmEmailTemplateSelection();
601
+ }
602
+ };
603
+
604
+ handleBlankTemplateAction = (item, channel) => {
605
+ const type = this.props.location.query.type;
606
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
607
+ let routeParams = {};
608
+ if (item === "uploadFile") {
609
+ document.getElementById('filename').click();
610
+ } else if (item === "editor") {
611
+ this.toggleEdmEmailTemplateSelection();
612
+ } else if (this.isEnabledInLibraryModule("callCreateFromProps")) {
613
+ this.props.createNew(item);
614
+ } else if (item === 'textTemplate') {
615
+ routeParams = {
616
+ pathname: `/${channel === 'line' ? 'line' : 'mobilepush'}/create/text`,
617
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
618
+ };
619
+ } else if (item === 'imageTemplate') {
620
+ routeParams = {
621
+ pathname: `/${channel === 'line' ? 'line' : 'mobilepush'}/create/image`,
622
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
623
+ };
624
+ }
625
+ this.setState({routeParams});
626
+ }
627
+
628
+ handleFileUpload = (e, {files}) => {
629
+ if (files.length === 0) {
630
+ return;
631
+ }
632
+ const fileExtension = files[0].name.split('.').pop();
633
+ const supportedZipFormats = ['zip'];
634
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
635
+ const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : true;
636
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
637
+
638
+ if (supportedZipFormats.indexOf(fileExtension.toLowerCase()) !== -1) {
639
+ this.props.actions.handleZipUpload(files[0]);
640
+ document.getElementById("filename").value = "";
641
+ } else if (fileExtension === 'html' || fileExtension === 'htm') {
642
+ const reader = new FileReader();
643
+ reader.onload = () => {
644
+ const text = reader.result;
645
+ this.props.actions.handleHtmlUpload(text);
646
+ document.getElementById("filename").value = "";
647
+ const type = this.props.location.query.type;
648
+ if (this.isEnabledInLibraryModule("callCreateFromProps")) {
649
+ this.props.createNew();
650
+ return;
651
+ }
652
+ this.setState({routeParams: {
653
+ pathname: `/${this.props.route.name.toLowerCase()}/create`,
654
+ query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module},
655
+ }});
656
+ };
657
+ reader.readAsText(files[0]);
658
+ } else {
659
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages.invalidUploadFileError), true);
660
+ this.props.globalActions.addMessageToQueue(message);
661
+ }
662
+ };
663
+
664
+ prepareWeChatPreviewData(template) {
665
+ if (template && template.versions && template.versions.base && !_.isEmpty(template.versions.base)) {
666
+ if (template.definition && template.definition.msgcontent && template.definition.msgcontent === "RICH_MEDIA_WECHAT") {
667
+ return template.versions.base.mediaList;
668
+ }
669
+ return this.prepareWeChatMappedPreviewData(template.versions.base.content, template.versions.base.Tag, template.versions.base.data);
670
+ }
671
+ return 'wrong template';
672
+ }
673
+
674
+ prepareWeChatMappedPreviewData(content, templateTags, tagData) {
675
+ let formattedContent = _.cloneDeep(content);
676
+ _.forEach(templateTags, (tag) => {
677
+ if (tagData[tag].value !== undefined) {
678
+ formattedContent = formattedContent.replace(`{{${tag}.DATA}}`, tagData[tag].value);
679
+ }
680
+ });
681
+ return formattedContent;
682
+ }
683
+
684
+ prepareMobilePushPreviewData(content) {
685
+ let result;
686
+ if (content.ANDROID) {
687
+ const data = content.ANDROID;
688
+ const bodyTextStyle = { WebkitLineClamp: 12};
689
+ if (data.expandableDetails && data.expandableDetails.ctas && ((data.expandableDetails.ctas[0] && data.expandableDetails.ctas[0].actionText) || (data.expandableDetails.ctas[1] && data.expandableDetails.ctas[1].actionText))) {
690
+ bodyTextStyle.WebkitLineClamp = 10;
691
+ }
692
+ if (data.expandableDetails && data.expandableDetails.image) {
693
+ bodyTextStyle.WebkitLineClamp = 3;
694
+ }
695
+ result = (
696
+ <div className="android-push-message-Container">
697
+ <div className="message-pop align-left">
698
+ <div className="message-container">
699
+ <div className="app-name">
700
+ <span className="app-icon"></span> {this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.name ? this.props.Templates.selectedWeChatAccount.name : "App name"}
701
+ </div>
702
+ <div className="title">
703
+ {data.title}
704
+ </div>
705
+ <div className="body-text" style={bodyTextStyle} >
706
+ {data.message}
707
+ </div>
708
+ {data.expandableDetails && data.expandableDetails.image && <div className="body-image">
709
+ <img src={data.expandableDetails.image} alt={data.expandableDetails.image}/>
710
+ </div>}
711
+ {(data.expandableDetails && data.expandableDetails.ctas && ((data.expandableDetails.ctas[0] && data.expandableDetails.ctas[0].actionText) || (data.expandableDetails.ctas[1] && data.expandableDetails.ctas[1].actionText))) &&
712
+ <div className="actions">
713
+ {_.map(data.expandableDetails.ctas, (action) => !!action.actionText &&
714
+ <span className="action">{action.actionText && action.actionText.toUpperCase()}</span>)}
715
+ </div>
716
+ }
717
+ </div>
718
+ </div>
719
+ </div>);
720
+ } else if (content.IOS) {
721
+ const data = content.IOS;
722
+ const bodyTextStyle = { WebkitLineClamp: 11};
723
+ if (data.expandableDetails && data.expandableDetails.ctas && data.expandableDetails.ctas[0] && data.expandableDetails.ctas[0].actionText) {
724
+ bodyTextStyle.WebkitLineClamp = 6;
725
+ }
726
+ if (data.expandableDetails && data.expandableDetails.image) {
727
+ bodyTextStyle.WebkitLineClamp = 1;
728
+ }
729
+ const iosActions = [];
730
+ if (data.expandableDetails.ctas && data.expandableDetails.ctas.length) {
731
+ if (data.expandableDetails.ctas[0].actionLabel) {
732
+ iosActions.push(<div className="actions">
733
+ <span className="action">{data.expandableDetails.ctas[0].actionLabel.toUpperCase()}</span>
734
+ </div>);
735
+ }
736
+ if (data.expandableDetails.ctas[0].actionLabel2) {
737
+ iosActions.push(<div className="actions">
738
+ <span className="action">{data.expandableDetails.ctas[0].actionLabel2.toUpperCase()}</span>
739
+ </div>);
740
+ }
741
+ }
742
+
743
+ result = (
744
+ <div className="iphone-push-message-Container">
745
+ <div className="message-pop align-left">
746
+ <div className="message-container">
747
+ <div className="app-name">
748
+ <span className="app-icon"></span>{this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.name ? this.props.Templates.selectedWeChatAccount.name : "App name"} <i className="material-icons">close</i>
749
+ </div>
750
+ {data.expandableDetails && data.expandableDetails.image && <div className={`body-image ${iosActions.length > 0 ? 'image-half' : ''}`}>
751
+ <img src={data.expandableDetails.image} alt={data.image}/>
752
+ </div>}
753
+ <div className="title">
754
+ {data.title}
755
+ </div>
756
+ <div className="body-text" style={bodyTextStyle}>
757
+ {data.message}
758
+ </div>
759
+ {data.expandableDetails && data.expandableDetails.ctas && data.expandableDetails.ctas[0] && data.expandableDetails.ctas[0].actionText && iosActions}
760
+ </div>
761
+ </div>
762
+ </div>);
763
+ }
764
+ return result;
765
+ }
766
+ startLoading(ifEdit) {
767
+ if (ifEdit) {
768
+ this.setState({loading: true});
769
+ }
770
+ }
771
+
772
+ startTemplateCreation(data) {
773
+ if (data.edit) {
774
+ const ifUnicode = checkUnicode(data.content);
775
+
776
+ const content = data.content;
777
+ const tempData = {
778
+ 'sms-editor': content,
779
+ 'unicode-validity': ifUnicode,
780
+ 'base': true,
781
+ };
782
+ const formData = {};
783
+ formData[0] = tempData;
784
+ formData.base = tempData;
785
+ this.setState({formData, loading: false});
786
+ }
787
+ }
788
+
789
+ handleFrameTasks = (e) => {
790
+ const type = e.data;
791
+ if (typeof type === 'object') {
792
+ const action = type.action;
793
+ switch (action) {
794
+ case "startTemplateCreation":
795
+ this.startTemplateCreation(type.value);
796
+ break;
797
+ case "startLoading":
798
+ this.startLoading(type.edit);
799
+ break;
800
+ case "getCurrentWindow":
801
+ this.getCurrentWindow(e.data);
802
+ break;
803
+ case "skipTemplateSelection":
804
+ this.skipTemplateSelection(e.data);
805
+ break;
806
+ default:
807
+ break;
808
+ }
809
+ }
810
+ switch (type) {
811
+ case "getFormData":
812
+ this.getFormData(e);
813
+ break;
814
+ case "startTemplateCreation":
815
+
816
+ //this.getFormData(e);
817
+ break;
818
+ case "validateContent":
819
+
820
+ this.validateContent(e);
821
+ break;
822
+ default:
823
+ break;
824
+ }
825
+ };
826
+
827
+ createTemplate(ev) {
828
+ const type = this.props.location.query.type;
829
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
830
+ const channel = this.state.channel.toLowerCase();
831
+ //const keyType = ev.key && ev.key.toLowerCase() !== undefined ? ev.state.toLowerCase() : '';
832
+ let routeParams = {};
833
+ if (this.isEnabledInLibraryModule("callCreateFromProps")) {
834
+ this.props.createNew();
835
+ } else if (ev.key && (ev.key.toLowerCase() === "text" || ev.key.toLowerCase() === "image")) {
836
+ routeParams = {
837
+ pathname: `/${channel === 'line' ? 'line' : 'mobilepush'}/create/${ev.key.toLowerCase()}`,
838
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
839
+ };
840
+ } else {
841
+ routeParams = {
842
+ pathname: `/${this.state.channel.toLowerCase()}/create`,
843
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
844
+ };
845
+ }
846
+ this.setState({routeParams});
847
+ }
848
+
849
+ menuOnClickEvent(ev) {
850
+ let type = this.props.location.query.type;
851
+ // const module = this.props.location.query.module ? this.props.location.query.module : 'default';
852
+ const channel = this.state.channel.toLowerCase();
853
+ switch (channel) {
854
+ case 'wechat':
855
+ if (ev && ev.key && ev.key.toLowerCase() === "map_template") {
856
+ type = this.props.location.query.type;
857
+ this.props.router.push({
858
+ pathname: `/wechat/create`,
859
+ query: type === 'embedded' ? {type: 'embedded'} : {},
860
+ });
861
+ } else if (ev && ev.key && ev.key.toLowerCase() === "richmedia_template") {
862
+ type = this.props.location.query.type;
863
+ if (this.props.Templates && this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && (_.isEmpty(this.props.Templates.selectedWeChatAccount.configs.wechat_app_id) || _.isEmpty(this.props.Templates.selectedWeChatAccount.configs.wechat_app_secret))) {
864
+ const errorMessage = this.props.intl.formatMessage(messages.wechatAccountNotConfigured);
865
+ const message = getMessageObject('error', errorMessage, true);
866
+ this.props.globalActions.addMessageToQueue(message);
867
+ } else {
868
+ this.props.router.push({
869
+ pathname: `/wechat/richmedia/create`,
870
+ query: type === 'embedded' ? {type: 'embedded'} : {},
871
+ });
872
+ }
873
+ }
874
+ break;
875
+ default:
876
+ this.props.router.push({
877
+ pathname: `*`,
878
+ });
879
+ break;
880
+ }
881
+ }
882
+
883
+ searchTemplate(data) {
884
+ this.setState({searchText: data}, () => {
885
+ const params = {
886
+ name: this.state.searchText,
887
+ sortBy: this.state.sortBy,
888
+ };
889
+ if (this.state.channel.toLowerCase() === 'wechat') {
890
+ params.wecrmId = this.props.Templates.selectedWeChatAccount.configs.wecrm_app_id;
891
+ params.wecrmToken = this.props.Templates.selectedWeChatAccount.configs.wecrm_token;
892
+ params.originalId = this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier;
893
+ }
894
+ if (this.state.channel.toLowerCase() === "mobilepush") {
895
+ params.accountId = this.props.Templates.selectedWeChatAccount.id;
896
+ }
897
+ this.getAllTemplates({params, resetPage: true});
898
+ });
899
+ }
900
+
901
+ handleSortBy(data) {
902
+ this.setState({sortBy: data}, () => {
903
+ const params = {
904
+ name: this.state.searchText,
905
+ sortBy: this.state.sortBy,
906
+ };
907
+ if (this.state.channel.toLowerCase() === 'wechat') {
908
+ params.wecrmId = this.props.Templates.selectedWeChatAccount.configs.wecrm_app_id;
909
+ params.wecrmToken = this.props.Templates.selectedWeChatAccount.configs.wecrm_token;
910
+ params.originalId = this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier;
911
+ }
912
+ if (this.state.channel.toLowerCase() === "mobilepush") {
913
+ params.accountId = this.props.Templates.selectedWeChatAccount.id;
914
+ }
915
+ this.getAllTemplates({params, resetPage: true});
916
+ });
917
+ }
918
+ handleType = (data) => {
919
+ this.setState({mode: data}, () => {
920
+ const params = {
921
+ name: this.state.searchText,
922
+ sortBy: this.state.sortBy,
923
+ };
924
+ if (this.state.channel.toLowerCase() === "mobilepush") {
925
+ params.accountId = this.props.Templates.selectedWeChatAccount.id;
926
+ }
927
+ if ( (this.state.channel.toLowerCase() === 'mobilepush' || this.state.channel.toLowerCase() === 'line') && data.toLowerCase() !== "all") {
928
+ params.mode = this.state.mode.toLowerCase();
929
+ }
930
+ this.getAllTemplates({params, resetPage: true});
931
+ });
932
+ };
933
+ togglePreview() {
934
+ if (this.state.channel.toLowerCase() === 'ebill' || this.state.channel.toLowerCase() === 'email') {
935
+ this.toggleEmailPreview();
936
+ } else {
937
+ this.setState( (prevState) => ({
938
+ previewOpen: !prevState.previewOpen}));
939
+ }
940
+ }
941
+
942
+ toggleEdmEmailTemplateSelection = () => {
943
+ this.setState( (prevState) => ({
944
+ showEdmEmailTemplates: !prevState.showEdmEmailTemplates}), () => {
945
+ this.props.actions.getEdmDefaultTemplates();
946
+ });
947
+ };
948
+
949
+ deleteTemplate(template) {
950
+ this.props.actions.deleteTemplate(this.state.channel.toUpperCase(), template._id);
951
+ this.setState({actionTemplate: {}});
952
+ }
953
+
954
+ duplicateTemplate(template) {
955
+ const duplicateObj = _.cloneDeep(template);
956
+ duplicateObj.name = `Copy of ${template.name} ${moment().format('MM-DD-YYYY hh:mma')}`;
957
+ delete duplicateObj._id;
958
+ const params = {
959
+ name: this.state.searchText,
960
+ sortBy: this.state.sortBy,
961
+ };
962
+ if (this.state.channel.toLowerCase() === "sms") {
963
+ this.props.smsActions.createTemplate(duplicateObj, (response) => {
964
+ if (response && response.templateId) {
965
+ const message = getMessageObject('success', `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`, true);
966
+ this.props.globalActions.addMessageToQueue(message);
967
+ this.getAllTemplates({params, resetPage: true});
968
+ this.props.smsActions.clearCreateResponse();
969
+ }
970
+ });
971
+ } else if (this.state.channel.toLowerCase() === "mobilepush") {
972
+ duplicateObj.definition.accountId = this.props.Templates.selectedWeChatAccount.id;
973
+ this.props.mobilepushActions.createTemplate(duplicateObj);
974
+ } else if (this.state.channel.toLowerCase() === "ebill") {
975
+ this.props.ebillActions.createTemplate(duplicateObj);
976
+ } else if (this.state.channel.toLowerCase() === "email") {
977
+ this.props.emailActions.duplicateTemplate(template._id, "EMAIL");
978
+ } else if (this.state.channel.toLowerCase() === "line") {
979
+ this.props.lineActions.createTemplate(duplicateObj);
980
+ }
981
+ }
982
+
983
+ handleOnHoverItem(isHovering, id) {
984
+ if (isHovering) {
985
+ this.setState({hoveredItem: id});
986
+ } else {
987
+ this.setState({hoveredItem: ''});
988
+ }
989
+ }
990
+
991
+ handleOnItemClick(isClicked, id) {
992
+ this.setState({clickedItem: id});
993
+ }
994
+
995
+ handleEdmDefaultTemplateSelection = (isSelected, id) => {
996
+ if (isSelected) {
997
+ const data = _.find(this.props.Templates.cmsTemplates, {_id: id});
998
+ const type = this.props.location.query.type;
999
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
1000
+ const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : true;
1001
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
1002
+ let getQuery = '';
1003
+
1004
+ this.props.actions.setEdmTemplate(data);
1005
+ if (this.state.channel && this.state.channel.toLowerCase() === 'email') {
1006
+ getQuery = (type === 'embedded') ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport};
1007
+ } else {
1008
+ getQuery = (type === 'embedded') ? {type: 'embedded', module} : {module};
1009
+ }
1010
+ if (this.isEnabledInLibraryModule("callCreateFromProps")) {
1011
+ this.props.createNew();
1012
+ return;
1013
+ }
1014
+ this.setState({routeParams: {
1015
+ pathname: `/${this.state.channel.toLowerCase()}/create`,
1016
+ query: getQuery,
1017
+ }});
1018
+ }
1019
+ };
1020
+
1021
+ handleEditClick(e, id, modeType, path) {
1022
+ if (modeType && modeType !== undefined) {
1023
+ this.setState({modeType});
1024
+ }
1025
+ const type = this.props.location.query.type;
1026
+ const module = this.props.location.query.module;
1027
+ const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : false;
1028
+ const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
1029
+ let getQuery = "";
1030
+ let pathName = path;
1031
+ e.stopPropagation();
1032
+
1033
+ this.props.actions.resetTemplateData();
1034
+ if (this.state.channel.toLowerCase() === 'sms') {
1035
+ pathName = `/sms/edit/${id}`;
1036
+ }
1037
+ if (this.state.channel.toLowerCase() === 'mobilepush') {
1038
+ pathName = `/mobilepush/edit/${id}`;
1039
+ }
1040
+ if (this.state.channel.toLowerCase() === 'email') {
1041
+ pathName = `/email/edit/${id}`;
1042
+ }
1043
+ if (this.state.channel.toLowerCase() === 'email') {
1044
+ getQuery = type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isEdmSupport};
1045
+ } else {
1046
+ getQuery = type === 'embedded' ? {type: 'embedded', module, account_id: this.props.location.query.account_id} : {module};
1047
+ }
1048
+ if (this.state.channel.toLowerCase() === 'ebill') {
1049
+ pathName = `/ebill/edit/${id}`;
1050
+ }
1051
+ if (this.state.channel.toLowerCase() === 'line') {
1052
+ pathName = `/line/edit/${modeType}/${id}`;
1053
+ }
1054
+ if (this.isEnabledInLibraryModule("callSelectFromProps")) {
1055
+ this.props.onSelectTemplate(id);
1056
+ } else {
1057
+ if (this.state.channel.toLowerCase() === 'ebill') {
1058
+ pathName = `/ebill/edit/${id}`;
1059
+ }
1060
+ this.setState({routeParams: {
1061
+ pathname: pathName,
1062
+ query: getQuery,
1063
+ }});
1064
+ }
1065
+ }
1066
+
1067
+ handlePreviewClick(template, modeType) {
1068
+ this.togglePreview();
1069
+ const templateInfo = _.cloneDeep(template);
1070
+ if (this.state.channel.toLowerCase() === 'line') {
1071
+ templateInfo.modeType = modeType;
1072
+ }
1073
+ templateInfo.updatedByName = commonUtil.getUserNameById(parseInt(template.updatedBy, 10), commonUtil.getMergedUserList(this.props.Templates.userList));
1074
+ if (this.state.channel === 'wechat') {
1075
+ templateInfo.content = this.prepareWeChatPreviewData(template);
1076
+ } else if (this.state.channel.toLowerCase() === "mobilepush") {
1077
+ templateInfo.content = template.versions.base;
1078
+ templateInfo.appName = this.props.Templates.selectedWeChatAccount.name;
1079
+ } else if (this.state.channel.toLowerCase() === "email") {
1080
+ this.props.actions.getTemplateDetails(template._id);
1081
+ } else if (this.state.channel.toLowerCase() === 'ebill') {
1082
+ this.props.actions.getTemplateDetails(template._id);
1083
+ }
1084
+ if (this.state.channel.toLowerCase() !== 'ebill') {
1085
+ this.setState({previewTemplate: templateInfo});
1086
+ }
1087
+ }
1088
+
1089
+ toggleDeleteTemplateModal = (template) => {
1090
+ this.setState({actionTemplate: template}, () => {
1091
+ this.setState({showModal: true});
1092
+ });
1093
+ }
1094
+
1095
+ handleOk = () => {
1096
+ this.setState({showModal: false});
1097
+ this.deleteTemplate(this.state.actionTemplate);
1098
+ }
1099
+
1100
+ handleCancel = () => {
1101
+ this.setState({showModal: false});
1102
+ }
1103
+
1104
+ populateTemplatesList = (data, blankTemplateRequired, layoutSelection) => {
1105
+ if (!data) {
1106
+ return [];
1107
+ }
1108
+ const type = this.props.location.query.type;
1109
+ const items = [];
1110
+ const channel = this.state.channel.toLowerCase();
1111
+
1112
+ if (type === 'embedded' && channel !== 'wechat' && blankTemplateRequired) {
1113
+ let content;
1114
+ if (channel === 'sms') {
1115
+ content = (<div className="sms-template-content" onClick={this.createTemplate}>
1116
+ <div style={{textAlign: 'center', lineHeight: '260px'}} className="sms-text">{this.props.intl.formatMessage(messages.blankTemplate)}</div>
1117
+ </div>);
1118
+ } else if (channel === 'email') {
1119
+ content = (<div className="sms-template-content">
1120
+ <div style={{textAlign: 'center', lineHeight: '260px'}} className="sms-text">
1121
+ <div>
1122
+ <button type="button" className="ant-btn cap-button edit-button ant-btn-ghost" onClick={() => this.handleBlankTemplateAction('uploadFile')}><span>Upload File</span></button>
1123
+ <button type="button" className="ant-btn cap-button preview-button ant-btn-danger" onClick={() => this.handleBlankTemplateAction('editor')}><span>Use Editor</span></button>
1124
+ </div>
1125
+ </div>
1126
+ </div>);
1127
+ } else if (channel === 'mobilepush' || channel === 'line') {
1128
+ content = (<div className="sms-template-content">
1129
+ <div style={{textAlign: 'center', lineHeight: '260px'}} className="sms-text">
1130
+ <div>
1131
+ <button
1132
+ type="button"
1133
+ className="ant-btn cap-button edit-button ant-btn-ghost"
1134
+ onClick={() => this.handleBlankTemplateAction('textTemplate', channel)}>
1135
+ <span>{this.props.intl.formatMessage(messages.textTemplate)}</span>
1136
+ </button>
1137
+ <button
1138
+ type="button"
1139
+ className="ant-btn cap-button preview-button ant-btn-danger"
1140
+ onClick={() => this.handleBlankTemplateAction('imageTemplate', channel)}>
1141
+ <span>{this.props.intl.formatMessage(messages.imageTemplate)}</span>
1142
+ </button>
1143
+ </div>
1144
+ </div>
1145
+ </div>);
1146
+ }
1147
+ items.push(
1148
+ {
1149
+ id: 'blankTemplate',
1150
+ content,
1151
+ }
1152
+ );
1153
+ }
1154
+ data.map( (template) => {
1155
+ //
1156
+ const temp = {};
1157
+ //
1158
+ const updateDateTime = (moment().format('DD-MM-YYYY') === moment(template.updatedAt).format('DD-MM-YYYY')) ? moment(template.updatedAt).format('hh:mma') : moment(template.updatedAt).format('DD MMM YYYY');
1159
+ let content = '';
1160
+ temp.id = template._id;
1161
+ if (this.state.channel === 'wechat') {
1162
+ let path = '';
1163
+ if (template && template.versions && template.versions.base && !_.isEmpty(template.versions.base)) {
1164
+ if (template.definition && template.definition.msgcontent && template.definition.msgcontent === "RICH_MEDIA_WECHAT") {
1165
+ path = `/wechat/richmedia/edit/${template._id}`;
1166
+ content = <WechatRichmediaTemplatePreview type={this.props.location && this.props.location.query.type ? this.props.location.query.type : ''} content={template.versions.base.mediaList}/>;
1167
+ } else {
1168
+ path = `/wechat/edit/${template._id}`;
1169
+ content = this.prepareWeChatPreviewData(template);
1170
+ }
1171
+ temp.content = (
1172
+ <div
1173
+ className="sms-template-content">
1174
+ <div className={`sms-text ${this.state.hoveredItem === template._id ? 'sms-text-blurred' : ''}`}>
1175
+ {content || ''}
1176
+ </div>
1177
+ {template._id === this.state.hoveredItem ? <CapButton onClick={(e) => this.handleEditClick(e, template._id, null, path)} className="edit-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectButton) : this.props.intl.formatMessage(messages.editButton)}</CapButton> : ''}
1178
+ {template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
1179
+ </div>
1180
+ );
1181
+ }
1182
+ } else if (this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill') {
1183
+ //
1184
+
1185
+ const imgSrc = template && template.versions && template.versions.base ? template.versions.base.preview_http_url : '';
1186
+ // const ifPreviewGenerated = template && template.versions && template.versions.base ? template.versions.base.isPreviewGenerated : 0;
1187
+ content = <img src={imgSrc || ''} alt={this.props.intl.formatMessage(messages.previewGenerateText)} width="100%" height="100%"/>;
1188
+
1189
+ temp.content = (
1190
+ <div
1191
+ className="sms-template-content">
1192
+ <div className={`sms-text ${this.state.hoveredItem === template._id ? 'sms-text-blurred' : ''}`}>
1193
+ {content}
1194
+ </div>
1195
+ {!layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={(e) => this.handleEditClick(e, template._id)} className="edit-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectButton) : this.props.intl.formatMessage(messages.editButton)}</CapButton> : ''}
1196
+ {layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handleEdmDefaultTemplateSelection(true, template._id)} className="select-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectDefaultButton) : this.props.intl.formatMessage(messages.selectDefaultButton)}</CapButton> : ''}
1197
+ {!layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
1198
+ </div>);
1199
+ } else if (this.state.channel.toLowerCase() === 'mobilepush') {
1200
+ content = this.prepareMobilePushPreviewData(template.versions.base);
1201
+ temp.content = (
1202
+ <div>
1203
+ <div className={`mobilepush-message ${this.state.hoveredItem === template._id ? 'sms-text-blurred' : ''}`}>
1204
+ {content || ''}
1205
+ </div>
1206
+ {template._id === this.state.hoveredItem ? <CapButton onClick={(e) => this.handleEditClick(e, template._id)} className="edit-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectButton) : this.props.intl.formatMessage(messages.editButton)}</CapButton> : ''}
1207
+ {template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
1208
+ </div>);
1209
+ } else if (this.state.channel.toLowerCase() === 'line') {
1210
+ //content = template.versions.base.messages[0].Text;
1211
+ content = {
1212
+ bodyText: template.versions.base.content.messages[0].text ? template.versions.base.content.messages[0].text : '',
1213
+ bodyImage: template.versions.base.content.messages[0].originalContentUrl ? template.versions.base.content.messages[0].originalContentUrl : '',
1214
+ };
1215
+ const modeType = template.versions.base.content.messages[0].type;
1216
+ temp.content = (
1217
+ <div className="sms-template-content" key={template._id}>
1218
+ {content.bodyText ? <div className={`sms-text ${this.state.hoveredItem === template._id ? 'sms-text-blurred' : ''}`}>{content.bodyText || ''}</div> : ''}
1219
+ {content.bodyImage ? <div className={`sms-text ${this.state.hoveredItem === template._id ? 'sms-text-blurred' : ''}`}>
1220
+ <img src={content.bodyImage} role={"presentation"} style={{maxWidth: '100%', objectFit: 'cover', height: '100%'}}/></div> : ''}
1221
+ {template._id === this.state.hoveredItem ? <CapButton onClick={(e) => this.handleEditClick(e, template._id, modeType)} className="edit-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectButton) : this.props.intl.formatMessage(messages.editButton)}</CapButton> : ''}
1222
+ {template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template, modeType)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
1223
+ </div>
1224
+ );
1225
+ } else {
1226
+ content = template && template.versions && template.versions.base ? template.versions.base['sms-editor'] : '';
1227
+ for (let idx = 2; idx <= 5; idx += 1) {
1228
+ if ((content === '' || !content) && template && template.versions && template.versions.base && template && template.versions && template.versions.base[`sms-editor${idx}`]) {
1229
+ content = template.versions.base[`sms-editor${idx}`];
1230
+ }
1231
+ }
1232
+ temp.content = (
1233
+ <div
1234
+ className="sms-template-content">
1235
+ <div className={`sms-text ${this.state.hoveredItem === template._id ? 'sms-text-blurred' : ''}`}>{content || ''}</div>
1236
+ {template._id === this.state.hoveredItem ? <CapButton onClick={(e) => this.handleEditClick(e, template._id)} className="edit-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectButton) : this.props.intl.formatMessage(messages.editButton)}</CapButton> : ''}
1237
+ {template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
1238
+ </div>
1239
+ );
1240
+ }
1241
+ let availableTemplates = "Android";
1242
+ if (template.versions && template.versions.base && template.versions.base.ANDROID && template.versions.base.IOS) {
1243
+ availableTemplates = `${availableTemplates} & IOS`;
1244
+ } else if (template.versions && template.versions.base && template.versions.base.IOS) {
1245
+ availableTemplates = 'iOS';
1246
+ }
1247
+ let deleteOption = this.props.intl.formatMessage(messages.deleteButton);
1248
+ if (this.state.channel.toLowerCase() === 'wechat' && !template.definition) {
1249
+ deleteOption = this.props.intl.formatMessage(messages.unMapButton);
1250
+ }
1251
+ if (!layoutSelection) {
1252
+ temp.footer = (
1253
+ <div className="footer-container">
1254
+ <div className="card-title">
1255
+ <span className="template-name" style={{ fontWeight: `${this.state.channel.toLowerCase() === 'wechat' ? '400' : '600'}` }}>
1256
+ { template && template.versions && template.versions.history && template.versions.history.length > 1 && this.state.channel.toLowerCase() !== 'mobilepush' && <i style={{fontSize: '16px', margin: '0 8px 0 0', verticalAlign: 'middle'}} className="material-icons">filter_none</i>}
1257
+ {template.name}
1258
+ </span>
1259
+ {this.props.location.query.type !== 'embedded' && <CapPopover
1260
+ trigger="click"
1261
+ content={
1262
+ <div className="popover-content">
1263
+ {this.state.channel !== 'wechat' && <div className="popover-action-container">
1264
+ <span onClick={() => this.duplicateTemplate(template)} className="popover-action" style={{cursor: 'pointer', padding: '8px 0px'}}>{this.props.intl.formatMessage(messages.duplicateButton)}</span>
1265
+ </div>}
1266
+ <div className="popover-action-container">
1267
+ <span onClick={() => this.toggleDeleteTemplateModal(template)} className="popover-action" style={{cursor: 'pointer', padding: '8px 0px'}}>{deleteOption}</span>
1268
+ </div>
1269
+ </div>
1270
+ }
1271
+ placement="bottomRight"
1272
+ >
1273
+ <i className="material-icons options-icon">&#xE5D4;</i>
1274
+ </CapPopover>}
1275
+ </div>
1276
+ {this.state.channel.toLowerCase() === "mobilepush" ?
1277
+ <p className="card-detail">{availableTemplates}</p>
1278
+ :
1279
+ <p className="card-detail">{this.props.intl.formatMessage(messages.uploadedAt)}: {updateDateTime}</p>
1280
+ }
1281
+ </div>
1282
+ );
1283
+ }
1284
+ items.push(temp);
1285
+ return true;
1286
+ });
1287
+ return items;
1288
+ };
1289
+
1290
+ toggleEmailPreview = () => {
1291
+ this.setState({ showHtmlPreview: !this.state.showHtmlPreview }, () => {
1292
+ if (!this.state.showHtmlPreview) {
1293
+ this.setState({previewTemplate: {}});
1294
+ }
1295
+ });
1296
+ };
1297
+
1298
+ changePreviewDevice = (device) => {
1299
+ this.setState({ device });
1300
+ };
1301
+ //Gets called only when creatives gets used as node library
1302
+ isEnabledInLibraryModule = (property) => {
1303
+ if (this.props.location.query.type === "embedded" && this.props.location.query.module === "library") {
1304
+ switch (property) {
1305
+ case "showAccountSelection":
1306
+ return (this.props.route && (this.props.route.name.toLowerCase() === "wechat" || this.props.route.name.toLowerCase() === "mobilepush"));
1307
+ case "setLocale":
1308
+ return true;
1309
+ case "callCreateFromProps":
1310
+ return true;
1311
+ case "callSelectFromProps":
1312
+ return true;
1313
+ default:
1314
+ return false;
1315
+ }
1316
+ } else {
1317
+ return false;
1318
+ }
1319
+ }
1320
+ isFullMode = () => this.props.location.query.type !== "embedded" || this.props.isFullMode
1321
+ isCreateDisabled = () => {
1322
+ let isDisabled = this.isLoading();
1323
+ const channel = this.state.channel.toUpperCase();
1324
+ if (channel === MOBILE_PUSH || channel === WECHAT) {
1325
+ isDisabled = isDisabled || _.isEmpty(this.props.Templates.selectedWeChatAccount);
1326
+ }
1327
+ if (channel === MOBILE_PUSH) {
1328
+ isDisabled = isDisabled || this.state.selectedAccountError;
1329
+ }
1330
+ return isDisabled;
1331
+ }
1332
+
1333
+
1334
+ isLoading = () => {
1335
+ const lineLoader = (this.props.Templates.getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'line');
1336
+ const smsLoader = (this.props.Templates.getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'sms');
1337
+ const wechatLoader = (((this.state.selectedAccount !== '' && this.props.Templates.getAllTemplatesInProgress) || (this.props.Templates.fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'wechat');
1338
+ const mobilePushLoader = (((this.props.Templates.getAllTemplatesInProgress) || (this.props.Templates.fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'mobilepush');
1339
+ const emailLoader = ((this.props.Templates.getAllTemplatesInProgress || this.props.Templates.sendingFile) && this.state.channel.toLowerCase() === 'email');
1340
+ const ebillLoader = ((this.props.Templates.getAllTemplatesInProgress || this.props.Templates.sendingFile) && this.state.channel.toLowerCase() === 'ebill');
1341
+ const isLoading = ((wechatLoader !== undefined) ? wechatLoader : false) ||
1342
+ (smsLoader !== undefined ? smsLoader : false) ||
1343
+ (emailLoader !== undefined ? emailLoader : false) ||
1344
+ (ebillLoader !== undefined ? ebillLoader : false) ||
1345
+ (mobilePushLoader !== undefined ? mobilePushLoader : false) ||
1346
+ (lineLoader !== undefined ? lineLoader : false);
1347
+ return isLoading;
1348
+ }
1349
+ renderEmailPreviewModal() {
1350
+ const slideboxContent = (
1351
+ <div style={{height: "75vh", width: '55vw'}}>
1352
+ <iframe />
1353
+ </div>
1354
+ );
1355
+
1356
+ return (
1357
+ <CapSlideBox
1358
+ header={this.state.previewTemplate.name}
1359
+ content={slideboxContent}
1360
+ show={this.state.showEmailPreviewModal}
1361
+ handleClose={this.toggleImagePreview}
1362
+ width={60}
1363
+ />
1364
+ );
1365
+ }
1366
+ renderDeleteConfirmationModal = () => {
1367
+ const modal =
1368
+ (<Modal
1369
+ visible={this.state.showModal}
1370
+ title={"Alert"}
1371
+ onOk={this.handleOk}
1372
+ onCancel={this.handleCancel}
1373
+ footer={[
1374
+ <CapButton key="back" onClick={this.handleCancel}>{this.props.intl.formatMessage(messages.cancelText)}</CapButton>,
1375
+ <CapButton key="submit" type="primary" id="delete-version" onClick={this.handleOk}>
1376
+ {this.props.intl.formatMessage(messages.yesText)}
1377
+ </CapButton>,
1378
+ ]}
1379
+ >
1380
+ {this.props.intl.formatMessage(messages.templateDeleteConfirm)}
1381
+ </Modal>);
1382
+ return modal;
1383
+ };
1384
+ render() {
1385
+ const accountOptions = [];
1386
+ const isFullMode = this.isFullMode();
1387
+ if ((this.state.channel.toUpperCase() === 'WECHAT' || this.state.channel.toUpperCase() === "MOBILEPUSH") && !_.isEmpty(this.props.Templates.weCrmAccounts)) {
1388
+ _.forEach(this.props.Templates.weCrmAccounts, (account) => {
1389
+ if ((this.state.channel.toUpperCase() === 'WECHAT' && account.configs && account.configs.is_wecrm_enabled) || this.state.channel.toUpperCase() === 'MOBILEPUSH') {
1390
+ if (this.props.location.query.type === 'embedded' && (!this.props.location.query.module || (this.props.location.query.module && this.props.location.query.module !== 'library'))) {
1391
+ if (this.props.location.query.source_account_id && account.sourceAccountIdentifier === this.props.location.query.source_account_id) {
1392
+ accountOptions.push(
1393
+ { key: this.state.channel.toUpperCase() === "MOBILEPUSH" ? account.id : account.uuid,
1394
+ label: account.name,
1395
+ value: account.name,
1396
+ }
1397
+ );
1398
+ } else if (this.props.location.query.module && (this.state.channel.toUpperCase() === "WECHAT" || this.state.channel.toUpperCase() === "MOBILEPUSH")) {
1399
+ accountOptions.push(
1400
+ {
1401
+ key: this.state.channel.toUpperCase() === "MOBILEPUSH" ? account.id : account.uuid,
1402
+ value: account.name,
1403
+ label: account.name,
1404
+ }
1405
+ );
1406
+ }
1407
+ } else {
1408
+ accountOptions.push(
1409
+ {
1410
+ key: this.state.channel.toUpperCase() === "MOBILEPUSH" ? account.id : account.uuid,
1411
+ value: account.name,
1412
+ label: account.name,
1413
+ }
1414
+ );
1415
+ }
1416
+ }
1417
+ });
1418
+ }
1419
+ const pageHeader = (
1420
+ <div>
1421
+ {(this.isEnabledInLibraryModule("showAccountSelection") || (((this.state.channel.toUpperCase() === 'WECHAT' || this.state.channel.toUpperCase() === "MOBILEPUSH") && (this.props.location.query.type !== 'embedded') && !_.isEmpty(this.props.Templates.weCrmAccounts)))) &&
1422
+ <CapSelect
1423
+ className="selectAccount"
1424
+ onSelect={this.onAccountSelect}
1425
+ value={this.props.Templates.selectedWeChatAccount ? this.props.Templates.selectedWeChatAccount.name : undefined}
1426
+ placeholder={this.props.intl.formatMessage(messages.selectAccount)}
1427
+ options={accountOptions}
1428
+ style={{width: '200px'}}
1429
+ />
1430
+ }
1431
+ </div>
1432
+ );
1433
+ const pageHeaderDvs = (
1434
+ <div>
1435
+ {((this.state.channel.toUpperCase() === 'WECHAT' || this.state.channel.toUpperCase() === "MOBILEPUSH") && (this.props.location.query.type === 'embedded') && !_.isEmpty(this.props.Templates.weCrmAccounts)) &&
1436
+ <CapSelect
1437
+ className="selectAccount"
1438
+ onSelect={this.onAccountSelect}
1439
+ value={this.props.Templates.selectedWeChatAccount ? this.props.Templates.selectedWeChatAccount.name : undefined} placeholder={this.props.intl.formatMessage(messages.selectAccount)}
1440
+ options={accountOptions}
1441
+ style={{width: '200px'}}
1442
+
1443
+ />
1444
+ }
1445
+ </div>
1446
+ );
1447
+ // let actionButton = '';
1448
+ // if (this.props.location.query.type !== 'embedded') {
1449
+ // if (this.state.channel.toUpperCase() === 'WECHAT') {
1450
+ // const createPushMenu = (
1451
+ // <Menu onClick={this.menuOnClickEvent}>
1452
+ // <MenuItem key="map_template">
1453
+ // {this.props.intl.formatMessage(messages.mapTemplate)}
1454
+ // </MenuItem>
1455
+ // <MenuItem key="richmedia_template">
1456
+ // {this.props.intl.formatMessage(messages.weChatRichmediaTemplate)}
1457
+ // </MenuItem>
1458
+ // </Menu>
1459
+ // );
1460
+ // actionButton = (<Dropdown disabled={_.isEmpty(this.props.Templates.selectedWeChatAccount)} overlay={createPushMenu} trigger={['click']}>
1461
+ // <CapButton style={{paddingLeft: '24px', paddingRight: '4px'}}>
1462
+ // <div style={{display: 'inline-flex'}}>
1463
+ // <p style={{ lineHeight: '28px'}}>{this.props.intl.formatMessage(messages.newTemplate)}</p>
1464
+ // <p style={{ height: '28px'}}>
1465
+ // <i style={{ color: '#fff', paddingTop: '2px', margin: '0', paddingRight: '8px'}} className="material-icons">arrow_drop_down</i>
1466
+ // </p>
1467
+ // </div>
1468
+ // </CapButton>
1469
+ // </Dropdown>);
1470
+ // } else if (this.state.channel.toUpperCase() === 'EMAIL' || this.state.channel.toUpperCase() === 'EBILL') {
1471
+ // const menuItems = [];
1472
+ // menuItems.push(<MenuItem key={'uploadFile'}>{this.props.intl.formatMessage(messages.uploadFile)}</MenuItem>);
1473
+ // menuItems.push(<MenuItem key={'useEditor'}>{this.props.intl.formatMessage(messages.useEditor)}</MenuItem>);
1474
+ // const menu = (
1475
+ // <Menu onClick={this.handleMenuAction}>
1476
+ // {menuItems}
1477
+ // </Menu>
1478
+ // );
1479
+ // actionButton = (
1480
+ // <Dropdown overlay={menu} trigger={["click"]}>
1481
+ // <CapButton style={{paddingLeft: '24px', paddingRight: '4px'}}>
1482
+ // <div style={{display: 'inline-flex'}}>
1483
+ // <p style={{ lineHeight: '32px', paddingRight: '12px' }}>{this.props.intl.formatMessage(messages.newTemplate)}</p>
1484
+ // <p style={{ height: '32px' }}>
1485
+ // <i style={{ color: '#fff', lineHeight: '32px', margin: '0'}} className="material-icons">arrow_drop_down</i>
1486
+ // </p>
1487
+ // </div>
1488
+ // </CapButton>
1489
+ // </Dropdown>
1490
+ // );
1491
+ // } else if (this.props.route.name.toLowerCase() === "mobilepush") {
1492
+ // const createPushMenu = (
1493
+ // <Menu onClick={this.createTemplate}>
1494
+ // <MenuItem key="text">
1495
+ // {this.props.intl.formatMessage(messages.textTemplate)}
1496
+ // </MenuItem>
1497
+ // <MenuItem key="image">
1498
+ // {this.props.intl.formatMessage(messages.imageTemplate)}
1499
+ // </MenuItem>
1500
+ // </Menu>
1501
+ // );
1502
+ // actionButton = (<Dropdown disabled={_.isEmpty(this.props.Templates.selectedWeChatAccount)} overlay={createPushMenu} trigger={['click']}>
1503
+ // <CapButton style={{paddingLeft: '24px', paddingRight: '4px'}}>
1504
+ // <div style={{display: 'inline-flex'}}>
1505
+ // <p style={{ lineHeight: '28px'}}>New Template</p>
1506
+ // <p style={{ height: '28px'}}>
1507
+ // <i style={{ color: '#fff', paddingTop: '2px', margin: '0', paddingRight: '8px'}} className="material-icons">arrow_drop_down</i>
1508
+ // </p>
1509
+ // </div>
1510
+ // </CapButton>
1511
+ // </Dropdown>);
1512
+ // } else if (this.props.route.name.toLowerCase() === "line") {
1513
+ // const lineMenu = (
1514
+ // <Menu onClick={this.createTemplate}>
1515
+ // <MenuItem key="text">
1516
+ // {this.props.intl.formatMessage(messages.textTemplate)}
1517
+ // </MenuItem>
1518
+ // <MenuItem key="image">
1519
+ // {this.props.intl.formatMessage(messages.imageTemplate)}
1520
+ // </MenuItem>
1521
+ // </Menu>
1522
+ // );
1523
+ // actionButton = (<Dropdown overlay={lineMenu} trigger={['click']}>
1524
+ // <CapButton style={{paddingLeft: '24px', paddingRight: '4px'}}>
1525
+ // <div style={{display: 'inline-flex'}}>
1526
+ // <p style={{ lineHeight: '28px'}}>New Template</p>
1527
+ // <p style={{ height: '28px'}}>
1528
+ // <i style={{ color: '#fff', paddingTop: '2px', margin: '0', paddingRight: '8px'}} className="material-icons">arrow_drop_down</i>
1529
+ // </p>
1530
+ // </div>
1531
+ // </CapButton>
1532
+ // </Dropdown>);
1533
+ // } else {
1534
+ // actionButton = (<CapButton onClick={this.createTemplate}>{this.state.channel.toUpperCase() === 'SMS' ? this.props.intl.formatMessage(messages.createSmsActionButton) : 'Create SMS'}</CapButton>);
1535
+ // }
1536
+ // }
1537
+
1538
+ const isLoading = this.isLoading();
1539
+ let previewHeader = this.props.intl.formatMessage(messages.preview);
1540
+ // const previewHeader = (this.state.channel.toLowerCase() === 'email' ? <h3>{this.props.intl.formatMessage(messages.emailPreview)}</h3> : <h3>{this.props.intl.formatMessage(messages.ebillPreview)}</h3>);
1541
+ if (this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill') {
1542
+ if (this.state.previewTemplate && this.state.previewTemplate.name !== '') {
1543
+ previewHeader = this.state.previewTemplate.name;
1544
+ }
1545
+ }
1546
+
1547
+ const cmsTemplateSelectionContent = (
1548
+ <CardGrid
1549
+ className={""}
1550
+ listItem={this.populateTemplatesList(this.props.Templates.cmsTemplates, false, true)}
1551
+ // filterContent={filterContent}
1552
+ onHoverItem={this.handleOnHoverItem}
1553
+ onItemClick={this.handleEdmDefaultTemplateSelection}
1554
+ colNumber={2}
1555
+ >
1556
+ </CardGrid>
1557
+ );
1558
+ const filterContent = (
1559
+ <div className="action-container">
1560
+ <CapInput.Search
1561
+ className="search-text"
1562
+ style={{width: '210px'}}
1563
+ placeholder={this.props.intl.formatMessage(messages.searchText)}
1564
+ value={this.state.searchText}
1565
+ onChange={(e) => this.searchTemplate(e.target.value)}
1566
+ />
1567
+ <div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
1568
+ {(this.props.location.query.type === 'embedded' ) ? pageHeaderDvs : pageHeader}
1569
+ <CapButton
1570
+ type={"primary"}
1571
+ disabled={this.isCreateDisabled()}
1572
+ style={{marginLeft: '8px'}}
1573
+ onClick={this.createTemplate} >
1574
+ { this.props.intl.formatMessage(messages.createNewActionButton) }
1575
+ </CapButton>
1576
+ </div>
1577
+
1578
+ </div>
1579
+ );
1580
+ let htmlPreviewContent = "";
1581
+ if (this.state.channel.toLowerCase() === 'ebill') {
1582
+ htmlPreviewContent = this.state.previewTemplate && this.state.previewTemplate.versions && this.state.previewTemplate.versions.base && this.state.previewTemplate.versions.base['ebill-editor'];
1583
+ } else if (this.state.channel.toLowerCase() === 'email') {
1584
+ htmlPreviewContent = this.state.previewTemplate && this.state.previewTemplate.versions && this.state.previewTemplate.versions.base && this.state.previewTemplate.versions.base[this.props.Global.currentOrgDetails.basic_details.base_language ? this.props.Global.currentOrgDetails.basic_details.base_language : 'en']['template-content'];
1585
+ }
1586
+
1587
+
1588
+ const creativesParams = this.getCreativesParams();
1589
+ const {route} = this.props;
1590
+ const loadingTip = (this.props.Templates.sendingFile && (this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill')) ? this.props.intl.formatMessage(messages.uploadingFile) : this.props.intl.formatMessage(messages.gettingAllTemplates);
1591
+ return (
1592
+ <div>
1593
+ <input type="file" id="filename" style={{ display: 'none'}} accept=".zip, .html, .htm" onChange={(event) => this.handleFileUpload(event, {files: event.target.files})} />
1594
+
1595
+
1596
+ <CapRow>
1597
+ <Pagination onPageChange={this.onPaginationChange} paginationSelector="pagination-container">
1598
+ {this.getTemplateDataForGrid({isLoading, loadingTip, channel: this.state.channel, templates: this.props.TemplatesList, filterContent, handlers: {handlePreviewClick: this.handlePreviewClick, handleEditClick: this.handleEditClick}})}
1599
+ </Pagination>
1600
+ {/* {!this.props.renderNewCardGrid && ((templateList && templateList.length > 0) || isSearch) && // old UI GRID
1601
+ <Pagination onPageChange={this.onPaginationChange} paginationSelector="pagination-container">
1602
+ <CardGrid
1603
+ className={this.state.channel.toLowerCase() === "mobilepush" ? "mobilepush-templates" : ""}
1604
+ listItem={templateList}
1605
+ filterContent={filterContent}
1606
+ onHoverItem={this.handleOnHoverItem}
1607
+ onItemClick={this.handleOnItemClick}
1608
+ enablePagination
1609
+ isLoading={isLoading}
1610
+ loadingTip={loadingTip}
1611
+ >
1612
+ </CardGrid>
1613
+ </Pagination>} */}
1614
+ {(((this.state.selectedAccount !== '' && !_.isEmpty(this.props.Templates.selectedWeChatAccount) && this.state.channel.toLowerCase() === 'wechat') || this.state.channel.toLowerCase() !== 'wechat') && _.isEmpty(this.props.TemplatesList)) && !this.props.Templates.getAllTemplatesInProgress &&
1615
+ <div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
1616
+ <CapHeading type="h6">{this.props.intl.formatMessage(messages.noTemplatesMessage)}</CapHeading>
1617
+ </div>}
1618
+ </CapRow>
1619
+ <CapRow>
1620
+ {!_.isEmpty(creativesParams.mode) && isFullMode && //creatives container for fullmode
1621
+ <CreativesContainer
1622
+ key={creativesParams.mode}
1623
+ messageDetails={{type: "default"}}
1624
+ creativesMode={creativesParams.mode}
1625
+ messages={messages}
1626
+ isFullMode={isFullMode}
1627
+ templateData={creativesParams}
1628
+ getCreativesData={this.onCreateComplete}
1629
+ channel={route.name.toUpperCase()}
1630
+ handleCloseCreatives={this.onCreateComplete}/>
1631
+ }
1632
+ </CapRow>
1633
+ <CapRow>
1634
+ {this.state.channel.toLowerCase() === 'wechat' && this.state.previewTemplate && this.state.previewTemplate.definition && this.state.previewTemplate.definition.msgcontent && this.state.previewTemplate.definition.msgcontent === 'RICH_MEDIA_WECHAT' &&
1635
+ <WechatRichmediaTemplatePreview
1636
+ show={this.state.previewOpen}
1637
+ closeSlideBox={this.togglePreview}
1638
+ header={this.state.previewTemplate.name}
1639
+ width={30}
1640
+ showSlidebox
1641
+ const type={this.props.location && this.props.location.query.type ? this.props.location.query.type : ''}
1642
+ content={this.state.previewTemplate.versions.base.mediaList}
1643
+ onEditClick={this.handleEditClick}
1644
+ showEdit
1645
+ templateId={this.state.previewTemplate._id}
1646
+ path={`/wechat/richmedia/edit/${this.state.previewTemplate._id}`}
1647
+ />
1648
+ }
1649
+
1650
+ {(this.state.channel.toLowerCase() === 'ebill' || this.state.channel.toLowerCase() === 'email') && htmlPreviewContent && <EmailPreview
1651
+ header={previewHeader}
1652
+ content={htmlPreviewContent}
1653
+ show={this.state.showHtmlPreview}
1654
+ device={this.state.device}
1655
+ handleClose={this.toggleEmailPreview}
1656
+ changePreviewDevice={this.changePreviewDevice}
1657
+ lastModified={this.state.previewTemplate ? this.state.previewTemplate.updatedAt : ''}
1658
+ updatedByName={commonUtil.getUserNameById(parseInt(this.state.previewTemplate.updatedBy, 10), commonUtil.getMergedUserList(this.props.Templates.userList))}
1659
+ />}
1660
+ <CapSlideBox
1661
+ header={(<h3>{this.props.intl.formatMessage(messages.layoutSelection)}</h3>)}
1662
+ width={60}
1663
+ content={cmsTemplateSelectionContent}
1664
+ show={this.state.showEdmEmailTemplates}
1665
+ handleClose={this.toggleEdmEmailTemplateSelection}
1666
+ loadingText={"Loading EDM Templates"}
1667
+ isLoading={this.props.Templates.getCmsTemplatesInProgress}
1668
+ />
1669
+ {this.renderDeleteConfirmationModal()}
1670
+ </CapRow>
1671
+
1672
+ </div>
1673
+ );
1674
+ }
1675
+ }
1676
+
1677
+ Templates.propTypes = {
1678
+ actions: PropTypes.object.isRequired,
1679
+ smsActions: PropTypes.object,
1680
+ mobilepushActions: PropTypes.object,
1681
+ smsEditActions: PropTypes.object,
1682
+ ebillActions: PropTypes.object,
1683
+ emailActions: PropTypes.object,
1684
+ TemplatesList: PropTypes.array,
1685
+ Templates: PropTypes.object,
1686
+ route: PropTypes.object,
1687
+ Create: PropTypes.object,
1688
+ location: PropTypes.object,
1689
+ globalActions: PropTypes.object,
1690
+ intl: intlShape.isRequired,
1691
+ Global: PropTypes.object,
1692
+ createNew: PropTypes.func,
1693
+ onSelectTemplate: PropTypes.func,
1694
+ lineActions: PropTypes.object,
1695
+ isFullMode: PropTypes.bool,
1696
+ handlePeviewTemplate: PropTypes.func,
1697
+ router: PropTypes.object,
1698
+ };
1699
+
1700
+ const mapStateToProps = createStructuredSelector({
1701
+ Templates: makeSelectTemplates(),
1702
+ TemplatesList: makeSelectTemplatesResponse(),
1703
+ Create: makeSelectCreateSms(),
1704
+ CreateMobilePush: makeSelectCreateMobilePush(),
1705
+ CreateEbill: makeSelectCreateEbill(),
1706
+ Edit: makeSelectEdit(),
1707
+ EmailCreate: makeSelectCreateEmail(),
1708
+ Global: makeSelectAuthenticated(),
1709
+ Line: makeSelectLine(),
1710
+ });
1711
+
1712
+ function mapDispatchToProps(dispatch) {
1713
+ return {
1714
+ actions: bindActionCreators(actions, dispatch),
1715
+ smsActions: bindActionCreators(smsActions, dispatch),
1716
+ mobilepushActions: bindActionCreators(mobilepushActions, dispatch),
1717
+ smsEditActions: bindActionCreators(smsEditActions, dispatch),
1718
+ ebillActions: bindActionCreators(ebillActions, dispatch),
1719
+ emailActions: bindActionCreators(emailActions, dispatch),
1720
+ globalActions: bindActionCreators(globalActions, dispatch),
1721
+ lineActions: bindActionCreators(lineActions, dispatch),
1722
+ };
1723
+ }
1724
+
1725
+ export default UserIsAuthenticated(connect(mapStateToProps, mapDispatchToProps)(injectIntl(Templates)));