@capillarytech/creatives-library 8.0.263 → 8.0.265

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 (280) hide show
  1. package/assets/Android.png +0 -0
  2. package/assets/iOS.png +0 -0
  3. package/constants/unified.js +1 -3
  4. package/initialReducer.js +0 -2
  5. package/package.json +1 -1
  6. package/services/api.js +0 -15
  7. package/services/tests/api.test.js +0 -34
  8. package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +35 -17
  9. package/tests/integration/TemplateCreation/api-response.js +1 -31
  10. package/tests/integration/TemplateCreation/msw-handler.js +0 -2
  11. package/utils/common.js +0 -11
  12. package/utils/commonUtils.js +5 -28
  13. package/utils/tests/commonUtil.test.js +0 -224
  14. package/utils/tests/transformerUtils.test.js +0 -297
  15. package/utils/transformTemplateConfig.js +10 -0
  16. package/utils/transformerUtils.js +0 -40
  17. package/v2Components/CapDeviceContent/index.js +56 -61
  18. package/v2Components/CapImageUpload/constants.js +0 -2
  19. package/v2Components/CapImageUpload/index.js +16 -65
  20. package/v2Components/CapImageUpload/index.scss +1 -4
  21. package/v2Components/CapImageUpload/messages.js +1 -5
  22. package/v2Components/CapTagList/index.js +1 -6
  23. package/v2Components/CapTagListWithInput/index.js +1 -5
  24. package/v2Components/CapTagListWithInput/messages.js +1 -1
  25. package/v2Components/CapWhatsappCTA/tests/index.test.js +0 -5
  26. package/v2Components/ErrorInfoNote/index.js +72 -402
  27. package/v2Components/ErrorInfoNote/messages.js +6 -32
  28. package/v2Components/ErrorInfoNote/style.scss +6 -278
  29. package/v2Components/FormBuilder/tests/index.test.js +4 -13
  30. package/v2Components/HtmlEditor/HTMLEditor.js +99 -418
  31. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +133 -1882
  32. package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +16 -27
  33. package/v2Components/HtmlEditor/_htmlEditor.scss +45 -108
  34. package/v2Components/HtmlEditor/_index.lazy.scss +1 -0
  35. package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +102 -23
  36. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +140 -148
  37. package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +1 -2
  38. package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
  39. package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +1 -9
  40. package/v2Components/HtmlEditor/components/EditorToolbar/index.js +6 -31
  41. package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +0 -22
  42. package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +7 -4
  43. package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +45 -35
  44. package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +3 -1
  45. package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
  46. package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +6 -7
  47. package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +10 -7
  48. package/v2Components/HtmlEditor/components/PreviewPane/index.js +43 -22
  49. package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
  50. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +152 -0
  51. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/_validationErrorDisplay.scss +0 -18
  52. package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +31 -36
  53. package/v2Components/HtmlEditor/components/ValidationPanel/_validationPanel.scss +34 -46
  54. package/v2Components/HtmlEditor/components/ValidationPanel/index.js +46 -52
  55. package/v2Components/HtmlEditor/constants.js +20 -45
  56. package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +16 -373
  57. package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +16 -351
  58. package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
  59. package/v2Components/HtmlEditor/hooks/useInAppContent.js +146 -88
  60. package/v2Components/HtmlEditor/hooks/useValidation.js +56 -213
  61. package/v2Components/HtmlEditor/index.js +1 -1
  62. package/v2Components/HtmlEditor/messages.js +94 -102
  63. package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +45 -214
  64. package/v2Components/HtmlEditor/utils/__tests__/validationAdapter.test.js +0 -134
  65. package/v2Components/HtmlEditor/utils/contentSanitizer.js +41 -40
  66. package/v2Components/HtmlEditor/utils/htmlValidator.js +72 -71
  67. package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +124 -158
  68. package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +25 -23
  69. package/v2Components/HtmlEditor/utils/validationAdapter.js +41 -66
  70. package/v2Components/MobilePushPreviewV2/index.js +7 -33
  71. package/v2Components/TemplatePreview/_templatePreview.scss +24 -55
  72. package/v2Components/TemplatePreview/index.js +32 -47
  73. package/v2Components/TemplatePreview/messages.js +0 -4
  74. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +0 -1
  75. package/v2Containers/App/constants.js +0 -5
  76. package/v2Containers/BeeEditor/index.js +90 -172
  77. package/v2Containers/CreativesContainer/SlideBoxContent.js +53 -184
  78. package/v2Containers/CreativesContainer/SlideBoxFooter.js +13 -163
  79. package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -3
  80. package/v2Containers/CreativesContainer/constants.js +0 -4
  81. package/v2Containers/CreativesContainer/index.js +46 -408
  82. package/v2Containers/CreativesContainer/messages.js +0 -12
  83. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -210
  84. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +2 -11
  85. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +50 -342
  86. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -103
  87. package/v2Containers/Email/actions.js +0 -7
  88. package/v2Containers/Email/constants.js +1 -5
  89. package/v2Containers/Email/index.js +36 -237
  90. package/v2Containers/Email/messages.js +0 -32
  91. package/v2Containers/Email/reducer.js +1 -12
  92. package/v2Containers/Email/sagas.js +7 -61
  93. package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +0 -2
  94. package/v2Containers/Email/tests/reducer.test.js +0 -46
  95. package/v2Containers/Email/tests/sagas.test.js +29 -320
  96. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +21 -211
  97. package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +74 -40
  98. package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +67 -2
  99. package/v2Containers/EmailWrapper/constants.js +0 -2
  100. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +77 -629
  101. package/v2Containers/EmailWrapper/index.js +23 -103
  102. package/v2Containers/EmailWrapper/messages.js +1 -65
  103. package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +214 -0
  104. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +77 -594
  105. package/v2Containers/InApp/actions.js +0 -7
  106. package/v2Containers/InApp/constants.js +4 -20
  107. package/v2Containers/InApp/index.js +359 -802
  108. package/v2Containers/InApp/index.scss +3 -4
  109. package/v2Containers/InApp/messages.js +3 -7
  110. package/v2Containers/InApp/reducer.js +3 -21
  111. package/v2Containers/InApp/sagas.js +9 -29
  112. package/v2Containers/InApp/selectors.js +5 -25
  113. package/v2Containers/InApp/tests/index.test.js +50 -154
  114. package/v2Containers/InApp/tests/reducer.test.js +0 -34
  115. package/v2Containers/InApp/tests/sagas.test.js +9 -61
  116. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
  117. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
  118. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -2
  119. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -9
  120. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -12
  121. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -4
  122. package/v2Containers/TagList/index.js +19 -62
  123. package/v2Containers/Templates/ChannelTypeIllustration.js +1 -13
  124. package/v2Containers/Templates/_templates.scss +1 -265
  125. package/v2Containers/Templates/actions.js +1 -2
  126. package/v2Containers/Templates/constants.js +0 -1
  127. package/v2Containers/Templates/index.js +38 -363
  128. package/v2Containers/Templates/messages.js +0 -28
  129. package/v2Containers/Templates/reducer.js +0 -2
  130. package/v2Containers/Templates/tests/index.test.js +0 -10
  131. package/v2Containers/TemplatesV2/TemplatesV2.style.js +2 -4
  132. package/v2Containers/TemplatesV2/index.js +7 -15
  133. package/v2Containers/TemplatesV2/messages.js +0 -4
  134. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +0 -34
  135. package/utils/imageUrlUpload.js +0 -141
  136. package/v2Components/CapImageUrlUpload/constants.js +0 -26
  137. package/v2Components/CapImageUrlUpload/index.js +0 -365
  138. package/v2Components/CapImageUrlUpload/index.scss +0 -35
  139. package/v2Components/CapImageUrlUpload/messages.js +0 -47
  140. package/v2Components/ErrorInfoNote/constants.js +0 -1
  141. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +0 -870
  142. package/v2Components/HtmlEditor/components/ValidationPanel/constants.js +0 -6
  143. package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +0 -281
  144. package/v2Components/HtmlEditor/components/ValidationTabs/index.js +0 -295
  145. package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +0 -51
  146. package/v2Components/HtmlEditor/utils/validationConstants.js +0 -38
  147. package/v2Components/MobilePushPreviewV2/constants.js +0 -6
  148. package/v2Containers/BeePopupEditor/_beePopupEditor.scss +0 -14
  149. package/v2Containers/BeePopupEditor/constants.js +0 -10
  150. package/v2Containers/BeePopupEditor/index.js +0 -194
  151. package/v2Containers/BeePopupEditor/tests/index.test.js +0 -627
  152. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1246
  153. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +0 -2472
  154. package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +0 -520
  155. package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +0 -956
  156. package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +0 -376
  157. package/v2Containers/InApp/__tests__/sagas.test.js +0 -363
  158. package/v2Containers/InApp/tests/selectors.test.js +0 -612
  159. package/v2Containers/InAppWrapper/components/InAppWrapperView.js +0 -151
  160. package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +0 -267
  161. package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +0 -23
  162. package/v2Containers/InAppWrapper/constants.js +0 -16
  163. package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +0 -473
  164. package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +0 -198
  165. package/v2Containers/InAppWrapper/index.js +0 -148
  166. package/v2Containers/InAppWrapper/messages.js +0 -49
  167. package/v2Containers/InappAdvance/index.js +0 -1099
  168. package/v2Containers/InappAdvance/index.scss +0 -10
  169. package/v2Containers/InappAdvance/tests/index.test.js +0 -448
  170. package/v2Containers/WebPush/Create/components/BrandIconSection.js +0 -108
  171. package/v2Containers/WebPush/Create/components/ButtonForm.js +0 -172
  172. package/v2Containers/WebPush/Create/components/ButtonItem.js +0 -101
  173. package/v2Containers/WebPush/Create/components/ButtonList.js +0 -145
  174. package/v2Containers/WebPush/Create/components/ButtonsLinksSection.js +0 -164
  175. package/v2Containers/WebPush/Create/components/ButtonsLinksSection.test.js +0 -463
  176. package/v2Containers/WebPush/Create/components/FormActions.js +0 -54
  177. package/v2Containers/WebPush/Create/components/FormActions.test.js +0 -163
  178. package/v2Containers/WebPush/Create/components/MediaSection.js +0 -142
  179. package/v2Containers/WebPush/Create/components/MediaSection.test.js +0 -341
  180. package/v2Containers/WebPush/Create/components/MessageSection.js +0 -103
  181. package/v2Containers/WebPush/Create/components/MessageSection.test.js +0 -268
  182. package/v2Containers/WebPush/Create/components/NotificationTitleSection.js +0 -87
  183. package/v2Containers/WebPush/Create/components/NotificationTitleSection.test.js +0 -210
  184. package/v2Containers/WebPush/Create/components/TemplateNameSection.js +0 -54
  185. package/v2Containers/WebPush/Create/components/TemplateNameSection.test.js +0 -143
  186. package/v2Containers/WebPush/Create/components/__snapshots__/ButtonsLinksSection.test.js.snap +0 -86
  187. package/v2Containers/WebPush/Create/components/__snapshots__/FormActions.test.js.snap +0 -16
  188. package/v2Containers/WebPush/Create/components/__snapshots__/MediaSection.test.js.snap +0 -41
  189. package/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +0 -54
  190. package/v2Containers/WebPush/Create/components/__snapshots__/NotificationTitleSection.test.js.snap +0 -37
  191. package/v2Containers/WebPush/Create/components/__snapshots__/TemplateNameSection.test.js.snap +0 -21
  192. package/v2Containers/WebPush/Create/components/_buttons.scss +0 -246
  193. package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +0 -554
  194. package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +0 -607
  195. package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +0 -633
  196. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +0 -666
  197. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +0 -74
  198. package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +0 -78
  199. package/v2Containers/WebPush/Create/hooks/useButtonManagement.js +0 -138
  200. package/v2Containers/WebPush/Create/hooks/useButtonManagement.test.js +0 -406
  201. package/v2Containers/WebPush/Create/hooks/useCharacterCount.js +0 -30
  202. package/v2Containers/WebPush/Create/hooks/useCharacterCount.test.js +0 -151
  203. package/v2Containers/WebPush/Create/hooks/useImageUpload.js +0 -104
  204. package/v2Containers/WebPush/Create/hooks/useImageUpload.test.js +0 -538
  205. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +0 -122
  206. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -633
  207. package/v2Containers/WebPush/Create/index.js +0 -1148
  208. package/v2Containers/WebPush/Create/index.scss +0 -134
  209. package/v2Containers/WebPush/Create/messages.js +0 -211
  210. package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +0 -228
  211. package/v2Containers/WebPush/Create/preview/NotificationContainer.js +0 -294
  212. package/v2Containers/WebPush/Create/preview/PreviewContent.js +0 -90
  213. package/v2Containers/WebPush/Create/preview/PreviewControls.js +0 -305
  214. package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +0 -25
  215. package/v2Containers/WebPush/Create/preview/WebPushPreview.js +0 -155
  216. package/v2Containers/WebPush/Create/preview/assets/Light.svg +0 -53
  217. package/v2Containers/WebPush/Create/preview/assets/Top.svg +0 -5
  218. package/v2Containers/WebPush/Create/preview/assets/android-arrow-down.svg +0 -9
  219. package/v2Containers/WebPush/Create/preview/assets/android-arrow-up.svg +0 -9
  220. package/v2Containers/WebPush/Create/preview/assets/chrome-icon.png +0 -0
  221. package/v2Containers/WebPush/Create/preview/assets/edge-icon.png +0 -0
  222. package/v2Containers/WebPush/Create/preview/assets/firefox-icon.svg +0 -106
  223. package/v2Containers/WebPush/Create/preview/assets/iOS.svg +0 -26
  224. package/v2Containers/WebPush/Create/preview/assets/macos-arrow-down-icon.svg +0 -9
  225. package/v2Containers/WebPush/Create/preview/assets/macos-triple-dot-icon.svg +0 -9
  226. package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +0 -18
  227. package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +0 -29
  228. package/v2Containers/WebPush/Create/preview/assets/windows-close-icon.svg +0 -9
  229. package/v2Containers/WebPush/Create/preview/assets/windows-triple-dot-icon.svg +0 -9
  230. package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +0 -51
  231. package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +0 -145
  232. package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +0 -45
  233. package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +0 -68
  234. package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +0 -61
  235. package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +0 -99
  236. package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +0 -733
  237. package/v2Containers/WebPush/Create/preview/components/tests/WindowsChromeExpanded.test.js +0 -571
  238. package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +0 -85
  239. package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/WindowsChromeExpanded.test.js.snap +0 -81
  240. package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +0 -50
  241. package/v2Containers/WebPush/Create/preview/constants.js +0 -637
  242. package/v2Containers/WebPush/Create/preview/notification-container.scss +0 -79
  243. package/v2Containers/WebPush/Create/preview/preview.scss +0 -358
  244. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +0 -370
  245. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +0 -12
  246. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +0 -12
  247. package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +0 -12
  248. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +0 -47
  249. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +0 -11
  250. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +0 -11
  251. package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +0 -11
  252. package/v2Containers/WebPush/Create/preview/styles/_base.scss +0 -207
  253. package/v2Containers/WebPush/Create/preview/styles/_ios.scss +0 -153
  254. package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +0 -107
  255. package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +0 -101
  256. package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +0 -229
  257. package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +0 -909
  258. package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +0 -1081
  259. package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +0 -723
  260. package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +0 -1327
  261. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +0 -131
  262. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +0 -112
  263. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +0 -144
  264. package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +0 -129
  265. package/v2Containers/WebPush/Create/utils/payloadBuilder.js +0 -96
  266. package/v2Containers/WebPush/Create/utils/payloadBuilder.test.js +0 -396
  267. package/v2Containers/WebPush/Create/utils/previewUtils.js +0 -89
  268. package/v2Containers/WebPush/Create/utils/urlValidation.js +0 -115
  269. package/v2Containers/WebPush/Create/utils/urlValidation.test.js +0 -449
  270. package/v2Containers/WebPush/Create/utils/validation.js +0 -75
  271. package/v2Containers/WebPush/Create/utils/validation.test.js +0 -283
  272. package/v2Containers/WebPush/actions.js +0 -60
  273. package/v2Containers/WebPush/constants.js +0 -132
  274. package/v2Containers/WebPush/index.js +0 -2
  275. package/v2Containers/WebPush/reducer.js +0 -104
  276. package/v2Containers/WebPush/sagas.js +0 -119
  277. package/v2Containers/WebPush/selectors.js +0 -65
  278. package/v2Containers/WebPush/tests/reducer.test.js +0 -863
  279. package/v2Containers/WebPush/tests/sagas.test.js +0 -566
  280. package/v2Containers/WebPush/tests/selectors.test.js +0 -960
