@capillarytech/creatives-library 2.0.70 → 2.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (391) hide show
  1. package/app.js +1 -1
  2. package/components/Ckeditor/index.js +2 -1
  3. package/components/FormBuilder/index.js +25 -10
  4. package/components/Header/index.js +3 -1
  5. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +38 -3
  6. package/components/TemplatePreview/index.js +45 -51
  7. package/components/TemplatePreview/messages.js +1 -1
  8. package/containers/Cap/actions.js +0 -5
  9. package/containers/Cap/reducer.js +1 -1
  10. package/containers/Cap/selectors.js +0 -13
  11. package/containers/Ebill/index.js +1 -2
  12. package/containers/Email/_email.scss +1 -0
  13. package/containers/Email/actions.js +3 -8
  14. package/containers/Email/constants.js +0 -1
  15. package/containers/Email/index.js +947 -322
  16. package/containers/Email/reducer.js +0 -3
  17. package/containers/Email/sagas.js +6 -3
  18. package/containers/Email/selectors.js +1 -4
  19. package/containers/Line/Create/index.js +1 -2
  20. package/containers/Line/Edit/_lineEdit.scss +4 -0
  21. package/containers/Line/Edit/index.js +1 -3
  22. package/containers/MobilePush/Create/_mobilePushCreate.scss +3 -12
  23. package/containers/MobilePush/Create/actions.js +0 -6
  24. package/containers/MobilePush/Create/constants.js +0 -1
  25. package/containers/MobilePush/Create/index.js +1133 -628
  26. package/containers/MobilePush/Create/messages.js +1 -5
  27. package/containers/MobilePush/Create/reducer.js +0 -2
  28. package/containers/MobilePush/Create/selectors.js +3 -3
  29. package/containers/MobilePush/Edit/_mobilePushCreate.scss +3 -9
  30. package/containers/MobilePush/Edit/index.js +1127 -393
  31. package/containers/MobilePush/Edit/messages.js +0 -4
  32. package/containers/MobilePush/Edit/reducer.js +1 -2
  33. package/containers/MobilePush/Edit/selectors.js +3 -6
  34. package/containers/Sms/Create/_smsCreate.scss +2 -1
  35. package/containers/Sms/Create/actions.js +4 -4
  36. package/containers/Sms/Create/index.js +570 -102
  37. package/containers/Sms/Create/sagas.js +2 -1
  38. package/containers/Sms/Edit/actions.js +5 -10
  39. package/containers/Sms/Edit/constants.js +0 -1
  40. package/containers/Sms/Edit/index.js +548 -103
  41. package/containers/Sms/Edit/reducer.js +0 -2
  42. package/containers/Sms/Edit/sagas.js +3 -1
  43. package/containers/TagList/index.js +3 -3
  44. package/containers/Templates/actions.js +1 -3
  45. package/containers/Templates/index.js +299 -268
  46. package/containers/Templates/messages.js +90 -122
  47. package/containers/Templates/reducer.js +3 -3
  48. package/containers/Templates/sagas.js +1 -5
  49. package/containers/Templates/selectors.js +1 -41
  50. package/containers/WeChat/MapTemplates/index.js +3 -4
  51. package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -4
  52. package/containers/WeChat/RichmediaTemplates/Create/messages.js +4 -0
  53. package/containers/WeChat/RichmediaTemplates/Edit/index.js +3 -1
  54. package/containers/WeChat/RichmediaTemplates/View/index.js +3 -1
  55. package/index.js +31 -31
  56. package/initialState.js +6 -0
  57. package/package.json +3 -3
  58. package/routes.js +24 -19
  59. package/services/api.js +6 -2
  60. package/services/getSchema.js +18 -0
  61. package/v2Containers/App/actions.js +7 -0
  62. package/v2Containers/App/constants.js +3 -0
  63. package/v2Containers/App/reducer.js +19 -0
  64. package/v2Containers/App/sagas.js +26 -0
  65. package/v2Containers/App/selectors.js +25 -0
  66. package/v2Containers/App/tests/actions.test.js +18 -0
  67. package/v2Containers/App/tests/reducer.test.js +9 -0
  68. package/v2Containers/App/tests/sagas.test.js +15 -0
  69. package/v2Containers/App/tests/selectors.test.js +10 -0
  70. package/v2Containers/Assets/Gallery/_gallery.scss +0 -0
  71. package/v2Containers/Assets/Gallery/actions.js +37 -0
  72. package/v2Containers/Assets/Gallery/constants.js +23 -0
  73. package/v2Containers/Assets/Gallery/index.js +479 -0
  74. package/v2Containers/Assets/Gallery/messages.js +97 -0
  75. package/v2Containers/Assets/Gallery/reducer.js +81 -0
  76. package/v2Containers/Assets/Gallery/sagas.js +84 -0
  77. package/v2Containers/Assets/Gallery/selectors.js +25 -0
  78. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +7 -0
  79. package/v2Containers/Assets/Gallery/tests/actions.test.js +26 -0
  80. package/v2Containers/Assets/Gallery/tests/index.test.js +10 -0
  81. package/v2Containers/Assets/Gallery/tests/reducer.test.js +95 -0
  82. package/v2Containers/Assets/Gallery/tests/sagas.test.js +15 -0
  83. package/v2Containers/Assets/Gallery/tests/selectors.test.js +10 -0
  84. package/v2Containers/CallTask/_callTask.scss +5 -0
  85. package/v2Containers/CallTask/actions.js +15 -0
  86. package/v2Containers/CallTask/constants.js +7 -0
  87. package/v2Containers/CallTask/index.js +141 -0
  88. package/v2Containers/CallTask/messages.js +21 -0
  89. package/v2Containers/CallTask/reducer.js +23 -0
  90. package/v2Containers/CallTask/sagas.js +11 -0
  91. package/v2Containers/CallTask/selectors.js +25 -0
  92. package/v2Containers/CallTask/tests/actions.test.js +18 -0
  93. package/v2Containers/CallTask/tests/index.test.js +10 -0
  94. package/v2Containers/CallTask/tests/reducer.test.js +9 -0
  95. package/v2Containers/CallTask/tests/sagas.test.js +15 -0
  96. package/v2Containers/CallTask/tests/selectors.test.js +10 -0
  97. package/v2Containers/Cap/actions.js +64 -0
  98. package/v2Containers/Cap/constants.js +24 -0
  99. package/v2Containers/Cap/index.js +349 -0
  100. package/v2Containers/Cap/messsages.js +63 -0
  101. package/v2Containers/Cap/reducer.js +111 -0
  102. package/v2Containers/Cap/sagas.js +143 -0
  103. package/v2Containers/Cap/selectors.js +85 -0
  104. package/v2Containers/Cap/tests/index.test.js +16 -0
  105. package/v2Containers/Cap/tests/selectors.test.js +28 -0
  106. package/v2Containers/ChannelTemplates/actions.js +20 -0
  107. package/v2Containers/ChannelTemplates/constants.js +8 -0
  108. package/v2Containers/ChannelTemplates/index.js +48 -0
  109. package/v2Containers/ChannelTemplates/messages.js +13 -0
  110. package/v2Containers/ChannelTemplates/reducer.js +34 -0
  111. package/v2Containers/ChannelTemplates/sagas.js +32 -0
  112. package/v2Containers/ChannelTemplates/selectors.js +25 -0
  113. package/v2Containers/ChannelTemplates/tests/actions.test.js +18 -0
  114. package/v2Containers/ChannelTemplates/tests/index.test.js +10 -0
  115. package/v2Containers/ChannelTemplates/tests/reducer.test.js +9 -0
  116. package/v2Containers/ChannelTemplates/tests/sagas.test.js +15 -0
  117. package/v2Containers/ChannelTemplates/tests/selectors.test.js +10 -0
  118. package/v2Containers/CreativesContainer/SlideBoxContent.js +257 -0
  119. package/v2Containers/CreativesContainer/SlideBoxFooter.js +45 -0
  120. package/v2Containers/CreativesContainer/SlideBoxHeader.js +70 -0
  121. package/v2Containers/CreativesContainer/actions.js +27 -0
  122. package/v2Containers/CreativesContainer/constants.js +16 -0
  123. package/v2Containers/CreativesContainer/index.js +483 -0
  124. package/v2Containers/CreativesContainer/index.scss +27 -0
  125. package/v2Containers/CreativesContainer/messages.js +293 -0
  126. package/v2Containers/CreativesContainer/reducer.js +29 -0
  127. package/v2Containers/CreativesContainer/sagas.js +11 -0
  128. package/v2Containers/CreativesContainer/selectors.js +30 -0
  129. package/v2Containers/CreativesContainer/tests/actions.test.js +18 -0
  130. package/v2Containers/CreativesContainer/tests/index.test.js +10 -0
  131. package/v2Containers/CreativesContainer/tests/reducer.test.js +9 -0
  132. package/v2Containers/CreativesContainer/tests/sagas.test.js +15 -0
  133. package/v2Containers/CreativesContainer/tests/selectors.test.js +10 -0
  134. package/v2Containers/Dashboard/actions.js +15 -0
  135. package/v2Containers/Dashboard/constants.js +7 -0
  136. package/v2Containers/Dashboard/index.js +54 -0
  137. package/v2Containers/Dashboard/messages.js +13 -0
  138. package/v2Containers/Dashboard/reducer.js +21 -0
  139. package/v2Containers/Dashboard/sagas.js +11 -0
  140. package/v2Containers/Dashboard/selectors.js +25 -0
  141. package/v2Containers/Dashboard/tests/actions.test.js +18 -0
  142. package/v2Containers/Dashboard/tests/index.test.js +10 -0
  143. package/v2Containers/Dashboard/tests/reducer.test.js +9 -0
  144. package/v2Containers/Dashboard/tests/sagas.test.js +15 -0
  145. package/v2Containers/Dashboard/tests/selectors.test.js +10 -0
  146. package/v2Containers/Ebill/_ebill.scss +5 -0
  147. package/v2Containers/Ebill/actions.js +43 -0
  148. package/v2Containers/Ebill/constants.js +20 -0
  149. package/v2Containers/Ebill/index.js +1261 -0
  150. package/v2Containers/Ebill/messages.js +73 -0
  151. package/v2Containers/Ebill/reducer.js +72 -0
  152. package/v2Containers/Ebill/sagas.js +65 -0
  153. package/v2Containers/Ebill/selectors.js +25 -0
  154. package/v2Containers/Ebill/tests/actions.test.js +18 -0
  155. package/v2Containers/Ebill/tests/index.test.js +10 -0
  156. package/v2Containers/Ebill/tests/reducer.test.js +9 -0
  157. package/v2Containers/Ebill/tests/sagas.test.js +15 -0
  158. package/v2Containers/Ebill/tests/selectors.test.js +10 -0
  159. package/v2Containers/Email/_email.scss +140 -0
  160. package/v2Containers/Email/actions.js +86 -0
  161. package/v2Containers/Email/constants.js +37 -0
  162. package/v2Containers/Email/index.js +2703 -0
  163. package/v2Containers/Email/initialSchema.js +540 -0
  164. package/v2Containers/Email/messages.js +237 -0
  165. package/v2Containers/Email/reducer.js +147 -0
  166. package/v2Containers/Email/sagas.js +133 -0
  167. package/v2Containers/Email/selectors.js +34 -0
  168. package/v2Containers/Email/tests/actions.test.js +18 -0
  169. package/v2Containers/Email/tests/index.test.js +10 -0
  170. package/v2Containers/Email/tests/reducer.test.js +9 -0
  171. package/v2Containers/Email/tests/sagas.test.js +15 -0
  172. package/v2Containers/Email/tests/selectors.test.js +10 -0
  173. package/v2Containers/EmailWrapper/actions.js +15 -0
  174. package/v2Containers/EmailWrapper/constants.js +7 -0
  175. package/v2Containers/EmailWrapper/index.js +258 -0
  176. package/v2Containers/EmailWrapper/messages.js +57 -0
  177. package/v2Containers/EmailWrapper/reducer.js +23 -0
  178. package/v2Containers/EmailWrapper/sagas.js +11 -0
  179. package/v2Containers/EmailWrapper/selectors.js +25 -0
  180. package/v2Containers/EmailWrapper/tests/actions.test.js +18 -0
  181. package/v2Containers/EmailWrapper/tests/index.test.js +10 -0
  182. package/v2Containers/EmailWrapper/tests/reducer.test.js +9 -0
  183. package/v2Containers/EmailWrapper/tests/sagas.test.js +15 -0
  184. package/v2Containers/EmailWrapper/tests/selectors.test.js +10 -0
  185. package/v2Containers/LanguageProvider/actions.js +17 -0
  186. package/v2Containers/LanguageProvider/constants.js +8 -0
  187. package/v2Containers/LanguageProvider/index.js +46 -0
  188. package/v2Containers/LanguageProvider/reducer.js +30 -0
  189. package/v2Containers/LanguageProvider/selectors.js +20 -0
  190. package/v2Containers/LanguageProvider/tests/actions.test.js +19 -0
  191. package/v2Containers/LanguageProvider/tests/index.test.js +49 -0
  192. package/v2Containers/LanguageProvider/tests/reducer.test.js +20 -0
  193. package/v2Containers/LanguageProvider/tests/selectors.test.js +15 -0
  194. package/v2Containers/Line/Create/_lineCreate.scss +43 -0
  195. package/v2Containers/Line/Create/actions.js +90 -0
  196. package/v2Containers/Line/Create/constants.js +39 -0
  197. package/v2Containers/Line/Create/index.js +822 -0
  198. package/v2Containers/Line/Create/messages.js +173 -0
  199. package/v2Containers/Line/Create/reducer.js +99 -0
  200. package/v2Containers/Line/Create/sagas.js +107 -0
  201. package/v2Containers/Line/Create/selectors.js +36 -0
  202. package/v2Containers/Line/Edit/_lineEdit.scss +21 -0
  203. package/v2Containers/Line/Edit/actions.js +79 -0
  204. package/v2Containers/Line/Edit/constants.js +27 -0
  205. package/v2Containers/Line/Edit/index.js +1050 -0
  206. package/v2Containers/Line/Edit/messages.js +157 -0
  207. package/v2Containers/Line/Edit/reducer.js +83 -0
  208. package/v2Containers/Line/Edit/sagas.js +81 -0
  209. package/v2Containers/Line/Edit/selectors.js +29 -0
  210. package/v2Containers/Line/Edit/tests/actions.test.js +18 -0
  211. package/v2Containers/Line/Edit/tests/index.test.js +10 -0
  212. package/v2Containers/Line/Edit/tests/reducer.test.js +9 -0
  213. package/v2Containers/Line/Edit/tests/sagas.test.js +15 -0
  214. package/v2Containers/Line/Edit/tests/selectors.test.js +10 -0
  215. package/v2Containers/Login/assets/images/capillary_logo.png +0 -0
  216. package/v2Containers/Login/components/LoginForm/index.js +59 -0
  217. package/v2Containers/Login/components/LoginForm/messages.js +21 -0
  218. package/v2Containers/Login/components/LoginForm/tests/index.test.js +10 -0
  219. package/v2Containers/Login/index.js +106 -0
  220. package/v2Containers/Login/messages.js +21 -0
  221. package/v2Containers/Login/selectors.js +25 -0
  222. package/v2Containers/Login/tests/index.test.js +10 -0
  223. package/v2Containers/Login/tests/sagas.test.js +15 -0
  224. package/v2Containers/Login/tests/selectors.test.js +10 -0
  225. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +41 -0
  226. package/v2Containers/MobilePush/Create/actions.js +52 -0
  227. package/v2Containers/MobilePush/Create/constants.js +24 -0
  228. package/v2Containers/MobilePush/Create/index.js +1759 -0
  229. package/v2Containers/MobilePush/Create/messages.js +237 -0
  230. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  231. package/v2Containers/MobilePush/Create/sagas.js +60 -0
  232. package/v2Containers/MobilePush/Create/selectors.js +28 -0
  233. package/v2Containers/MobilePush/Create/tests/actions.test.js +18 -0
  234. package/v2Containers/MobilePush/Create/tests/index.test.js +10 -0
  235. package/v2Containers/MobilePush/Create/tests/reducer.test.js +9 -0
  236. package/v2Containers/MobilePush/Create/tests/sagas.test.js +15 -0
  237. package/v2Containers/MobilePush/Create/tests/selectors.test.js +10 -0
  238. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +38 -0
  239. package/v2Containers/MobilePush/Edit/actions.js +91 -0
  240. package/v2Containers/MobilePush/Edit/constants.js +35 -0
  241. package/v2Containers/MobilePush/Edit/index.js +1846 -0
  242. package/v2Containers/MobilePush/Edit/messages.js +253 -0
  243. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  244. package/v2Containers/MobilePush/Edit/sagas.js +119 -0
  245. package/v2Containers/MobilePush/Edit/selectors.js +32 -0
  246. package/v2Containers/MobilePush/Edit/tests/actions.test.js +18 -0
  247. package/v2Containers/MobilePush/Edit/tests/index.test.js +10 -0
  248. package/v2Containers/MobilePush/Edit/tests/reducer.test.js +9 -0
  249. package/v2Containers/MobilePush/Edit/tests/sagas.test.js +15 -0
  250. package/v2Containers/MobilePush/Edit/tests/selectors.test.js +10 -0
  251. package/v2Containers/MobilePush/commonMethods.js +249 -0
  252. package/v2Containers/MobilePush/eventsMap.js +127 -0
  253. package/v2Containers/MobilePush/initialSchema.js +1739 -0
  254. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +18 -0
  255. package/v2Containers/MobilepushWrapper/index.js +136 -0
  256. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  257. package/v2Containers/MobilepushWrapper/tests/index.test.js +10 -0
  258. package/v2Containers/NotFoundPage/index.js +25 -0
  259. package/v2Containers/NotFoundPage/messages.js +13 -0
  260. package/v2Containers/NotFoundPage/tests/index.test.js +17 -0
  261. package/v2Containers/Sms/Create/_smsCreate.scss +58 -0
  262. package/v2Containers/Sms/Create/actions.js +27 -0
  263. package/v2Containers/Sms/Create/constants.js +16 -0
  264. package/v2Containers/Sms/Create/index.js +1017 -0
  265. package/v2Containers/Sms/Create/messages.js +85 -0
  266. package/v2Containers/Sms/Create/reducer.js +41 -0
  267. package/v2Containers/Sms/Create/sagas.js +35 -0
  268. package/v2Containers/Sms/Create/selectors.js +28 -0
  269. package/v2Containers/Sms/Create/tests/actions.test.js +18 -0
  270. package/v2Containers/Sms/Create/tests/index.test.js +10 -0
  271. package/v2Containers/Sms/Create/tests/reducer.test.js +9 -0
  272. package/v2Containers/Sms/Create/tests/sagas.test.js +15 -0
  273. package/v2Containers/Sms/Create/tests/selectors.test.js +10 -0
  274. package/v2Containers/Sms/Edit/actions.js +45 -0
  275. package/v2Containers/Sms/Edit/constants.js +18 -0
  276. package/v2Containers/Sms/Edit/index.js +1018 -0
  277. package/v2Containers/Sms/Edit/messages.js +89 -0
  278. package/v2Containers/Sms/Edit/reducer.js +52 -0
  279. package/v2Containers/Sms/Edit/sagas.js +50 -0
  280. package/v2Containers/Sms/Edit/selectors.js +32 -0
  281. package/v2Containers/Sms/Edit/tests/actions.test.js +18 -0
  282. package/v2Containers/Sms/Edit/tests/index.test.js +10 -0
  283. package/v2Containers/Sms/Edit/tests/reducer.test.js +9 -0
  284. package/v2Containers/Sms/Edit/tests/sagas.test.js +15 -0
  285. package/v2Containers/Sms/Edit/tests/selectors.test.js +10 -0
  286. package/v2Containers/Sms/initialSchema.js +281 -0
  287. package/v2Containers/TagList/_tagList.scss +8 -0
  288. package/v2Containers/TagList/actions.js +15 -0
  289. package/v2Containers/TagList/constants.js +7 -0
  290. package/v2Containers/TagList/index.js +236 -0
  291. package/v2Containers/TagList/messages.js +13 -0
  292. package/v2Containers/TagList/reducer.js +23 -0
  293. package/v2Containers/TagList/sagas.js +11 -0
  294. package/v2Containers/TagList/selectors.js +25 -0
  295. package/v2Containers/TagList/tests/actions.test.js +18 -0
  296. package/v2Containers/TagList/tests/index.test.js +10 -0
  297. package/v2Containers/TagList/tests/reducer.test.js +9 -0
  298. package/v2Containers/TagList/tests/sagas.test.js +15 -0
  299. package/v2Containers/TagList/tests/selectors.test.js +10 -0
  300. package/v2Containers/Templates/_templates.scss +349 -0
  301. package/v2Containers/Templates/actions.js +110 -0
  302. package/v2Containers/Templates/constants.js +45 -0
  303. package/v2Containers/Templates/index.js +1682 -0
  304. package/v2Containers/Templates/messages.js +273 -0
  305. package/v2Containers/Templates/reducer.js +142 -0
  306. package/v2Containers/Templates/sagas.js +180 -0
  307. package/v2Containers/Templates/selectors.js +68 -0
  308. package/v2Containers/Templates/tests/actions.test.js +18 -0
  309. package/v2Containers/Templates/tests/index.test.js +10 -0
  310. package/v2Containers/Templates/tests/reducer.test.js +9 -0
  311. package/v2Containers/Templates/tests/sagas.test.js +15 -0
  312. package/v2Containers/Templates/tests/selectors.test.js +10 -0
  313. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  314. package/v2Containers/TemplatesV2/actions.js +16 -0
  315. package/v2Containers/TemplatesV2/constants.js +10 -0
  316. package/v2Containers/TemplatesV2/index.js +217 -0
  317. package/v2Containers/TemplatesV2/messages.js +29 -0
  318. package/v2Containers/TemplatesV2/selectors.js +25 -0
  319. package/v2Containers/TemplatesV2/tests/actions.test.js +18 -0
  320. package/v2Containers/TemplatesV2/tests/index.test.js +10 -0
  321. package/v2Containers/TemplatesV2/tests/reducer.test.js +9 -0
  322. package/v2Containers/TemplatesV2/tests/sagas.test.js +15 -0
  323. package/v2Containers/TemplatesV2/tests/selectors.test.js +10 -0
  324. package/v2Containers/TestPage/constants.js +7 -0
  325. package/v2Containers/TestPage/index.js +31 -0
  326. package/v2Containers/TestPage/messages.js +13 -0
  327. package/v2Containers/TestPage/reducer.js +21 -0
  328. package/v2Containers/TestPage/sagas.js +11 -0
  329. package/v2Containers/Testv2/actions.js +15 -0
  330. package/v2Containers/Testv2/constants.js +7 -0
  331. package/v2Containers/Testv2/index.js +47 -0
  332. package/v2Containers/Testv2/messages.js +13 -0
  333. package/v2Containers/Testv2/reducer.js +23 -0
  334. package/v2Containers/Testv2/sagas.js +11 -0
  335. package/v2Containers/Testv2/selectors.js +25 -0
  336. package/v2Containers/Testv2/tests/actions.test.js +18 -0
  337. package/v2Containers/Testv2/tests/index.test.js +10 -0
  338. package/v2Containers/Testv2/tests/reducer.test.js +9 -0
  339. package/v2Containers/Testv2/tests/sagas.test.js +15 -0
  340. package/v2Containers/Testv2/tests/selectors.test.js +10 -0
  341. package/v2Containers/WeChat/MapTemplates/_mapTemplates.scss +8 -0
  342. package/v2Containers/WeChat/MapTemplates/actions.js +52 -0
  343. package/v2Containers/WeChat/MapTemplates/constants.js +28 -0
  344. package/v2Containers/WeChat/MapTemplates/index.js +1385 -0
  345. package/v2Containers/WeChat/MapTemplates/messages.js +73 -0
  346. package/v2Containers/WeChat/MapTemplates/reducer.js +74 -0
  347. package/v2Containers/WeChat/MapTemplates/sagas.js +86 -0
  348. package/v2Containers/WeChat/MapTemplates/selectors.js +25 -0
  349. package/v2Containers/WeChat/MapTemplates/tests/actions.test.js +18 -0
  350. package/v2Containers/WeChat/MapTemplates/tests/index.test.js +10 -0
  351. package/v2Containers/WeChat/MapTemplates/tests/reducer.test.js +9 -0
  352. package/v2Containers/WeChat/MapTemplates/tests/sagas.test.js +15 -0
  353. package/v2Containers/WeChat/MapTemplates/tests/selectors.test.js +10 -0
  354. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +57 -0
  355. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +36 -0
  356. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +15 -0
  357. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1053 -0
  358. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +141 -0
  359. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +60 -0
  360. package/v2Containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  361. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +48 -0
  362. package/v2Containers/WeChat/RichmediaTemplates/Create/selectors.js +37 -0
  363. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/actions.test.js +18 -0
  364. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/index.test.js +10 -0
  365. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/reducer.test.js +9 -0
  366. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/sagas.test.js +15 -0
  367. package/v2Containers/WeChat/RichmediaTemplates/Create/tests/selectors.test.js +10 -0
  368. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +20 -0
  369. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +10 -0
  370. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +116 -0
  371. package/v2Containers/WeChat/RichmediaTemplates/Edit/messages.js +13 -0
  372. package/v2Containers/WeChat/RichmediaTemplates/Edit/reducer.js +28 -0
  373. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +32 -0
  374. package/v2Containers/WeChat/RichmediaTemplates/Edit/selectors.js +30 -0
  375. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/actions.test.js +18 -0
  376. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/index.test.js +10 -0
  377. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/reducer.test.js +9 -0
  378. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/sagas.test.js +15 -0
  379. package/v2Containers/WeChat/RichmediaTemplates/Edit/tests/selectors.test.js +10 -0
  380. package/v2Containers/WeChat/RichmediaTemplates/View/actions.js +15 -0
  381. package/v2Containers/WeChat/RichmediaTemplates/View/constants.js +7 -0
  382. package/v2Containers/WeChat/RichmediaTemplates/View/index.js +47 -0
  383. package/v2Containers/WeChat/RichmediaTemplates/View/messages.js +13 -0
  384. package/v2Containers/WeChat/RichmediaTemplates/View/reducer.js +23 -0
  385. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +11 -0
  386. package/v2Containers/WeChat/RichmediaTemplates/View/selectors.js +25 -0
  387. package/v2Containers/WeChat/RichmediaTemplates/View/tests/actions.test.js +18 -0
  388. package/v2Containers/WeChat/RichmediaTemplates/View/tests/index.test.js +10 -0
  389. package/v2Containers/WeChat/RichmediaTemplates/View/tests/reducer.test.js +9 -0
  390. package/v2Containers/WeChat/RichmediaTemplates/View/tests/sagas.test.js +15 -0
  391. package/v2Containers/WeChat/RichmediaTemplates/View/tests/selectors.test.js +10 -0
