@capillarytech/creatives-library 8.0.242-alpha.10 → 8.0.242-alpha.11
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.
- package/assets/Android.png +0 -0
- package/assets/iOS.png +0 -0
- package/config/app.js +1 -1
- package/constants/unified.js +2 -2
- package/initialReducer.js +0 -2
- package/package.json +1 -1
- package/services/api.js +5 -10
- package/services/tests/api.test.js +0 -18
- package/translations/en.json +4 -3
- package/utils/common.js +6 -5
- package/utils/commonUtils.js +1 -14
- package/utils/imageUrlUpload.js +141 -0
- package/utils/tests/commonUtil.test.js +0 -224
- package/utils/transformTemplateConfig.js +10 -0
- package/v2Components/CapDeviceContent/index.js +56 -61
- package/v2Components/CapImageUpload/constants.js +2 -0
- package/v2Components/CapImageUpload/index.js +65 -16
- package/v2Components/CapImageUpload/index.scss +4 -1
- package/v2Components/CapImageUpload/messages.js +5 -1
- package/v2Components/CapImageUrlUpload/constants.js +26 -0
- package/v2Components/CapImageUrlUpload/index.js +365 -0
- package/v2Components/CapImageUrlUpload/index.scss +35 -0
- package/v2Components/CapImageUrlUpload/messages.js +47 -0
- package/v2Components/CapTagList/index.js +1 -6
- package/v2Components/CapTagListWithInput/index.js +1 -5
- package/v2Components/CapTagListWithInput/messages.js +1 -1
- package/v2Components/CapWhatsappCTA/tests/index.test.js +0 -5
- package/v2Components/ErrorInfoNote/index.js +72 -412
- package/v2Components/ErrorInfoNote/messages.js +0 -22
- package/v2Components/ErrorInfoNote/style.scss +2 -279
- package/v2Components/HtmlEditor/HTMLEditor.js +91 -220
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +133 -1132
- package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +12 -17
- package/v2Components/HtmlEditor/_htmlEditor.scss +45 -107
- package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
- package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +101 -13
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +139 -148
- package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +1 -2
- package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
- package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +0 -9
- package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
- package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +0 -22
- package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +7 -4
- package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +45 -35
- package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +3 -1
- package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
- package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +6 -7
- package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +6 -3
- package/v2Components/HtmlEditor/components/PreviewPane/index.js +11 -10
- package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +72 -70
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +31 -49
- package/v2Components/HtmlEditor/constants.js +20 -29
- package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +16 -373
- package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
- package/v2Components/HtmlEditor/hooks/useInAppContent.js +146 -88
- package/v2Components/HtmlEditor/index.js +1 -1
- package/v2Components/HtmlEditor/messages.js +85 -95
- package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +101 -99
- package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +25 -23
- package/v2Components/HtmlEditor/utils/validationAdapter.js +41 -34
- package/v2Components/MobilePushPreviewV2/index.js +7 -32
- package/v2Components/TemplatePreview/_templatePreview.scss +24 -44
- package/v2Components/TemplatePreview/index.js +32 -47
- package/v2Components/TemplatePreview/messages.js +0 -4
- package/v2Components/TestAndPreviewSlidebox/index.js +25 -31
- package/v2Containers/App/constants.js +5 -0
- package/v2Containers/BeeEditor/index.js +80 -82
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +4 -3
- package/v2Containers/CreativesContainer/SlideBoxContent.js +118 -148
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +3 -9
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -2
- package/v2Containers/CreativesContainer/constants.js +2 -1
- package/v2Containers/CreativesContainer/index.js +41 -173
- package/v2Containers/CreativesContainer/messages.js +4 -4
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +210 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +354 -38
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -36
- package/v2Containers/Email/actions.js +0 -7
- package/v2Containers/Email/constants.js +1 -5
- package/v2Containers/Email/index.js +0 -13
- package/v2Containers/Email/messages.js +0 -32
- package/v2Containers/Email/reducer.js +1 -12
- package/v2Containers/Email/sagas.js +6 -41
- package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +0 -2
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +7 -193
- package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +74 -40
- package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +67 -2
- package/v2Containers/EmailWrapper/constants.js +0 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +67 -436
- package/v2Containers/EmailWrapper/index.js +23 -99
- package/v2Containers/EmailWrapper/messages.js +1 -61
- package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +214 -0
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +77 -111
- package/v2Containers/InApp/actions.js +0 -7
- package/v2Containers/InApp/constants.js +4 -20
- package/v2Containers/InApp/index.js +357 -801
- package/v2Containers/InApp/index.scss +3 -4
- package/v2Containers/InApp/messages.js +3 -7
- package/v2Containers/InApp/reducer.js +3 -21
- package/v2Containers/InApp/sagas.js +9 -29
- package/v2Containers/InApp/selectors.js +5 -25
- package/v2Containers/InApp/tests/index.test.js +50 -154
- package/v2Containers/InApp/tests/reducer.test.js +0 -34
- package/v2Containers/InApp/tests/sagas.test.js +9 -61
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +12 -12
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +8 -8
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +100 -77
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +72 -63
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +184 -150
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +16 -12
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +32 -28
- package/v2Containers/TagList/index.js +1 -67
- package/v2Containers/Templates/ChannelTypeIllustration.js +13 -1
- package/v2Containers/Templates/_templates.scss +202 -56
- package/v2Containers/Templates/actions.js +2 -1
- package/v2Containers/Templates/constants.js +1 -0
- package/v2Containers/Templates/index.js +278 -128
- package/v2Containers/Templates/messages.js +24 -4
- package/v2Containers/Templates/reducer.js +2 -0
- package/v2Containers/Templates/tests/index.test.js +10 -0
- package/v2Containers/TemplatesV2/index.js +8 -1
- package/v2Containers/TemplatesV2/messages.js +4 -0
- package/v2Containers/WebPush/Create/components/BrandIconSection.js +108 -0
- package/v2Containers/WebPush/Create/components/ButtonForm.js +172 -0
- package/v2Containers/WebPush/Create/components/ButtonItem.js +101 -0
- package/v2Containers/WebPush/Create/components/ButtonList.js +145 -0
- package/v2Containers/WebPush/Create/components/ButtonsLinksSection.js +164 -0
- package/v2Containers/WebPush/Create/components/ButtonsLinksSection.test.js +463 -0
- package/v2Containers/WebPush/Create/components/FormActions.js +54 -0
- package/v2Containers/WebPush/Create/components/FormActions.test.js +163 -0
- package/v2Containers/WebPush/Create/components/MediaSection.js +142 -0
- package/v2Containers/WebPush/Create/components/MediaSection.test.js +341 -0
- package/v2Containers/WebPush/Create/components/MessageSection.js +103 -0
- package/v2Containers/WebPush/Create/components/MessageSection.test.js +268 -0
- package/v2Containers/WebPush/Create/components/NotificationTitleSection.js +87 -0
- package/v2Containers/WebPush/Create/components/NotificationTitleSection.test.js +210 -0
- package/v2Containers/WebPush/Create/components/TemplateNameSection.js +54 -0
- package/v2Containers/WebPush/Create/components/TemplateNameSection.test.js +143 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/ButtonsLinksSection.test.js.snap +86 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/FormActions.test.js.snap +16 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/MediaSection.test.js.snap +41 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +54 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/NotificationTitleSection.test.js.snap +37 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/TemplateNameSection.test.js.snap +21 -0
- package/v2Containers/WebPush/Create/components/_buttons.scss +246 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +554 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +607 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +633 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +666 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +74 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +78 -0
- package/v2Containers/WebPush/Create/hooks/useButtonManagement.js +138 -0
- package/v2Containers/WebPush/Create/hooks/useButtonManagement.test.js +406 -0
- package/v2Containers/WebPush/Create/hooks/useCharacterCount.js +30 -0
- package/v2Containers/WebPush/Create/hooks/useCharacterCount.test.js +151 -0
- package/v2Containers/WebPush/Create/hooks/useImageUpload.js +104 -0
- package/v2Containers/WebPush/Create/hooks/useImageUpload.test.js +538 -0
- package/v2Containers/WebPush/Create/hooks/useTagManagement.js +122 -0
- package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +633 -0
- package/v2Containers/WebPush/Create/index.js +1056 -0
- package/v2Containers/WebPush/Create/index.scss +134 -0
- package/v2Containers/WebPush/Create/messages.js +203 -0
- package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +228 -0
- package/v2Containers/WebPush/Create/preview/NotificationContainer.js +294 -0
- package/v2Containers/WebPush/Create/preview/PreviewContent.js +90 -0
- package/v2Containers/WebPush/Create/preview/PreviewControls.js +305 -0
- package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +23 -0
- package/v2Containers/WebPush/Create/preview/WebPushPreview.js +150 -0
- package/v2Containers/WebPush/Create/preview/assets/Light.svg +53 -0
- package/v2Containers/WebPush/Create/preview/assets/Top.svg +5 -0
- package/v2Containers/WebPush/Create/preview/assets/android-arrow-down.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/android-arrow-up.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/chrome-icon.png +0 -0
- package/v2Containers/WebPush/Create/preview/assets/edge-icon.png +0 -0
- package/v2Containers/WebPush/Create/preview/assets/firefox-icon.svg +106 -0
- package/v2Containers/WebPush/Create/preview/assets/iOS.svg +26 -0
- package/v2Containers/WebPush/Create/preview/assets/macos-arrow-down-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/macos-triple-dot-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +18 -0
- package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +29 -0
- package/v2Containers/WebPush/Create/preview/assets/windows-close-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/windows-triple-dot-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +47 -0
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +141 -0
- package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +45 -0
- package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +68 -0
- package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +61 -0
- package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +99 -0
- package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +733 -0
- package/v2Containers/WebPush/Create/preview/components/tests/WindowsChromeExpanded.test.js +571 -0
- package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +81 -0
- package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/WindowsChromeExpanded.test.js.snap +81 -0
- package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +50 -0
- package/v2Containers/WebPush/Create/preview/constants.js +637 -0
- package/v2Containers/WebPush/Create/preview/notification-container.scss +79 -0
- package/v2Containers/WebPush/Create/preview/preview.scss +351 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +370 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +47 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_base.scss +207 -0
- package/v2Containers/WebPush/Create/preview/styles/_ios.scss +153 -0
- package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +107 -0
- package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +101 -0
- package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +229 -0
- package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +909 -0
- package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +1081 -0
- package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +723 -0
- package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +943 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +131 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +112 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +144 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +129 -0
- package/v2Containers/WebPush/Create/utils/payloadBuilder.js +94 -0
- package/v2Containers/WebPush/Create/utils/payloadBuilder.test.js +390 -0
- package/v2Containers/WebPush/Create/utils/previewUtils.js +89 -0
- package/v2Containers/WebPush/Create/utils/urlValidation.js +115 -0
- package/v2Containers/WebPush/Create/utils/urlValidation.test.js +449 -0
- package/v2Containers/WebPush/Create/utils/validation.js +75 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +283 -0
- package/v2Containers/WebPush/actions.js +60 -0
- package/v2Containers/WebPush/constants.js +128 -0
- package/v2Containers/WebPush/index.js +2 -0
- package/v2Containers/WebPush/reducer.js +104 -0
- package/v2Containers/WebPush/sagas.js +119 -0
- package/v2Containers/WebPush/selectors.js +65 -0
- package/v2Containers/WebPush/tests/reducer.test.js +863 -0
- package/v2Containers/WebPush/tests/sagas.test.js +566 -0
- package/v2Containers/WebPush/tests/selectors.test.js +843 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +528 -431
- package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +0 -254
- package/v2Components/HtmlEditor/components/ValidationTabs/index.js +0 -362
- package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +0 -51
- package/v2Containers/BeePopupEditor/constants.js +0 -10
- package/v2Containers/BeePopupEditor/index.js +0 -193
- package/v2Containers/BeePopupEditor/tests/index.test.js +0 -627
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1046
- package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +0 -376
- package/v2Containers/InApp/__tests__/sagas.test.js +0 -363
- package/v2Containers/InApp/tests/selectors.test.js +0 -612
- package/v2Containers/InAppWrapper/components/InAppWrapperView.js +0 -162
- package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +0 -267
- package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +0 -9
- package/v2Containers/InAppWrapper/constants.js +0 -16
- package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +0 -473
- package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +0 -198
- package/v2Containers/InAppWrapper/index.js +0 -148
- package/v2Containers/InAppWrapper/messages.js +0 -49
- package/v2Containers/InappAdvance/index.js +0 -1099
- package/v2Containers/InappAdvance/index.scss +0 -10
- package/v2Containers/InappAdvance/tests/index.test.js +0 -448
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
useState, useEffect, useMemo, useCallback, useRef,
|
|
3
|
-
} from 'react';
|
|
1
|
+
import { useState, useEffect, useMemo, useCallback } from 'react';
|
|
4
2
|
import isEmpty from 'lodash/isEmpty';
|
|
5
|
-
import find from 'lodash/find';
|
|
6
3
|
import get from 'lodash/get';
|
|
4
|
+
import find from 'lodash/find';
|
|
7
5
|
import { GA } from '@capillarytech/cap-ui-utils';
|
|
8
6
|
import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
|
|
9
|
-
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
10
7
|
import { CHANNEL_CREATE_TRACK_MAPPING } from '../../App/constants';
|
|
11
8
|
import { gtmPush } from '../../../utils/gtmTrackers';
|
|
12
9
|
import { EMAIL } from '../../CreativesContainer/constants';
|
|
13
10
|
import messages from '../messages';
|
|
14
|
-
import { STEPS
|
|
11
|
+
import { STEPS } from '../constants';
|
|
12
|
+
import { EMAIL_CREATE_MODES } from '../constants';
|
|
15
13
|
import { containsBase64Images } from '../../../utils/content';
|
|
16
|
-
import { hasSupportCKEditor } from '../../../utils/common';
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
* Custom hook to handle EmailWrapper component business logic
|
|
@@ -59,21 +56,12 @@ const useEmailWrapper = ({
|
|
|
59
56
|
handleTestAndPreview,
|
|
60
57
|
handleCloseTestAndPreview,
|
|
61
58
|
isTestAndPreviewMode,
|
|
62
|
-
// Props for BEE enabled check
|
|
63
|
-
location,
|
|
64
|
-
emailActions,
|
|
65
|
-
Email,
|
|
66
|
-
templateData,
|
|
67
|
-
params,
|
|
68
59
|
}) => {
|
|
69
60
|
// State management
|
|
70
61
|
const [templateName, setTemplateName] = useState('');
|
|
71
62
|
const [isTemplateNameEmpty, setIsTemplateNameEmpty] = useState(true);
|
|
72
63
|
const [selectedCreateMode, setSelectedCreateMode] = useState('');
|
|
73
64
|
const [modeContent, setModeContent] = useState({});
|
|
74
|
-
const [isBeeEditorEnabled, setIsBeeEditorEnabled] = useState(null); // null = not checked yet, true/false = checked
|
|
75
|
-
const beeStatusCheckRef = useRef(false); // Track if we've made the API call for current step
|
|
76
|
-
const defaultTemplatesFetchedRef = useRef(false);
|
|
77
65
|
const [routeParams] = useState({
|
|
78
66
|
pathname: `/email/create`,
|
|
79
67
|
query: { module: 'library', type: 'embedded' },
|
|
@@ -88,7 +76,7 @@ const useEmailWrapper = ({
|
|
|
88
76
|
}, [onResetStep, templatesActions]);
|
|
89
77
|
|
|
90
78
|
// Event handlers
|
|
91
|
-
const onTemplateNameChange = useCallback(({
|
|
79
|
+
const onTemplateNameChange = useCallback(({target: {value}}) => {
|
|
92
80
|
const isEmptyTemplateName = !value?.trim();
|
|
93
81
|
setTemplateName(value);
|
|
94
82
|
setIsTemplateNameEmpty(isEmptyTemplateName);
|
|
@@ -100,123 +88,9 @@ const useEmailWrapper = ({
|
|
|
100
88
|
}
|
|
101
89
|
}, [onEnterTemplateName, onRemoveTemplateName]);
|
|
102
90
|
|
|
103
|
-
// Check BEE enabled status from API response
|
|
104
|
-
// BEE is enabled if isDragDrop is true in the API response
|
|
105
|
-
// This should work for both full mode and library mode
|
|
106
|
-
const checkBeeEditorEnabled = useCallback(() => {
|
|
107
|
-
// If we have checked the API and got a response, use that
|
|
108
|
-
if (isBeeEditorEnabled !== null) {
|
|
109
|
-
return isBeeEditorEnabled;
|
|
110
|
-
}
|
|
111
|
-
// If we haven't checked yet, return false (disabled) until API responds
|
|
112
|
-
return false;
|
|
113
|
-
}, [isBeeEditorEnabled]);
|
|
114
|
-
|
|
115
|
-
// Helper function to convert numeric templateStep to string step
|
|
116
|
-
const getStepFromTemplateStep = useCallback((templateStepValue) => {
|
|
117
|
-
// templateStep is numeric: 1 = modeSelection, 2 = templateSelection, 3 = createTemplateContent
|
|
118
|
-
if (typeof templateStepValue === 'number') {
|
|
119
|
-
switch (templateStepValue) {
|
|
120
|
-
case 1:
|
|
121
|
-
return STEPS.MODE_SELECTION;
|
|
122
|
-
case 2:
|
|
123
|
-
return STEPS.TEMPLATE_SELECTION;
|
|
124
|
-
case 3:
|
|
125
|
-
return STEPS.CREATE_TEMPLATE_CONTENT;
|
|
126
|
-
default:
|
|
127
|
-
return STEPS.MODE_SELECTION;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
// If it's already a string, return as-is
|
|
131
|
-
return templateStepValue || STEPS.MODE_SELECTION;
|
|
132
|
-
}, []);
|
|
133
|
-
|
|
134
|
-
// Convert step to string format if it's numeric
|
|
135
|
-
const currentStep = useMemo(() => getStepFromTemplateStep(step), [step, getStepFromTemplateStep]);
|
|
136
|
-
|
|
137
|
-
// Effect to check BEE enabled status via new API when entering MODE_SELECTION step
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
const supportCKEditor = hasSupportCKEditor();
|
|
140
|
-
// Only check BEE enabled status for new flow (when supportCKEditor is false)
|
|
141
|
-
// Reset the ref when step changes to MODE_SELECTION to allow API call
|
|
142
|
-
if (currentStep === STEPS.MODE_SELECTION) {
|
|
143
|
-
beeStatusCheckRef.current = false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Only check BEE enabled status for new flow (when supportCKEditor is false)
|
|
147
|
-
// Check all conditions
|
|
148
|
-
const shouldMakeCall = !supportCKEditor
|
|
149
|
-
&& currentStep === STEPS.MODE_SELECTION
|
|
150
|
-
&& !beeStatusCheckRef.current
|
|
151
|
-
&& emailActions;
|
|
152
|
-
|
|
153
|
-
if (shouldMakeCall) {
|
|
154
|
-
// Mark that we've made the API call
|
|
155
|
-
beeStatusCheckRef.current = true;
|
|
156
|
-
|
|
157
|
-
// Make API call to check BEE enabled status using new endpoint
|
|
158
|
-
emailActions.getCmsAccounts('BEE_PLUGIN');
|
|
159
|
-
}
|
|
160
|
-
}, [currentStep, emailActions]);
|
|
161
|
-
|
|
162
|
-
// Effect to update isBeeEditorEnabled based on new API response
|
|
163
|
-
// This effect watches for isBeeEnabled from the new API response
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
// Only process if we're in MODE_SELECTION step (when we're checking BEE status)
|
|
166
|
-
// Also check if we've made the API call (beeStatusCheckRef.current === true)
|
|
167
|
-
if (currentStep === STEPS.MODE_SELECTION && beeStatusCheckRef.current) {
|
|
168
|
-
// Use isBeeEnabled from the new API response
|
|
169
|
-
if (Email?.isBeeEnabled !== undefined) {
|
|
170
|
-
setIsBeeEditorEnabled(Email.isBeeEnabled);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// If API call fails, treat as disabled
|
|
174
|
-
if (Email?.fetchingCmsAccountsError && beeStatusCheckRef.current) {
|
|
175
|
-
setIsBeeEditorEnabled(false);
|
|
176
|
-
}
|
|
177
|
-
}, [Email?.isBeeEnabled, Email?.fetchingCmsAccountsError, currentStep]);
|
|
178
|
-
|
|
179
91
|
const onChange = useCallback((e) => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (value === EMAIL_CREATE_MODES.DRAG_DROP && !checkBeeEditorEnabled()) {
|
|
183
|
-
return; // Ignore selection if BEE editor is disabled
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// CRITICAL: When DRAG_DROP is selected, set selectedCreateMode to DRAG_DROP
|
|
187
|
-
// This ensures emailProps will have editor: 'BEE' and selectedEditorMode: null
|
|
188
|
-
if (value === EMAIL_CREATE_MODES.DRAG_DROP) {
|
|
189
|
-
setSelectedCreateMode(EMAIL_CREATE_MODES.DRAG_DROP);
|
|
190
|
-
} else {
|
|
191
|
-
setSelectedCreateMode(value);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const supportCKEditor = hasSupportCKEditor();
|
|
195
|
-
|
|
196
|
-
// Map new modes to existing modes for backwards compatibility
|
|
197
|
-
let mappedValue = value;
|
|
198
|
-
|
|
199
|
-
if (!supportCKEditor) {
|
|
200
|
-
// New flow: Handle HTML Editor, Drag & Drop, and Upload Zip
|
|
201
|
-
// Don't auto-navigate - wait for Next button click
|
|
202
|
-
if (value === EMAIL_CREATE_MODES.HTML_EDITOR) {
|
|
203
|
-
// HTML Editor: Map to EDITOR but skip template selection
|
|
204
|
-
mappedValue = EMAIL_CREATE_MODES.EDITOR;
|
|
205
|
-
setModeContent({ skipTemplateSelection: true });
|
|
206
|
-
} else if (value === EMAIL_CREATE_MODES.DRAG_DROP) {
|
|
207
|
-
// Drag & Drop: Map to EDITOR and show template selection
|
|
208
|
-
mappedValue = EMAIL_CREATE_MODES.EDITOR;
|
|
209
|
-
} else if (value === EMAIL_CREATE_MODES.UPLOAD) {
|
|
210
|
-
// Upload Zip: Keep as UPLOAD
|
|
211
|
-
mappedValue = EMAIL_CREATE_MODES.UPLOAD;
|
|
212
|
-
}
|
|
213
|
-
} else if (value === EMAIL_CREATE_MODES.EDITOR && showNextStep) {
|
|
214
|
-
// Legacy flow: Auto-navigate immediately (existing behavior)
|
|
215
|
-
showNextStep();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
onEmailModeChange(mappedValue, value); // Pass both mapped value and original selected mode
|
|
219
|
-
}, [onEmailModeChange, showNextStep, checkBeeEditorEnabled]);
|
|
92
|
+
onEmailModeChange(e.target.value);
|
|
93
|
+
}, [onEmailModeChange]);
|
|
220
94
|
|
|
221
95
|
const handleZipUploadError = useCallback(() => {
|
|
222
96
|
const message = {
|
|
@@ -320,12 +194,8 @@ const useEmailWrapper = ({
|
|
|
320
194
|
const data = find(CmsTemplates, { _id: id });
|
|
321
195
|
templatesActions.setEdmTemplate(data);
|
|
322
196
|
templatesActions.setBEETemplate(data);
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (!selectedCreateMode) {
|
|
326
|
-
setSelectedCreateMode(EMAIL_CREATE_MODES.EDITOR);
|
|
327
|
-
}
|
|
328
|
-
}, [CmsTemplates, templatesActions, selectedCreateMode]);
|
|
197
|
+
setSelectedCreateMode(EMAIL_CREATE_MODES.EDITOR);
|
|
198
|
+
}, [CmsTemplates, templatesActions]);
|
|
329
199
|
|
|
330
200
|
const useFileUpload = useCallback(({ file }) => {
|
|
331
201
|
setModeContent({});
|
|
@@ -339,73 +209,41 @@ const useEmailWrapper = ({
|
|
|
339
209
|
|
|
340
210
|
// Main logic effect - MOVED AFTER function declarations
|
|
341
211
|
useEffect(() => {
|
|
342
|
-
|
|
212
|
+
// Skip if user has already made a selection
|
|
213
|
+
if (selectedCreateMode) return;
|
|
343
214
|
|
|
344
215
|
// Handle different steps
|
|
345
|
-
switch (
|
|
216
|
+
switch (step) {
|
|
346
217
|
case STEPS.MODE_SELECTION:
|
|
347
218
|
if (emailCreateMode === EMAIL_CREATE_MODES.UPLOAD && !EmailLayout) {
|
|
348
219
|
// Commented out: document.getElementById('upload-email-template').click();
|
|
349
220
|
}
|
|
350
221
|
break;
|
|
351
222
|
|
|
352
|
-
case STEPS.TEMPLATE_SELECTION:
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
// NOT needed for HTML_EDITOR (goes directly to editor)
|
|
357
|
-
|
|
358
|
-
let needsTemplates = false;
|
|
359
|
-
if (supportCKEditor) {
|
|
360
|
-
// Legacy flow: only for EDITOR mode
|
|
361
|
-
needsTemplates = emailCreateMode === EMAIL_CREATE_MODES.EDITOR
|
|
362
|
-
&& !CmsTemplates
|
|
363
|
-
&& !getCmsTemplatesInProgress;
|
|
364
|
-
} else {
|
|
365
|
-
// New flow: for DRAG_DROP only (not HTML_EDITOR)
|
|
366
|
-
needsTemplates = selectedCreateMode === EMAIL_CREATE_MODES.DRAG_DROP
|
|
367
|
-
&& !CmsTemplates
|
|
368
|
-
&& !getCmsTemplatesInProgress;
|
|
369
|
-
}
|
|
223
|
+
case STEPS.TEMPLATE_SELECTION:
|
|
224
|
+
const needsTemplates = emailCreateMode === EMAIL_CREATE_MODES.EDITOR
|
|
225
|
+
&& !CmsTemplates
|
|
226
|
+
&& !getCmsTemplatesInProgress;
|
|
370
227
|
|
|
371
|
-
if (needsTemplates
|
|
228
|
+
if (needsTemplates) {
|
|
372
229
|
templatesActions.getDefaultBeeTemplates();
|
|
373
|
-
defaultTemplatesFetchedRef.current = true;
|
|
374
230
|
}
|
|
375
231
|
break;
|
|
376
|
-
}
|
|
377
232
|
|
|
378
|
-
case STEPS.CREATE_TEMPLATE_CONTENT:
|
|
233
|
+
case STEPS.CREATE_TEMPLATE_CONTENT:
|
|
379
234
|
if (emailCreateMode === EMAIL_CREATE_MODES.UPLOAD && !isEmpty(EmailLayout)) {
|
|
380
235
|
setSelectedCreateMode(EMAIL_CREATE_MODES.UPLOAD);
|
|
381
|
-
} else if (emailCreateMode === EMAIL_CREATE_MODES.EDITOR
|
|
382
|
-
|
|
383
|
-
|| selectedCreateMode === EMAIL_CREATE_MODES.EDITOR
|
|
384
|
-
|| selectedCreateMode === EMAIL_CREATE_MODES.DRAG_DROP) {
|
|
385
|
-
if (!supportCKEditor && selectedCreateMode === EMAIL_CREATE_MODES.HTML_EDITOR) {
|
|
386
|
-
// HTML Editor mode: Skip template selection, go directly to editor
|
|
387
|
-
setSelectedCreateMode(EMAIL_CREATE_MODES.HTML_EDITOR);
|
|
388
|
-
} else if (isEmpty(SelectedEdmDefaultTemplate) && modeContent.id) {
|
|
389
|
-
// Legacy EDITOR or DRAG_DROP: Need template selection
|
|
390
|
-
handleEdmDefaultTemplateSelection(modeContent.id);
|
|
391
|
-
} else if (!supportCKEditor && selectedCreateMode === EMAIL_CREATE_MODES.DRAG_DROP) {
|
|
392
|
-
// CRITICAL: Template already selected for DRAG_DROP - ensure selectedCreateMode is DRAG_DROP
|
|
393
|
-
// This ensures emailProps will have editor: 'BEE' and selectedEditorMode: null
|
|
394
|
-
setSelectedCreateMode(EMAIL_CREATE_MODES.DRAG_DROP);
|
|
395
|
-
} else {
|
|
396
|
-
// Template already selected for legacy EDITOR
|
|
397
|
-
setSelectedCreateMode(EMAIL_CREATE_MODES.EDITOR);
|
|
398
|
-
}
|
|
236
|
+
} else if (emailCreateMode === EMAIL_CREATE_MODES.EDITOR && isEmpty(SelectedEdmDefaultTemplate)) {
|
|
237
|
+
handleEdmDefaultTemplateSelection(modeContent.id);
|
|
399
238
|
}
|
|
400
239
|
break;
|
|
401
|
-
}
|
|
402
240
|
|
|
403
241
|
default:
|
|
404
242
|
// No operation for other steps
|
|
405
243
|
break;
|
|
406
244
|
}
|
|
407
245
|
}, [
|
|
408
|
-
|
|
246
|
+
step,
|
|
409
247
|
selectedCreateMode,
|
|
410
248
|
emailCreateMode,
|
|
411
249
|
EmailLayout,
|
|
@@ -414,155 +252,58 @@ const useEmailWrapper = ({
|
|
|
414
252
|
modeContent.id,
|
|
415
253
|
SelectedEdmDefaultTemplate,
|
|
416
254
|
templatesActions,
|
|
417
|
-
handleEdmDefaultTemplateSelection
|
|
255
|
+
handleEdmDefaultTemplateSelection
|
|
418
256
|
]);
|
|
419
257
|
|
|
420
|
-
// CRITICAL: Reset selectedCreateMode when templateData is cleared (new template creation)
|
|
421
|
-
// This ensures that when user creates a new template after editing, selectedCreateMode is reset
|
|
422
|
-
useEffect(() => {
|
|
423
|
-
// If templateData is cleared/null and we're not in edit mode, reset selectedCreateMode
|
|
424
|
-
const hasParamsId = params?.id
|
|
425
|
-
|| location?.query?.id
|
|
426
|
-
|| location?.params?.id
|
|
427
|
-
|| location?.pathname?.includes('/edit/');
|
|
428
|
-
const hasTemplateData = templateData && !isEmpty(templateData);
|
|
429
|
-
const isEditMode = hasParamsId || hasTemplateData;
|
|
430
|
-
|
|
431
|
-
// If we're creating a new template (no templateData and no params.id), reset selectedCreateMode
|
|
432
|
-
// BUT only if we're in MODE_SELECTION step (navigating back to start)
|
|
433
|
-
// DO NOT reset in CREATE_TEMPLATE_CONTENT - that's where we need selectedCreateMode to render the editor!
|
|
434
|
-
// Also DO NOT reset if emailCreateMode is set - it means user has made a selection
|
|
435
|
-
if (!isEditMode && !hasTemplateData && selectedCreateMode && currentStep === STEPS.MODE_SELECTION && !emailCreateMode) {
|
|
436
|
-
// Reset only when returning to MODE_SELECTION step
|
|
437
|
-
// This preserves user selection while in content creation
|
|
438
|
-
setSelectedCreateMode('');
|
|
439
|
-
}
|
|
440
|
-
}, [templateData, params?.id, location?.query?.id, location?.params?.id, location?.pathname, selectedCreateMode, templateName, currentStep, emailCreateMode]);
|
|
441
|
-
|
|
442
258
|
// Derived state
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
// Prepare props for Email component - MOVED BEFORE isShowEmailCreate to avoid circular dependency
|
|
446
|
-
const emailProps = useMemo(() => {
|
|
447
|
-
// Determine editor type and mode based on selectedCreateMode
|
|
448
|
-
let editorType = editor;
|
|
449
|
-
let selectedEditorMode = null;
|
|
450
|
-
|
|
451
|
-
if (!supportCKEditorFlag) {
|
|
452
|
-
// CRITICAL: Check selectedCreateMode FIRST to prioritize user's explicit selection
|
|
453
|
-
// This ensures DRAG_DROP selection takes precedence over edit mode detection
|
|
454
|
-
// even if templateDetails persists from a previous template
|
|
455
|
-
if (selectedCreateMode === EMAIL_CREATE_MODES.DRAG_DROP) {
|
|
456
|
-
// CRITICAL: DRAG_DROP mode always uses BEE editor
|
|
457
|
-
// This takes precedence over edit mode detection
|
|
458
|
-
editorType = 'BEE';
|
|
459
|
-
selectedEditorMode = null; // BEE uses existing flow (null indicates BEE editor)
|
|
460
|
-
} else if (selectedCreateMode === EMAIL_CREATE_MODES.HTML_EDITOR) {
|
|
461
|
-
// HTML_EDITOR mode: Always use HTML editor
|
|
462
|
-
editorType = 'HTML';
|
|
463
|
-
selectedEditorMode = EMAIL_CREATE_MODES.HTML_EDITOR;
|
|
464
|
-
} else {
|
|
465
|
-
// Check if we're editing an existing template
|
|
466
|
-
// CRITICAL: Only treat as edit mode if we have params.id (actual edit URL)
|
|
467
|
-
// Don't use templateDetails existence alone, as it might persist from previous template
|
|
468
|
-
const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
|
|
469
|
-
const hasTemplateDetails = Email?.templateDetails && !isEmpty(Email.templateDetails);
|
|
470
|
-
const hasBEETemplate = Email?.BEETemplate && !isEmpty(Email.BEETemplate);
|
|
471
|
-
// CRITICAL: Only consider it edit mode if we have params.id (actual edit URL)
|
|
472
|
-
// This prevents false edit mode detection when templateDetails persists in Redux from previous template
|
|
473
|
-
const isEditMode = hasParamsId && (hasTemplateDetails || hasBEETemplate);
|
|
474
|
-
|
|
475
|
-
if (isEditMode) {
|
|
476
|
-
// Edit mode: Determine editor based on template data
|
|
477
|
-
// Check if template was created in BEE editor
|
|
478
|
-
const editTemplateData = Email?.templateDetails || Email?.BEETemplate || templateData;
|
|
479
|
-
const isDragDrop = get(editTemplateData, 'versions.base.is_drag_drop', false)
|
|
480
|
-
|| get(editTemplateData, 'base.is_drag_drop', false)
|
|
481
|
-
|| get(editTemplateData, 'is_drag_drop', false)
|
|
482
|
-
|| get(editTemplateData, 'versions.base[0].is_drag_drop', false);
|
|
483
|
-
|
|
484
|
-
// Check if BEE is enabled for org (equivalent to checkBeeEditorAllowedForLibrary)
|
|
485
|
-
// For library mode: BEE is enabled if editor prop is "BEE"
|
|
486
|
-
// For full mode: BEE is always enabled
|
|
487
|
-
const isBeeEnabled = isFullMode || (editor === "BEE" && !isFullMode) || checkBeeEditorEnabled();
|
|
488
|
-
|
|
489
|
-
// If template was created in BEE AND BEE is enabled → open in BEE editor
|
|
490
|
-
// Otherwise → open in HTML editor (fallback)
|
|
491
|
-
// IMPORTANT: When supportCKEditor is false, default to HTML editor unless explicitly BEE
|
|
492
|
-
if (isDragDrop && isBeeEnabled) {
|
|
493
|
-
editorType = 'BEE';
|
|
494
|
-
selectedEditorMode = null; // BEE uses existing flow
|
|
495
|
-
} else {
|
|
496
|
-
// Fallback to HTML editor if BEE not enabled or template not created in BEE
|
|
497
|
-
// This ensures HTML editor is used when supportCKEditor is false
|
|
498
|
-
editorType = 'HTML';
|
|
499
|
-
selectedEditorMode = EMAIL_CREATE_MODES.HTML_EDITOR;
|
|
500
|
-
}
|
|
501
|
-
} else if (selectedCreateMode === EMAIL_CREATE_MODES.EDITOR) {
|
|
502
|
-
// EDITOR mode: Check if selected template is a BEE template
|
|
503
|
-
// When a default template is selected, it's stored in Templates.BEETemplate
|
|
504
|
-
const beeTemplate = Email?.BEETemplate || SelectedEdmDefaultTemplate;
|
|
505
|
-
const isBEETemplate = beeTemplate && (
|
|
506
|
-
get(beeTemplate, 'versions.base.is_drag_drop') === true
|
|
507
|
-
|| get(beeTemplate, 'base.is_drag_drop') === true
|
|
508
|
-
|| beeTemplate.is_drag_drop === true
|
|
509
|
-
);
|
|
510
|
-
|
|
511
|
-
if (isBEETemplate && checkBeeEditorEnabled()) {
|
|
512
|
-
// Template is BEE and BEE is enabled → use BEE editor
|
|
513
|
-
editorType = 'BEE';
|
|
514
|
-
selectedEditorMode = null; // BEE uses existing flow
|
|
515
|
-
} else {
|
|
516
|
-
// Template is not BEE or BEE is disabled → use HTML editor
|
|
517
|
-
editorType = 'HTML';
|
|
518
|
-
selectedEditorMode = EMAIL_CREATE_MODES.HTML_EDITOR;
|
|
519
|
-
}
|
|
520
|
-
} else {
|
|
521
|
-
// Default: When supportCKEditor is false and no mode selected, use HTML editor
|
|
522
|
-
editorType = 'HTML';
|
|
523
|
-
selectedEditorMode = EMAIL_CREATE_MODES.HTML_EDITOR;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
// UPLOAD mode uses existing editor prop
|
|
527
|
-
}
|
|
528
|
-
// Legacy flow (supportCKEditor is true): Use existing editor prop as-is - no changes
|
|
259
|
+
const isShowEmailCreate = !isEmpty(selectedCreateMode) && (!isEmpty(EmailLayout) || SelectedEdmDefaultTemplate);
|
|
529
260
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
261
|
+
// Memoize static data
|
|
262
|
+
const modes = useMemo(() => [
|
|
263
|
+
{
|
|
264
|
+
title: formatMessage(messages.zipUpload),
|
|
265
|
+
content: formatMessage(messages.zipUploadDesc),
|
|
266
|
+
value: EMAIL_CREATE_MODES.UPLOAD,
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
title: formatMessage(messages.useEditor),
|
|
270
|
+
content: formatMessage(messages.useEditorDesc),
|
|
271
|
+
value: EMAIL_CREATE_MODES.EDITOR,
|
|
272
|
+
},
|
|
273
|
+
], [formatMessage]);
|
|
274
|
+
|
|
275
|
+
// Prepare props for Email component
|
|
276
|
+
const emailProps = useMemo(() => ({
|
|
277
|
+
setIsLoadingContent,
|
|
278
|
+
key: "email-create-template",
|
|
279
|
+
location: routeParams,
|
|
280
|
+
route: { name: 'email' },
|
|
281
|
+
params: {},
|
|
282
|
+
isGetFormData,
|
|
283
|
+
getFormdata,
|
|
284
|
+
getFormSubscriptionData: getFormdata,
|
|
285
|
+
getDefaultTags: type,
|
|
286
|
+
isFullMode,
|
|
287
|
+
defaultData: { 'template-name': templateName },
|
|
288
|
+
cap,
|
|
289
|
+
showTemplateName,
|
|
290
|
+
showLiquidErrorInFooter,
|
|
291
|
+
onValidationFail,
|
|
292
|
+
forwardedTags,
|
|
293
|
+
selectedOfferDetails,
|
|
294
|
+
onPreviewContentClicked,
|
|
295
|
+
onTestContentClicked,
|
|
296
|
+
editor,
|
|
297
|
+
moduleType,
|
|
298
|
+
eventContextTags,
|
|
299
|
+
isLoyaltyModule,
|
|
300
|
+
showTestAndPreviewSlidebox,
|
|
301
|
+
handleTestAndPreview,
|
|
302
|
+
handleCloseTestAndPreview,
|
|
303
|
+
isTestAndPreviewMode,
|
|
304
|
+
}), [
|
|
561
305
|
setIsLoadingContent,
|
|
562
306
|
routeParams,
|
|
563
|
-
Email?.BEETemplate,
|
|
564
|
-
SelectedEdmDefaultTemplate,
|
|
565
|
-
checkBeeEditorEnabled,
|
|
566
307
|
isGetFormData,
|
|
567
308
|
getFormdata,
|
|
568
309
|
type,
|
|
@@ -584,118 +325,8 @@ const useEmailWrapper = ({
|
|
|
584
325
|
handleTestAndPreview,
|
|
585
326
|
handleCloseTestAndPreview,
|
|
586
327
|
isTestAndPreviewMode,
|
|
587
|
-
selectedCreateMode,
|
|
588
|
-
supportCKEditorFlag,
|
|
589
|
-
checkBeeEditorEnabled,
|
|
590
|
-
Email,
|
|
591
|
-
location,
|
|
592
|
-
params,
|
|
593
|
-
editor,
|
|
594
|
-
isFullMode,
|
|
595
|
-
templateData,
|
|
596
328
|
]);
|
|
597
329
|
|
|
598
|
-
const isShowEmailCreate = useMemo(() => {
|
|
599
|
-
// Check if we're in edit mode (templateDetails or BEETemplate exists, or params.id exists)
|
|
600
|
-
const hasTemplateDetails = Email?.templateDetails && !isEmpty(Email.templateDetails);
|
|
601
|
-
const hasBEETemplate = Email?.BEETemplate && !isEmpty(Email.BEETemplate);
|
|
602
|
-
const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
|
|
603
|
-
const isEditMode = hasTemplateDetails || hasBEETemplate || hasParamsId;
|
|
604
|
-
|
|
605
|
-
// In edit mode with HTML editor (when supportCKEditor is false), always show editor
|
|
606
|
-
if (!supportCKEditorFlag && isEditMode) {
|
|
607
|
-
// Check if it's explicitly BEE editor
|
|
608
|
-
const isExplicitlyBEE = emailCreateMode === EMAIL_CREATE_MODES.DRAG_DROP
|
|
609
|
-
|| (emailProps?.editor === 'BEE' && emailProps?.selectedEditorMode === null);
|
|
610
|
-
// If not BEE, show HTML editor
|
|
611
|
-
if (!isExplicitlyBEE) {
|
|
612
|
-
return true;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
if (!selectedCreateMode) return false;
|
|
617
|
-
|
|
618
|
-
// For HTML Editor (new flow): Always show editor directly without template selection
|
|
619
|
-
// This takes precedence over step check to ensure HTML Editor is shown even if step is temporarily TEMPLATE_SELECTION
|
|
620
|
-
if (!supportCKEditorFlag && selectedCreateMode === EMAIL_CREATE_MODES.HTML_EDITOR) {
|
|
621
|
-
return true;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
// CRITICAL: For DRAG_DROP mode, show template selection first (CmsTemplatesComponent)
|
|
625
|
-
// Only show editor (Email component with BEE) after template is selected
|
|
626
|
-
if (emailCreateMode === EMAIL_CREATE_MODES.DRAG_DROP || selectedCreateMode === EMAIL_CREATE_MODES.DRAG_DROP) {
|
|
627
|
-
// If we're in TEMPLATE_SELECTION step, show template selection (not email editor)
|
|
628
|
-
if (currentStep === STEPS.TEMPLATE_SELECTION) {
|
|
629
|
-
return false;
|
|
630
|
-
}
|
|
631
|
-
// After template selection, show editor when template is selected
|
|
632
|
-
return !isEmpty(SelectedEdmDefaultTemplate);
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
// If we're in TEMPLATE_SELECTION step, show template selection (not email editor)
|
|
636
|
-
// This applies to legacy Editor modes
|
|
637
|
-
if (currentStep === STEPS.TEMPLATE_SELECTION) {
|
|
638
|
-
return false;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// For Upload: Show editor when EmailLayout exists
|
|
642
|
-
if (emailCreateMode === EMAIL_CREATE_MODES.UPLOAD) {
|
|
643
|
-
return !isEmpty(EmailLayout);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
// For Editor: Show editor when template is selected
|
|
647
|
-
return !isEmpty(SelectedEdmDefaultTemplate);
|
|
648
|
-
}, [currentStep, selectedCreateMode, supportCKEditorFlag, emailCreateMode, EmailLayout, SelectedEdmDefaultTemplate, Email?.templateDetails, Email?.BEETemplate, params?.id, location?.query?.id, location?.params?.id, location?.pathname, emailProps?.editor, emailProps?.selectedEditorMode]);
|
|
649
|
-
|
|
650
|
-
// Memoize static data
|
|
651
|
-
const modes = useMemo(() => {
|
|
652
|
-
const supportCKEditor = hasSupportCKEditor();
|
|
653
|
-
const isBeeEditorEnabledValue = checkBeeEditorEnabled();
|
|
654
|
-
|
|
655
|
-
if (supportCKEditor) {
|
|
656
|
-
// Legacy flow: Show only 2 options (Upload Zip, Use Editor)
|
|
657
|
-
return [
|
|
658
|
-
{
|
|
659
|
-
title: formatMessage(messages.zipUpload),
|
|
660
|
-
content: formatMessage(messages.zipUploadDesc),
|
|
661
|
-
value: EMAIL_CREATE_MODES.UPLOAD,
|
|
662
|
-
},
|
|
663
|
-
{
|
|
664
|
-
title: formatMessage(messages.useEditor),
|
|
665
|
-
content: formatMessage(messages.useEditorDesc),
|
|
666
|
-
value: EMAIL_CREATE_MODES.EDITOR,
|
|
667
|
-
},
|
|
668
|
-
];
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
// New flow: Show 3 options (HTML Editor, Drag & Drop, Upload Zip)
|
|
672
|
-
return [
|
|
673
|
-
{
|
|
674
|
-
title: formatMessage(messages.htmlEditorTitle),
|
|
675
|
-
content: formatMessage(messages.htmlEditorDesc),
|
|
676
|
-
value: EMAIL_CREATE_MODES.HTML_EDITOR,
|
|
677
|
-
icon: <CapIcon type="code" />,
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
title: formatMessage(messages.dragDropEditorTitle),
|
|
681
|
-
content: formatMessage(messages.dragDropEditorDesc),
|
|
682
|
-
value: EMAIL_CREATE_MODES.DRAG_DROP,
|
|
683
|
-
icon: <CapIcon type="draggable" svgProps={{ fill: 'currentColor' }} />,
|
|
684
|
-
disabled: !isBeeEditorEnabledValue,
|
|
685
|
-
tooltipProps: !isBeeEditorEnabledValue ? {
|
|
686
|
-
title: formatMessage(messages.beeEditorDisabledTooltip),
|
|
687
|
-
placement: 'top',
|
|
688
|
-
} : undefined,
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
title: formatMessage(messages.uploadZipTitle),
|
|
692
|
-
content: formatMessage(messages.uploadZipDesc),
|
|
693
|
-
value: EMAIL_CREATE_MODES.UPLOAD,
|
|
694
|
-
icon: <CapIcon type="file" />,
|
|
695
|
-
},
|
|
696
|
-
];
|
|
697
|
-
}, [formatMessage, checkBeeEditorEnabled]);
|
|
698
|
-
|
|
699
330
|
// Prepare props for CmsTemplatesComponent
|
|
700
331
|
const cmsTemplatesProps = useMemo(() => ({
|
|
701
332
|
cmsTemplates: CmsTemplates,
|