@capillarytech/creatives-library 8.0.242-alpha.0 → 8.0.242-alpha.1
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/constants/unified.js +2 -1
- package/initialReducer.js +2 -0
- package/package.json +1 -1
- package/sagas/__tests__/assetPolling.test.js +74 -3
- package/sagas/assetPolling.js +8 -1
- package/services/api.js +10 -5
- package/services/tests/api.test.js +18 -0
- package/translations/en.json +0 -1
- package/utils/common.js +5 -0
- package/utils/commonUtils.js +14 -1
- package/utils/tests/commonUtil.test.js +224 -0
- package/utils/transformTemplateConfig.js +0 -10
- package/utils/transformerUtils.js +0 -42
- package/v2Components/CapDeviceContent/index.js +61 -56
- package/v2Components/CapImageUpload/constants.js +0 -2
- package/v2Components/CapImageUpload/index.js +14 -54
- package/v2Components/CapImageUpload/index.scss +1 -4
- package/v2Components/CapImageUpload/messages.js +0 -4
- package/v2Components/CapTagList/index.js +6 -1
- package/v2Components/CapTagListWithInput/index.js +5 -1
- package/v2Components/CapTagListWithInput/messages.js +1 -1
- package/v2Components/CapWhatsappCTA/tests/index.test.js +5 -0
- package/v2Components/ErrorInfoNote/index.js +412 -72
- package/v2Components/ErrorInfoNote/messages.js +22 -0
- package/v2Components/ErrorInfoNote/style.scss +279 -2
- package/v2Components/HtmlEditor/HTMLEditor.js +210 -89
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +1132 -133
- package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +17 -12
- package/v2Components/HtmlEditor/_htmlEditor.scss +8 -23
- package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
- package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +13 -101
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +148 -139
- package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +2 -1
- package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
- package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
- package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +1 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +4 -7
- package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +35 -45
- package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +1 -3
- package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
- package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +7 -6
- package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +3 -6
- package/v2Components/HtmlEditor/components/PreviewPane/index.js +10 -11
- package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +87 -62
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +49 -31
- package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +254 -0
- package/v2Components/HtmlEditor/components/ValidationTabs/index.js +362 -0
- package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +51 -0
- package/v2Components/HtmlEditor/constants.js +29 -20
- package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +373 -16
- package/v2Components/HtmlEditor/hooks/useEditorContent.js +5 -2
- package/v2Components/HtmlEditor/hooks/useInAppContent.js +88 -146
- package/v2Components/HtmlEditor/index.js +1 -1
- package/v2Components/HtmlEditor/messages.js +95 -85
- package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +99 -101
- package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +23 -25
- package/v2Components/HtmlEditor/utils/validationAdapter.js +34 -41
- package/v2Components/MobilePushPreviewV2/index.js +32 -7
- package/v2Components/TemplatePreview/_templatePreview.scss +44 -24
- package/v2Components/TemplatePreview/index.js +47 -32
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +31 -25
- package/v2Containers/App/constants.js +0 -5
- package/v2Containers/BeeEditor/index.js +82 -80
- package/v2Containers/BeePopupEditor/constants.js +10 -0
- package/v2Containers/BeePopupEditor/index.js +193 -0
- package/v2Containers/BeePopupEditor/tests/index.test.js +627 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +148 -120
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +9 -3
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -2
- package/v2Containers/CreativesContainer/constants.js +1 -2
- package/v2Containers/CreativesContainer/index.js +173 -193
- package/v2Containers/CreativesContainer/messages.js +4 -4
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +38 -50
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +36 -0
- package/v2Containers/Email/actions.js +7 -0
- package/v2Containers/Email/constants.js +5 -1
- package/v2Containers/Email/index.js +13 -0
- package/v2Containers/Email/messages.js +32 -0
- package/v2Containers/Email/reducer.js +12 -1
- package/v2Containers/Email/sagas.js +41 -6
- package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +2 -0
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +1045 -0
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +193 -7
- package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +40 -74
- package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +2 -67
- package/v2Containers/EmailWrapper/constants.js +2 -0
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +436 -67
- package/v2Containers/EmailWrapper/index.js +99 -23
- package/v2Containers/EmailWrapper/messages.js +61 -1
- package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +26 -1
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +111 -77
- package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +376 -0
- package/v2Containers/InApp/__tests__/sagas.test.js +363 -0
- package/v2Containers/InApp/actions.js +7 -0
- package/v2Containers/InApp/constants.js +20 -4
- package/v2Containers/InApp/index.js +800 -357
- package/v2Containers/InApp/index.scss +4 -3
- package/v2Containers/InApp/messages.js +7 -3
- package/v2Containers/InApp/reducer.js +21 -3
- package/v2Containers/InApp/sagas.js +29 -9
- package/v2Containers/InApp/selectors.js +25 -5
- package/v2Containers/InApp/tests/index.test.js +154 -50
- package/v2Containers/InApp/tests/reducer.test.js +34 -0
- package/v2Containers/InApp/tests/sagas.test.js +61 -9
- package/v2Containers/InApp/tests/selectors.test.js +612 -0
- package/v2Containers/InAppWrapper/components/InAppWrapperView.js +162 -0
- package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +267 -0
- package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +9 -0
- package/v2Containers/InAppWrapper/constants.js +16 -0
- package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +473 -0
- package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +198 -0
- package/v2Containers/InAppWrapper/index.js +148 -0
- package/v2Containers/InAppWrapper/messages.js +49 -0
- package/v2Containers/InappAdvance/index.js +1099 -0
- package/v2Containers/InappAdvance/index.scss +10 -0
- package/v2Containers/InappAdvance/tests/index.test.js +448 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -25
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -18
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -46
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +0 -4
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -8
- package/v2Containers/TagList/index.js +67 -1
- package/v2Containers/Templates/ChannelTypeIllustration.js +1 -13
- package/v2Containers/Templates/_templates.scss +56 -200
- package/v2Containers/Templates/actions.js +1 -2
- package/v2Containers/Templates/constants.js +0 -1
- package/v2Containers/Templates/index.js +124 -277
- package/v2Containers/Templates/messages.js +4 -24
- package/v2Containers/Templates/reducer.js +0 -2
- package/v2Containers/Templates/tests/index.test.js +0 -10
- package/v2Containers/TemplatesV2/index.js +2 -3
- package/v2Containers/TemplatesV2/messages.js +0 -4
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +35 -132
- package/v2Components/CapImageUrlUpload/constants.js +0 -19
- package/v2Components/CapImageUrlUpload/index.js +0 -455
- package/v2Components/CapImageUrlUpload/index.scss +0 -35
- package/v2Components/CapImageUrlUpload/messages.js +0 -47
- package/v2Containers/WebPush/Create/components/ButtonForm.js +0 -175
- package/v2Containers/WebPush/Create/components/ButtonItem.js +0 -101
- package/v2Containers/WebPush/Create/components/ButtonList.js +0 -144
- package/v2Containers/WebPush/Create/components/_buttons.scss +0 -246
- package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +0 -554
- package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +0 -607
- package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +0 -633
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +0 -666
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +0 -74
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +0 -80
- package/v2Containers/WebPush/Create/index.js +0 -1755
- package/v2Containers/WebPush/Create/index.scss +0 -123
- package/v2Containers/WebPush/Create/messages.js +0 -199
- package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +0 -241
- package/v2Containers/WebPush/Create/preview/NotificationContainer.js +0 -290
- package/v2Containers/WebPush/Create/preview/PreviewContent.js +0 -81
- package/v2Containers/WebPush/Create/preview/PreviewControls.js +0 -240
- package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +0 -23
- package/v2Containers/WebPush/Create/preview/WebPushPreview.js +0 -144
- package/v2Containers/WebPush/Create/preview/assets/Light.svg +0 -53
- package/v2Containers/WebPush/Create/preview/assets/Top.svg +0 -5
- 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 +0 -106
- package/v2Containers/WebPush/Create/preview/assets/iOS.svg +0 -26
- package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +0 -18
- package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +0 -29
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +0 -44
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +0 -110
- package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +0 -45
- package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +0 -72
- package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +0 -55
- package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +0 -70
- package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +0 -512
- package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +0 -77
- package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +0 -527
- package/v2Containers/WebPush/Create/preview/constants.js +0 -162
- package/v2Containers/WebPush/Create/preview/notification-container.scss +0 -104
- package/v2Containers/WebPush/Create/preview/preview.scss +0 -409
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +0 -300
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +0 -12
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +0 -12
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +0 -12
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +0 -303
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +0 -11
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +0 -11
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +0 -11
- package/v2Containers/WebPush/Create/preview/styles/_base.scss +0 -188
- package/v2Containers/WebPush/Create/preview/styles/_ios.scss +0 -106
- package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +0 -107
- package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +0 -75
- package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +0 -174
- package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +0 -909
- package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +0 -1077
- package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +0 -723
- package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +0 -943
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +0 -128
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +0 -121
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +0 -144
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +0 -127
- package/v2Containers/WebPush/Create/utils/urlValidation.js +0 -116
- package/v2Containers/WebPush/Create/utils/urlValidation.test.js +0 -449
- package/v2Containers/WebPush/actions.js +0 -60
- package/v2Containers/WebPush/constants.js +0 -108
- package/v2Containers/WebPush/index.js +0 -2
- package/v2Containers/WebPush/reducer.js +0 -104
- package/v2Containers/WebPush/sagas.js +0 -119
- package/v2Containers/WebPush/selectors.js +0 -65
- package/v2Containers/WebPush/tests/reducer.test.js +0 -863
- package/v2Containers/WebPush/tests/sagas.test.js +0 -566
- package/v2Containers/WebPush/tests/selectors.test.js +0 -960
|
@@ -79,7 +79,6 @@ import * as whatsappActions from '../Whatsapp/actions';
|
|
|
79
79
|
import * as rcsActions from '../Rcs/actions';
|
|
80
80
|
import * as zaloActions from '../Zalo/actions';
|
|
81
81
|
import * as inAppActions from '../InApp/actions';
|
|
82
|
-
import * as webpushActions from '../WebPush/actions';
|
|
83
82
|
import * as globalActions from '../Cap/actions';
|
|
84
83
|
import { makeSelectAuthenticated } from '../Cap/selectors';
|
|
85
84
|
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
@@ -126,17 +125,18 @@ import {
|
|
|
126
125
|
VIDEO,
|
|
127
126
|
GIF,
|
|
128
127
|
} from '../Whatsapp/constants';
|
|
129
|
-
import { INAPP_LAYOUT_DETAILS } from '../InApp/constants';
|
|
128
|
+
import { INAPP_LAYOUT_DETAILS, INAPP_MESSAGE_LAYOUT_TYPES, INAPP_MEDIA_TYPES, BIG_HTML, ANDROID, IOS } from '../InApp/constants';
|
|
130
129
|
import { ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
|
|
131
130
|
import { getWhatsappContent, getWhatsappStatus, getWhatsappCategory, getWhatsappCta, getWhatsappQuickReply, getWhatsappAutoFill, getWhatsappCarouselButtonView } from '../Whatsapp/utils';
|
|
132
131
|
import { getRCSContent } from '../Rcs/utils';
|
|
133
132
|
import {RCS_STATUSES} from '../Rcs/constants';
|
|
134
133
|
import zaloMessages from '../Zalo/messages';
|
|
135
134
|
import rcsMessages from '../Rcs/messages';
|
|
135
|
+
import inAppMessages from '../InApp/messages';
|
|
136
136
|
import globalMessages from '../../v2Containers/Cap/messages';
|
|
137
137
|
import { handlePreviewInNewTab } from '../../utils/common';
|
|
138
138
|
|
|
139
|
-
import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE, VIBER, FACEBOOK, WHATSAPP, RCS, ZALO, INAPP
|
|
139
|
+
import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE, VIBER, FACEBOOK, WHATSAPP, RCS, ZALO, INAPP } from '../CreativesContainer/constants';
|
|
140
140
|
|
|
141
141
|
import {CREATIVE} from '../Facebook/constants';
|
|
142
142
|
import videoPlay from '../../assets/videoPlay.svg';
|
|
@@ -154,13 +154,10 @@ import { DAEMON } from '@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes'
|
|
|
154
154
|
import { Rcs } from '../Rcs';
|
|
155
155
|
import { makeSelectRcs } from '../Rcs/selectors';
|
|
156
156
|
import { getRcsStatusType } from '../Rcs/utils';
|
|
157
|
-
import { makeSelectWebPush } from '../WebPush/selectors';
|
|
158
157
|
import { v2MobilePushSagas } from '../MobilePushNew/sagas';
|
|
159
158
|
import { AUTO_CAROUSEL, BIG_PICTURE, FILMSTRIP_CAROUSEL, MANUAL_CAROUSEL } from '../MobilePushNew/constants';
|
|
160
159
|
import CapPageSpinner from '../../v2Components/CapPageSpinner';
|
|
161
|
-
import webPushSagas from '../WebPush/sagas';
|
|
162
160
|
const withMobilePushNewSaga = injectSaga({ key: 'mobilePushNew', saga: v2MobilePushSagas, mode: DAEMON });
|
|
163
|
-
const withWebPushSaga = injectSaga({ key: 'webPush', saga: webPushSagas, mode: DAEMON });
|
|
164
161
|
|
|
165
162
|
const { timeTracker } = GA;
|
|
166
163
|
const {CapCustomCardList} = CapCustomCard;
|
|
@@ -202,6 +199,29 @@ const SMS_FILTERS = {
|
|
|
202
199
|
SERVICE_IMPLICIT: 'implicit',
|
|
203
200
|
};
|
|
204
201
|
|
|
202
|
+
const INAPP_LAYOUT_OPTIONS = [
|
|
203
|
+
{
|
|
204
|
+
key: 'popup',
|
|
205
|
+
value: INAPP_MESSAGE_LAYOUT_TYPES.MODAL,
|
|
206
|
+
label: <FormattedMessage {...inAppMessages.layoutModal} />,
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
key: 'topBanner',
|
|
210
|
+
value: INAPP_MESSAGE_LAYOUT_TYPES.TOPBANNER,
|
|
211
|
+
label: <FormattedMessage {...inAppMessages.layoutTopBanner} />,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
key: 'bottomBanner',
|
|
215
|
+
value: INAPP_MESSAGE_LAYOUT_TYPES.BOTTOMBANNER,
|
|
216
|
+
label: <FormattedMessage {...inAppMessages.layoutBottomBanner} />,
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
key: 'fullScreen',
|
|
220
|
+
value: INAPP_MESSAGE_LAYOUT_TYPES.FULLSCREEN,
|
|
221
|
+
label: <FormattedMessage {...inAppMessages.layoutFullScreen} />,
|
|
222
|
+
},
|
|
223
|
+
];
|
|
224
|
+
|
|
205
225
|
const WHATSAPP_LOWERCASE = WHATSAPP.toLowerCase();
|
|
206
226
|
const RCS_LOWERCASE = RCS.toLowerCase();
|
|
207
227
|
const SMS_LOWERCASE = SMS.toLowerCase();
|
|
@@ -214,7 +234,6 @@ const EBILL_LOWERCASE = EBILL.toLowerCase();
|
|
|
214
234
|
const LINE_LOWERCASE = LINE.toLowerCase();
|
|
215
235
|
const ZALO_LOWERCASE = ZALO.toLowerCase();
|
|
216
236
|
const WECHAT_LOWERCASE = WECHAT.toLowerCase();
|
|
217
|
-
const WEBPUSH_LOWERCASE = WEBPUSH.toLowerCase();
|
|
218
237
|
const duplicateEnum = {
|
|
219
238
|
sms: "smsActions",
|
|
220
239
|
line: "lineActions",
|
|
@@ -253,6 +272,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
253
272
|
selectedWhatsappStatus: '',
|
|
254
273
|
selectedWhatsappCategory: '',
|
|
255
274
|
selectedZaloStatus: '',
|
|
275
|
+
selectedInAppLayout: '',
|
|
256
276
|
hostName: '',
|
|
257
277
|
searchedZaloTemplates: [],
|
|
258
278
|
searchingZaloTemplate: false,
|
|
@@ -267,9 +287,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
267
287
|
// Add flag to prevent duplicate API calls
|
|
268
288
|
isProcessingEditResponse: false,
|
|
269
289
|
};
|
|
270
|
-
// Timeout IDs for cleanup
|
|
271
|
-
this._clearEditTimeout = null;
|
|
272
|
-
this._clearCreateTimeout = null;
|
|
273
290
|
this.getAllTemplates = this.getAllTemplates.bind(this);
|
|
274
291
|
this.createTemplate = this.createTemplate.bind(this);
|
|
275
292
|
this.searchTemplate = this.searchTemplate.bind(this);
|
|
@@ -392,19 +409,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
392
409
|
orgUnitId: -1,
|
|
393
410
|
});
|
|
394
411
|
break;
|
|
395
|
-
case WEBPUSH:
|
|
396
|
-
channel = 'Webpush';
|
|
397
|
-
activeMode = ACCOUNT_SELECTION_MODE;
|
|
398
|
-
this.props.actions.getWeCrmAccounts('WebPush');
|
|
399
|
-
break;
|
|
400
412
|
default:
|
|
401
413
|
channel = '';
|
|
402
414
|
}
|
|
403
415
|
this.setState({ channel, activeMode });
|
|
404
|
-
// Clear templates when entering account selection mode to prevent showing old channel templates
|
|
405
|
-
if (activeMode === ACCOUNT_SELECTION_MODE) {
|
|
406
|
-
this.props.actions.resetTemplate();
|
|
407
|
-
}
|
|
408
416
|
if (isEmpty(this.props.Templates?.userList)) {
|
|
409
417
|
this.props.actions.getUserList();
|
|
410
418
|
}
|
|
@@ -502,10 +510,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
502
510
|
channel = 'Facebook';
|
|
503
511
|
this.setState({defaultAccount: true});
|
|
504
512
|
nextProps.actions.getAccountsSettings();
|
|
505
|
-
} else if (nextProps.route.name.toLowerCase() === WEBPUSH_LOWERCASE) {
|
|
506
|
-
this.setState({defaultAccount: true});
|
|
507
|
-
channel = 'Webpush';
|
|
508
|
-
nextProps.actions.getWeCrmAccounts('WebPush');
|
|
509
513
|
}
|
|
510
514
|
|
|
511
515
|
this.setState({ channel }, () => {
|
|
@@ -651,50 +655,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
651
655
|
}, 1000);
|
|
652
656
|
}
|
|
653
657
|
|
|
654
|
-
// Check for WebPush edit response - prevent duplicate calls
|
|
655
|
-
if (selectedChannel === WEBPUSH_LOWERCASE && nextProps.WebPush?.editResponse && (nextProps.WebPush.editResponse.templateId || nextProps.WebPush.editResponse._id) && !isEqual(nextProps.WebPush.editResponse, this.props.WebPush?.editResponse)) {
|
|
656
|
-
const channelLabel = this.props.intl.formatMessage(messages.webpushHeader);
|
|
657
|
-
const message = `${channelLabel} ${this.props.intl.formatMessage(messages.templateUpdateSuccess)}`;
|
|
658
|
-
CapNotification.success({
|
|
659
|
-
key: 'webpushEditSuccess',
|
|
660
|
-
message
|
|
661
|
-
});
|
|
662
|
-
// Clear previous state before loading newer templates
|
|
663
|
-
this.props.actions.resetTemplate();
|
|
664
|
-
this.getAllTemplates({params, resetPage: true});
|
|
665
|
-
// Delay clearing to allow drawer to close first
|
|
666
|
-
// Clear any existing timeout before setting a new one
|
|
667
|
-
if (this._clearEditTimeout) {
|
|
668
|
-
clearTimeout(this._clearEditTimeout);
|
|
669
|
-
}
|
|
670
|
-
this._clearEditTimeout = setTimeout(() => {
|
|
671
|
-
this.props.webpushActions.clearEditResponse();
|
|
672
|
-
this._clearEditTimeout = null;
|
|
673
|
-
}, 200);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
// Check for WebPush create response (for new template creation)
|
|
677
|
-
if (selectedChannel === WEBPUSH_LOWERCASE && nextProps.WebPush?.response && (nextProps.WebPush.response?.templateId || nextProps.WebPush.response?._id) && !isEqual(nextProps.WebPush.response, this.props.WebPush?.response)) {
|
|
678
|
-
// Skip showing generic "created" toast when this is a duplicate operation
|
|
679
|
-
if (!nextProps.WebPush.response.meta?.isDuplicate) {
|
|
680
|
-
const channelLabel = this.props.intl.formatMessage(messages.webpushHeader);
|
|
681
|
-
const message = `${channelLabel} ${this.props.intl.formatMessage(messages.templateCreateSuccess)}`;
|
|
682
|
-
CapNotification.success({key: 'webpushCreateSuccess', message});
|
|
683
|
-
// Clear previous state before loading newer templates
|
|
684
|
-
this.props.actions.resetTemplate();
|
|
685
|
-
this.getAllTemplates({params, resetPage: true});
|
|
686
|
-
// Delay clearing to allow drawer to close first
|
|
687
|
-
// Clear any existing timeout before setting a new one
|
|
688
|
-
if (this._clearCreateTimeout) {
|
|
689
|
-
clearTimeout(this._clearCreateTimeout);
|
|
690
|
-
}
|
|
691
|
-
this._clearCreateTimeout = setTimeout(() => {
|
|
692
|
-
this.props.webpushActions.clearCreateResponse();
|
|
693
|
-
this._clearCreateTimeout = null;
|
|
694
|
-
}, 200);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
658
|
|
|
699
659
|
|
|
700
660
|
if (nextProps.Create && this.props.Create && nextProps.Create.createTemplateError && !isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
|
|
@@ -702,7 +662,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
702
662
|
if ((this.state.channel || '').toLowerCase() !== "sms") {
|
|
703
663
|
CapNotification.error({key: 'somethingWrong', message});
|
|
704
664
|
}
|
|
705
|
-
const { smsActions, mobilepushActions, ebillActions, lineActions, viberActions, facebookActions, whatsappActions, inAppActions, rcsActions
|
|
665
|
+
const { smsActions, mobilepushActions, ebillActions, lineActions, viberActions, facebookActions, whatsappActions, inAppActions, rcsActions } = this.props;
|
|
706
666
|
switch (selectedChannel) {
|
|
707
667
|
case SMS_LOWERCASE:
|
|
708
668
|
smsActions.clearCreateResponse();
|
|
@@ -731,9 +691,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
731
691
|
case inAppActions:
|
|
732
692
|
inAppActions.clearCreateResponse();
|
|
733
693
|
break;
|
|
734
|
-
case WEBPUSH_LOWERCASE:
|
|
735
|
-
webpushActions.clearCreateResponse();
|
|
736
|
-
break;
|
|
737
694
|
default:
|
|
738
695
|
break;
|
|
739
696
|
}
|
|
@@ -746,10 +703,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
746
703
|
nextProps.Templates.deleteResponse) {
|
|
747
704
|
const message = `${this.state.channel} ${this.props.intl.formatMessage(messages['Template deleted successfully'])}`;
|
|
748
705
|
CapNotification.success({key: 'deleteSucess', message});
|
|
749
|
-
// Clear previous state before loading newer templates for web push channel
|
|
750
|
-
if (selectedChannel === WEBPUSH_LOWERCASE) {
|
|
751
|
-
this.props.actions.resetTemplate();
|
|
752
|
-
}
|
|
753
706
|
this.getAllTemplates({params, resetPage: true});
|
|
754
707
|
}
|
|
755
708
|
|
|
@@ -888,23 +841,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
888
841
|
window.removeEventListener("message", this.handleFrameTasks);
|
|
889
842
|
this.props.actions.resetTemplateStoreData();
|
|
890
843
|
this.props.globalActions.clearMetaEntities();
|
|
891
|
-
// Clear any pending timeouts to prevent memory leaks
|
|
892
|
-
if (this._clearEditTimeout) {
|
|
893
|
-
clearTimeout(this._clearEditTimeout);
|
|
894
|
-
this._clearEditTimeout = null;
|
|
895
|
-
}
|
|
896
|
-
if (this._clearCreateTimeout) {
|
|
897
|
-
clearTimeout(this._clearCreateTimeout);
|
|
898
|
-
this._clearCreateTimeout = null;
|
|
899
|
-
}
|
|
900
844
|
// this.props.actions.resetAccount();
|
|
901
845
|
// this.setState({defaultAccount: false});
|
|
902
846
|
}
|
|
903
847
|
|
|
904
|
-
onAccountSelect(e) {
|
|
848
|
+
onAccountSelect(e) {
|
|
905
849
|
const value = e.target.value;
|
|
906
|
-
// Clear templates immediately when account is selected to prevent showing old channel templates
|
|
907
|
-
this.props.actions.resetTemplate();
|
|
908
850
|
this.setState({selectedAccount: value}, () => {
|
|
909
851
|
const params = {};
|
|
910
852
|
if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
|
|
@@ -932,7 +874,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
932
874
|
} else {
|
|
933
875
|
this.setState({ selectedAccountError: false });
|
|
934
876
|
}
|
|
935
|
-
} else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE, WHATSAPP_LOWERCASE
|
|
877
|
+
} else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel)) {
|
|
936
878
|
const setAcc = this.props?.Templates?.weCrmAccounts?.find((item) => item?.name === this.state.selectedAccount);
|
|
937
879
|
const { domainProperties = [] } = this.props?.Templates?.senderDetails || {};
|
|
938
880
|
let hostName = '';
|
|
@@ -959,9 +901,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
959
901
|
params.accountId = sourceAccountIdentifier;
|
|
960
902
|
params.host = hostName;
|
|
961
903
|
}
|
|
962
|
-
if (selectedChannel === WEBPUSH_LOWERCASE && setAcc) {
|
|
963
|
-
params.accountId = setAcc.accountId || setAcc.id;
|
|
964
|
-
}
|
|
965
904
|
if (selectedChannel === RCS_LOWERCASE && hostName) {
|
|
966
905
|
const { configs: { accessToken = "" } = {} } = setAcc || {};
|
|
967
906
|
params.accountId = sourceAccountIdentifier;
|
|
@@ -1003,44 +942,37 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1003
942
|
let creativesParams = {mode: ''};
|
|
1004
943
|
if (!isEmpty(routeParams)) {
|
|
1005
944
|
const { pathname } = routeParams;
|
|
1006
|
-
if (pathname) {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
// Merge the full template data into creativesParams
|
|
1035
|
-
creativesParams = {
|
|
1036
|
-
...creativesParams,
|
|
1037
|
-
...webpushSelectedTemplateData,
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
945
|
+
if (pathname.includes('create')) {
|
|
946
|
+
creativesParams.mode = 'create';
|
|
947
|
+
} else if (pathname.includes('edit') || pathname.includes('overview')) {
|
|
948
|
+
creativesParams.mode = 'edit';
|
|
949
|
+
if (pathname.includes('richmedia')) {
|
|
950
|
+
creativesParams._id = pathname.split('/')[4];
|
|
951
|
+
creativesParams.definition = {
|
|
952
|
+
msgcontent: "RICH_MEDIA_WECHAT",
|
|
953
|
+
};
|
|
954
|
+
} else {
|
|
955
|
+
creativesParams._id = pathname.split('/')[3];
|
|
956
|
+
creativesParams.modeType = pathname.split('/')[4];
|
|
957
|
+
creativesParams.account = pathname.split('/')[5];
|
|
958
|
+
if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
959
|
+
const whatsappSelectedTemplateData = this.selectTemplate(creativesParams._id) || {};
|
|
960
|
+
const { name = '', versions = {} } = whatsappSelectedTemplateData;
|
|
961
|
+
creativesParams.whatsappTemplateName = name;
|
|
962
|
+
creativesParams.whatsappTemplateCategory = get(versions, `base.content.whatsapp.category`, '');
|
|
963
|
+
creativesParams.whatsappTemplateLanguageCode = get(versions, `base.content.whatsapp.languages[0].language`, '');
|
|
964
|
+
} else if (this.state.channel.toLocaleLowerCase() === ZALO_LOWERCASE) {
|
|
965
|
+
const zaloSelectedTemplateData = this.selectTemplate(parseInt(creativesParams._id, 10)) || {};
|
|
966
|
+
const { name = '' } = zaloSelectedTemplateData;
|
|
967
|
+
creativesParams.name = name
|
|
968
|
+
} else if (this.state.channel?.toLowerCase() === EMAIL_LOWERCASE) {
|
|
969
|
+
const emailSelectedTemplateData = this.selectTemplate(creativesParams._id) || {};
|
|
970
|
+
const activeTab = get(emailSelectedTemplateData, 'versions.base.activeTab', 'en');
|
|
971
|
+
const isDragDrop = get(emailSelectedTemplateData, `versions.base.${activeTab}.is_drag_drop`, false);
|
|
972
|
+
creativesParams.is_drag_drop = isDragDrop;
|
|
1041
973
|
}
|
|
1042
|
-
creativesParams.type = this.state.channel.toUpperCase();
|
|
1043
974
|
}
|
|
975
|
+
creativesParams.type = this.state.channel.toUpperCase();
|
|
1044
976
|
}
|
|
1045
977
|
}
|
|
1046
978
|
if (this.state.previewOpen) {
|
|
@@ -1074,13 +1006,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1074
1006
|
queryParams.host = params?.host || this.state?.hostName;
|
|
1075
1007
|
};
|
|
1076
1008
|
|
|
1077
|
-
setWebpushQueryParams = (queryParams, params) => {
|
|
1078
|
-
const selectedAccount = this.props.Templates?.selectedWebPushAccount;
|
|
1079
|
-
queryParams.accountId = params?.accountId
|
|
1080
|
-
|| selectedAccount?.accountId
|
|
1081
|
-
|| selectedAccount?.id;
|
|
1082
|
-
};
|
|
1083
|
-
|
|
1084
1009
|
getAllTemplates = ({params, getNextPage, resetPage}, resetTemplates) => {
|
|
1085
1010
|
let queryParams = params || {};
|
|
1086
1011
|
let page = this.state.page;
|
|
@@ -1112,9 +1037,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1112
1037
|
if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
1113
1038
|
this.setWhatsappQueryParams(queryParams, params);
|
|
1114
1039
|
}
|
|
1115
|
-
if (this.state?.channel?.toLowerCase() === WEBPUSH_LOWERCASE) {
|
|
1116
|
-
this.setWebpushQueryParams(queryParams, params);
|
|
1117
|
-
}
|
|
1118
1040
|
if (this.state?.channel?.toLowerCase() === RCS_LOWERCASE && !isEmpty(this.props.Templates?.selectedRcsAccount)) {
|
|
1119
1041
|
const { sourceAccountIdentifier = '', configs: { accessToken = '' } = {}, hostName = '' } = this.props.Templates.selectedRcsAccount;
|
|
1120
1042
|
if (sourceAccountIdentifier) {
|
|
@@ -1179,9 +1101,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1179
1101
|
if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
1180
1102
|
this.setWhatsappQueryParams(queryParams, params);
|
|
1181
1103
|
}
|
|
1182
|
-
if (this.state?.channel?.toLowerCase() === WEBPUSH_LOWERCASE) {
|
|
1183
|
-
this.setWebpushQueryParams(queryParams, params);
|
|
1184
|
-
}
|
|
1185
1104
|
if (this.state?.channel?.toLowerCase() === RCS_LOWERCASE && !isEmpty(this.props.Templates?.selectedRcsAccount)) {
|
|
1186
1105
|
const { sourceAccountIdentifier = '', configs: { accessToken = '' } = {}, hostName = '' } = this.props.Templates.selectedRcsAccount;
|
|
1187
1106
|
if (sourceAccountIdentifier) {
|
|
@@ -1274,6 +1193,19 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1274
1193
|
return templates;
|
|
1275
1194
|
}
|
|
1276
1195
|
|
|
1196
|
+
filterInAppTemplates = (templates) => {
|
|
1197
|
+
const { selectedInAppLayout } = this.state;
|
|
1198
|
+
if (!selectedInAppLayout) {
|
|
1199
|
+
return templates;
|
|
1200
|
+
}
|
|
1201
|
+
return templates.filter((template) => {
|
|
1202
|
+
const androidBodyType = get(template, 'versions.base.content.ANDROID.bodyType');
|
|
1203
|
+
const iosBodyType = get(template, 'versions.base.content.IOS.bodyType');
|
|
1204
|
+
const inappBodyType = androidBodyType || iosBodyType;
|
|
1205
|
+
return inappBodyType === selectedInAppLayout;
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1277
1209
|
filterSMSTemplates = (templates) => {
|
|
1278
1210
|
const { smsFilter } = this.state;
|
|
1279
1211
|
if (SMS_FILTERS.ALL === smsFilter) {
|
|
@@ -1360,6 +1292,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1360
1292
|
case ZALO:
|
|
1361
1293
|
filteredTemplates = this.filterZaloTemplates(templates);
|
|
1362
1294
|
break;
|
|
1295
|
+
case INAPP:
|
|
1296
|
+
filteredTemplates = this.filterInAppTemplates(templates);
|
|
1297
|
+
break;
|
|
1363
1298
|
default:
|
|
1364
1299
|
break;
|
|
1365
1300
|
}
|
|
@@ -1579,9 +1514,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1579
1514
|
templateData.isNewMobilePush = commonUtil.hasNewMobilePushFeatureEnabled();
|
|
1580
1515
|
}
|
|
1581
1516
|
break;
|
|
1582
|
-
case INAPP:
|
|
1517
|
+
case INAPP: {
|
|
1518
|
+
// Pass the full template object to CapCustomCard so getInAppContent can extract the data
|
|
1519
|
+
// Similar to how MOBILE_PUSH passes the full template when new feature is enabled
|
|
1583
1520
|
templateData.content = template;
|
|
1584
1521
|
break;
|
|
1522
|
+
}
|
|
1585
1523
|
case WECHAT:
|
|
1586
1524
|
templateData.content = this.prepareWeChatPreviewData(template);
|
|
1587
1525
|
break;
|
|
@@ -1858,70 +1796,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1858
1796
|
templateData.content = <CapLabel type="label19" className="zalo-listing-content desc">{template.name}</CapLabel>;
|
|
1859
1797
|
break;
|
|
1860
1798
|
}
|
|
1861
|
-
case WEBPUSH: {
|
|
1862
|
-
const webpushContent = get(template, 'versions.base.content.webpush', {});
|
|
1863
|
-
const notificationTitle = webpushContent?.title || '';
|
|
1864
|
-
const notificationMessage = webpushContent?.message || '';
|
|
1865
|
-
const brandIcon = webpushContent?.brandIcon || '';
|
|
1866
|
-
const mediaImage = webpushContent?.image || '';
|
|
1867
|
-
const ctaButtons = Array.isArray(webpushContent?.ctas)
|
|
1868
|
-
? webpushContent.ctas.filter(
|
|
1869
|
-
(cta) => typeof cta?.actionText === 'string' && cta.actionText.trim()
|
|
1870
|
-
)
|
|
1871
|
-
: [];
|
|
1872
|
-
const visibleCtas = ctaButtons.slice(0, 2);
|
|
1873
|
-
templateData.content = (
|
|
1874
|
-
<div className="sms-template-content webpush-template-content">
|
|
1875
|
-
<div className="webpush-template-card">
|
|
1876
|
-
<div className="webpush-template-meta">
|
|
1877
|
-
{brandIcon ? (
|
|
1878
|
-
<img
|
|
1879
|
-
src={brandIcon}
|
|
1880
|
-
alt="Brand Icon"
|
|
1881
|
-
className="webpush-brand-icon"
|
|
1882
|
-
/>
|
|
1883
|
-
) : (
|
|
1884
|
-
<span className="webpush-brand-icon-placeholder" />
|
|
1885
|
-
)}
|
|
1886
|
-
<div className="webpush-template-text">
|
|
1887
|
-
<div className="webpush-template-header">
|
|
1888
|
-
<div className="webpush-template-title">
|
|
1889
|
-
{notificationTitle}
|
|
1890
|
-
</div>
|
|
1891
|
-
<div className="webpush-template-time">2:29 PM</div>
|
|
1892
|
-
</div>
|
|
1893
|
-
{notificationMessage ? (
|
|
1894
|
-
<div className="webpush-template-message">
|
|
1895
|
-
{notificationMessage}
|
|
1896
|
-
</div>
|
|
1897
|
-
) : null}
|
|
1898
|
-
{mediaImage ? (
|
|
1899
|
-
<img
|
|
1900
|
-
src={mediaImage}
|
|
1901
|
-
alt="Media"
|
|
1902
|
-
className="webpush-media-image"
|
|
1903
|
-
/>
|
|
1904
|
-
) : null}
|
|
1905
|
-
</div>
|
|
1906
|
-
</div>
|
|
1907
|
-
{visibleCtas.length ? (
|
|
1908
|
-
<div
|
|
1909
|
-
className={`webpush-template-cta-section${
|
|
1910
|
-
visibleCtas.length === 1 ? ' single-cta' : ''
|
|
1911
|
-
}`}
|
|
1912
|
-
>
|
|
1913
|
-
{visibleCtas.map((cta, index) => (
|
|
1914
|
-
<div className="webpush-template-cta-item" key={`webpush-cta-${index}`}>
|
|
1915
|
-
<span className="webpush-template-cta-text">{cta.actionText}</span>
|
|
1916
|
-
</div>
|
|
1917
|
-
))}
|
|
1918
|
-
</div>
|
|
1919
|
-
) : null}
|
|
1920
|
-
</div>
|
|
1921
|
-
</div>
|
|
1922
|
-
);
|
|
1923
|
-
break;
|
|
1924
|
-
}
|
|
1925
1799
|
default:
|
|
1926
1800
|
templateData.content = "";
|
|
1927
1801
|
}
|
|
@@ -1959,7 +1833,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1959
1833
|
return (<div>
|
|
1960
1834
|
{[WECHAT, MOBILE_PUSH, INAPP, WHATSAPP, ZALO,RCS].includes(currentChannel) && this.showAccountName()}
|
|
1961
1835
|
{filterContent}
|
|
1962
|
-
{[WHATSAPP, ZALO,RCS].includes(currentChannel) && this.selectedFilters()}
|
|
1836
|
+
{[WHATSAPP, ZALO, INAPP,RCS].includes(currentChannel) && this.selectedFilters()}
|
|
1963
1837
|
{<div>
|
|
1964
1838
|
{!isEmpty(filteredTemplates) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError) ? (
|
|
1965
1839
|
<div className={!isEmpty(this.state.searchText) && isEmpty(cardDataList) ? '' : this.isFullMode() ? "v2-pagination-container" : "v2-pagination-container-half"}>
|
|
@@ -2031,11 +1905,6 @@ return (<div>
|
|
|
2031
1905
|
<ChannelTypeIllustration isFullMode={this.props.isFullMode} createTemplate={this.createTemplate} currentChannel={currentChannel}/>
|
|
2032
1906
|
</div>
|
|
2033
1907
|
}
|
|
2034
|
-
{showIllustrationForChannel(WEBPUSH_LOWERCASE) &&
|
|
2035
|
-
<div style={this.isFullMode() ? { height: "calc(100vh - 20.3125rem)", overflow: 'auto' } : {}}>
|
|
2036
|
-
<ChannelTypeIllustration isFullMode={this.props.isFullMode} createTemplate={this.createTemplate} currentChannel={currentChannel} hostName={this.state?.hostName}/>
|
|
2037
|
-
</div>
|
|
2038
|
-
}
|
|
2039
1908
|
{<CapCustomSkeleton loader={isInitialLoading && (isLoading || getAllTemplatesInProgress)} />}
|
|
2040
1909
|
{<CapPageSpinner spinning={!isInitialLoading && (isLoading || getAllTemplatesInProgress)} />}
|
|
2041
1910
|
</div>
|
|
@@ -2174,6 +2043,9 @@ return (<div>
|
|
|
2174
2043
|
|
|
2175
2044
|
prepareWeChatMappedPreviewData(content, templateTags, tagData) {
|
|
2176
2045
|
let formattedContent = cloneDeep(content);
|
|
2046
|
+
if (!formattedContent || typeof formattedContent !== 'string') {
|
|
2047
|
+
return formattedContent || '';
|
|
2048
|
+
}
|
|
2177
2049
|
forEach(templateTags, (tag) => {
|
|
2178
2050
|
if (tagData[tag].value !== undefined) {
|
|
2179
2051
|
formattedContent = formattedContent.replace(`{{${tag}.DATA}}`, tagData[tag].value);
|
|
@@ -2429,10 +2301,6 @@ return (<div>
|
|
|
2429
2301
|
params.host = this.state?.hostName;
|
|
2430
2302
|
}
|
|
2431
2303
|
this.delay(() => {
|
|
2432
|
-
// Clear previous state before loading newer templates for web push channel
|
|
2433
|
-
if (this.state.channel.toLowerCase() === WEBPUSH_LOWERCASE) {
|
|
2434
|
-
this.props.actions.resetTemplate();
|
|
2435
|
-
}
|
|
2436
2304
|
this.getAllTemplates({params, resetPage: true});
|
|
2437
2305
|
}, 500);
|
|
2438
2306
|
});
|
|
@@ -2596,32 +2464,6 @@ return (<div>
|
|
|
2596
2464
|
this.getAllTemplates({params: {}}, true);
|
|
2597
2465
|
this.props.inAppActions.clearCreateResponse();
|
|
2598
2466
|
});
|
|
2599
|
-
} else if (this.state.channel.toLowerCase() === "webpush") {
|
|
2600
|
-
const params = {
|
|
2601
|
-
name: this.state.searchText,
|
|
2602
|
-
sortBy: this.state.sortBy,
|
|
2603
|
-
};
|
|
2604
|
-
|
|
2605
|
-
// Get the selected WebPush account
|
|
2606
|
-
const selectedAccount = this.props.Templates?.selectedWebPushAccount;
|
|
2607
|
-
|
|
2608
|
-
// Set the accountId in the duplicate object
|
|
2609
|
-
if (duplicateObj.definition) {
|
|
2610
|
-
duplicateObj.definition.accountId = selectedAccount?.accountId || selectedAccount?.id;
|
|
2611
|
-
}
|
|
2612
|
-
|
|
2613
|
-
const channelLabel = this.props.intl.formatMessage(messages.webpushHeader);
|
|
2614
|
-
this.props.webpushActions.createTemplate(duplicateObj, (response) => {
|
|
2615
|
-
if (response && (response.templateId || response._id)) {
|
|
2616
|
-
// Clear response immediately to prevent componentWillReceiveProps from showing "created" notification
|
|
2617
|
-
this.props.webpushActions.clearCreateResponse();
|
|
2618
|
-
// Clear previous state before loading newer templates
|
|
2619
|
-
this.props.actions.resetTemplate();
|
|
2620
|
-
const message = `${channelLabel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
|
|
2621
|
-
CapNotification.success({key: 'duplicateSuccess', message});
|
|
2622
|
-
this.getAllTemplates({params, resetPage: true});
|
|
2623
|
-
}
|
|
2624
|
-
}, { isDuplicate: true });
|
|
2625
2467
|
} else if (this.state.channel.toLowerCase() === "ebill") {
|
|
2626
2468
|
this.props.ebillActions.createTemplate(duplicateObj);
|
|
2627
2469
|
} else if (this.state.channel.toLowerCase() === "email") {
|
|
@@ -2709,10 +2551,6 @@ return (<div>
|
|
|
2709
2551
|
pathName = `/ebill/edit/${id}`;
|
|
2710
2552
|
break;
|
|
2711
2553
|
}
|
|
2712
|
-
case WEBPUSH_LOWERCASE: {
|
|
2713
|
-
pathName = `/webpush/edit/${id}`;
|
|
2714
|
-
break;
|
|
2715
|
-
}
|
|
2716
2554
|
case 'line': {
|
|
2717
2555
|
const { messages } = template.versions.base.content;
|
|
2718
2556
|
const type = messages && messages[0] && messages[0].type;
|
|
@@ -2758,10 +2596,6 @@ return (<div>
|
|
|
2758
2596
|
pathName = `/inapp/edit/${id}/`;
|
|
2759
2597
|
break;
|
|
2760
2598
|
}
|
|
2761
|
-
case WEBPUSH: {
|
|
2762
|
-
pathName = `/webpush/edit/${id}`;
|
|
2763
|
-
break;
|
|
2764
|
-
}
|
|
2765
2599
|
default:
|
|
2766
2600
|
break;
|
|
2767
2601
|
}
|
|
@@ -3109,14 +2943,6 @@ return (<div>
|
|
|
3109
2943
|
fetchingWeCrmAccounts,
|
|
3110
2944
|
sendingFile,
|
|
3111
2945
|
} = Templates;
|
|
3112
|
-
|
|
3113
|
-
// Show loading when in account selection or account change mode
|
|
3114
|
-
const isAccountSelectionMode = this.state.activeMode === ACCOUNT_SELECTION_MODE ||
|
|
3115
|
-
this.state.activeMode === ACCOUNT_CHANGE_MODE;
|
|
3116
|
-
if (isAccountSelectionMode) {
|
|
3117
|
-
return true;
|
|
3118
|
-
}
|
|
3119
|
-
|
|
3120
2946
|
const lineLoader = this.checkLoader('line');
|
|
3121
2947
|
const smsLoader = this.checkLoader('sms');
|
|
3122
2948
|
const viberLoader = this.checkLoader(VIBER_CHANNEL);
|
|
@@ -3139,10 +2965,6 @@ return (<div>
|
|
|
3139
2965
|
fetchingWeCrmAccounts ) &&
|
|
3140
2966
|
this.state.channel.toLowerCase() === ZALO_LOWERCASE;
|
|
3141
2967
|
const mobilePushLoader = (((getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'mobilepush');
|
|
3142
|
-
const webpushLoader = (
|
|
3143
|
-
(getAllTemplatesInProgress && this.state.channel.toLowerCase() === WEBPUSH_LOWERCASE) ||
|
|
3144
|
-
(fetchingWeCrmAccounts && this.state.channel.toLowerCase() === WEBPUSH_LOWERCASE)
|
|
3145
|
-
);
|
|
3146
2968
|
const inAppLoader = (((this.state.selectedAccount !== '' && getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === INAPP_LOWERCASE);
|
|
3147
2969
|
const emailLoader = (
|
|
3148
2970
|
(getAllTemplatesInProgress ||
|
|
@@ -3157,7 +2979,6 @@ return (<div>
|
|
|
3157
2979
|
(emailLoader !== undefined ? emailLoader : false) ||
|
|
3158
2980
|
(ebillLoader !== undefined ? ebillLoader : false) ||
|
|
3159
2981
|
(mobilePushLoader !== undefined ? mobilePushLoader : false) ||
|
|
3160
|
-
(webpushLoader !== undefined ? webpushLoader : false) ||
|
|
3161
2982
|
(lineLoader !== undefined ? lineLoader : false) ||
|
|
3162
2983
|
(facebookLoader !== undefined ? facebookLoader : false) ||
|
|
3163
2984
|
(viberLoader !== undefined ? viberLoader : false) ||
|
|
@@ -3228,9 +3049,9 @@ return (<div>
|
|
|
3228
3049
|
const isMobilePushChannel = channel === MOBILE_PUSH;
|
|
3229
3050
|
const isInAppChannel = channel === INAPP;
|
|
3230
3051
|
const isFacebookChannel = channel === FACEBOOK;
|
|
3231
|
-
if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP,
|
|
3052
|
+
if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP, RCS].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
|
|
3232
3053
|
forEach(weCrmAccounts, (account) => {
|
|
3233
|
-
if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP,
|
|
3054
|
+
if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP, RCS].includes(channel)) {
|
|
3234
3055
|
if (query.type === 'embedded' && (!query.module || (query.module && query.module !== 'library'))) {
|
|
3235
3056
|
if (query.source_account_id && account.sourceAccountIdentifier === query.source_account_id) {
|
|
3236
3057
|
accountOptions.push(
|
|
@@ -3309,11 +3130,6 @@ return (<div>
|
|
|
3309
3130
|
noAccountHeader = messages.noAccountsPresentZalo;
|
|
3310
3131
|
break;
|
|
3311
3132
|
}
|
|
3312
|
-
case WEBPUSH: {
|
|
3313
|
-
accountHeader = formatMessage(messages.webpushAccount);
|
|
3314
|
-
noAccountHeader = messages.noAccountsPresentWebpush;
|
|
3315
|
-
break;
|
|
3316
|
-
}
|
|
3317
3133
|
case RCS: {
|
|
3318
3134
|
accountHeader = formatMessage(messages.rcsAccount);
|
|
3319
3135
|
noAccountHeader = messages.noAccountsPresentRcs;
|
|
@@ -3370,12 +3186,10 @@ return (<div>
|
|
|
3370
3186
|
};
|
|
3371
3187
|
|
|
3372
3188
|
setAccountSelectionMode = () => {
|
|
3373
|
-
this.props.actions.resetTemplate();
|
|
3374
3189
|
this.setState({activeMode: ACCOUNT_SELECTION_MODE});
|
|
3375
3190
|
}
|
|
3376
3191
|
|
|
3377
3192
|
setAccountChangeMode = () => {
|
|
3378
|
-
this.props.actions.resetTemplate();
|
|
3379
3193
|
this.setState({activeMode: ACCOUNT_CHANGE_MODE});
|
|
3380
3194
|
}
|
|
3381
3195
|
|
|
@@ -3427,14 +3241,19 @@ return (<div>
|
|
|
3427
3241
|
}
|
|
3428
3242
|
|
|
3429
3243
|
removeZaloFilter = () => this.setState({ selectedZaloStatus: null });
|
|
3244
|
+
removeInAppLayoutFilter = () => this.setState({ selectedInAppLayout: '' });
|
|
3430
3245
|
|
|
3431
3246
|
selectedFilters = () => {
|
|
3432
|
-
const { selectedWhatsappStatus, selectedWhatsappCategory, selectedZaloStatus } = this.state;
|
|
3247
|
+
const { selectedWhatsappStatus, selectedWhatsappCategory, selectedZaloStatus, selectedInAppLayout } = this.state;
|
|
3433
3248
|
const {
|
|
3434
3249
|
intl: {
|
|
3435
3250
|
formatMessage,
|
|
3436
3251
|
},
|
|
3437
3252
|
} = this.props;
|
|
3253
|
+
const getInAppLayoutLabel = (layoutValue) => {
|
|
3254
|
+
const layoutOption = INAPP_LAYOUT_OPTIONS.find(opt => opt.value === layoutValue);
|
|
3255
|
+
return layoutOption ? layoutOption.label : layoutValue;
|
|
3256
|
+
};
|
|
3438
3257
|
return (
|
|
3439
3258
|
<CapRow type="flex" align="middle" className="selected-whatsapp-filters">
|
|
3440
3259
|
{
|
|
@@ -3469,6 +3288,23 @@ return (<div>
|
|
|
3469
3288
|
</CapTag>
|
|
3470
3289
|
) : null
|
|
3471
3290
|
}
|
|
3291
|
+
{
|
|
3292
|
+
selectedInAppLayout ? (
|
|
3293
|
+
<CapTag closable onClose={this.removeInAppLayoutFilter}>
|
|
3294
|
+
{formatMessage(messages.layout)}: {getInAppLayoutLabel(selectedInAppLayout)}
|
|
3295
|
+
</CapTag>
|
|
3296
|
+
) : null
|
|
3297
|
+
}
|
|
3298
|
+
{
|
|
3299
|
+
selectedInAppLayout ? (
|
|
3300
|
+
<CapLink
|
|
3301
|
+
onClick={() => {
|
|
3302
|
+
this.removeInAppLayoutFilter();
|
|
3303
|
+
}}
|
|
3304
|
+
title={this.props.intl.formatMessage(messages.clearAll)}
|
|
3305
|
+
/>
|
|
3306
|
+
) : null
|
|
3307
|
+
}
|
|
3472
3308
|
</CapRow>
|
|
3473
3309
|
);
|
|
3474
3310
|
}
|
|
@@ -3479,6 +3315,7 @@ return (<div>
|
|
|
3479
3315
|
setLineFilter = (e) => this.setState({lineFilter: e.target.value});
|
|
3480
3316
|
setSMSFilter = (e) => this.setState({smsFilter: e.target.value});
|
|
3481
3317
|
setZaloStatus = (value) => this.setState({selectedZaloStatus: value?.item?.props?.value});
|
|
3318
|
+
setInAppLayout = (value) => this.setState({selectedInAppLayout: value?.item?.props?.value});
|
|
3482
3319
|
|
|
3483
3320
|
openCreativesFullMode = () => {
|
|
3484
3321
|
const channelLowerCase = this.state.channel.toLowerCase();
|
|
@@ -3731,6 +3568,21 @@ return (<div>
|
|
|
3731
3568
|
)
|
|
3732
3569
|
: () => null
|
|
3733
3570
|
}
|
|
3571
|
+
{
|
|
3572
|
+
channel.toUpperCase() === INAPP && (
|
|
3573
|
+
<div className="inapp-filters">
|
|
3574
|
+
<CapSelectFilter
|
|
3575
|
+
placement="bottomLeft"
|
|
3576
|
+
data={INAPP_LAYOUT_OPTIONS}
|
|
3577
|
+
onSelect={this.setInAppLayout}
|
|
3578
|
+
selectedValue={this.state.selectedInAppLayout}
|
|
3579
|
+
placeholder="Layout"
|
|
3580
|
+
showBadge
|
|
3581
|
+
width="120px"
|
|
3582
|
+
/>
|
|
3583
|
+
</div>
|
|
3584
|
+
)
|
|
3585
|
+
}
|
|
3734
3586
|
<div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
|
|
3735
3587
|
{
|
|
3736
3588
|
this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && (isWhatsappCountExeeded)? (
|
|
@@ -3951,8 +3803,6 @@ Templates.propTypes = {
|
|
|
3951
3803
|
rcsActions: PropTypes.object,
|
|
3952
3804
|
zaloActions: PropTypes.object,
|
|
3953
3805
|
inAppActions: PropTypes.object,
|
|
3954
|
-
webpushActions: PropTypes.object,
|
|
3955
|
-
WebPush: PropTypes.object,
|
|
3956
3806
|
smsRegister: PropTypes.any,
|
|
3957
3807
|
isDltFromRcs: PropTypes.bool,
|
|
3958
3808
|
};
|
|
@@ -3972,7 +3822,6 @@ const mapStateToProps = createStructuredSelector({
|
|
|
3972
3822
|
Rcs: makeSelectRcs(),
|
|
3973
3823
|
Zalo: makeSelectZalo(),
|
|
3974
3824
|
InApp: makeSelectInApp(),
|
|
3975
|
-
WebPush: makeSelectWebPush(),
|
|
3976
3825
|
});
|
|
3977
3826
|
|
|
3978
3827
|
function mapDispatchToProps(dispatch) {
|
|
@@ -3992,7 +3841,6 @@ function mapDispatchToProps(dispatch) {
|
|
|
3992
3841
|
whatsappActions: bindActionCreators(whatsappActions, dispatch),
|
|
3993
3842
|
rcsActions: bindActionCreators(rcsActions, dispatch),
|
|
3994
3843
|
zaloActions: bindActionCreators(zaloActions, dispatch),
|
|
3995
|
-
webpushActions: bindActionCreators(webpushActions, dispatch),
|
|
3996
3844
|
};
|
|
3997
3845
|
}
|
|
3998
3846
|
|
|
@@ -4006,7 +3854,6 @@ export default compose(
|
|
|
4006
3854
|
UserIsAuthenticated,
|
|
4007
3855
|
withSaga,
|
|
4008
3856
|
withMobilePushNewSaga,
|
|
4009
|
-
withWebPushSaga,
|
|
4010
3857
|
withReducer,
|
|
4011
3858
|
withConnect,
|
|
4012
3859
|
)(injectIntl(Templates));
|