@@ -0,0 +1,1846 @@
1
+
2
+ /*
3
+ *
4
+ * Create
5
+ *
6
+ */
7
+
8
+ import PropTypes from 'prop-types';
9
+
10
+ import React from 'react';
11
+ import {bindActionCreators} from "redux";
12
+ import { connect } from 'react-redux';
13
+ import { notification } from 'antd';
14
+ import { createStructuredSelector } from 'reselect';
15
+ import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
16
+ import _, {get, findIndex, set, forEach, cloneDeep} from 'lodash';
17
+ import { CapSpin, CapSlideBox, CapHeader, CapTable, CapLink, CapRow, CapColumn, CapIcons} from '@capillarytech/cap-ui-library';
18
+ import styled from 'styled-components';
19
+ import {makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse, makeSelectIosCta} from "./selectors";
20
+ import {makeSelectMetaEntities, setInjectedTags, isLoadingMetaEntities} from "../../Cap/selectors";
21
+ import {getMessageObject} from "../../../utils/messageUtils";
22
+ import FormBuilder from '../../../components/FormBuilder';
23
+ import * as globalActions from "../../Cap/actions";
24
+ import * as actions from "../../MobilePush/Edit/actions";
25
+ import * as templatesActions from "../../Templates/actions";
26
+ import {makeSelectTemplates} from "../../Templates/selectors";
27
+ import messages from './messages';
28
+ import './_mobilePushCreate.scss';
29
+ import callNativeEvent from '../../../utils/callNativeEvent';
30
+ import {makeSelectCreate} from "../Create/selectors";
31
+
32
+ import getEventsMap from '../eventsMap';
33
+ import {getPrimaryCtaFields, getSecondaryCtaFields, getLinkTypeFields} from '../commonMethods';
34
+
35
+ const PrefixWrapper = styled.div`
36
+ margin-right: 16px;
37
+ `;
38
+ export class Edit extends React.Component { // eslint-disable-line react/prefer-stateless-function
39
+ constructor(props) {
40
+ super(props);
41
+ const eventsMap = getEventsMap(this);
42
+ this.state = {
43
+ formData: {},
44
+ tabCount: 1,
45
+ schema: {},
46
+ currentTab: 1,
47
+ editData: {},
48
+ loading: false,
49
+ isFormValid: true,
50
+ injectedTags: {},
51
+ showModal: false,
52
+ eventsMap,
53
+ startValidation: false,
54
+ modalContent: {title: "Alert", body: this.props.intl.formatMessage(messages['template not configured,']), type: 'confirm'},
55
+ };
56
+ this.getPrimaryCtaFields = getPrimaryCtaFields.bind(this);
57
+ this.getSecondaryCtaFields = getSecondaryCtaFields.bind(this);
58
+ this.getLinkTypeFields = getLinkTypeFields.bind(this);
59
+ }
60
+ componentWillMount() {
61
+ console.log('edit mounting');
62
+ this.props.actions.getWeCrmAccounts("mobilepush");
63
+ if (!this.props.Templates.selectedWeChatAccount && this.props.location.query.type !== 'embedded') {
64
+ const type = this.props.location.query.type;
65
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
66
+ this.props.router.push({
67
+ pathname: `/mobilepush/`,
68
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
69
+ });
70
+ } else {
71
+ const query = {
72
+ layout: 'MOBILEPUSH',
73
+ type: 'LAYOUT',
74
+ version: "v2",
75
+ };
76
+ this.props.globalActions.fetchSchemaForEntity(query);
77
+ console.log(this.props.params);
78
+ }
79
+ }
80
+ componentDidMount() {
81
+ window.addEventListener("message", this.handleFrameTasks);
82
+ if (!_.isEmpty(this.state.schema)) {
83
+ this.injectEvents(this.state.schema);
84
+ }
85
+ if (this.props.location.query && (typeof this.props.location.query.module === 'undefined' || this.props.isFullMode === false)) { // when this containers is imported from creatives library
86
+ const templateId = get(this, "props.params.id");
87
+ if (templateId) {
88
+ this.props.actions.getTemplateDetails(templateId);
89
+ } else {
90
+ this.props.actions.setTemplateDetails(this.props.templateData);
91
+ }
92
+ }
93
+ const type = this.props.location.query.type;
94
+ if (type === 'embedded') {
95
+ const response = {
96
+ action: 'startTemplateCreation',
97
+ };
98
+ parent.postMessage(JSON.stringify(response), '*');
99
+ }
100
+ }
101
+ componentWillReceiveProps(nextProps) {
102
+ if (nextProps.isGetFormData && !this.props.isFullMode) {
103
+ nextProps.getFormLibraryData(this.getFormData());
104
+ } else if (nextProps.isGetFormData && this.props.isFullMode && !this.props.Edit.editTemplateInProgress) {
105
+ this.startValidation();
106
+ }
107
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
108
+ if (this.props.location.query.type === 'embedded' && !nextProps.Edit.fetchingWeCrmAccounts && !_.isEqual(this.props.Edit.weCrmAccounts, nextProps.Edit.weCrmAccounts) && (!selectedWeChatAccount || _.isEmpty(selectedWeChatAccount))) {
109
+ console.log('got new accounts setting account again', nextProps.Edit.weCrmAccounts);
110
+ this.setMobilePushAccountOptions(nextProps.Edit.weCrmAccounts);
111
+ }
112
+ if (!_.isEmpty(nextProps.Edit.selectedWeChatAccount) && !_.isEqual(this.props.Edit.selectedWeChatAccount, nextProps.Edit.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && this.props.location.query.module === "loyalty") {
113
+ const params = {
114
+ name: '',
115
+ sortBy: 'Most Recent',
116
+ accountId: nextProps.Edit.selectedWeChatAccount.id,
117
+ };
118
+ this.props.actions.getMobilepushTemplatesList('mobilepush', params);
119
+ }
120
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.fullSchema)) {
121
+ this.setState({fullSchema: nextProps.metaEntities.layouts[0].definition, schema: (nextProps.location.query.module === 'loyalty') ? nextProps.metaEntities.layouts[0].definition.textSchema : {}}, () => {
122
+ const templateId = get(this, "props.params.id");
123
+ if (nextProps.location.query.module !== 'loyalty' && templateId && templateId !== 'temp') {
124
+ this.props.actions.getTemplateDetails(templateId);
125
+ }
126
+ const type = this.props.location.query.type;
127
+ if (type === 'embedded' && templateId === 'temp' && _.isEmpty(this.state.formData)) { // when his.props.params.id is temp that means mobile push template content will be passed from post message from parent with startTemplateCreation action
128
+ const response = {
129
+ action: 'startTemplateCreation',
130
+ };
131
+ parent.postMessage(JSON.stringify(response), '*');
132
+ this.getTags();
133
+ }
134
+ });
135
+ if (this.props.location.query.type === 'embedded') {
136
+ this.showNext();
137
+ }
138
+ }
139
+ if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && nextProps.Edit.mobilepushTemplates && !_.isEqual(nextProps.Edit.mobilepushTemplates, this.props.Edit.mobilepushTemplates)) { //used inloyalty
140
+ if (nextProps.location.query.type === 'embedded' && nextProps.location.query.module === 'loyalty') {
141
+ this.setTemplateOptions(nextProps.Edit.mobilepushTemplates);
142
+ }
143
+ }
144
+ if (!_.isEmpty(nextProps.templateDetails) && _.isEmpty(this.state.editData) && !_.isEmpty(this.state.fullSchema) && selectedWeChatAccount && (this.props.location.query.type !== 'embedded' || this.props.isFullMode === false)) {
145
+ this.props = nextProps;
146
+ const mode = nextProps.templateDetails.definition ? nextProps.templateDetails.definition.mode : nextProps.templateDetails.mode;
147
+ const schema = mode === "text" ? this.state.fullSchema.textSchema : this.state.fullSchema.imageSchema;
148
+ const isAndroidSupported = get(this, "props.Templates.selectedWeChatAccount.configs.android") === '1';
149
+ const isIosSupported = get(this, "props.Templates.selectedWeChatAccount.configs.ios") === '1';
150
+ if (!isAndroidSupported) {
151
+ const androidField = get(schema, "containers[0].panes[0]");
152
+ androidField.isSupported = false;
153
+ this.setState({currentTab: 2});
154
+ set(schema, "containers[0].panes[0]", androidField);
155
+ }
156
+ if (!isIosSupported) {
157
+ const iosField = get(schema, "containers[0].panes[1]");
158
+ iosField.isSupported = false;
159
+
160
+ set(schema, "containers[0].panes[1]", iosField);
161
+ }
162
+ this.setEditState(nextProps.templateDetails, schema);
163
+ this.getTags();
164
+ }
165
+ if (nextProps.Edit.uploadedAssetData) {
166
+ const formData = _.cloneDeep(this.state.formData);
167
+ formData[this.state.currentTab - 1].image = nextProps.Edit.uploadedAssetData.metaInfo.public_url;
168
+ this.setState({formData});
169
+ this.props.actions.clearAsset();
170
+ }
171
+ if (nextProps.iosCtasData) {
172
+ this.setState({showIosCtaTable: true});
173
+ }
174
+ if (nextProps.Edit.editTemplateError && !_.isEqual(nextProps.Edit.editTemplateError, this.props.Edit.editTemplateError)) {
175
+ const message = getMessageObject('error', (nextProps.Edit.editTemplateErrorMessage && nextProps.Edit.editTemplateErrorMessage !== '') ? nextProps.Edit.editTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
176
+ this.props.globalActions.addMessageToQueue(message);
177
+ }
178
+ }
179
+ componentWillUnmount() {
180
+ this.props.actions.clearData();
181
+ window.removeEventListener("message", this.handleFrameTasks);
182
+ }
183
+ onTemplateChange = (isEvent, formData) => {
184
+ _.forEach(this.props.Edit.mobilepushTemplates, (template) => {
185
+ if (template._id === formData['mobilepush-template']) {
186
+ this.setState({editData: {}, formData: {}}, () => {
187
+ this.props.actions.setSelectedTemplate(template);
188
+ });
189
+ }
190
+ });
191
+ };
192
+ onFormDataChange = (formData, tabCount, currentTab) => {
193
+ console.log('Form data changed is ', formData, tabCount, currentTab);
194
+ const newFormData = _.cloneDeep(formData);
195
+ const {templateCta} = this.state;
196
+ if (!_.isEmpty(templateCta) && this.state.currentTab === 2) {
197
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = templateCta.name;
198
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = templateCta.ctaTemplateDetails[0].buttonText;
199
+ delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
200
+ if (templateCta.ctaTemplateDetails[1]) {
201
+ newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = templateCta.ctaTemplateDetails[1].buttonText;
202
+ }
203
+ }
204
+ if (newFormData["mobilepush-accounts"] !== this.state.formData["mobilepush-accounts"]) {
205
+ this.setMobilePushAccountOptions(this.props.Edit.weCrmAccounts, newFormData["mobilepush-accounts"]);
206
+ delete newFormData['mobilepush-template'];
207
+ delete newFormData['template-name'];
208
+ if (!_.isEmpty(newFormData[0])) {
209
+ delete newFormData[0];
210
+ }
211
+ if (!_.isEmpty(newFormData[1])) {
212
+ delete newFormData[1];
213
+ }
214
+ }
215
+ if (this.state.isSchemaChanged) {
216
+ this.setState({isSchemaChanged: false});
217
+ }
218
+ if (this.props.isFullMode && this.props.defaultData && _.isEmpty(formData['template-name'])) {
219
+ newFormData['template-name'] = _.get(this.props, "defaultData['template-name']");
220
+ }
221
+ this.setState({formData: newFormData, tabCount}, () => {
222
+ this.props.showTemplateName({formData: this.state.formData, onFormDataChange: this.onFormDataChange});
223
+ });
224
+ if (currentTab) {
225
+ this.setState({currentTab});
226
+ }
227
+ };
228
+
229
+ onLinkTypeChange = (eventTriggered, formData, field, currentTab, inputSchema) => {
230
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
231
+ const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
232
+ const tabIndex = currentTab || this.state.currentTab;
233
+ const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
234
+ const id = field.id;
235
+ const fieldIndex = findIndex(inputFields, {identifier: id});
236
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
237
+ const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
238
+ // let inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${id}-select` : `${id}-text`;
239
+ // if (field.id === "cta-deeplink-secondary-cta-1" && (tabIndex > 1 || this.state.currentTab > 1)) {
240
+ // inputId = `${inputId}${tabIndex || this.state.currentTab}`;
241
+ // }
242
+ const newInputFields = this.getLinkTypeFields({inputFieldsArgs: inputFields, fieldIndex, deepLinkOptions, formData, field});
243
+ set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
244
+
245
+ if (currentTab) { // identifying where ist called from setEditData or by event handler
246
+ return schema;
247
+ }
248
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
249
+ this.injectEvents(schema);
250
+ return schema;
251
+ };
252
+
253
+ onTabChange = (data) => {
254
+ console.log('inside parent ontabchange', data, this.state);
255
+ this.setState({currentTab: data});
256
+ };
257
+
258
+ onTagSelect = (data, currentTab, srcComp) => {
259
+ console.log('parent data tag', data, currentTab);
260
+ const editorId = srcComp.target;
261
+ this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`);
262
+ document.getElementById(editorId).focus();
263
+ };
264
+ onModalCancel = () => {
265
+ if (this.state.modalContent && this.state.modalContent.show) {
266
+ this.setState({modalContent: {...this.state.modalContent, show: false}});
267
+ }
268
+ };
269
+ onUpdateTemplateComplete = () => {
270
+ console.log('reseting schema');
271
+ this.resetSchema();
272
+ this.setState({
273
+ formData: {},
274
+ tabCount: 1,
275
+ currentTab: 1,
276
+ editData: {},
277
+ });
278
+ const message = getMessageObject('success', this.props.intl.formatMessage(messages['MOBILEPUSH Template Edited Successfully']), true);
279
+ this.props.globalActions.addMessageToQueue(message);
280
+ this.props.actions.clearEditResponse();
281
+ if (this.props.isFullMode) {
282
+ this.props.getFormLibraryData(this.getFormData());
283
+ } else {
284
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
285
+ const type = this.props.location.query.type;
286
+ this.props.router.push({
287
+ pathname: `/mobilepush/`,
288
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
289
+ });
290
+ }
291
+ }
292
+ setMobilePushAccountOptions = (accounts, newAccountId) => {
293
+ let accId = newAccountId || this.props.location.query.account_id;
294
+ if (this.props.location.query.module !== "loyalty" && this.props.location.query.module !== "dvs") {
295
+ accId = Number(accId);
296
+ }
297
+ const formData = _.cloneDeep(this.state.formData);
298
+ let selectedAccount = {};
299
+ if (accId) {
300
+ _.forEach(accounts, (account) => {
301
+ let acccountId = account.id;
302
+ if ((this.props.location.query.module === "loyalty" || this.props.location.query.module === "dvs") && typeof accId === 'string') {
303
+ acccountId = account.sourceAccountIdentifier;
304
+ }
305
+ if (acccountId === accId) {
306
+ this.props.templatesActions.setWeChatAccount(account);
307
+ selectedAccount = account;
308
+ formData['mobilepush-accounts'] = account.id;
309
+ if (this.props.location.query.account_id) {
310
+ formData['mobilepush-template'] = this.props.params.id;
311
+ }
312
+ }
313
+ });
314
+ } else {
315
+ selectedAccount = accounts[0];
316
+ formData['mobilepush-accounts'] = accounts[0].id;
317
+ }
318
+ this.props.actions.setWeChatAccount(selectedAccount);
319
+ this.setState({formData, accountsOptions: accounts.map((acc) => ({key: acc.id, label: acc.name, value: acc.id}))});
320
+ };
321
+
322
+ getTransformedData = (formData) => {
323
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
324
+ const obj = _.cloneDeep(this.state.editData);
325
+ obj.versions = {
326
+ base: {},
327
+ };
328
+ obj.type = 'MOBILEPUSH';
329
+ obj.name = formData['template-name'];
330
+ obj.definition = {
331
+ accountId: selectedWeChatAccount.id,
332
+ licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
333
+ };
334
+ if (this.props.location.query && this.props.location.query.module !== 'dvs') {
335
+ obj.definition.mode = this.props.Edit.templateDetails.mode || get(this, 'props.Edit.templateDetails.definition.mode');
336
+ }
337
+ const android = {};
338
+ Object.keys(formData[0]).forEach((data) => {
339
+ if (!!formData[0][data] && data !== "tabKey") {
340
+ android[data] = formData[0][data];
341
+ }
342
+ });
343
+ const ios = {};
344
+ Object.keys(formData[1]).forEach((data) => {
345
+ if (!!formData[1][data] && data !== "tabKey") {
346
+ ios[data] = formData[1][data];
347
+ }
348
+ });
349
+ obj.versions.base = {};
350
+ delete android.base;
351
+ if (!_.isEmpty(android)) {
352
+ obj.versions.base.ANDROID = {
353
+ luid: "{{luid}}",
354
+ cuid: "{{cuid}}",
355
+ communicationId: "{{communicationId}}",
356
+ title: android['message-title'],
357
+ message: android['message-editor'],
358
+ expandableDetails: {
359
+ style: "BIG_TEXT",
360
+ message: android['message-editor'],
361
+ },
362
+ custom: _.map(android, (field, key) => {
363
+ if (key.indexOf('custom-value') > -1) {
364
+ return field !== "" ? {key: key.replace('custom-value-', "").replace('-cta-deeplink-select', '').replace('-cta-deeplink-secondary-cta-0-select', '').replace('-cta-deeplink-secondary-cta-1-select', ''), value: field} : undefined;
365
+ }
366
+ return undefined;
367
+ }).filter((custom) => custom),
368
+ };
369
+ }
370
+ if (android['cta-deeplink'] && android['cta-deeplink'] !== "") {
371
+ obj.versions.base.ANDROID.cta = {
372
+ type: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
373
+ actionLink: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? android['cta-deeplink-select'] : android['cta-deeplink-text'],
374
+ deepLinkName: android['cta-deeplink'] && android['cta-deeplink'].toLowerCase() === "deeplink" ? this.getLinkName(android['cta-deeplink-select']) : undefined,
375
+ };
376
+ if (this.props.location.query.type === 'embedded') {
377
+ delete obj.versions.base.ANDROID.cta.deepLinkName;
378
+ }
379
+ }
380
+ if (!_.isEmpty(ios)) {
381
+ obj.versions.base.IOS = {
382
+ luid: "{{luid}}",
383
+ cuid: "{{cuid}}",
384
+ communicationId: "{{communicationId}}",
385
+ title: ios['message-title2'],
386
+ message: ios['message-editor2'],
387
+ expandableDetails: {
388
+ style: "BIG_TEXT",
389
+ message: ios['message-title2'],
390
+ ctas: [
391
+
392
+ ],
393
+ categoryId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].id : undefined,
394
+ },
395
+ custom: _.map(ios, (field, key) => {
396
+ if (key.indexOf('custom-value') > -1) {
397
+ return field !== "" ? {key: key.replace('custom-value-', "").replace('-cta-deeplink2-select', '').replace('-cta-deeplink-secondary-cta-0-select', '').replace('-cta-deeplink-secondary-cta-1-select2', ''), value: field} : undefined;
398
+ }
399
+ return undefined;
400
+ }).filter((custom) => custom),
401
+ };
402
+ }
403
+ if (ios['cta-deeplink2'] && ios['cta-deeplink2'] !== "") {
404
+ obj.versions.base.IOS.cta = {
405
+ type: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
406
+ actionLink: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? ios['cta-deeplink2-select'] : ios['cta-deeplink2-text'],
407
+ deepLinkName: ios['cta-deeplink2'] && ios['cta-deeplink2'].toLowerCase() === "deeplink" ? this.getLinkName(ios['cta-deeplink2-select']) : undefined,
408
+ };
409
+ if (this.props.location.query.type === 'embedded') {
410
+ delete obj.versions.base.IOS.cta.deepLinkName;
411
+ }
412
+ }
413
+ const imageLink = android.image;
414
+ if (imageLink) {
415
+ obj.versions.base.ANDROID.expandableDetails.image = imageLink;
416
+ obj.versions.base.ANDROID.expandableDetails.style = "BIG_PICTURE";
417
+ }
418
+ if (obj.versions.base.ANDROID && obj.versions.base.ANDROID.cta) {
419
+ if (obj.versions.base.ANDROID.cta.type === "DEEP_LINK") {
420
+ const params = _.map(android, (field, key) => {
421
+ let actionLink;
422
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-select') > -1) {
423
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-select', '');
424
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
425
+ }
426
+ return actionLink;
427
+ }).filter((actionLink) => actionLink);
428
+ if (params.length) {
429
+ obj.versions.base.ANDROID.cta.actionLink = `${obj.versions.base.ANDROID.cta.actionLink}?${params.join('&')}`;
430
+ }
431
+ }
432
+ }
433
+ const secondaryCta1 = !!android["cta-deeplink-secondary-cta-0-select"] || !!android['secondary-cta-0-label'];
434
+ const secondaryCta2 = !!android['cta-deeplink-secondary-cta-1-select'] || !!android['secondary-cta-1-label'];
435
+ if (secondaryCta1 || secondaryCta2 ) {
436
+ obj.versions.base.ANDROID.expandableDetails.ctas = [];
437
+ if (secondaryCta1) {
438
+ const cta = {
439
+ actionText: android['secondary-cta-0-label'],
440
+ type: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
441
+ actionLink: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
442
+ seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-0-select']),
443
+ };
444
+ if (this.props.location.query.type === 'embedded') {
445
+ delete cta.seccdeepLinkName;
446
+ }
447
+ obj.versions.base.ANDROID.expandableDetails.ctas.push(cta);
448
+ if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
449
+ const params = _.map(android, (field, key) => {
450
+ let actionLink;
451
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-0-select') > -1) {
452
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-0-select', '');
453
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
454
+ }
455
+ return actionLink;
456
+ }).filter((actionLink) => actionLink);
457
+ if (params.length) {
458
+ obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
459
+ }
460
+ }
461
+ }
462
+ if (secondaryCta2) {
463
+ obj.versions.base.ANDROID.expandableDetails.ctas.push({
464
+ actionText: android['secondary-cta-1-label'],
465
+ type: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
466
+ actionLink: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
467
+ seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-1-select']),
468
+ });
469
+ if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
470
+ const params = _.map(android, (field, key) => {
471
+ let actionLink;
472
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
473
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select', '');
474
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
475
+ }
476
+ return actionLink;
477
+ }).filter((actionLink) => actionLink);
478
+ if (params.length) {
479
+ obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
480
+ }
481
+ }
482
+ }
483
+ }
484
+ const imageLinkIos = ios.image;
485
+ if (imageLinkIos) {
486
+ obj.versions.base.IOS.expandableDetails.image = imageLinkIos;
487
+ obj.versions.base.IOS.expandableDetails.style = "BIG_PICTURE";
488
+ }
489
+ if (obj.versions.base.IOS && obj.versions.base.IOS.cta) {
490
+ if (obj.versions.base.IOS.cta.type === "DEEP_LINK") {
491
+ const params = _.map(ios, (field, key) => {
492
+ let actionLink;
493
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink2-select') > -1) {
494
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink2-select', '');
495
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
496
+ }
497
+ return actionLink;
498
+ }).filter((actionLink) => actionLink);
499
+ if (params.length) {
500
+ obj.versions.base.IOS.cta.actionLink = `${obj.versions.base.IOS.cta.actionLink}?${params.join('&')}`;
501
+ }
502
+ }
503
+ }
504
+ const secondaryCtaIos = !!ios['cta-deeplink-secondary-cta-1-select'] || !!ios['secondary-cta-1-label'];
505
+
506
+ if (secondaryCtaIos) {
507
+ obj.versions.base.IOS.expandableDetails.ctas = [];
508
+ const templateCtaId = get(this.state, "templateCta.ctaTemplateDetails[0].id");
509
+
510
+ const cta = {
511
+ actionText: ios['secondary-cta-1-label'],
512
+ actionLabel: ios['secondary-cta-1-action'],
513
+ actionLabel2: ios['secondary-cta-1-action2'],
514
+ type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
515
+ actionLink: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? ios['cta-deeplink-secondary-cta-1-select2'] : ios['cta-deeplink-secondary-cta-1-text2']),
516
+ ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
517
+ templateCtaId,
518
+ };
519
+ if (this.props.location.query.type === 'embedded') {
520
+ delete cta.ioscdeepLinkName;
521
+ }
522
+ obj.versions.base.IOS.expandableDetails.ctas.push(cta);
523
+ if (obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
524
+ const params = _.map(ios, (field, key) => {
525
+ let actionLink;
526
+ if (key.indexOf('custom-value') > -1 && key.indexOf('cta-deeplink-secondary-cta-1-select') > -1) {
527
+ const param = key.replace('custom-value-', "").replace('-cta-deeplink-secondary-cta-1-select2', '');
528
+ actionLink = field !== "" ? `${param}=${field}` : undefined;
529
+ }
530
+ return actionLink;
531
+ }).filter((actionLink) => actionLink);
532
+ if (params.length) {
533
+ obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].actionLink = `${obj.versions.base.IOS.expandableDetails.ctas[obj.versions.base.IOS.expandableDetails.ctas.length - 1].actionLink}?${params.join('&')}`;
534
+ }
535
+ }
536
+ }
537
+ return obj;
538
+ };
539
+
540
+ getLinkName = (link) => {
541
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
542
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
543
+ const deepLinkOptions = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (l) => l.link === link);
544
+ if (deepLinkOptions[0]) {
545
+ return deepLinkOptions[0].name;
546
+ }
547
+ return undefined;
548
+ };
549
+
550
+ setFormValidity = (isFormValid) => {
551
+ this.setState({isFormValid});
552
+ };
553
+
554
+ getMappedEvent = (id, event) => {
555
+ const map = this.state.eventsMap;
556
+ if (!map[id] || !map[id][event]) {
557
+ console.log(`error map[id] ${map[id]} ${id} ${event}` );
558
+ }
559
+ return map[id][event];
560
+ };
561
+
562
+ getCurrentWindow = (e) => {
563
+ console.log('in sms create', e);
564
+ const response = {
565
+ action: e.action,
566
+ value: 'edit',
567
+ direction: e.value,
568
+ };
569
+ parent.postMessage(JSON.stringify(response), '*');
570
+ };
571
+
572
+ getFormData = (e) => {
573
+ console.log('posting final result', this.state.formData);
574
+ const response = {
575
+ action: "getFormData",
576
+ value: this.getTransformedData(this.state.formData),
577
+ validity: this.state.isFormValid,
578
+ };
579
+ console.log('GetForm Data ', response);
580
+ this.setState({checkValidation: true});
581
+ if (e) {
582
+ e.source.postMessage(JSON.stringify(response), e.origin);
583
+ }
584
+ return response;
585
+ };
586
+
587
+
588
+ setEditState(data, schema) {
589
+ console.log('Test 1234', data, schema);
590
+ const tabCount = Object.keys(data.versions.base).length;
591
+ const formData = {};
592
+ if (this.props.location.query.type === 'embedded' && this.props.location.query.module === "loyalty") {
593
+ formData["mobilepush-accounts"] = this.state.formData["mobilepush-accounts"];
594
+ formData['mobilepush-template'] = this.state.formData['mobilepush-template'];
595
+ }
596
+ formData['template-name'] = data.name;
597
+ const androidData = data.versions.base.ANDROID;
598
+ const iosData = data.versions.base.IOS;
599
+ const android = {};
600
+ android[`message-title`] = androidData ? androidData.title : '';
601
+ android['message-editor'] = androidData ? androidData.message : '';
602
+ if (data.mode === "image") {
603
+ android.image = "";
604
+ }
605
+ if (androidData) {
606
+ if (androidData.cta) {
607
+ android['cta-deeplink'] = androidData.cta.type === "DEEP_LINK" ? "Deeplink" : "External Link";
608
+ if ( androidData.cta.type === "DEEP_LINK") {
609
+ android['cta-deeplink-select'] = androidData ? androidData.cta.actionLink : '';
610
+ } else {
611
+ android['cta-deeplink-text'] = androidData ? androidData.cta.actionLink : '';
612
+ }
613
+ if (androidData.cta.type === "DEEP_LINK" ) {
614
+ const link = android['cta-deeplink-select'].split('?')[0];
615
+ const params = android['cta-deeplink-select'].split('?')[1] && android['cta-deeplink-select'].split('?')[1].split('&');
616
+ android['cta-deeplink-select'] = link;
617
+ _.forEach(params, (param) => {
618
+ android[`custom-value-${param.split('=')[0]}-cta-deeplink-select`] = param.split('=')[1];
619
+ });
620
+ }
621
+ }
622
+ if (androidData.expandableDetails && androidData.expandableDetails.image) {
623
+ android.image = androidData.expandableDetails.image;
624
+ }
625
+ if (androidData.expandableDetails && androidData.expandableDetails.ctas && androidData.expandableDetails.ctas.length) {
626
+ android['cta-deeplink-secondary-cta-0'] = androidData.expandableDetails.ctas[0].type === "DEEP_LINK" ? "Deeplink" : "External Link";
627
+ if ( androidData.expandableDetails.ctas[0].type === "DEEP_LINK") {
628
+ android['cta-deeplink-secondary-cta-0-select'] = androidData.expandableDetails.ctas[0].actionLink;
629
+ } else {
630
+ android['cta-deeplink-secondary-cta-0-text'] = androidData.expandableDetails.ctas[0].actionLink;
631
+ }
632
+ android['secondary-cta-0-label'] = androidData.expandableDetails.ctas[0].actionText;
633
+ if (androidData.expandableDetails.ctas[0].type === "DEEP_LINK") {
634
+ const link = android['cta-deeplink-secondary-cta-0-select'].split('?')[0];
635
+ const params = android['cta-deeplink-secondary-cta-0-select'].split('?')[1] && android['cta-deeplink-secondary-cta-0-select'].split('?')[1].split('&');
636
+ android['cta-deeplink-secondary-cta-0-select'] = link;
637
+ _.forEach(params, (param) => {
638
+ android[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-0-select`] = param.split('=')[1];
639
+ });
640
+ }
641
+ }
642
+ if (androidData.expandableDetails && androidData.expandableDetails.ctas && androidData.expandableDetails.ctas.length > 1) {
643
+ android['cta-deeplink-secondary-cta-1'] = androidData.expandableDetails.ctas[1].type === "DEEP_LINK" ? "Deeplink" : "External Link";
644
+ if (androidData.expandableDetails.ctas[1].type === "DEEP_LINK") {
645
+ android['cta-deeplink-secondary-cta-1-select'] = androidData.expandableDetails.ctas[1].actionLink;
646
+ } else {
647
+ android['cta-deeplink-secondary-cta-1-text'] = androidData.expandableDetails.ctas[1].actionLink;
648
+ }
649
+ android['secondary-cta-1-label'] = androidData.expandableDetails.ctas[1].actionText;
650
+ if (androidData.expandableDetails.ctas[1].type === "DEEP_LINK" && android['cta-deeplink-secondary-cta-1-select']) {
651
+ const link = android['cta-deeplink-secondary-cta-1-select'].split('?')[0];
652
+ const params = android['cta-deeplink-secondary-cta-1-select'].split('?')[1] && android['cta-deeplink-secondary-cta-1-select'].split('?')[1].split('&');
653
+ android['cta-deeplink-secondary-cta-1-select'] = link;
654
+ _.forEach(params, (param) => {
655
+ android[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select`] = param.split('=')[1];
656
+ });
657
+ }
658
+ }
659
+ }
660
+ formData[0] = android;
661
+ const ios = {};
662
+ const templateCta = {};
663
+ ios[`message-title2`] = iosData ? iosData.title : '';
664
+ ios['message-editor2'] = iosData ? iosData.message : '';
665
+ if (data.mode === "image") {
666
+ ios.image = "";
667
+ }
668
+ if (iosData) {
669
+ if (iosData.cta) {
670
+ ios['cta-deeplink2'] = iosData.cta.type === "DEEP_LINK" ? "Deeplink" : "External Link";
671
+ if (iosData.cta.type === "DEEP_LINK") {
672
+ ios['cta-deeplink2-select'] = iosData ? iosData.cta.actionLink : '';
673
+ } else {
674
+ ios['cta-deeplink2-text'] = iosData ? iosData.cta.actionLink : '';
675
+ }
676
+ if (iosData.cta.type === "DEEP_LINK") {
677
+ const link = ios['cta-deeplink2-select'].split('?')[0];
678
+ let params = ios['cta-deeplink2-select'].split('?');
679
+ if (params[1]) {
680
+ params = params[1].split('&');
681
+ _.forEach(params, (param) => {
682
+ ios[`custom-value-${param.split('=')[0]}-cta-deeplink2-select`] = param.split('=')[1];
683
+ });
684
+ }
685
+ ios['cta-deeplink2-select'] = link;
686
+ }
687
+ }
688
+ if (iosData.expandableDetails && iosData.expandableDetails.image) {
689
+ ios.image = iosData.expandableDetails.image;
690
+ }
691
+ if (iosData.expandableDetails && iosData.expandableDetails.ctas && iosData.expandableDetails.ctas.length) {
692
+ if (iosData.expandableDetails.ctas[0].type) {
693
+ ios['cta-deeplink-secondary-cta-1'] = iosData.expandableDetails.ctas[0].type === "DEEP_LINK" ? "Deeplink" : "External Link";
694
+ }
695
+ if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK") {
696
+ ios['cta-deeplink-secondary-cta-1-select2'] = iosData.expandableDetails.ctas[0].actionLink;
697
+ } else {
698
+ ios['cta-deeplink-secondary-cta-1-text2'] = iosData.expandableDetails.ctas[0].actionLink;
699
+ }
700
+ ios['secondary-cta-1-label'] = iosData.expandableDetails.ctas[0].actionText;
701
+ if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK" && ios['cta-deeplink-secondary-cta-1-select2']) {
702
+ const link = ios['cta-deeplink-secondary-cta-1-select2'].split('?')[0];
703
+ const paramsIos = ios['cta-deeplink-secondary-cta-1-select2'].split('?')[1] && ios['cta-deeplink-secondary-cta-1-select2'].split('?')[1].split('&');
704
+ ios['cta-deeplink-secondary-cta-1-select2'] = link;
705
+ _.forEach(paramsIos, (param) => {
706
+ ios[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select2`] = param.split('=')[1];
707
+ });
708
+ }
709
+ set(templateCta, "ctaTemplateDetails[0].buttonText", iosData.expandableDetails.ctas[0].actionLabel);
710
+ set(templateCta, "name", iosData.expandableDetails.ctas[0].actionText);
711
+ set(templateCta, "ctaTemplateDetails[0].id", iosData.expandableDetails.ctas[0].templateCtaId);
712
+ ios['secondary-cta-1-action'] = iosData.expandableDetails.ctas[0].actionLabel;
713
+ if (iosData.expandableDetails.ctas[0].actionLabel2) {
714
+ set(templateCta, "ctaTemplateDetails[1].buttonText", iosData.expandableDetails.ctas[0].actionLabel2);
715
+ ios['secondary-cta-1-action2'] = iosData.expandableDetails.ctas[0].actionLabel2;
716
+ }
717
+ }
718
+ }
719
+ formData[1] = ios;
720
+ formData.base = formData[0];
721
+ formData[0].base = true;
722
+ // formData[0].tabKey = '1';
723
+ // formData[1].tabKey = '2';
724
+ console.log('form data after discarding ', formData);
725
+ this.setState({templateCta}, () => {
726
+ this.getSchemaForFormData(formData, schema);
727
+ this.setState({tabCount, formData, editData: data, currentTab: 1}, () => {
728
+ this.props.showTemplateName({formData, onFormDataChange: this.onFormDataChange});
729
+ });
730
+ });
731
+ }
732
+
733
+ getSchemaForFormData = (formdata, inputSchema) => {
734
+ let schema = inputSchema;
735
+ const formData = _.cloneDeep(formdata);
736
+ if (!_.isEmpty(formData[0])) {
737
+ if (formData[0]['cta-deeplink']) {
738
+ formData[0]['add-pri-cta'] = true;
739
+ schema = this.addPrimaryCta(null, formData, {id: 'add-pri-cta'}, schema, 1);
740
+ schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink'}, 1, schema);
741
+ schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-select'}, 1, schema);
742
+ }
743
+ if (formData[0]['cta-deeplink-secondary-cta-0']) {
744
+ formData[0]['add-sec-cta'] = true;
745
+ schema = this.addSecondoryCta(null, formData, {id: 'add-sec-cta'}, schema, 1);
746
+ schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-0'}, 1, schema);
747
+ schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-0-select'}, 1, schema);
748
+ }
749
+ if (formData[0]['cta-deeplink-secondary-cta-1']) {
750
+ formData[0]['add-sec-cta-2'] = true;
751
+ schema = this.addSecondoryCta(null, formData, {id: 'add-sec-cta-2'}, schema, 1);
752
+ schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-1'}, 1, schema);
753
+ schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-1-select'}, 1, schema);
754
+ }
755
+ }
756
+ if (!_.isEmpty(formData[1])) {
757
+ if (formData[1]['cta-deeplink2']) {
758
+ formData[1]['add-pri-cta-ios'] = true;
759
+ schema = this.addPrimaryCta(null, formData, {id: 'add-pri-cta-ios'}, schema, 2);
760
+ schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink2'}, 2, schema);
761
+ schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink2-select'}, 2, schema);
762
+ }
763
+ if (formData[1]['secondary-cta-1-action']) {
764
+ formData[1]['add-sec-cta-ios'] = true;
765
+
766
+ schema = this.showSelectedIosCta(schema, {id: 'add-sec-cta-ios'}, 2, undefined, formData[1]['cta-deeplink-secondary-cta-1']);
767
+ schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-1'}, 2, schema);
768
+ schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-1-select2'}, 2, schema);
769
+ }
770
+ }
771
+ this.setState({schema, isSchemaChanged: true, formData});
772
+ this.injectEvents(schema);
773
+ };
774
+ setTemplateOptions = (mobilepushTemplates) => {
775
+ const templateOptions = [];
776
+ let selectedTemplate = {};
777
+ if (!_.isEmpty(mobilepushTemplates)) {
778
+ _.forEach(mobilepushTemplates, (template) => {
779
+ templateOptions.push({
780
+ key: template._id,
781
+ label: template.name,
782
+ value: template._id,
783
+ });
784
+ if (this.state.formData['mobilepush-template'] && template._id === this.state.formData['mobilepush-template']) {
785
+ selectedTemplate = template;
786
+ }
787
+ });
788
+ }
789
+ this.setState({templateOptions}, () => {
790
+ if (!_.isEmpty(selectedTemplate)) {
791
+ this.props.actions.setSelectedTemplate(selectedTemplate);
792
+ }
793
+ if (!_.isEmpty(this.state.schema)) {
794
+ this.injectEvents(this.state.schema);
795
+ }
796
+ });
797
+ };
798
+ getTags = () => {
799
+ const query = {
800
+ layout: 'mobilepush',
801
+ type: 'TAG',
802
+ context: this.props.location.query.type === 'embedded' ? this.props.location.query.module : 'default',
803
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
804
+ };
805
+ if (this.props.getDefaultTags) {
806
+ query.context = this.props.getDefaultTags;
807
+ }
808
+ this.props.globalActions.fetchSchemaForEntity(query);
809
+ }
810
+ setModalContent = (type) => {
811
+ if (type === 'ios') {
812
+ const modalContent = {
813
+ title: "Alert",
814
+ body: "Android template is not configured. Save without Android template",
815
+ type: 'confirm',
816
+ id: 'ios',
817
+ };
818
+ this.setState({modalContent, showModal: true});
819
+ } else if (type === 'android') {
820
+ const modalContent = {
821
+ title: "Alert",
822
+ body: "IOS template is not configured, Save without IOS template",
823
+ type: 'confirm',
824
+ id: 'android',
825
+ };
826
+ this.setState({modalContent, showModal: true});
827
+ }
828
+ }
829
+
830
+ openNotificationWithIcon = (type, message) => {
831
+ const dur = (type === 'error' || type === 'warning') ? null : 5;
832
+ notification[type]({
833
+ message: (`${type.toUpperCase()} ! ! ! `),
834
+ description: message, //'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
835
+ duration: dur,
836
+ });
837
+ }
838
+
839
+ handleCancelModal = () => {
840
+ this.setState({showModal: false});
841
+ };
842
+
843
+ insertAtCursor = (field, myValue) => {
844
+ //IE support
845
+ const myField = field;
846
+ if (document.selection) {
847
+ myField.focus();
848
+ const sel = document.selection.createRange();
849
+ sel.text = myValue;
850
+ } else if (myField.selectionStart || myField.selectionStart === '0') { //MOZILLA and others
851
+ const startPos = myField.selectionStart;
852
+ const endPos = myField.selectionEnd;
853
+ myField.value = myField.value.substring(0, startPos)
854
+ + myValue
855
+ + myField.value.substring(endPos, myField.value.length);
856
+ myField.selectionStart = startPos + myValue.length;
857
+ myField.selectionEnd = startPos + myValue.length;
858
+ } else {
859
+ myField.value += myValue;
860
+ }
861
+ const event = new Event('input', { bubbles: true });
862
+ callNativeEvent({field, value: myField.value, event});
863
+ };
864
+
865
+ selectCtaIos = (selectedConfig) => {
866
+ this.showSelectedIosCta(null, null, null, selectedConfig);
867
+ };
868
+
869
+ uploadImage = (data) => {
870
+ if (data.fileParams.error) {
871
+ const message = getMessageObject('error', this.props.intl.formatMessage(messages['File size cannot be more than 5mb']), true);
872
+ this.props.globalActions.addMessageToQueue(message);
873
+ } else {
874
+ const name = data.file.name.split('.');
875
+ const blob = data.file.slice(0, -1, 'image');
876
+ const newFile = new File([blob], `${name[0]}${Date.now()}.${name[1]}`, {type: 'image'});
877
+ this.props.actions.uploadAsset(newFile, data.type, data.fileParams);
878
+ }
879
+ };
880
+
881
+ copyIphoneContent = () => {
882
+ const formData = _.cloneDeep(this.state.formData);
883
+ if (!!formData[1]['message-title2'] && !!formData[1]['message-editor2']) {
884
+ formData[0]['message-title'] = formData[1]['message-title2'];
885
+ formData[0]['message-editor'] = formData[1]['message-editor2'];
886
+ this.setState({formData});
887
+ } else {
888
+ this.openNotificationWithIcon('warning', "Cannot copy empty field values.");
889
+ }
890
+ };
891
+ copyAndroidContent = () => {
892
+ const formData = _.cloneDeep(this.state.formData);
893
+ if (!!formData[0]['message-title'] && formData[0]['message-editor']) {
894
+ formData[1]['message-title2'] = formData[0]['message-title'];
895
+ formData[1]['message-editor2'] = formData[0]['message-editor'];
896
+ this.setState({formData});
897
+ } else {
898
+ this.openNotificationWithIcon('warning', "Cannot copy empty field values.");
899
+ }
900
+ };
901
+
902
+ showSelectedIosCta = (inputSchema, field, tab, selectedConfig) => {
903
+ const currentTab = tab || this.state.currentTab;
904
+ const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
905
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
906
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
907
+ const deepLinkOptions = _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) );
908
+
909
+ const inputFields = get(schema, `containers[0].panes[${currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
910
+ forEach(inputFields, (inputField, fieldIndex) => {
911
+ forEach(inputField.cols, (col) => {
912
+ if (col.id === "add-sec-cta-ios") {
913
+ const inputId = `secondary-cta-${currentTab - 1}`;
914
+ inputFields.splice(fieldIndex + 1, 0, {
915
+ rowClassName: 'mobile-push-row',
916
+ cols: [
917
+ {
918
+ id: `${inputId}-action-display`,
919
+ metaType: "label",
920
+ value: <CapRow>
921
+ <CapColumn span={18}>
922
+ <CapHeader
923
+ title={this.state.templateCta.name}
924
+ description={get(this.state, "templateCta.ctaTemplateDetails[0].buttonText")}
925
+ size={"label"}/>
926
+ </CapColumn>
927
+ <CapColumn span={6}>
928
+ <CapLink title="change" onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
929
+ </CapColumn>
930
+ </CapRow>,
931
+ primitive: true,
932
+ dynamicTab: false,
933
+ type: "div",
934
+ width: 18,
935
+ offset: 1,
936
+ },
937
+ {
938
+ id: `${inputId}-action`,
939
+ metaType: "label",
940
+ value: "",
941
+ primitive: true,
942
+ dynamicTab: false,
943
+ type: "div",
944
+ width: 8,
945
+ offset: 0,
946
+ style: {
947
+ display: 'none',
948
+ },
949
+ },
950
+ {
951
+ id: `${inputId}-action2`,
952
+ metaType: "label",
953
+ value: "",
954
+ primitive: true,
955
+ dynamicTab: false,
956
+ type: "div",
957
+ width: 8,
958
+ offset: 0,
959
+ style: {display: 'none'},
960
+ },
961
+
962
+ ],
963
+ });
964
+ if (selectedConfig && (selectedConfig.id !== "16589g0g" && selectedConfig.id !== "17543720" && selectedConfig.id !== "1a491g56")) {
965
+ inputFields.splice(fieldIndex + 2, 0, {
966
+ rowClassName: "mobile-push-row",
967
+ identifier: `cta-deeplink-${inputId}`,
968
+ cols: [
969
+
970
+ {
971
+ id: `cta-deeplink-${inputId}`,
972
+ type: "radioGroup", //Resembles component to be used
973
+ metaType: "text",
974
+ datatype: "string",
975
+ options: ["Deeplink", "External Link"],
976
+ inductiveText: ["A page within mobile app", "An external web page"],
977
+ value: "Deeplink",
978
+ required: true,
979
+ width: 18,
980
+ offset: 1,
981
+ errorMessage: "Please select link type",
982
+ fluid: true,
983
+
984
+ styling: "semantic",
985
+ order: 1,
986
+ supportedEvents: ["onChange"],
987
+ customComponent: false,
988
+ },
989
+ ],
990
+ });
991
+ inputFields.splice(fieldIndex + 3, 0, {
992
+ rowClassName: 'mobile-push-row',
993
+ id: 'cta-deeplink-select-section',
994
+ identifier: `cta-deeplink-${inputId}-select2`,
995
+ cols: [
996
+
997
+ {
998
+ id: `cta-deeplink-${inputId}-select2`,
999
+ placeholder: "Select DeepLink",
1000
+ type: "select", //Resembles component to be used
1001
+ options: deepLinkOptions,
1002
+ metaType: "text",
1003
+ datatype: "string",
1004
+ errorMessage: "Select a deeplink",
1005
+ required: true,
1006
+ fluid: true,
1007
+ width: 18,
1008
+ offset: 1,
1009
+ style: {
1010
+ width: '100%',
1011
+ marginBottom: '16px',
1012
+ },
1013
+ styling: "semantic",
1014
+ order: 1,
1015
+ customComponent: false,
1016
+ supportedEvents: [
1017
+ 'onSelect',
1018
+ ],
1019
+ },
1020
+ ],
1021
+ });
1022
+ }
1023
+ }
1024
+ });
1025
+ });
1026
+ if (!inputSchema) {
1027
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1028
+ this.injectEvents(schema);
1029
+ }
1030
+ return schema;
1031
+ };
1032
+
1033
+ deletePrimaryCTA = (event) => {
1034
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1035
+ const id = event.currentTarget.id;
1036
+ const schema = _.cloneDeep(this.state.schema);
1037
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1038
+ const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`${id.replace('delete', 'select')}`];
1039
+ const formData = _.cloneDeep(this.state.formData);
1040
+ const self = this;
1041
+ _.forEach(schema.containers, (container) => {
1042
+ _.forEach(container.panes, (pane) => {
1043
+ _.forEach(pane.sections, (section) => {
1044
+ _.forEach(section.childSections, (childeSection) => {
1045
+ _.forEach(childeSection.childSections, (formChild) => {
1046
+ const child = formChild;
1047
+ if (child.type === 'multicols') {
1048
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1049
+ if (inputField) {
1050
+ _.forEach(inputField.cols, (col) => {
1051
+ if (col.id === id) {
1052
+ child.inputFields.splice(fieldIndex, 1);
1053
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1054
+ child.inputFields.splice(fieldIndex, 1);
1055
+ delete formData[self.state.currentTab - 1][`${id.replace('delete', 'text')}`];
1056
+ delete formData[self.state.currentTab - 1][`${id.replace('-delete', '')}`];
1057
+ }
1058
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1059
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1060
+ const configkeys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === selectedDeeplink) : [];
1061
+ if (configkeys.length) {
1062
+ const options = configkeys[0].keys;
1063
+ _.forEach(options, (opt) => {
1064
+ delete formData[this.state.currentTab - 1][`custom-value-${opt}-${id.replace('delete', 'select')}`];
1065
+ });
1066
+ child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1067
+ delete formData[self.state.currentTab - 1][`${id.replace('delete', 'select')}`];
1068
+ delete formData[self.state.currentTab - 1][`${id.replace('-delete', '')}`];
1069
+ } else {
1070
+ child.inputFields.splice(fieldIndex, 1);
1071
+ }
1072
+ }
1073
+ child.inputFields.splice(fieldIndex, 0, {
1074
+ cols: [
1075
+ {
1076
+ id: `${this.state.currentTab === 1 ? "add-pri-cta" : "add-pri-cta-ios"}`,
1077
+ metaType: "label",
1078
+ value: "Add Primary CTA",
1079
+ primitive: true,
1080
+ dynamicTab: false,
1081
+ type: "div",
1082
+ style: {
1083
+ backgroundColor: 'white',
1084
+ textAlign: 'left',
1085
+ color: '#2673D7',
1086
+ lineHeight: '24px',
1087
+ fontSize: '14px',
1088
+ fontWeight: '600',
1089
+ fontFamily: 'open-sans',
1090
+ fontStyle: 'normal',
1091
+ cursor: 'pointer',
1092
+ },
1093
+ offset: 0,
1094
+ onlyDisplay: true,
1095
+ colStyle: {
1096
+ flex: 1,
1097
+ },
1098
+ submitAction: "addPrimaryCta",
1099
+ supportedEvents: ["addPrimaryCta"],
1100
+ },
1101
+ ],
1102
+ });
1103
+ }
1104
+ });
1105
+ }
1106
+ });
1107
+ }
1108
+ });
1109
+ });
1110
+ });
1111
+ });
1112
+ });
1113
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1114
+ this.injectEvents(schema);
1115
+ };
1116
+
1117
+ deleteSecondaryCtaIos = (callback) => {
1118
+ const schema = cloneDeep(this.state.schema);
1119
+ const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1120
+ forEach(inputFields, (inputField, fieldIndex) => {
1121
+ if (inputField) {
1122
+ forEach(inputField.cols, (col) => {
1123
+ if (col.id === "add-sec-cta-ios") {
1124
+ inputFields.splice(fieldIndex + 1, inputFields.length);
1125
+ }
1126
+ });
1127
+ }
1128
+ });
1129
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, callback);
1130
+ this.injectEvents(schema);
1131
+ };
1132
+
1133
+ deleteSecondaryCTA = (event) => {
1134
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1135
+ const id = event.currentTarget.id;
1136
+ if (id === "secondary-cta-0-delete") {
1137
+ const secCta2 = document.getElementById("secondary-cta-1-delete");
1138
+ if (secCta2) {
1139
+ const modalContent = {title: "Alert", body: "Please delete second Secondary cta First", type: 'info', show: true, onCancel: this.onModalCancel};
1140
+ this.setState({modalContent, showModal: true});
1141
+ return;
1142
+ }
1143
+ }
1144
+ const schema = _.cloneDeep(this.state.schema);
1145
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1146
+ const selectedDeeplink = this.state.formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1147
+ const formData = _.cloneDeep(this.state.formData);
1148
+ const self = this;
1149
+ const device = this.state.currentTab === 1 ? 'android' : 'ios';
1150
+ _.forEach(schema.containers, (container) => {
1151
+ _.forEach(container.panes, (pane) => {
1152
+ _.forEach(pane.sections, (section) => {
1153
+ _.forEach(section.childSections, (childeSection) => {
1154
+ _.forEach(childeSection.childSections, (formChild) => {
1155
+ const child = formChild;
1156
+ if (child.type === 'multicols') {
1157
+ _.forEach(child.inputFields, (inputField, fieldIndex) => {
1158
+ if (inputField) {
1159
+ _.forEach(inputField.cols, (col) => {
1160
+ if (col.id === id) {
1161
+ if (device === 'ios') {
1162
+ child.inputFields.splice(fieldIndex, 3);
1163
+ } else {
1164
+ child.inputFields.splice(fieldIndex, 2);
1165
+ }
1166
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-external-link") {
1167
+ child.inputFields.splice(fieldIndex, 1);
1168
+ delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'text')}`];
1169
+ }
1170
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].id === "cta-deeplink-select-section") {
1171
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1172
+ const configkeys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === selectedDeeplink) : [];
1173
+
1174
+ if (configkeys.length) {
1175
+ const options = configkeys[0].keys;
1176
+ _.forEach(options, (opt) => {
1177
+ delete formData[this.state.currentTab - 1][`custom-value-${opt}-cta-deeplink-${id.replace('delete', 'select')}`];
1178
+ });
1179
+ child.inputFields = child.inputFields.slice(0, fieldIndex).concat(child.inputFields.slice( fieldIndex + options.length + 1, child.inputFields.length));
1180
+ delete formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1181
+ } else {
1182
+ child.inputFields.splice(fieldIndex, 1);
1183
+ }
1184
+ }
1185
+ delete formData[this.state.currentTab - 1][`${id.replace('delete', 'label')}`];
1186
+ delete formData[this.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1187
+ if (device === 'ios') {
1188
+ child.inputFields[fieldIndex] = {
1189
+ cols: [
1190
+ {
1191
+ id: "add-sec-cta-ios",
1192
+ metaType: "label",
1193
+ value: "Add Secondary CTA",
1194
+ primitive: true,
1195
+ dynamicTab: false,
1196
+ type: "div",
1197
+ style: {
1198
+ backgroundColor: 'white',
1199
+ textAlign: 'left',
1200
+ color: '#2673D7',
1201
+ lineHeight: '24px',
1202
+ fontSize: '14px',
1203
+ marginTop: '16px',
1204
+ fontWeight: '600',
1205
+ fontFamily: 'open-sans',
1206
+ fontStyle: 'normal',
1207
+ cursor: 'pointer',
1208
+ },
1209
+ offset: 0,
1210
+ onlyDisplay: true,
1211
+ colStyle: {
1212
+ flex: 1,
1213
+ },
1214
+ submitAction: "addSecondaryCtaIos",
1215
+ supportedEvents: ["addSecondaryCtaIos"],
1216
+ },
1217
+ ],
1218
+ };
1219
+ } else {
1220
+ if (child.inputFields[fieldIndex] && child.inputFields[fieldIndex].cols[0] && child.inputFields[fieldIndex].cols[0].id === "add-sec-cta") {
1221
+ child.inputFields[fieldIndex] = {
1222
+ cols: [
1223
+ {
1224
+ id: "add-sec-cta",
1225
+ metaType: "label",
1226
+ value: "Add Secondary CTA",
1227
+ primitive: true,
1228
+ dynamicTab: false,
1229
+ type: "div",
1230
+ style: {
1231
+ backgroundColor: 'white',
1232
+ textAlign: 'left',
1233
+ color: '#2673D7',
1234
+ lineHeight: '24px',
1235
+ fontSize: '14px',
1236
+ marginTop: '16px',
1237
+ fontWeight: '600',
1238
+ fontFamily: 'open-sans',
1239
+ fontStyle: 'normal',
1240
+ cursor: 'pointer',
1241
+ },
1242
+ offset: 0,
1243
+ onlyDisplay: true,
1244
+ colStyle: {
1245
+ flex: 1,
1246
+ },
1247
+ submitAction: "addSecondaryCta",
1248
+ supportedEvents: ['addSecondaryCta'],
1249
+ fieldsLimit: 2,
1250
+ fieldsCount: 0,
1251
+ },
1252
+ ],
1253
+ };
1254
+ }
1255
+ if (id === "secondary-cta-1-delete" || child.inputFields[fieldIndex].cols[0].id === "cta-label" || child.inputFields[fieldIndex].cols[0].id === "secondary-cta-1-space") {
1256
+ let nextFieldIndex = fieldIndex;
1257
+ if (id === "secondary-cta-1-delete" || child.inputFields[fieldIndex].cols[0].id === "secondary-cta-1-space") {
1258
+ nextFieldIndex = child.inputFields.length;
1259
+ }
1260
+ child.inputFields[nextFieldIndex] = {
1261
+ cols: [
1262
+ {
1263
+ id: "add-sec-cta",
1264
+ metaType: "label",
1265
+ value: "Add Another CTA",
1266
+ primitive: true,
1267
+ dynamicTab: false,
1268
+ type: "div",
1269
+ style: {
1270
+ backgroundColor: 'white',
1271
+ textAlign: 'left',
1272
+ color: '#2673D7',
1273
+ lineHeight: '24px',
1274
+ fontSize: '14px',
1275
+ fontWeight: '600',
1276
+ fontFamily: 'open-sans',
1277
+ fontStyle: 'normal',
1278
+ cursor: 'pointer',
1279
+ },
1280
+ offset: 0,
1281
+ onlyDisplay: true,
1282
+ colStyle: {
1283
+ flex: 1,
1284
+ },
1285
+ submitAction: "addSecondaryCta",
1286
+ supportedEvents: ['addSecondaryCta'],
1287
+ fieldsLimit: 2,
1288
+ fieldsCount: 1,
1289
+ },
1290
+ ],
1291
+ };
1292
+ }
1293
+ }
1294
+ }
1295
+ });
1296
+ }
1297
+ });
1298
+ }
1299
+ });
1300
+ });
1301
+ });
1302
+ });
1303
+ });
1304
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, formData, isSchemaChanged: true});
1305
+ this.injectEvents(schema);
1306
+ };
1307
+
1308
+
1309
+ startTemplateCreation = (data) => {
1310
+ console.log('startTemplateCreation', data);
1311
+ if (!this.state.isContentEditLoaded && this.state.fullSchema && this.props.Edit.weCrmAccounts) {
1312
+ const schema = JSON.stringify(data).indexOf("BIG_PICTURE") > -1 ? this.state.fullSchema.imageSchema : this.state.fullSchema.textSchema;
1313
+ this.setMobilePushAccountOptions(this.props.Edit.weCrmAccounts, data.content.accId);
1314
+ this.setState({schema, isContentEditLoaded: true, loadingContentEdit: true}, () => {
1315
+ this.injectEvents(this.state.schema);
1316
+ let editData = data.content;
1317
+ editData = editData.versions && editData.versions.base ? editData : {versions: {base: editData}};
1318
+ this.setEditState(editData, this.state.schema);
1319
+ });
1320
+ }
1321
+ if (data.tags) {
1322
+ this.props.globalActions.setInjectedTags(data.tags);
1323
+ }
1324
+ };
1325
+ discardValues = () => {
1326
+ console.log('discarding', this.props.Edit);
1327
+ this.resetSchema();
1328
+ this.setState({
1329
+ formData: {},
1330
+ tabCount: 1,
1331
+ currentTab: 1,
1332
+ editData: {},
1333
+ }, () => {
1334
+ const schema = this.props.Edit.templateDetails.mode === "image" ? this.state.fullSchema.imageSchema : this.state.fullSchema.textSchema;
1335
+ this.setEditState(this.props.Edit.templateDetails, schema);
1336
+ });
1337
+ };
1338
+ resetSchema = () => {
1339
+ this.setState({ schema: this.state.initialState ? this.state.initialState : this.state.schema});
1340
+ };
1341
+ showNext = () => {
1342
+ const response = {
1343
+ action: "showNext",
1344
+ value: true,
1345
+ };
1346
+ parent.postMessage(JSON.stringify(response), '*');
1347
+ };
1348
+ copyContent = () => {
1349
+
1350
+ };
1351
+ moveToTemplates = () => {
1352
+ console.log('in move to Templates');
1353
+ const modalContent = {
1354
+ title: "Alert",
1355
+ body: "Do you really want to go back? All your temporary changes will be lost!",
1356
+ type: 'confirm',
1357
+ id: 'template-back-confirm-modal',
1358
+ show: true,
1359
+ };
1360
+ this.setState({modalContent, showModal: true});
1361
+ };
1362
+ injectSections = (sections) => {
1363
+ _.forEach(sections, (section) => {
1364
+ let temp = section;
1365
+ if (temp.type === 'col-label') {
1366
+ temp = this.injectColLabelSection(temp);
1367
+ } else if (section.type === 'multicols') {
1368
+ temp = this.injectMultiColSection(temp);
1369
+ } else if (section.type === 'parent') {
1370
+ temp = this.injectSections(temp.childSections);
1371
+ }
1372
+ });
1373
+ return sections;
1374
+ };
1375
+ injectMultiColSection = (section) => {
1376
+ _.forEach(section.inputFields, (inputField) => {
1377
+ _.forEach(inputField.cols, (col) => {
1378
+ const temp = col;
1379
+ if (temp.type === 'popover') {
1380
+ temp.content.sections = this.injectSections(temp.content.sections);
1381
+ temp.value.sections = this.injectSections(temp.value.sections);
1382
+ return true;
1383
+ }
1384
+ temp.injectedEvents = {};
1385
+ temp.className = temp.className ? temp.className : '';
1386
+ if (this.props.location.query.type === 'embedded' && ((temp.type === "tag-list" || temp.type === "div" || temp.type === "icon") && this.props.location.query.module !== "dvs") && (temp.supportedEvents)) {
1387
+ temp.className = `${temp.className} hide`;
1388
+ }
1389
+ // if (this.props.location.query.type === 'embedded' && (temp.type === "input" || temp.type === "textarea" || temp.type === "radioGroup") && this.props.location.query.module !== "dvs") {
1390
+ // temp.className = `${temp.className} disabled`;
1391
+ // temp.disabled = true;
1392
+ // }
1393
+ if (this.props.location.query.type === 'embedded' && temp.id === "mobilepush-template" ) {
1394
+ temp.options = this.state.templateOptions ? this.state.templateOptions : [];
1395
+ }
1396
+ if (this.props.location.query.type === 'embedded' && temp.id === "mobilepush-accounts" ) {
1397
+ temp.options = this.state.templateOptions ? this.state.accountsOptions : [];
1398
+ }
1399
+ if (temp.id === "mobile-push-preview" && this.props.Templates.selectedWeChatAccount && !_.isEmpty(this.props.Templates.selectedWeChatAccount)) {
1400
+ temp.content.appName = this.props.Templates.selectedWeChatAccount.name;
1401
+ }
1402
+ _.forEach(col.supportedEvents, (event) => {
1403
+ console.log('injected event for ', col, event, this.getMappedEvent(col.id, event));
1404
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
1405
+ });
1406
+ return true;
1407
+ });
1408
+ });
1409
+ _.forEach(section.actionFields, (actionField) => {
1410
+ _.forEach(actionField.cols, (col) => {
1411
+ const temp = col;
1412
+ // temp.disabled = this.props.location.query.type === 'embedded' && this.props.location.query.module !== "dvs";
1413
+ if (temp.type === 'popover') {
1414
+ temp.content.sections = this.injectSections(temp.content.sections);
1415
+ temp.value.sections = this.injectSections(temp.value.sections);
1416
+ return true;
1417
+ }
1418
+ temp.injectedEvents = {};
1419
+ _.forEach(col.supportedEvents, (event) => {
1420
+ temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
1421
+ });
1422
+ return true;
1423
+ });
1424
+ });
1425
+ return section;
1426
+ };
1427
+
1428
+ saveFormData = (formData) => {
1429
+ console.log('Saving form data', formData, this.state.tabCount);
1430
+ const obj = this.getTransformedData(formData);
1431
+ console.log('obj', obj);
1432
+ this.props.actions.editTemplate(obj, this.onUpdateTemplateComplete);
1433
+ };
1434
+ handleFrameTasks = (e) => {
1435
+ // console.log('data listened to is', e.data);
1436
+ const type = e.data;
1437
+ console.log('data type', typeof type);
1438
+ if (typeof type === 'object') {
1439
+ // console.log('received something', type);
1440
+ const action = type.action;
1441
+ switch (action) {
1442
+ case "startTemplateCreation":
1443
+ this.startTemplateCreation(type.value);
1444
+ break;
1445
+ case "startLoading":
1446
+ this.startLoading(type.edit);
1447
+ break;
1448
+ case "getCurrentWindow":
1449
+ this.getCurrentWindow(type);
1450
+ break;
1451
+ default:
1452
+ break;
1453
+ }
1454
+ } else {
1455
+ switch (type) {
1456
+ case "getFormData":
1457
+ this.getFormData(e);
1458
+ break;
1459
+ case "startTemplateCreation":
1460
+ console.log('Starting to create template');
1461
+ //this.getFormData(e);
1462
+ break;
1463
+ case "moveToTemplates":
1464
+ console.log('moving to templates');
1465
+ this.moveToTemplates();
1466
+ break;
1467
+ case "validateContent":
1468
+ console.log('validating Content');
1469
+ this.validateContent(e);
1470
+ break;
1471
+ default:
1472
+ break;
1473
+ }
1474
+ }
1475
+ };
1476
+
1477
+ cancelTemplate = () => {
1478
+ const type = this.props.location.query.type;
1479
+ const module = this.props.location.query.module ? this.props.location.query.module : 'default';
1480
+ this.props.router.push({
1481
+ pathname: `/mobilepush/`,
1482
+ query: type === 'embedded' ? {type: 'embedded', module} : {module},
1483
+ });
1484
+ };
1485
+
1486
+ showCtaKeys = (eventTriggered, formData, field, tabIndex, schemaInput) => {
1487
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1488
+ const currentTab = tabIndex || this.state.currentTab;
1489
+ const schema = _.cloneDeep(schemaInput || this.state.schema);
1490
+ const eventsMap = _.cloneDeep(this.state.eventsMap);
1491
+ let inputFields = get(schema, `containers[0].panes[${currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1492
+ const {id} = field;
1493
+ const fieldIndex = findIndex(inputFields, {identifier: id});
1494
+ const formDataKey = id.replace("-show-keys", "");
1495
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1496
+ let keys = selectedWeChatAccount ? _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === formData[currentTab - 1][formDataKey]) : [];
1497
+ if (keys[0]) {
1498
+ keys = keys[0].keys;
1499
+ }
1500
+ _.map(keys, (key, index) => {
1501
+ const row = {
1502
+ rowClassName: 'mobile-push-row',
1503
+ id: 'cta-deeplink-keys',
1504
+ cols: [
1505
+ {
1506
+ id: `custom-value-${key}-${id}`,
1507
+ label: key.replace('_', " "),
1508
+ type: "input", //Resembles component to be used
1509
+ metaType: "text",
1510
+ datatype: "string",
1511
+ required: true,
1512
+ width: 18,
1513
+ offset: 1,
1514
+ placeholder: `Please input ${key.replace('_', " ")}.`,
1515
+ fluid: true,
1516
+ styling: "semantic",
1517
+ order: 1,
1518
+ customComponent: false,
1519
+ errorMessage: "value cannot be empty.",
1520
+ },
1521
+ ],
1522
+ };
1523
+ inputFields.splice(fieldIndex + index + 1, 0, row);
1524
+ });
1525
+ if (!tabIndex) { // removes the existing selected options keys so that newly selected options keys can be added.
1526
+ const configkeys = _.filter(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (dl) => dl.link === this.state.formData[currentTab - 1][field.id]);
1527
+ if (configkeys.length) {
1528
+ const options = configkeys[0].keys;
1529
+ inputFields = inputFields.slice(0, fieldIndex + 1).concat(inputFields.slice(fieldIndex + options.length + 1, inputFields.length));
1530
+ // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('delete', 'select')}`];
1531
+ // delete formData[self.state.currentTab - 1][`cta-deeplink-${id.replace('-delete', '')}`];
1532
+ }
1533
+ }
1534
+ if (tabIndex) {
1535
+ return schema;
1536
+ }
1537
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, eventsMap, isSchemaChanged: true});
1538
+ this.injectEvents(schema);
1539
+ return schema;
1540
+ };
1541
+ addPrimaryCta = (flag, formData, field, inputSchema, currentTab) => {
1542
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1543
+ const id = field.id;
1544
+ const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1545
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1546
+ const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1547
+ // const eventsMap = _.cloneDeep(this.state.eventsMap);
1548
+ const tabIndex = currentTab || this.state.currentTab;
1549
+ const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1550
+ const fieldIndex = findIndex(inputFields, {identifier: id});
1551
+ let newInputFields;
1552
+ if (formData[tabIndex - 1][id]) {
1553
+ newInputFields = this.getPrimaryCtaFields({inputFields, fieldIndex, deepLinkOptions});
1554
+ } else {
1555
+ const identifier = (tabIndex - 1) ? 'add-sec-cta-ios' : 'add-sec-cta';
1556
+ const indexOfNextField = findIndex(inputFields, {identifier});
1557
+ const deleteCount = indexOfNextField - fieldIndex;
1558
+ newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
1559
+ }
1560
+ set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1561
+ if (inputSchema) {
1562
+ return schema;
1563
+ }
1564
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1565
+ this.injectEvents(schema);
1566
+ return schema;
1567
+ };
1568
+
1569
+ addSecondoryCta = (flag, formData, field, inputSchema, currentTab) => {
1570
+ const id = field.id;
1571
+ const tabIndex = currentTab || this.state.currentTab;
1572
+ const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
1573
+ const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
1574
+ const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
1575
+ const deepLinkOptions = selectedWeChatAccount ? _.map(JSON.parse(ck ? selectedWeChatAccount.configs.deeplink : '[]'), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
1576
+ const inputFields = get(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1577
+ const fieldIndex = findIndex(inputFields, {identifier: id});
1578
+ let newInputFields;
1579
+ if (formData[tabIndex - 1][id]) {
1580
+ newInputFields = this.getSecondaryCtaFields({inputFields, fieldIndex, deepLinkOptions});
1581
+ } else {
1582
+ const identifier = id === "add-sec-cta" ? 'add-sec-cta-2' : null;
1583
+ const indexOfNextField = identifier ? findIndex(inputFields, {identifier}) : inputFields.length;
1584
+ const deleteCount = indexOfNextField - fieldIndex;
1585
+ newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
1586
+ }
1587
+ set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1588
+ if (inputSchema) {
1589
+ return schema;
1590
+ }
1591
+ this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
1592
+ this.injectEvents(schema);
1593
+ return schema;
1594
+ };
1595
+
1596
+ addSecondoryCtaIos = (flag, formData, schemaField) => {
1597
+ const id = schemaField.id;
1598
+ if (formData[this.state.currentTab - 1][id]) {
1599
+ const actionText = formData[this.state.currentTab - 1]['secondary-cta-1-action'];
1600
+ if (!this.props.iosCtasData) {
1601
+ if (!_.isEmpty(actionText)) {
1602
+ this.deleteSecondaryCtaIos();
1603
+ }
1604
+ this.props.actions.getIosCtas(this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier);//TODO: need to get license code of accoutn and send as arg
1605
+ } else {
1606
+ this.deleteSecondaryCtaIos(() => { // oncick of change
1607
+ this.setState({showIosCtaTable: true});
1608
+ });
1609
+ }
1610
+ } else {
1611
+ const schema = cloneDeep(this.state.schema);
1612
+ const inputFields = get(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`);
1613
+ forEach(inputFields, (inputField, fieldIndex) => {
1614
+ forEach(inputField.cols, (col) => {
1615
+ if (col.id === id) {
1616
+ const indexOfNextField = inputFields.length;
1617
+ const deleteCount = indexOfNextField - fieldIndex;
1618
+ const newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputField.length)];
1619
+ set(schema, `containers[0].panes[${this.state.currentTab - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
1620
+ this.setState({schema});
1621
+ }
1622
+ });
1623
+ });
1624
+ }
1625
+ };
1626
+ handleClose = () => {
1627
+ const formData = cloneDeep(this.state.formData);
1628
+ formData[this.state.currentTab - 1]['add-sec-cta-ios'] = false;
1629
+ this.setState({showIosCtaTable: false, formData});
1630
+ }
1631
+ injectContainer = (container) => {
1632
+ const temp = container;
1633
+ if (temp.type === 'tabs') {
1634
+ temp.injectedEvents = {};
1635
+ _.forEach(temp.supportedEvents, (event) => {
1636
+ temp.injectedEvents[event] = this.getMappedEvent(temp.id, event);
1637
+ });
1638
+ _.forEach(temp.panes, (pane) => {
1639
+ const tempPane = pane;
1640
+ tempPane.sectionsHeaders = this.injectSections(tempPane.sectionsHeaders);
1641
+ tempPane.sections = this.injectSections(tempPane.sections);
1642
+ });
1643
+ }
1644
+ return temp;
1645
+ };
1646
+
1647
+ injectEvents = (schema) => {
1648
+ const temp = schema;
1649
+ if (this.injectSections && temp.standalone) {
1650
+ temp.standalone.sections = this.injectSections(temp.standalone.sections);
1651
+ }
1652
+ _.forEach(temp.containers, (container) => {
1653
+ let tempContainer = container;
1654
+ tempContainer = this.injectContainer(tempContainer);
1655
+ return tempContainer;
1656
+ });
1657
+ console.log('final injected schema', schema);
1658
+ this.setState({schema, loadingContentEdit: false}, () => {
1659
+ this.removeStandAlone();
1660
+ });
1661
+ return schema;
1662
+ };
1663
+ removeStandAlone = () => {
1664
+ const schema = _.cloneDeep(this.state.schema);
1665
+ const {isFullMode} = this.props;
1666
+ if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'loyalty') {
1667
+ if (schema.standalone.sections.length === 2) {
1668
+ schema.standalone.sections.splice(0, 1);
1669
+ }
1670
+ } else if ((this.props.location.query.type === 'embedded' && typeof this.props.location.query.module !== 'undefined') || isFullMode) {
1671
+ delete schema.standalone;
1672
+ } else {
1673
+ schema.standalone.sections.splice(1, 1);
1674
+ }
1675
+ this.setState({ schema });
1676
+ };
1677
+ handleOnTagsContextChange = (data) => {
1678
+ console.log('parent tags context', data);
1679
+ const query = {
1680
+ layout: 'mobilepush',
1681
+ type: 'TAG',
1682
+ context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
1683
+ embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
1684
+ };
1685
+ this.props.globalActions.fetchSchemaForEntity(query);
1686
+ };
1687
+ startValidation = () => {
1688
+ this.setState({startValidation: true});
1689
+ }
1690
+ stopValidation = () => {
1691
+ this.setState({startValidation: false});
1692
+ }
1693
+
1694
+ render() {
1695
+ const schema = this.state.schema;
1696
+ let tipText = this.props.Edit && ("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) ? 'Getting template details...' : '';
1697
+ tipText = this.props.Edit && ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress) ? 'Saving Template...' : '';
1698
+ const loadingContentEdit = this.state.loadingContentEdit || (this.props.location.query.module === 'dvs' && _.isEmpty(this.state.schema));
1699
+ const spinning = this.props.isLoadingMetaEntities || loadingContentEdit || this.props.Edit.fetchingDefaultTemplates || this.props.Edit.assetUploading || this.state.loading || (this.props.Edit && (("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) || ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress)));
1700
+ let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
1701
+ if (this.props.supportedTags) {
1702
+ tags = this.props.supportedTags;
1703
+ }
1704
+ return (
1705
+ <div className="creatives-mobilepush-edit">
1706
+ <CapSpin tip={tipText} spinning={spinning}>
1707
+ <CapRow>
1708
+ <CapColumn>
1709
+ {!this.props.isLoadingMetaEntities && <FormBuilder
1710
+ schema={schema}
1711
+ onSubmit={this.saveFormData}
1712
+ onChange={this.onFormDataChange}
1713
+ formData={_.cloneDeep(this.state.formData)}
1714
+ currentTab={this.state.currentTab}
1715
+ parent={this}
1716
+ location={this.props.location}
1717
+ isEdit
1718
+ tabCount={2}
1719
+ iosCtasData={this.state.iosCtasData}
1720
+ tags={tags}
1721
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
1722
+ onFormValidityChange={this.setFormValidity}
1723
+ usingTabContainer
1724
+ checkValidation={this.state.checkValidation}
1725
+ onContextChange={this.handleOnTagsContextChange}
1726
+ showModal={this.state.showModal}
1727
+ iframeParent={parent}
1728
+ router={this.props.router}
1729
+ isSchemaChanged={this.state.isSchemaChanged}
1730
+ handleCancelModal={this.handleCancelModal}
1731
+ modal={this.state.modalContent}
1732
+ setModalContent={this.setModalContent}
1733
+ startValidation={this.state.startValidation}
1734
+ stopValidation={this.stopValidation}
1735
+ />}
1736
+ </CapColumn>
1737
+ {this.props.iosCtasData && this.state.showIosCtaTable &&
1738
+ <CapSlideBox
1739
+ size="size-l"
1740
+ header={<CapHeader
1741
+ title={<FormattedMessage {...messages.selectActionButton} />}
1742
+ prefix={
1743
+ <PrefixWrapper>
1744
+ <CapIcons.backIcon onClick={this.handleClose} />
1745
+ </PrefixWrapper>
1746
+ }
1747
+
1748
+ />}
1749
+ content={<CapTable
1750
+ rowSelection={{
1751
+ type: 'radio',
1752
+ onSelect: (record) => {
1753
+ this.setState({templateCta: record, showIosCtaTable: false}, () => this.selectCtaIos(record));
1754
+ },
1755
+ }}
1756
+ dataSource={this.props.iosCtasData} columns={[
1757
+ {
1758
+ title: "Name and Description",
1759
+ dataIndex: "name",
1760
+ key: "name",
1761
+ width: 200,
1762
+ render: (text, record) => (
1763
+ <div>
1764
+ <div>{record.name}</div>
1765
+ <div>{record.description}</div>
1766
+ </div>),
1767
+ },
1768
+ {
1769
+ title: "Button 1",
1770
+ dataIndex: "description",
1771
+ key: "button1",
1772
+ width: 100,
1773
+ render: (text, record) => (
1774
+ <div>
1775
+ {record.ctaTemplateDetails[0] && record.ctaTemplateDetails[0].buttonText}
1776
+ </div>),
1777
+ },
1778
+ {
1779
+ title: "Button 2",
1780
+ dataIndex: "description",
1781
+ key: "button2",
1782
+ width: 100,
1783
+ render: (text, record) => (
1784
+ <div>
1785
+ {record.ctaTemplateDetails[1] ? record.ctaTemplateDetails[1].buttonText : ''}
1786
+ </div>
1787
+ ),
1788
+ },
1789
+ ]}
1790
+ />}
1791
+ show={this.state.showIosCtaTable}
1792
+ handleClose={this.handleClose}
1793
+ />
1794
+ }
1795
+ </CapRow>
1796
+ </CapSpin>
1797
+ </div>
1798
+ );
1799
+ }
1800
+ }
1801
+
1802
+ Edit.propTypes = {
1803
+ actions: PropTypes.object.isRequired,
1804
+ Edit: PropTypes.object,
1805
+ params: PropTypes.object,
1806
+ router: PropTypes.object,
1807
+ location: PropTypes.object,
1808
+ globalActions: PropTypes.object,
1809
+ templatesActions: PropTypes.object,
1810
+ Templates: PropTypes.object,
1811
+ metaEntities: PropTypes.object,
1812
+ templateDetails: PropTypes.object,
1813
+ intl: intlShape.isRequired,
1814
+ supportedTags: PropTypes.array,
1815
+ getDefaultTags: PropTypes.string,
1816
+ templateData: PropTypes.object,
1817
+ isFullMode: PropTypes.bool,
1818
+ iosCtasData: PropTypes.array,
1819
+ isLoadingMetaEntities: PropTypes.bool,
1820
+ injectedTags: PropTypes.object,
1821
+ defaultData: PropTypes.object,
1822
+ showTemplateName: PropTypes.func,
1823
+ getFormLibraryData: PropTypes.func,
1824
+ };
1825
+
1826
+ const mapStateToProps = createStructuredSelector({
1827
+ Edit: makeSelectEdit(),
1828
+ Create: makeSelectCreate(),
1829
+ editResponse: makeSelectEditResponse(),
1830
+ templateDetails: makeSelectTemplateDetailsResponse(),
1831
+ metaEntities: makeSelectMetaEntities(),
1832
+ Templates: makeSelectTemplates(),
1833
+ iosCtasData: makeSelectIosCta(),
1834
+ isLoadingMetaEntities: isLoadingMetaEntities(),
1835
+ injectedTags: setInjectedTags(),
1836
+ });
1837
+
1838
+ function mapDispatchToProps(dispatch) {
1839
+ return {
1840
+ actions: bindActionCreators(actions, dispatch),
1841
+ globalActions: bindActionCreators(globalActions, dispatch),
1842
+ templatesActions: bindActionCreators(templatesActions, dispatch),
1843
+ };
1844
+ }
1845
+
1846
+ export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(Edit));