@@ -46,10 +46,6 @@ export default defineMessages({
46
46
  id: `${scope}.mobilepushHeader`,
47
47
  defaultMessage: `Mobile Push`,
48
48
  },
49
- "webpushHeader": {
50
- id: `${scope}.webpushHeader`,
51
- defaultMessage: `Web Push`,
52
- },
53
49
  "ebillHeader": {
54
50
  id: `${scope}.ebillHeader`,
55
51
  defaultMessage: `Ebill`,
@@ -346,10 +342,6 @@ export default defineMessages({
346
342
  id: `${scope}.newWhatsappTemplate`,
347
343
  defaultMessage: 'Add new Whatsapp {template}',
348
344
  },
349
- "newWebPushTemplate": {
350
- id: `${scope}.newWebPushTemplate`,
351
- defaultMessage: 'Add new Web push {template}',
352
- },
353
345
  "newInAppMessageTemplate": {
354
346
  id: `${scope}.newInAppMessageTemplate`,
355
347
  defaultMessage: 'Add new In app message {template}',
@@ -386,14 +378,6 @@ export default defineMessages({
386
378
  id: `${scope}.whatsappDescIllustration`,
387
379
  defaultMessage: 'These templates can be reused when creating a\nnew message content.',
388
380
  },
389
- "webPushTitleIllustration": {
390
- id: `${scope}.webPushTitleIllustration`,
391
- defaultMessage: 'Add a new Web push creative {template}',
392
- },
393
- "webPushDescIllustration": {
394
- id: `${scope}.webPushDescIllustration`,
395
- defaultMessage: 'These templates can be reused when creating a new message content.',
396
- },
397
381
  "whatsappAccountNotConfiguredTitle": {
398
382
  id: `${scope}.whatsappAccountNotConfiguredTitle`,
399
383
  defaultMessage: 'Whatsapp account is not configured',
@@ -478,10 +462,6 @@ export default defineMessages({
478
462
  id: `${scope}.zaloAccount`,
479
463
  defaultMessage: 'Zalo account',
480
464
  },
481
- "webpushAccount": {
482
- id: `${scope}.webpushAccount`,
483
- defaultMessage: 'Web push account',
484
- },
485
465
  "rcsAccount": {
486
466
  id: `${scope}.rcsAccount`,
487
467
  defaultMessage: 'RCS account',
@@ -518,10 +498,6 @@ export default defineMessages({
518
498
  id: `${scope}.noAccountsPresentZalo`,
519
499
  defaultMessage: "Zalo accounts are not setup for your brand",
520
500
  },
521
- "noAccountsPresentWebpush": {
522
- id: `${scope}.noAccountsPresentWebpush`,
523
- defaultMessage: "Web push accounts are not setup for your brand",
524
- },
525
501
  "noAccountsPresentRcs": {
526
502
  id: `${scope}.noAccountsPresentRcs`,
527
503
  defaultMessage: "RCS accounts are not setup for your brand",
@@ -558,10 +534,6 @@ export default defineMessages({
558
534
  id: `${scope}.rcsOnlyApprovedTemplates`,
559
535
  defaultMessage: 'Only "Approved" templates are available here, as you can use those templates to create a message.',
560
536
  },
561
- "layout": {
562
- id: `${scope}.layout`,
563
- defaultMessage: `Layout`,
564
- },
565
537
  "status": {
566
538
  id: `${scope}.status`,
567
539
  defaultMessage: 'Status',
@@ -124,8 +124,6 @@ function templatesReducer(state = initialState, action) {
124
124
  return state
125
125
  .set('selectedFacebookAccount', fromJS(action.faceBookAccount))
126
126
  .set('templates', []);
127
- case types.SET_WEBPUSH_ACCOUNT:
128
- return state.set('selectedWebPushAccount', fromJS(action.account));
129
127
  case types.RESET_ACCOUNT:
130
128
  return state
131
129
  .remove('selectedWeChatAccount')
@@ -22,7 +22,6 @@ describe('Test Templates container', () => {
22
22
  const getAllTemplates = jest.fn();
23
23
  const getUserList = jest.fn();
24
24
  const getSenderDetails = jest.fn();
25
- const resetTemplate = jest.fn();
26
25
  let renderedComponent;
27
26
 
28
27
  beforeEach(() => {
@@ -55,7 +54,6 @@ describe('Test Templates container', () => {
55
54
  getAllTemplates,
56
55
  getUserList,
57
56
  getSenderDetails,
58
- resetTemplate,
59
57
  }}
60
58
  location={{
61
59
  pathname: `/${channel}`,
@@ -81,8 +79,6 @@ describe('Test Templates container', () => {
81
79
  channel: 'WHATSAPP',
82
80
  orgUnitId: -1,
83
81
  });
84
- // resetTemplate should be called when entering account selection mode
85
- expect(resetTemplate).toHaveBeenCalled();
86
82
  });
87
83
 
88
84
  it('Should render temlates when whatsapp templates are passed', () => {
@@ -107,8 +103,6 @@ describe('Test Templates container', () => {
107
103
  Templates: {},
108
104
  });
109
105
  expect(renderedComponent).toMatchSnapshot();
110
- // SMS doesn't enter account selection mode, so resetTemplate shouldn't be called on mount
111
- expect(resetTemplate).not.toHaveBeenCalled();
112
106
  });
113
107
 
114
108
  it('Should render temlates when whatsapp templates are passed in full mode', () => {
@@ -129,8 +123,6 @@ describe('Test Templates container', () => {
129
123
  it('Should render correct component for zalo channel', () => {
130
124
  RenderFunctionFor('zalo');
131
125
  expect(renderedComponent).toMatchSnapshot();
132
- // resetTemplate should be called when entering account selection mode
133
- expect(resetTemplate).toHaveBeenCalled();
134
126
  });
135
127
  it('Should render temlates when zalo templates are passed', () => {
136
128
  RenderFunctionFor('zalo');
@@ -209,8 +201,6 @@ describe('Test Templates container', () => {
209
201
  channel: 'RCS',
210
202
  orgUnitId: -1,
211
203
  });
212
- // resetTemplate should be called when entering account selection mode
213
- expect(resetTemplate).toHaveBeenCalled();
214
204
  });
215
205
 
216
206
  it('Should render templates when RCS templates are passed', () => {
@@ -14,10 +14,8 @@ export default css`
14
14
  margin: 0 auto;
15
15
  width: 100%;
16
16
  padding: ${CAP_SPACE_24} 0;
17
- /* Only main channel tabs content, not HTML Editor validation panel tabs */
18
- > .cap-tab-v2 > .ant-tabs-content-holder > .ant-tabs-content,
19
- > .cap-tab-v2 > .ant-tabs-content {
20
- margin-top: ${CAP_SPACE_16};
17
+ .ant-tabs-content{
18
+ margin-top: ${CAP_SPACE_16}
21
19
  }
22
20
  ` : `.cap-tab-v2 {
23
21
  height: calc(100vh - 11.25rem);
@@ -30,11 +30,11 @@ import FTP from '../FTP';
30
30
  import Gallery from '../Assets/Gallery';
31
31
  import withStyles from '../../hoc/withStyles';
32
32
  import styles, { CapTabStyle } from './TemplatesV2.style';
33
- import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, JP_LOCALE_HIDE_FEATURE, ZALO, INAPP, WEBPUSH } from '../App/constants';
33
+ import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, JP_LOCALE_HIDE_FEATURE, ZALO, INAPP } from '../App/constants';
34
34
  import AccessForbidden from '../../v2Components/AccessForbidden';
35
35
  import { getObjFromQueryParams } from '../../utils/v2common';
36
36
  import { makeSelectAuthenticated, selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
37
- import { LOYALTY_SUPPORTED_ACTION, COMMON_CHANNELS } from "../CreativesContainer/constants";
37
+ import { LOYALTY_SUPPORTED_ACTION } from "../CreativesContainer/constants";
38
38
 
39
39
  const {CapCustomCardList} = CapCustomCard;
40
40
 
@@ -65,13 +65,6 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
65
65
  email: {content: <></>, tab: intl.formatMessage(messages.email), key: 'email'},
66
66
  //'wechat': {content: this.getTemplatesComponent('wechat'), tab: 'Wechat', key: 'wechat'},
67
67
  mPush: {content: <></>, tab: intl.formatMessage(messages.pushNotification), key: 'mobilepush'},
68
- ...(commonUtil.hasWebPushFeatureEnabled() ? {
69
- webpush: {
70
- content: <div></div>,
71
- tab: intl.formatMessage(messages.webPush),
72
- key: WEBPUSH,
73
- }
74
- } : {}),
75
68
  viber: {content: <></>, tab: intl.formatMessage(messages.viber), key: 'viber'},
76
69
  whatsapp: { content: <></>, tab: intl.formatMessage(messages.whatsapp), key: WHATSAPP },
77
70
  zalo: { content: <div></div>, tab: intl.formatMessage(messages.zalo), key: ZALO },
@@ -95,7 +88,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
95
88
  return obj;
96
89
  }, []);
97
90
 
98
- if (isFullMode ) {
91
+ if (isFullMode ) {
99
92
  filteredPanes.push({content: <div></div>, tab: intl.formatMessage(messages.gallery), key: 'assets'});
100
93
  } else {
101
94
  if (!channelsToHide.includes('callTask')) {
@@ -105,19 +98,18 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
105
98
  filteredPanes.push({content: <></>, tab: intl.formatMessage(messages.FTP), key: 'ftp'});
106
99
  defaultChannel = 'FTP';
107
100
  }
101
+ const commonChannels = ['sms', 'email', 'wechat', 'mobilepush', 'line', 'viber', 'facebook', 'call_task', 'ftp', 'assets'];
108
102
 
109
- // Create a local copy of COMMON_CHANNELS to avoid mutating the imported array
110
- const channels = [...COMMON_CHANNELS];
111
103
  const { actionName = ''} = loyaltyMetaData;
112
104
  if (isLoyaltyModule && actionName === LOYALTY_SUPPORTED_ACTION) {
113
- channels.push(WHATSAPP, ZALO);
105
+ commonChannels.push(WHATSAPP, ZALO);
114
106
  }
115
107
 
116
- // we only show channels which other than COMMON_CHANNELS
108
+ // we only show channels which other than commonChannels
117
109
  // if it is coming in enableNewChannels array
118
110
  filteredPanes = filteredPanes.filter((item) => {
119
111
  const channel = item.key;
120
- if (!channels.includes(channel)) {
112
+ if (!commonChannels.includes(channel)) {
121
113
  return enableNewChannels.includes(channel.toUpperCase());
122
114
  }
123
115
  return true;
@@ -86,8 +86,4 @@ export default defineMessages({
86
86
  id: `creatives.containersV2.TemplatesV2.inapp`,
87
87
  defaultMessage: 'In app message',
88
88
  },
89
- webPush: {
90
- id: `creatives.containersV2.TemplatesV2.webPush`,
91
- defaultMessage: 'Web Push',
92
- },
93
89
  });
@@ -2281,7 +2281,6 @@ new message content.",
2281
2281
  "email": [Function],
2282
2282
  "facebookPreview": [Function],
2283
2283
  "gallery": [Function],
2284
- "inApp": [Function],
2285
2284
  "language": [Function],
2286
2285
  "navigationConfig": [Function],
2287
2286
  "previewAndTest": [Function],
@@ -23690,7 +23689,6 @@ new message content.",
23690
23689
  "email": [Function],
23691
23690
  "facebookPreview": [Function],
23692
23691
  "gallery": [Function],
23693
- "inApp": [Function],
23694
23692
  "language": [Function],
23695
23693
  "navigationConfig": [Function],
23696
23694
  "previewAndTest": [Function],
@@ -47215,7 +47213,6 @@ new message content.",
47215
47213
  "email": [Function],
47216
47214
  "facebookPreview": [Function],
47217
47215
  "gallery": [Function],
47218
- "inApp": [Function],
47219
47216
  "language": [Function],
47220
47217
  "navigationConfig": [Function],
47221
47218
  "previewAndTest": [Function],
@@ -71728,7 +71725,6 @@ new message content.",
71728
71725
  "email": [Function],
71729
71726
  "facebookPreview": [Function],
71730
71727
  "gallery": [Function],
71731
- "inApp": [Function],
71732
71728
  "language": [Function],
71733
71729
  "navigationConfig": [Function],
71734
71730
  "previewAndTest": [Function],
@@ -98538,7 +98534,6 @@ new message content.",
98538
98534
  "email": [Function],
98539
98535
  "facebookPreview": [Function],
98540
98536
  "gallery": [Function],
98541
- "inApp": [Function],
98542
98537
  "language": [Function],
98543
98538
  "navigationConfig": [Function],
98544
98539
  "previewAndTest": [Function],
@@ -119977,7 +119972,6 @@ new message content.",
119977
119972
  "email": [Function],
119978
119973
  "facebookPreview": [Function],
119979
119974
  "gallery": [Function],
119980
- "inApp": [Function],
119981
119975
  "language": [Function],
119982
119976
  "navigationConfig": [Function],
119983
119977
  "previewAndTest": [Function],
@@ -141386,7 +141380,6 @@ new message content.",
141386
141380
  "email": [Function],
141387
141381
  "facebookPreview": [Function],
141388
141382
  "gallery": [Function],
141389
- "inApp": [Function],
141390
141383
  "language": [Function],
141391
141384
  "navigationConfig": [Function],
141392
141385
  "previewAndTest": [Function],
@@ -166807,7 +166800,6 @@ new message content.",
166807
166800
  "email": [Function],
166808
166801
  "facebookPreview": [Function],
166809
166802
  "gallery": [Function],
166810
- "inApp": [Function],
166811
166803
  "language": [Function],
166812
166804
  "navigationConfig": [Function],
166813
166805
  "previewAndTest": [Function],
@@ -193216,7 +193208,6 @@ new message content.",
193216
193208
  "email": [Function],
193217
193209
  "facebookPreview": [Function],
193218
193210
  "gallery": [Function],
193219
- "inApp": [Function],
193220
193211
  "language": [Function],
193221
193212
  "navigationConfig": [Function],
193222
193213
  "previewAndTest": [Function],
@@ -221922,7 +221913,6 @@ new message content.",
221922
221913
  "email": [Function],
221923
221914
  "facebookPreview": [Function],
221924
221915
  "gallery": [Function],
221925
- "inApp": [Function],
221926
221916
  "language": [Function],
221927
221917
  "navigationConfig": [Function],
221928
221918
  "previewAndTest": [Function],
@@ -251610,7 +251600,6 @@ new message content.",
251610
251600
  "email": [Function],
251611
251601
  "facebookPreview": [Function],
251612
251602
  "gallery": [Function],
251613
- "inApp": [Function],
251614
251603
  "language": [Function],
251615
251604
  "navigationConfig": [Function],
251616
251605
  "previewAndTest": [Function],
@@ -267364,7 +267353,6 @@ new message content.",
267364
267353
  "email": [Function],
267365
267354
  "facebookPreview": [Function],
267366
267355
  "gallery": [Function],
267367
- "inApp": [Function],
267368
267356
  "language": [Function],
267369
267357
  "navigationConfig": [Function],
267370
267358
  "previewAndTest": [Function],
@@ -281969,7 +281957,6 @@ new message content.",
281969
281957
  "email": [Function],
281970
281958
  "facebookPreview": [Function],
281971
281959
  "gallery": [Function],
281972
- "inApp": [Function],
281973
281960
  "language": [Function],
281974
281961
  "navigationConfig": [Function],
281975
281962
  "previewAndTest": [Function],
@@ -298681,7 +298668,6 @@ new message content.",
298681
298668
  "email": [Function],
298682
298669
  "facebookPreview": [Function],
298683
298670
  "gallery": [Function],
298684
- "inApp": [Function],
298685
298671
  "language": [Function],
298686
298672
  "navigationConfig": [Function],
298687
298673
  "previewAndTest": [Function],
@@ -322730,7 +322716,6 @@ new message content.",
322730
322716
  "email": [Function],
322731
322717
  "facebookPreview": [Function],
322732
322718
  "gallery": [Function],
322733
- "inApp": [Function],
322734
322719
  "language": [Function],
322735
322720
  "navigationConfig": [Function],
322736
322721
  "previewAndTest": [Function],
@@ -350369,7 +350354,6 @@ new message content.",
350369
350354
  "email": [Function],
350370
350355
  "facebookPreview": [Function],
350371
350356
  "gallery": [Function],
350372
- "inApp": [Function],
350373
350357
  "language": [Function],
350374
350358
  "navigationConfig": [Function],
350375
350359
  "previewAndTest": [Function],
@@ -366694,7 +366678,6 @@ new message content.",
366694
366678
  "email": [Function],
366695
366679
  "facebookPreview": [Function],
366696
366680
  "gallery": [Function],
366697
- "inApp": [Function],
366698
366681
  "language": [Function],
366699
366682
  "navigationConfig": [Function],
366700
366683
  "previewAndTest": [Function],
@@ -388103,7 +388086,6 @@ new message content.",
388103
388086
  "email": [Function],
388104
388087
  "facebookPreview": [Function],
388105
388088
  "gallery": [Function],
388106
- "inApp": [Function],
388107
388089
  "language": [Function],
388108
388090
  "navigationConfig": [Function],
388109
388091
  "previewAndTest": [Function],
@@ -413524,7 +413506,6 @@ new message content.",
413524
413506
  "email": [Function],
413525
413507
  "facebookPreview": [Function],
413526
413508
  "gallery": [Function],
413527
- "inApp": [Function],
413528
413509
  "language": [Function],
413529
413510
  "navigationConfig": [Function],
413530
413511
  "previewAndTest": [Function],
@@ -434933,7 +434914,6 @@ new message content.",
434933
434914
  "email": [Function],
434934
434915
  "facebookPreview": [Function],
434935
434916
  "gallery": [Function],
434936
- "inApp": [Function],
434937
434917
  "language": [Function],
434938
434918
  "navigationConfig": [Function],
434939
434919
  "previewAndTest": [Function],
@@ -457162,7 +457142,6 @@ new message content.",
457162
457142
  "email": [Function],
457163
457143
  "facebookPreview": [Function],
457164
457144
  "gallery": [Function],
457165
- "inApp": [Function],
457166
457145
  "language": [Function],
457167
457146
  "navigationConfig": [Function],
457168
457147
  "previewAndTest": [Function],
@@ -480214,7 +480193,6 @@ new message content.",
480214
480193
  "email": [Function],
480215
480194
  "facebookPreview": [Function],
480216
480195
  "gallery": [Function],
480217
- "inApp": [Function],
480218
480196
  "language": [Function],
480219
480197
  "navigationConfig": [Function],
480220
480198
  "previewAndTest": [Function],
@@ -504086,7 +504064,6 @@ new message content.",
504086
504064
  "email": [Function],
504087
504065
  "facebookPreview": [Function],
504088
504066
  "gallery": [Function],
504089
- "inApp": [Function],
504090
504067
  "language": [Function],
504091
504068
  "navigationConfig": [Function],
504092
504069
  "previewAndTest": [Function],
@@ -528801,7 +528778,6 @@ new message content.",
528801
528778
  "email": [Function],
528802
528779
  "facebookPreview": [Function],
528803
528780
  "gallery": [Function],
528804
- "inApp": [Function],
528805
528781
  "language": [Function],
528806
528782
  "navigationConfig": [Function],
528807
528783
  "previewAndTest": [Function],
@@ -554356,7 +554332,6 @@ new message content.",
554356
554332
  "email": [Function],
554357
554333
  "facebookPreview": [Function],
554358
554334
  "gallery": [Function],
554359
- "inApp": [Function],
554360
554335
  "language": [Function],
554361
554336
  "navigationConfig": [Function],
554362
554337
  "previewAndTest": [Function],
@@ -580742,7 +580717,6 @@ new message content.",
580742
580717
  "email": [Function],
580743
580718
  "facebookPreview": [Function],
580744
580719
  "gallery": [Function],
580745
- "inApp": [Function],
580746
580720
  "language": [Function],
580747
580721
  "navigationConfig": [Function],
580748
580722
  "previewAndTest": [Function],
@@ -607959,7 +607933,6 @@ new message content.",
607959
607933
  "email": [Function],
607960
607934
  "facebookPreview": [Function],
607961
607935
  "gallery": [Function],
607962
- "inApp": [Function],
607963
607936
  "language": [Function],
607964
607937
  "navigationConfig": [Function],
607965
607938
  "previewAndTest": [Function],
@@ -635988,7 +635961,6 @@ new message content.",
635988
635961
  "email": [Function],
635989
635962
  "facebookPreview": [Function],
635990
635963
  "gallery": [Function],
635991
- "inApp": [Function],
635992
635964
  "language": [Function],
635993
635965
  "navigationConfig": [Function],
635994
635966
  "previewAndTest": [Function],
@@ -658258,7 +658230,6 @@ new message content.",
658258
658230
  "email": [Function],
658259
658231
  "facebookPreview": [Function],
658260
658232
  "gallery": [Function],
658261
- "inApp": [Function],
658262
658233
  "language": [Function],
658263
658234
  "navigationConfig": [Function],
658264
658235
  "previewAndTest": [Function],
@@ -681355,7 +681326,6 @@ new message content.",
681355
681326
  "email": [Function],
681356
681327
  "facebookPreview": [Function],
681357
681328
  "gallery": [Function],
681358
- "inApp": [Function],
681359
681329
  "language": [Function],
681360
681330
  "navigationConfig": [Function],
681361
681331
  "previewAndTest": [Function],
@@ -705343,7 +705313,6 @@ new message content.",
705343
705313
  "email": [Function],
705344
705314
  "facebookPreview": [Function],
705345
705315
  "gallery": [Function],
705346
- "inApp": [Function],
705347
705316
  "language": [Function],
705348
705317
  "navigationConfig": [Function],
705349
705318
  "previewAndTest": [Function],
@@ -726752,7 +726721,6 @@ new message content.",
726752
726721
  "email": [Function],
726753
726722
  "facebookPreview": [Function],
726754
726723
  "gallery": [Function],
726755
- "inApp": [Function],
726756
726724
  "language": [Function],
726757
726725
  "navigationConfig": [Function],
726758
726726
  "previewAndTest": [Function],
@@ -751488,7 +751456,6 @@ new message content.",
751488
751456
  "email": [Function],
751489
751457
  "facebookPreview": [Function],
751490
751458
  "gallery": [Function],
751491
- "inApp": [Function],
751492
751459
  "language": [Function],
751493
751460
  "navigationConfig": [Function],
751494
751461
  "previewAndTest": [Function],
@@ -776332,7 +776299,6 @@ new message content.",
776332
776299
  "email": [Function],
776333
776300
  "facebookPreview": [Function],
776334
776301
  "gallery": [Function],
776335
- "inApp": [Function],
776336
776302
  "language": [Function],
776337
776303
  "navigationConfig": [Function],
776338
776304
  "previewAndTest": [Function],
@@ -1,141 +0,0 @@
1
- /**
2
- * Utility functions for uploading images from URLs
3
- *
4
- * NOTE: CORS-limited; will be replaced with backend implementation.
5
- * Flow currently hidden (not removed) from frontend.
6
- */
7
-
8
- import {
9
- DEFAULT_ALLOWED_CONTENT_TYPES,
10
- MIME_TYPE_TO_EXTENSION,
11
- DEFAULT_IMAGE_EXTENSION,
12
- } from '../v2Components/CapImageUrlUpload/constants';
13
-
14
- /**
15
- * Fetches an image from a URL
16
- *
17
- * @param {string} url - The image URL to fetch
18
- * @returns {Promise<Response>} - The fetch response object
19
- * @throws {Error} - If the fetch fails (network/CORS error)
20
- */
21
- export const fetchImageFromUrl = async (url) => {
22
- const trimmedUrl = url?.trim() || '';
23
-
24
- if (!trimmedUrl) {
25
- throw new Error('URL is required');
26
- }
27
-
28
- // CORS-limited: fails for images without proper CORS headers
29
- const response = await fetch(trimmedUrl, {
30
- method: 'GET',
31
- redirect: 'follow',
32
- mode: 'cors',
33
- });
34
-
35
- if (!response.ok) {
36
- throw new Error(`Failed to fetch image: ${response.status} ${response.statusText}`);
37
- }
38
-
39
- return response;
40
- };
41
-
42
- /**
43
- * Helper function to upload image from URL
44
- * Fetches image, validates content type and size, converts to File, and uploads via uploadAsset
45
- *
46
- * @param {string} url - The image URL to upload
47
- * @param {Function} formatMessage - React Intl formatMessage function
48
- * @param {Object} messages - React Intl messages object
49
- * @param {Function} uploadAssetFn - Function to upload the asset (file, type, fileParams)
50
- * @param {string} fileNamePrefix - Prefix for the generated file name
51
- * @param {number} maxSize - Maximum file size in bytes
52
- * @param {string[]} allowedContentTypes - Array of allowed MIME types (defaults to DEFAULT_ALLOWED_CONTENT_TYPES)
53
- * @returns {Promise<{success: boolean, error: string}>} - Result object with success status and error message
54
- *
55
- * @example
56
- * const result = await uploadImageFromUrlHelper(
57
- * 'https://example.com/image.jpg',
58
- * formatMessage,
59
- * messages,
60
- * uploadAsset,
61
- * 'my-image',
62
- * 5000000,
63
- * ['image/jpeg', 'image/png']
64
- * );
65
- */
66
- export const uploadImageFromUrlHelper = async (
67
- url,
68
- formatMessage,
69
- messages,
70
- uploadAssetFn,
71
- fileNamePrefix,
72
- maxSize,
73
- allowedContentTypes = DEFAULT_ALLOWED_CONTENT_TYPES,
74
- ) => {
75
- const trimmedUrl = url?.trim() || '';
76
-
77
- try {
78
- const response = await fetchImageFromUrl(trimmedUrl);
79
-
80
- // Validate Content-Type
81
- const contentType = response.headers?.get('Content-Type') || '';
82
- const normalizedContentType = contentType.split(';')[0].toLowerCase().trim();
83
-
84
- if (!allowedContentTypes.includes(normalizedContentType)) {
85
- return {
86
- success: false,
87
- error: formatMessage(messages.imageTypeInvalid),
88
- };
89
- }
90
-
91
- const blob = await response.blob();
92
-
93
- if (blob.size > maxSize) {
94
- return {
95
- success: false,
96
- error: formatMessage(messages.imageSizeInvalid),
97
- };
98
- }
99
-
100
- // Load image to get dimensions and verify validity
101
- return new Promise((resolve) => {
102
- const img = new Image();
103
- const objectUrl = URL.createObjectURL(blob);
104
-
105
- img.onload = () => {
106
- const extension = MIME_TYPE_TO_EXTENSION[normalizedContentType] || DEFAULT_IMAGE_EXTENSION;
107
- const fileName = `${fileNamePrefix}.${extension}`;
108
- const file = new File([blob], fileName, { type: blob.type });
109
- const fileParams = {
110
- width: img.width,
111
- height: img.height,
112
- error: false,
113
- };
114
-
115
- uploadAssetFn(file, 'image', fileParams);
116
- URL.revokeObjectURL(objectUrl);
117
-
118
- resolve({
119
- success: true,
120
- error: '',
121
- });
122
- };
123
-
124
- img.onerror = () => {
125
- URL.revokeObjectURL(objectUrl);
126
- resolve({
127
- success: false,
128
- error: formatMessage(messages.imageLoadError),
129
- });
130
- };
131
-
132
- img.src = objectUrl;
133
- });
134
- } catch (error) {
135
- return {
136
- success: false,
137
- error: formatMessage(messages.imageLoadError),
138
- };
139
- }
140
- };
141
-
@@ -1,26 +0,0 @@
1
- // Default allowed content types for image URL validation
2
- export const DEFAULT_ALLOWED_CONTENT_TYPES = ['image/jpeg', 'image/jpg', 'image/png'];
3
-
4
- // Default maximum file size (5MB)
5
- export const DEFAULT_MAX_SIZE = 5000000;
6
-
7
- // Default allowed extensions regex
8
- export const DEFAULT_ALLOWED_EXTENSIONS_REGEX = /\.(jpe?g|png)$/i;
9
-
10
- // MIME type to file extension mapping
11
- export const MIME_TYPE_TO_EXTENSION = {
12
- 'image/jpeg': 'jpg',
13
- 'image/jpg': 'jpg',
14
- 'image/png': 'png',
15
- };
16
-
17
- // Default image extension fallback
18
- export const DEFAULT_IMAGE_EXTENSION = 'png';
19
-
20
- // Upload status state machine states
21
- export const UPLOAD_STATUS = {
22
- IDLE: 'idle',
23
- UPLOADING: 'uploading',
24
- WAITING: 'waiting',
25
- };
26
-