@capillarytech/creatives-library 2.0.70 → 2.0.72

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