@capillarytech/creatives-library 7.18.0-beta.0 → 8.0.0
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/app.js +27 -54
- package/assets/Line_Preview_English.svg +24 -0
- package/assets/Line_Preview_Japanese.svg +24 -0
- package/components/CapTagList/index.js +2 -2
- package/components/CapTagList/messages.js +8 -0
- package/components/Ckeditor/index.js +4 -2
- package/components/Ckeditor/style.scss +3 -0
- package/components/FormBuilder/_formBuilder.scss +4 -16
- package/components/FormBuilder/index.js +4 -3
- package/components/FormBuilder/messages.js +4 -0
- package/components/Sidebar/index.js +4 -4
- package/config/path.js +1 -1
- package/containers/App/constants.js +95 -0
- package/containers/App/index.js +52 -0
- package/containers/App/sagas.js +8 -3
- package/containers/Assets/Gallery/index.js +17 -3
- package/containers/Assets/Gallery/messages.js +4 -0
- package/containers/Assets/Gallery/sagas.js +14 -14
- package/containers/Cap/index.js +84 -50
- package/containers/Cap/sagas.js +20 -12
- package/containers/Cap/selectors.js +13 -13
- package/containers/Cap/tests/__snapshots__/index.test.js.snap +1 -1
- package/containers/Cap/tests/saga.test.js +81 -1
- package/containers/Dashboard/index.js +34 -17
- package/containers/Dashboard/sagas.js +7 -1
- package/containers/Ebill/index.js +16 -3
- package/containers/Ebill/sagas.js +18 -11
- package/containers/Email/index.js +20 -3
- package/containers/Email/sagas.js +34 -23
- package/containers/LanguageProvider/index.js +49 -31
- package/containers/LanguageProvider/tests/index.test.js +5 -3
- package/containers/Line/Create/index.js +15 -2
- package/containers/Line/Create/sagas.js +26 -17
- package/containers/Line/Edit/sagas.js +12 -13
- package/containers/Login/index.js +36 -11
- package/containers/MobilePush/Create/index.js +17 -2
- package/containers/MobilePush/Create/sagas.js +18 -12
- package/containers/MobilePush/Edit/index.js +20 -3
- package/containers/MobilePush/Edit/sagas.js +30 -20
- package/containers/Sms/Create/index.js +15 -2
- package/containers/Sms/Create/sagas.js +8 -6
- package/containers/Sms/Edit/index.js +15 -3
- package/containers/Sms/Edit/sagas.js +14 -8
- package/containers/TagList/constants.js +23 -0
- package/containers/Templates/actions.js +0 -5
- package/containers/Templates/index.js +47 -14
- package/containers/Templates/sagas.js +20 -23
- package/containers/WeChat/MapTemplates/index.js +19 -2
- package/containers/WeChat/MapTemplates/sagas.js +17 -17
- package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -2
- package/containers/WeChat/RichmediaTemplates/Create/sagas.js +11 -8
- package/containers/WeChat/RichmediaTemplates/Edit/index.js +21 -2
- package/containers/WeChat/RichmediaTemplates/Edit/sagas.js +9 -5
- package/entry.js +2 -0
- package/global-styles.js +2 -2
- package/gtm/eventDefinitionsMap.js +1 -1
- package/helpers/intl-enzym-test-helpers.js +1 -1
- package/hoc/withReactRouterV3Compatibility.js +66 -0
- package/index.js +12 -0
- package/initialReducer.js +32 -0
- package/initialState.js +1 -0
- package/mfe-exposed-components.js +8 -0
- package/package.json +16 -11
- package/routes.js +206 -749
- package/services/api.js +62 -17
- package/services/tests/api.test.js +248 -1
- package/styles/components/navigation/_leftnav.scss +13 -0
- package/styles/containers/layout/_layoutPage.scss +14 -0
- package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +21 -16
- package/tests/store.test.js +5 -3
- package/translations/en.json +1 -9
- package/translations/ja-JP.json +0 -8
- package/translations/zh.json +0 -8
- package/utils/authWrapper.js +43 -17
- package/utils/cdnTransformation.js +73 -44
- package/utils/checkStore.js +21 -0
- package/utils/common.js +198 -8
- package/utils/commonUtils.js +17 -1
- package/utils/customAuthWrapper.js +62 -0
- package/utils/customConnectedAuthWrapper.js +26 -0
- package/utils/history.js +8 -0
- package/utils/injectReducer.js +2 -0
- package/utils/injectSaga.js +2 -0
- package/utils/tagValidations.js +2 -2
- package/utils/tests/cdnTransformation.test.js +6 -4
- package/utils/tests/common.mockdata.js +623 -0
- package/utils/tests/common.test.js +273 -0
- package/utils/tests/commonUtil.test.js +79 -0
- package/v2Components/CapDeviceContent/index.js +330 -0
- package/v2Components/CapDeviceContent/index.scss +115 -0
- package/v2Components/CapDeviceContent/messages.js +94 -0
- package/v2Components/CapDeviceContent/tests/index.test.js +89 -0
- package/v2Components/CapImageUpload/constants.js +6 -0
- package/v2Components/CapImageUpload/index.js +23 -15
- package/v2Components/CapImageUpload/index.scss +6 -0
- package/v2Components/CapImageUpload/messages.js +7 -7
- package/v2Components/CapInAppCTA/constants.js +25 -0
- package/v2Components/CapInAppCTA/index.js +279 -0
- package/v2Components/CapInAppCTA/index.scss +99 -0
- package/v2Components/CapInAppCTA/messages.js +85 -0
- package/v2Components/CapTagList/index.js +149 -26
- package/v2Components/CapTagList/messages.js +12 -0
- package/v2Components/CapTagList/style.scss +26 -0
- package/v2Components/CapVideoUpload/constants.js +6 -0
- package/v2Components/CapVideoUpload/index.js +48 -22
- package/v2Components/CapVideoUpload/index.scss +4 -2
- package/v2Components/CapVideoUpload/messages.js +10 -6
- package/v2Components/CapWhatsappQuickReply/index.js +255 -0
- package/v2Components/CapWhatsappQuickReply/index.scss +54 -0
- package/v2Components/CapWhatsappQuickReply/messages.js +32 -0
- package/v2Components/Ckeditor/index.js +56 -22
- package/v2Components/Ckeditor/style.scss +3 -0
- package/v2Components/Ckeditor/tests/index.test.js +44 -0
- package/v2Components/CmsTemplatesComponent/index.js +1 -0
- package/v2Components/CmsTemplatesComponent/messages.js +4 -0
- package/v2Components/EmailMobilePreview/index.js +4 -2
- package/v2Components/EmailPreviewV2/index.js +6 -4
- package/v2Components/EmailPreviewV2/tests/__snapshots__/index.test.js.snap +0 -3
- package/v2Components/FormBuilder/_formBuilder.scss +1 -0
- package/v2Components/FormBuilder/constants.js +1 -1
- package/v2Components/FormBuilder/index.js +111 -29
- package/v2Components/FormBuilder/messages.js +4 -0
- package/v2Components/FormBuilder/tests/index.test.js +5 -2
- package/v2Components/MobilePushPreviewV2/index.js +57 -22
- package/v2Components/NavigationBar/constants.js +1 -0
- package/v2Components/NavigationBar/index.js +84 -113
- package/v2Components/NavigationBar/messages.js +8 -0
- package/v2Components/NavigationBar/style.js +9 -0
- package/v2Components/NavigationBar/tests/index.test.js +32 -9
- package/v2Components/NavigationBar/tests/mockData.js +1 -0
- package/v2Components/NewCallTask/tests/index.test.js +5 -3
- package/v2Components/Pagination/index.js +2 -1
- package/v2Components/RenderRoute/RenderRoute.js +11 -0
- package/v2Components/RenderRoute/index.js +1 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +535 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_bottom.svg +11 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_full.svg +11 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_modal.svg +11 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_top.svg +11 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_bottom.svg +6 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_full.svg +18 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_modal.svg +7 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_top.svg +13 -0
- package/v2Components/TemplatePreview/index.js +745 -362
- package/v2Components/TemplatePreview/messages.js +8 -0
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +47 -14
- package/v2Components/TemplatePreview/tests/index.test.js +9 -0
- package/v2Components/WhatsappStatusContainer/_whatsappStatusContainer.scss +8 -1
- package/v2Containers/App/constants.js +12 -6
- package/v2Containers/App/sagas.js +0 -1
- package/v2Containers/Assets/Gallery/index.js +1 -0
- package/v2Containers/Assets/Gallery/sagas.js +15 -14
- package/v2Containers/BeeEditor/index.js +3 -1
- package/v2Containers/BeeEditor/sagas.js +8 -5
- package/v2Containers/CallTask/sagas.js +7 -1
- package/v2Containers/Cap/actions.js +4 -0
- package/v2Containers/Cap/constants.js +20 -1
- package/v2Containers/Cap/index.js +116 -17
- package/v2Containers/Cap/messages.js +8 -0
- package/v2Containers/Cap/reducer.js +18 -3
- package/v2Containers/Cap/sagas.js +64 -9
- package/v2Containers/Cap/selectors.js +27 -13
- package/v2Containers/Cap/tests/Cap.test.js +164 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +2 -1
- package/v2Containers/Cap/tests/actions.test.js +11 -0
- package/v2Containers/Cap/tests/reducer.test.js +59 -0
- package/v2Containers/Cap/tests/saga.test.js +181 -2
- package/v2Containers/Cap/tests/selectors.test.js +42 -18
- package/v2Containers/CapFacebookPreview/sagas.js +7 -5
- package/v2Containers/CreativesContainer/SlideBoxContent.js +86 -4
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +4 -3
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +30 -14
- package/v2Containers/CreativesContainer/constants.js +5 -0
- package/v2Containers/CreativesContainer/index.js +157 -38
- package/v2Containers/CreativesContainer/index.scss +12 -0
- package/v2Containers/CreativesContainer/messages.js +33 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +11 -0
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +5 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +7 -1
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +227 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +73 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +80 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +16 -0
- package/v2Containers/Ebill/sagas.js +3 -10
- package/v2Containers/Email/index.js +38 -19
- package/v2Containers/Email/initialSchema.js +1 -1
- package/v2Containers/Email/sagas.js +22 -26
- package/v2Containers/EmailWrapper/index.js +18 -8
- package/v2Containers/FTP/index.js +2 -2
- package/v2Containers/FTP/sagas.js +3 -4
- package/v2Containers/Facebook/sagas.js +26 -17
- package/v2Containers/InApp/actions.js +64 -0
- package/v2Containers/InApp/constants.js +160 -0
- package/v2Containers/InApp/index.js +792 -0
- package/v2Containers/InApp/index.scss +50 -0
- package/v2Containers/InApp/messages.js +114 -0
- package/v2Containers/InApp/reducer.js +109 -0
- package/v2Containers/InApp/sagas.js +151 -0
- package/v2Containers/InApp/selectors.js +12 -0
- package/v2Containers/InApp/tests/action.test.js +53 -0
- package/v2Containers/InApp/tests/index.test.js +165 -0
- package/v2Containers/InApp/tests/mockData.js +898 -0
- package/v2Containers/InApp/tests/reducer.test.js +177 -0
- package/v2Containers/InApp/tests/sagas.test.js +391 -0
- package/v2Containers/InApp/utils.js +12 -0
- package/v2Containers/LanguageProvider/index.js +17 -5
- package/v2Containers/LanguageProvider/reducer.js +3 -2
- package/v2Containers/LanguageProvider/sagas.js +7 -8
- package/v2Containers/LanguageProvider/selectors.js +2 -1
- package/v2Containers/LanguageProvider/tests/index.test.js +5 -2
- package/v2Containers/LanguageProvider/tests/reducer.test.js +6 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +28 -16
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Line/Container/ImageCarousel/tests/content.test.js +5 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/index.test.js +5 -3
- package/v2Containers/Line/Container/ImageMap/index.js +1 -1
- package/v2Containers/Line/Container/Text/index.js +16 -1
- package/v2Containers/Line/Container/Video/index.js +2 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +18134 -107
- package/v2Containers/Line/Container/Wrapper/tests/index.test.js +5 -3
- package/v2Containers/Line/Container/Wrapper/utils.js +1 -1
- package/v2Containers/Line/Container/index.js +4 -0
- package/v2Containers/Line/Container/sagas.js +30 -20
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +123 -81
- package/v2Containers/Line/Container/tests/index.test.js +5 -2
- package/v2Containers/Login/index.js +1 -2
- package/v2Containers/MobilePush/Create/index.js +40 -17
- package/v2Containers/MobilePush/Create/sagas.js +18 -12
- package/v2Containers/MobilePush/Edit/index.js +16 -7
- package/v2Containers/MobilePush/Edit/sagas.js +30 -20
- package/v2Containers/MobilepushWrapper/index.js +3 -0
- package/v2Containers/Rcs/sagas.js +14 -14
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +123 -87
- package/v2Containers/Rcs/tests/index.test.js +5 -3
- package/v2Containers/Sms/Create/sagas.js +10 -6
- package/v2Containers/Sms/Edit/sagas.js +14 -8
- package/v2Containers/SmsTrai/Create/sagas.js +9 -10
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -4
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +12 -8
- package/v2Containers/SmsTrai/Edit/tests/index.test.js +5 -3
- package/v2Containers/TagList/_tagList.scss +18 -0
- package/v2Containers/TagList/index.js +81 -42
- package/v2Containers/TagList/tests/TagList.test.js +6 -7
- package/v2Containers/TagList/tests/mockdata.js +10 -166
- package/v2Containers/TagList/tests/utils.test.js +17 -0
- package/v2Containers/TagList/utils.js +15 -0
- package/v2Containers/Templates/_templates.scss +60 -5
- package/v2Containers/Templates/actions.js +6 -5
- package/v2Containers/Templates/constants.js +2 -1
- package/v2Containers/Templates/index.js +576 -181
- package/v2Containers/Templates/messages.js +52 -8
- package/v2Containers/Templates/reducer.js +3 -1
- package/v2Containers/Templates/sagas.js +54 -38
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +669 -43
- package/v2Containers/Templates/tests/actions.test.js +19 -0
- package/v2Containers/Templates/tests/index.test.js +53 -1
- package/v2Containers/Templates/tests/mockData.js +45 -1
- package/v2Containers/Templates/tests/reducer.test.js +50 -0
- package/v2Containers/Templates/tests/sagas.test.js +116 -3
- package/v2Containers/Templates/tests/selector.test.js +17 -0
- package/v2Containers/TemplatesV2/index.js +180 -8
- package/v2Containers/TemplatesV2/messages.js +8 -0
- package/v2Containers/TemplatesV2/tests/index.test.js +104 -0
- package/v2Containers/TemplatesV2/tests/mockData.js +685 -0
- package/v2Containers/Viber/constants.js +58 -0
- package/v2Containers/Viber/index.js +404 -421
- package/v2Containers/Viber/index.scss +107 -0
- package/v2Containers/Viber/messages.js +70 -2
- package/v2Containers/Viber/sagas.js +22 -14
- package/v2Containers/Viber/style.js +20 -0
- package/v2Containers/Viber/tests/index.test.js +299 -0
- package/v2Containers/Viber/tests/mockData.js +134 -0
- package/v2Containers/WeChat/MapTemplates/sagas.js +22 -14
- package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +12 -11
- package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +9 -5
- package/v2Containers/Whatsapp/actions.js +16 -0
- package/v2Containers/Whatsapp/constants.js +24 -0
- package/v2Containers/Whatsapp/index.js +892 -222
- package/v2Containers/Whatsapp/index.scss +91 -1
- package/v2Containers/Whatsapp/messages.js +98 -1
- package/v2Containers/Whatsapp/reducer.js +19 -0
- package/v2Containers/Whatsapp/sagas.js +67 -12
- package/v2Containers/Whatsapp/styles.scss +35 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34983 -24886
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +12 -0
- package/v2Containers/Whatsapp/tests/actions.test.js +21 -0
- package/v2Containers/Whatsapp/tests/index.test.js +17 -4
- package/v2Containers/Whatsapp/tests/mockData.js +77 -0
- package/v2Containers/Whatsapp/tests/reducer.test.js +67 -0
- package/v2Containers/Whatsapp/tests/saga.test.js +201 -0
- package/v2Containers/Whatsapp/tests/utils.test.js +18 -0
- package/v2Containers/Whatsapp/utils.js +65 -4
- package/v2Containers/Zalo/actions.js +24 -0
- package/v2Containers/Zalo/constants.js +59 -0
- package/v2Containers/Zalo/index.js +548 -0
- package/v2Containers/Zalo/index.scss +75 -0
- package/v2Containers/Zalo/messages.js +86 -0
- package/v2Containers/Zalo/reducer.js +63 -0
- package/v2Containers/Zalo/saga.js +45 -0
- package/v2Containers/Zalo/selectors.js +19 -0
- package/v2Containers/Zalo/tests/actions.test.js +26 -0
- package/v2Containers/Zalo/tests/index.test.js +149 -0
- package/v2Containers/Zalo/tests/mockData.js +11527 -0
- package/v2Containers/Zalo/tests/reducer.test.js +96 -0
- package/v2Containers/Zalo/tests/saga.test.js +118 -0
- package/v2Containers/Zalo/tests/selector.test.js +51 -0
- package/v2Containers/mockdata.js +1531 -680
- package/containers/TestPage/constants.js +0 -7
- package/containers/TestPage/index.js +0 -31
- package/containers/TestPage/messages.js +0 -13
- package/containers/TestPage/reducer.js +0 -21
- package/containers/TestPage/sagas.js +0 -11
- package/containers/Testv2/actions.js +0 -15
- package/containers/Testv2/constants.js +0 -7
- package/containers/Testv2/index.js +0 -47
- package/containers/Testv2/messages.js +0 -21
- package/containers/Testv2/reducer.js +0 -23
- package/containers/Testv2/sagas.js +0 -11
- package/containers/Testv2/selectors.js +0 -25
- package/reducers.js +0 -73
- package/store.js +0 -61
- package/utils/tests/asyncInjectors.test.js +0 -173
- package/v2Containers/TestPage/constants.js +0 -7
- package/v2Containers/TestPage/index.js +0 -31
- package/v2Containers/TestPage/messages.js +0 -13
- package/v2Containers/TestPage/reducer.js +0 -21
- package/v2Containers/TestPage/sagas.js +0 -11
- package/v2Containers/Testv2/actions.js +0 -15
- package/v2Containers/Testv2/constants.js +0 -7
- package/v2Containers/Testv2/index.js +0 -47
- package/v2Containers/Testv2/messages.js +0 -21
- package/v2Containers/Testv2/reducer.js +0 -23
- package/v2Containers/Testv2/sagas.js +0 -11
- package/v2Containers/Testv2/selectors.js +0 -25
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import isEmpty from 'lodash/isEmpty';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { bindActionCreators } from "redux";
|
|
5
|
+
import { createStructuredSelector } from "reselect";
|
|
6
|
+
import { injectIntl, FormattedMessage } from "react-intl";
|
|
7
|
+
import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
|
|
8
|
+
import CapSpin from "@capillarytech/cap-ui-library/CapSpin";
|
|
9
|
+
import CapInput from "@capillarytech/cap-ui-library/CapInput";
|
|
10
|
+
import CapRadioGroup from "@capillarytech/cap-ui-library/CapRadioGroup";
|
|
11
|
+
import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
12
|
+
import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
|
|
13
|
+
import CapButton from "@capillarytech/cap-ui-library/CapButton";
|
|
14
|
+
import CapTab from "@capillarytech/cap-ui-library/CapTab";
|
|
15
|
+
import CapNotification from "@capillarytech/cap-ui-library/CapNotification";
|
|
16
|
+
import { makeSelectInApp, makeSelectAccount } from "./selectors";
|
|
17
|
+
import {
|
|
18
|
+
isLoadingMetaEntities,
|
|
19
|
+
makeSelectMetaEntities,
|
|
20
|
+
setInjectedTags,
|
|
21
|
+
} from "../Cap/selectors";
|
|
22
|
+
import * as inAppActions from "./actions";
|
|
23
|
+
import './index.scss';
|
|
24
|
+
import messages from "./messages";
|
|
25
|
+
import globalMessages from "../Cap/messages";
|
|
26
|
+
import withCreatives from "../../hoc/withCreatives";
|
|
27
|
+
import TemplatePreview from "../../v2Components/TemplatePreview";
|
|
28
|
+
import { validateTags } from "../../utils/tagValidations";
|
|
29
|
+
|
|
30
|
+
import {
|
|
31
|
+
ANDROID,
|
|
32
|
+
BIG_PICTURE,
|
|
33
|
+
BIG_TEXT,
|
|
34
|
+
DEEP_LINK,
|
|
35
|
+
DEVICE_SUPPORTED,
|
|
36
|
+
INAPP_BUTTON_TYPES,
|
|
37
|
+
INAPP_MEDIA_TYPES,
|
|
38
|
+
INAPP_MESSAGE_LAYOUT_TYPES,
|
|
39
|
+
INITIAL_CTA_DATA,
|
|
40
|
+
IOS,
|
|
41
|
+
LAYOUT_RADIO_OPTIONS,
|
|
42
|
+
} from "./constants";
|
|
43
|
+
import { INAPP, SMS } from "../CreativesContainer/constants";
|
|
44
|
+
import { ALL, TAG, EMBEDDED, DEFAULT, FULL, LIBRARY } from "../Whatsapp/constants";
|
|
45
|
+
import CapDeviceContent from "../../v2Components/CapDeviceContent";
|
|
46
|
+
import { getCdnUrl } from "../../utils/cdnTransformation";
|
|
47
|
+
import { getCtaObject } from "./utils";
|
|
48
|
+
let editContent = {};
|
|
49
|
+
|
|
50
|
+
export const InApp = (props) => {
|
|
51
|
+
const {
|
|
52
|
+
intl,
|
|
53
|
+
actions,
|
|
54
|
+
isFullMode,
|
|
55
|
+
onCreateComplete,
|
|
56
|
+
params,
|
|
57
|
+
templateData = {},
|
|
58
|
+
editData = {},
|
|
59
|
+
accountData = {},
|
|
60
|
+
globalActions,
|
|
61
|
+
location,
|
|
62
|
+
getDefaultTags,
|
|
63
|
+
supportedTags,
|
|
64
|
+
metaEntities,
|
|
65
|
+
injectedTags,
|
|
66
|
+
getFormData,
|
|
67
|
+
selectedOfferDetails,
|
|
68
|
+
} = props || {};
|
|
69
|
+
const { formatMessage } = intl;
|
|
70
|
+
const [titleAndroid, setTitleAndroid] = useState("");
|
|
71
|
+
const [titleIos, setTitleIos] = useState("");
|
|
72
|
+
const [templateMediaType, setTemplateMediaType] = useState(
|
|
73
|
+
INAPP_MEDIA_TYPES.TEXT
|
|
74
|
+
);
|
|
75
|
+
const [templateName, setTemplateName] = useState("");
|
|
76
|
+
const [templateLayoutType, setTemplateLayoutType] = useState(
|
|
77
|
+
INAPP_MESSAGE_LAYOUT_TYPES.MODAL
|
|
78
|
+
);
|
|
79
|
+
const [addActionLinkAndroid, setAddActionLinkAndroid] = useState(false);
|
|
80
|
+
const [addActionLinkIos, setAddActionLinkIos] = useState(false);
|
|
81
|
+
const [deepLinkValueAndroid, setDeepLinkValueAndroid] = useState('');
|
|
82
|
+
const [deepLinkValueIos, setDeepLinkValueIos] = useState('');
|
|
83
|
+
const [templateMessageAndroid, setTemplateMessageAndroid] = useState("");
|
|
84
|
+
const [templateMessageIos, setTemplateMessageIos] = useState("");
|
|
85
|
+
const [templateMessageErrorAndroid, setTemplateMessageErrorAndroid] = useState(false);
|
|
86
|
+
const [templateMessageErrorIos, setTemplateMessageErrorIos] = useState(false);
|
|
87
|
+
const [templateTitleErrorAndroid, setTemplateTitleErrorAndroid] = useState(false);
|
|
88
|
+
const [templateTitleErrorIos, setTemplateTitleErrorIos] = useState(false);
|
|
89
|
+
const [accountId, setAccountId] = useState("");
|
|
90
|
+
const [accessToken, setAccessToken] = useState("");
|
|
91
|
+
const [accountName, setAccountName] = useState("");
|
|
92
|
+
const [deepLink, setDeepLink] = useState([]);
|
|
93
|
+
const [spin, setSpin] = useState(false);
|
|
94
|
+
const [inAppImageSrcAndroid, setInAppImageSrcAndroid] = useState("");
|
|
95
|
+
const [inAppImageSrcIos, setInAppImageSrcIos] = useState("");
|
|
96
|
+
const [panes, setPanes] = useState(ANDROID);
|
|
97
|
+
//for tag only
|
|
98
|
+
const [tags, updateTags] = useState([]);
|
|
99
|
+
//for edit only
|
|
100
|
+
const [isEditFlow, setEditFlow] = useState(false);
|
|
101
|
+
const [templateDate, setTemplateDate] = useState("");
|
|
102
|
+
|
|
103
|
+
//buttons
|
|
104
|
+
const [ctaDataAndroid, setCtaDataAndroid] = useState(INITIAL_CTA_DATA);
|
|
105
|
+
const [ctaDataIos, setCtaDataIos] = useState(INITIAL_CTA_DATA);
|
|
106
|
+
const [buttonTypeAndroid, setButtonTypeAndroid] = useState(
|
|
107
|
+
INAPP_BUTTON_TYPES.NONE
|
|
108
|
+
);
|
|
109
|
+
const [buttonTypeIos, setButtonTypeIos] = useState(INAPP_BUTTON_TYPES.NONE);
|
|
110
|
+
const isBtnTypeCtaAndroid = buttonTypeAndroid === INAPP_BUTTON_TYPES.CTA;
|
|
111
|
+
const isBtnTypeCTaIos = buttonTypeIos === INAPP_BUTTON_TYPES.CTA;
|
|
112
|
+
|
|
113
|
+
//gets account details
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
const accountObj = accountData?.selectedWeChatAccount || {};
|
|
116
|
+
const deepLinkObj = accountObj?.configs?.deeplink || '';
|
|
117
|
+
if (!isEmpty(accountObj)) {
|
|
118
|
+
const {
|
|
119
|
+
sourceAccountIdentifier = "",
|
|
120
|
+
configs = {},
|
|
121
|
+
name = "",
|
|
122
|
+
} = accountObj;
|
|
123
|
+
const isAndroidSupported = configs?.android === DEVICE_SUPPORTED;
|
|
124
|
+
// DEVICE_SUPPORTED is '1', which indicates if the particular account is supported, and '0' if the devive is not supported
|
|
125
|
+
//get deep link keys in an array
|
|
126
|
+
const deepLinkKeys = Object.values(JSON.parse(deepLinkObj || '{}'));
|
|
127
|
+
const keys = deepLinkKeys?.map((link) => ({label: link.name, value: link.link, title: link.link }));
|
|
128
|
+
setPanes(isAndroidSupported ? ANDROID : IOS);
|
|
129
|
+
setDeepLink(keys);
|
|
130
|
+
setAccountId(sourceAccountIdentifier);
|
|
131
|
+
setAccessToken(configs?.accessToken || "");
|
|
132
|
+
setAccountName(name);
|
|
133
|
+
}
|
|
134
|
+
}, [accountData?.selectedWeChatAccount]);
|
|
135
|
+
|
|
136
|
+
//gets template details
|
|
137
|
+
const paramObj = params || {};
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
const { id } = paramObj;
|
|
140
|
+
if (id) {
|
|
141
|
+
if (isFullMode) {
|
|
142
|
+
setSpin(true);
|
|
143
|
+
actions.getTemplateDetails(id, setSpin);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//cleanup code
|
|
147
|
+
return () => {
|
|
148
|
+
actions.resetEditTemplate();
|
|
149
|
+
};
|
|
150
|
+
}, [paramObj.id]);
|
|
151
|
+
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
const {
|
|
154
|
+
name = "",
|
|
155
|
+
versions = {},
|
|
156
|
+
createdAt = "",
|
|
157
|
+
} = isFullMode ? editData?.templateDetails || {} : templateData || {};
|
|
158
|
+
editContent = get(versions, `base.content`, {});
|
|
159
|
+
if (editContent && !isEmpty(editContent)) {
|
|
160
|
+
setEditFlow(true);
|
|
161
|
+
setTemplateName(name);
|
|
162
|
+
setTemplateDate(createdAt);
|
|
163
|
+
setTemplateLayoutType(editContent?.ANDROID?.bodyType);
|
|
164
|
+
const androidContent = editContent?.ANDROID;
|
|
165
|
+
if (!isEmpty(androidContent)) {
|
|
166
|
+
const {
|
|
167
|
+
title: androidTitle = '',
|
|
168
|
+
message: androidMessage = '',
|
|
169
|
+
ctas: androidCta = {},
|
|
170
|
+
expandableDetails: androidExpandableDetails = {},
|
|
171
|
+
} = androidContent || {};
|
|
172
|
+
const {
|
|
173
|
+
style: androidStyle,
|
|
174
|
+
image: androidImage,
|
|
175
|
+
ctas: androidCtas,
|
|
176
|
+
} = androidExpandableDetails || {};
|
|
177
|
+
const androidCtaLength = androidCtas?.length;
|
|
178
|
+
setTitleAndroid(androidTitle);
|
|
179
|
+
setTemplateMessageAndroid(androidMessage);
|
|
180
|
+
setTemplateMediaType(
|
|
181
|
+
androidStyle === BIG_TEXT
|
|
182
|
+
? INAPP_MEDIA_TYPES.TEXT
|
|
183
|
+
: INAPP_MEDIA_TYPES.IMAGE
|
|
184
|
+
);
|
|
185
|
+
setInAppImageSrcAndroid(androidImage);
|
|
186
|
+
setDeepLinkValueAndroid(androidCta[0]?.actionLink || '');
|
|
187
|
+
setAddActionLinkAndroid(!isEmpty(androidCta) && true);
|
|
188
|
+
setButtonTypeAndroid(
|
|
189
|
+
androidCtaLength ? INAPP_BUTTON_TYPES.CTA : INAPP_BUTTON_TYPES.NONE
|
|
190
|
+
);
|
|
191
|
+
if (androidCtaLength > 0) {
|
|
192
|
+
setCtaDataAndroid(getCtaObject(androidCtas));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const iosContent = editContent?.IOS;
|
|
196
|
+
if (!isEmpty(iosContent)) {
|
|
197
|
+
const {
|
|
198
|
+
title: iosTitle = '',
|
|
199
|
+
message: iosMessage = '',
|
|
200
|
+
ctas: iosCta = {},
|
|
201
|
+
expandableDetails: iosExpandableDetails = {},
|
|
202
|
+
} = iosContent || {};
|
|
203
|
+
const {
|
|
204
|
+
style: iosStyle,
|
|
205
|
+
image: iosImage,
|
|
206
|
+
ctas: iosCtas,
|
|
207
|
+
} = iosExpandableDetails || {};
|
|
208
|
+
const iosCtaLength = iosCtas?.length;
|
|
209
|
+
setTitleIos(iosTitle);
|
|
210
|
+
setTemplateMessageIos(iosMessage);
|
|
211
|
+
setTemplateMediaType(iosStyle === BIG_TEXT ? INAPP_MEDIA_TYPES.TEXT : INAPP_MEDIA_TYPES.IMAGE);
|
|
212
|
+
setInAppImageSrcIos(iosImage);
|
|
213
|
+
setButtonTypeIos(iosCtaLength ? INAPP_BUTTON_TYPES.CTA : INAPP_BUTTON_TYPES.NONE);
|
|
214
|
+
setAddActionLinkIos(!isEmpty(iosCta) && true);
|
|
215
|
+
setDeepLinkValueIos(iosCta[0]?.actionLink || '');
|
|
216
|
+
if (iosCtaLength > 0) {
|
|
217
|
+
setCtaDataIos(getCtaObject(iosCtas));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}, [editData.templateDetails || templateData]);
|
|
222
|
+
|
|
223
|
+
// tag Code start from here
|
|
224
|
+
useEffect(() => {
|
|
225
|
+
//fetching tags
|
|
226
|
+
const { type, module } = location.query || {};
|
|
227
|
+
const isEmbedded = type === EMBEDDED;
|
|
228
|
+
const context = isEmbedded ? module : DEFAULT;
|
|
229
|
+
const embedded = isEmbedded ? type : FULL;
|
|
230
|
+
const query = {
|
|
231
|
+
layout: SMS,
|
|
232
|
+
type: TAG,
|
|
233
|
+
context,
|
|
234
|
+
embedded,
|
|
235
|
+
};
|
|
236
|
+
if (getDefaultTags) {
|
|
237
|
+
query.context = getDefaultTags;
|
|
238
|
+
}
|
|
239
|
+
globalActions.fetchSchemaForEntity(query);
|
|
240
|
+
}, []);
|
|
241
|
+
|
|
242
|
+
useEffect(() => {
|
|
243
|
+
let tag = get(metaEntities, `tags.standard`, []);
|
|
244
|
+
const { type, module } = location.query || {};
|
|
245
|
+
if (type === EMBEDDED && module === LIBRARY && !getDefaultTags) {
|
|
246
|
+
tag = supportedTags;
|
|
247
|
+
}
|
|
248
|
+
updateTags(tag);
|
|
249
|
+
}, [metaEntities]);
|
|
250
|
+
|
|
251
|
+
const handleOnTagsContextChange = (data) => {
|
|
252
|
+
const { type } = location.query || {};
|
|
253
|
+
const tempData = (data || '').toLowerCase();
|
|
254
|
+
const isEmbedded = type === EMBEDDED;
|
|
255
|
+
const embedded = isEmbedded ? type : FULL;
|
|
256
|
+
const context = tempData === ALL ? DEFAULT : tempData;
|
|
257
|
+
const query = {
|
|
258
|
+
layout: SMS,
|
|
259
|
+
type: TAG,
|
|
260
|
+
context,
|
|
261
|
+
embedded,
|
|
262
|
+
};
|
|
263
|
+
globalActions.fetchSchemaForEntity(query);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const templateDescErrorHandler = (value) => {
|
|
267
|
+
let errorMessage = false;
|
|
268
|
+
const { unsupportedTags, isBraceError } =
|
|
269
|
+
validateTags({
|
|
270
|
+
content: value,
|
|
271
|
+
tagsParam: tags,
|
|
272
|
+
injectedTagsParams: injectedTags,
|
|
273
|
+
location,
|
|
274
|
+
tagModule: getDefaultTags,
|
|
275
|
+
}) || {};
|
|
276
|
+
if (value === '' && INAPP_MEDIA_TYPES.NONE) {
|
|
277
|
+
errorMessage = formatMessage(messages.emptyTemplateDescErrorMessage);
|
|
278
|
+
} else if (unsupportedTags?.length > 0) {
|
|
279
|
+
errorMessage = formatMessage(
|
|
280
|
+
globalMessages.unsupportedTagsValidationError,
|
|
281
|
+
{
|
|
282
|
+
unsupportedTags,
|
|
283
|
+
},
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
if (isBraceError) {
|
|
287
|
+
errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
288
|
+
}
|
|
289
|
+
return errorMessage;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const onTagSelect = (data, id) => {
|
|
293
|
+
if (id === 0) {
|
|
294
|
+
const tempTitle = `${panes === ANDROID ? titleAndroid : titleIos}{{${data}}}`;
|
|
295
|
+
if (panes === ANDROID) {
|
|
296
|
+
setTitleAndroid(tempTitle);
|
|
297
|
+
} else {
|
|
298
|
+
setTitleIos(tempTitle);
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
const tempMsg = `${panes === ANDROID ? templateMessageAndroid : templateMessageIos}{{${data}}}`;
|
|
302
|
+
const error = templateDescErrorHandler(tempMsg);
|
|
303
|
+
if (panes === ANDROID) {
|
|
304
|
+
setTemplateMessageAndroid(tempMsg);
|
|
305
|
+
setTemplateMessageErrorAndroid(error);
|
|
306
|
+
} else {
|
|
307
|
+
setTemplateMessageIos(tempMsg);
|
|
308
|
+
setTemplateMessageErrorIos(error);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
// tag Code end
|
|
313
|
+
|
|
314
|
+
const onTemplateNameChange = ({ target: { value } }) => {
|
|
315
|
+
setTemplateName(value);
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const onTemplateLayoutTypeChange = ({ target: { value } }) => {
|
|
319
|
+
setTemplateLayoutType(value);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const onCopyTitleAndContent = () => {
|
|
323
|
+
if (panes === ANDROID) {
|
|
324
|
+
setTitleAndroid(titleIos);
|
|
325
|
+
setTemplateMessageAndroid(templateMessageIos);
|
|
326
|
+
} else {
|
|
327
|
+
setTitleIos(titleAndroid);
|
|
328
|
+
setTemplateMessageIos(templateMessageAndroid);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const PANES = [
|
|
333
|
+
{
|
|
334
|
+
content: (
|
|
335
|
+
<CapDeviceContent
|
|
336
|
+
intl={intl}
|
|
337
|
+
location={location}
|
|
338
|
+
injectedTags={injectIntl}
|
|
339
|
+
selectedOfferDetails={selectedOfferDetails}
|
|
340
|
+
panes={panes}
|
|
341
|
+
actions={actions}
|
|
342
|
+
editData={editData}
|
|
343
|
+
isFullMode={isFullMode}
|
|
344
|
+
inAppImageSrc={inAppImageSrcAndroid}
|
|
345
|
+
setInAppImageSrc={setInAppImageSrcAndroid}
|
|
346
|
+
isEditFlow={isEditFlow}
|
|
347
|
+
ctaData={ctaDataAndroid}
|
|
348
|
+
setCtaData={setCtaDataAndroid}
|
|
349
|
+
buttonType={buttonTypeAndroid}
|
|
350
|
+
setButtonType={setButtonTypeAndroid}
|
|
351
|
+
accountId={accountId}
|
|
352
|
+
accessToken={accessToken}
|
|
353
|
+
templateMediaType={templateMediaType}
|
|
354
|
+
setTemplateMediaType={setTemplateMediaType}
|
|
355
|
+
title={titleAndroid}
|
|
356
|
+
setTitle={setTitleAndroid}
|
|
357
|
+
templateMessageError={templateMessageErrorAndroid}
|
|
358
|
+
templateMessage={templateMessageAndroid}
|
|
359
|
+
setTemplateMessage={setTemplateMessageAndroid}
|
|
360
|
+
setTemplateMessageError={setTemplateMessageErrorAndroid}
|
|
361
|
+
templateTitleError={templateTitleErrorAndroid}
|
|
362
|
+
setTemplateTitleError={setTemplateTitleErrorAndroid}
|
|
363
|
+
addActionLink={addActionLinkAndroid}
|
|
364
|
+
setAddActionLink={setAddActionLinkAndroid}
|
|
365
|
+
deepLink={deepLink}
|
|
366
|
+
deepLinkValue={deepLinkValueAndroid}
|
|
367
|
+
setDeepLinkValue={setDeepLinkValueAndroid}
|
|
368
|
+
onCopyTitleAndContent={onCopyTitleAndContent}
|
|
369
|
+
tags={tags}
|
|
370
|
+
onTagSelect={onTagSelect}
|
|
371
|
+
handleOnTagsContextChange={handleOnTagsContextChange}
|
|
372
|
+
templateDescErrorHandler={templateDescErrorHandler}
|
|
373
|
+
/>
|
|
374
|
+
),
|
|
375
|
+
tab: <FormattedMessage {...messages.Android} />,
|
|
376
|
+
key: ANDROID,
|
|
377
|
+
isSupported: get(accountData, 'selectedWeChatAccount.configs.android') === DEVICE_SUPPORTED,
|
|
378
|
+
// DEVICE_SUPPORTED is '1', which indicates if the particular account is supported, and '0' if the devive is not supported
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
content: (
|
|
382
|
+
<CapDeviceContent
|
|
383
|
+
intl={intl}
|
|
384
|
+
location={location}
|
|
385
|
+
injectedTags={injectIntl}
|
|
386
|
+
selectedOfferDetails={selectedOfferDetails}
|
|
387
|
+
panes={panes}
|
|
388
|
+
actions={actions}
|
|
389
|
+
editData={editData}
|
|
390
|
+
isFullMode={isFullMode}
|
|
391
|
+
inAppImageSrc={inAppImageSrcIos}
|
|
392
|
+
setInAppImageSrc={setInAppImageSrcIos}
|
|
393
|
+
isEditFlow={isEditFlow}
|
|
394
|
+
ctaData={ctaDataIos}
|
|
395
|
+
setCtaData={setCtaDataIos}
|
|
396
|
+
buttonType={buttonTypeIos}
|
|
397
|
+
setButtonType={setButtonTypeIos}
|
|
398
|
+
accountId={accountId}
|
|
399
|
+
accessToken={accessToken}
|
|
400
|
+
templateMediaType={templateMediaType}
|
|
401
|
+
setTemplateMediaType={setTemplateMediaType}
|
|
402
|
+
title={titleIos}
|
|
403
|
+
setTitle={setTitleIos}
|
|
404
|
+
templateMessageError={templateMessageErrorIos}
|
|
405
|
+
templateMessage={templateMessageIos}
|
|
406
|
+
setTemplateMessage={setTemplateMessageIos}
|
|
407
|
+
setTemplateMessageError={setTemplateMessageErrorIos}
|
|
408
|
+
templateTitleError={templateTitleErrorIos}
|
|
409
|
+
setTemplateTitleError={setTemplateTitleErrorIos}
|
|
410
|
+
addActionLink={addActionLinkIos}
|
|
411
|
+
setAddActionLink={setAddActionLinkIos}
|
|
412
|
+
deepLink={deepLink}
|
|
413
|
+
deepLinkValue={deepLinkValueIos}
|
|
414
|
+
setDeepLinkValue={setDeepLinkValueIos}
|
|
415
|
+
onCopyTitleAndContent={onCopyTitleAndContent}
|
|
416
|
+
tags={tags}
|
|
417
|
+
onTagSelect={onTagSelect}
|
|
418
|
+
handleOnTagsContextChange={handleOnTagsContextChange}
|
|
419
|
+
templateDescErrorHandler={templateDescErrorHandler}
|
|
420
|
+
/>
|
|
421
|
+
),
|
|
422
|
+
tab: <FormattedMessage {...messages.Ios} />,
|
|
423
|
+
key: IOS,
|
|
424
|
+
isSupported: get(accountData, 'selectedWeChatAccount.configs.ios') === DEVICE_SUPPORTED,
|
|
425
|
+
},
|
|
426
|
+
];
|
|
427
|
+
|
|
428
|
+
const createModeContent = (
|
|
429
|
+
<CapRow>
|
|
430
|
+
{/* template name */}
|
|
431
|
+
<CapHeading type="h4">
|
|
432
|
+
<FormattedMessage {...messages.creativeName} />
|
|
433
|
+
</CapHeading>
|
|
434
|
+
<CapInput
|
|
435
|
+
id="inapp-template-name-input"
|
|
436
|
+
className="inapp-template-name-input"
|
|
437
|
+
onChange={onTemplateNameChange}
|
|
438
|
+
placeholder={formatMessage(globalMessages.templateNamePlaceholder)}
|
|
439
|
+
value={templateName}
|
|
440
|
+
size="default"
|
|
441
|
+
/>
|
|
442
|
+
</CapRow>
|
|
443
|
+
);
|
|
444
|
+
//create methods end
|
|
445
|
+
|
|
446
|
+
//used by create and edit
|
|
447
|
+
const getPreviewSection = () => {
|
|
448
|
+
const templateTitle = panes === ANDROID ? titleAndroid : titleIos;
|
|
449
|
+
const templateMsg = panes === ANDROID ? templateMessageAndroid : templateMessageIos;
|
|
450
|
+
const mediaPreview = {};
|
|
451
|
+
let ctaData = {};
|
|
452
|
+
if (panes === ANDROID) {
|
|
453
|
+
ctaData = ctaDataAndroid;
|
|
454
|
+
switch (templateMediaType) {
|
|
455
|
+
case INAPP_MEDIA_TYPES.IMAGE:
|
|
456
|
+
mediaPreview.inAppImageSrcAndroid = inAppImageSrcAndroid;
|
|
457
|
+
break;
|
|
458
|
+
default:
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
} else {
|
|
462
|
+
ctaData = ctaDataIos;
|
|
463
|
+
switch (templateMediaType) {
|
|
464
|
+
case INAPP_MEDIA_TYPES.IMAGE:
|
|
465
|
+
mediaPreview.inAppImageSrcIos = inAppImageSrcIos;
|
|
466
|
+
break;
|
|
467
|
+
default:
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return (
|
|
472
|
+
<TemplatePreview
|
|
473
|
+
channel={INAPP}
|
|
474
|
+
content={{
|
|
475
|
+
inAppPreviewContent: {
|
|
476
|
+
mediaPreview,
|
|
477
|
+
templateTitle,
|
|
478
|
+
templateMsg,
|
|
479
|
+
...((isBtnTypeCtaAndroid || isBtnTypeCTaIos) && {
|
|
480
|
+
ctaData,
|
|
481
|
+
}),
|
|
482
|
+
},
|
|
483
|
+
}}
|
|
484
|
+
inAppAccountName={accountName}
|
|
485
|
+
templateLayoutType={templateLayoutType}
|
|
486
|
+
device={panes}
|
|
487
|
+
/>
|
|
488
|
+
);
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
const isDisableDone = (device) => {
|
|
492
|
+
const isIosDevice = device === IOS;
|
|
493
|
+
const isAndroidDevice = device === ANDROID;
|
|
494
|
+
//if template name is not entered
|
|
495
|
+
if (isFullMode && templateName.trim() === '') {
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
//if template message is not entered
|
|
499
|
+
//for android
|
|
500
|
+
if (isAndroidDevice && (templateMessageAndroid.trim() === '' || templateMessageErrorAndroid)) {
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
if (isIosDevice && (templateMessageIos.trim() === '' || templateMessageErrorIos)) {
|
|
504
|
+
return true;
|
|
505
|
+
}//for ios
|
|
506
|
+
|
|
507
|
+
//if template title is not entered
|
|
508
|
+
//for android
|
|
509
|
+
if (isAndroidDevice && (titleAndroid.trim() === '' || templateTitleErrorAndroid)) {
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
if (isIosDevice && (titleIos.trim() === '' || templateTitleErrorIos)) {
|
|
513
|
+
return true;
|
|
514
|
+
}//for ios
|
|
515
|
+
//if media type is image and the mediaType file is not uploaded
|
|
516
|
+
if (isAndroidDevice && !(templateMediaType === INAPP_MEDIA_TYPES.TEXT) && inAppImageSrcAndroid === '') {
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
if (isIosDevice && !(templateMediaType === INAPP_MEDIA_TYPES.TEXT) && inAppImageSrcIos === '') {
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
//cta
|
|
523
|
+
if (isBtnTypeCtaAndroid) {
|
|
524
|
+
if (ctaDataAndroid[0]?.isSaved) {
|
|
525
|
+
//if button type is cta and 1st button is saved
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
//if button type is cta and there are no buttons saved
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
if (isBtnTypeCTaIos) {
|
|
532
|
+
if (ctaDataIos[0]?.isSaved) {
|
|
533
|
+
//if button type is cta and 1st button is saved
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
//if button type is cta and there are no buttons saved
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// action link
|
|
541
|
+
if (addActionLinkAndroid && !deepLinkValueAndroid) {
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
if (addActionLinkIos && !deepLinkValueIos) {
|
|
545
|
+
return true;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return false;
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
const getCtaPayload = (type) =>
|
|
552
|
+
(type === ANDROID ? ctaDataAndroid : ctaDataIos).map((cta) => {
|
|
553
|
+
const { text, urlType, url } = cta;
|
|
554
|
+
return {
|
|
555
|
+
type: urlType,
|
|
556
|
+
actionText: text,
|
|
557
|
+
actionLink: url,
|
|
558
|
+
};
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
const createPayload = () => {
|
|
562
|
+
let androidMediaParams = {};
|
|
563
|
+
let iosMediaParams = {};
|
|
564
|
+
const commonDevicePayload = {
|
|
565
|
+
luid: "{{luid}}",
|
|
566
|
+
cuid: "{{cuid}}",
|
|
567
|
+
communicationId: "{{communicationId}}",
|
|
568
|
+
};
|
|
569
|
+
switch (templateMediaType) {
|
|
570
|
+
case INAPP_MEDIA_TYPES.IMAGE:
|
|
571
|
+
androidMediaParams = {
|
|
572
|
+
image: getCdnUrl({url: inAppImageSrcAndroid, channelName: INAPP }),
|
|
573
|
+
style: BIG_PICTURE,
|
|
574
|
+
};
|
|
575
|
+
iosMediaParams = {
|
|
576
|
+
image: getCdnUrl({url: inAppImageSrcIos, channelName: INAPP }),
|
|
577
|
+
style: BIG_PICTURE,
|
|
578
|
+
};
|
|
579
|
+
break;
|
|
580
|
+
default:
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
const accountObj = accountData?.selectedWeChatAccount || {};
|
|
584
|
+
const {
|
|
585
|
+
sourceAccountIdentifier = "",
|
|
586
|
+
id,
|
|
587
|
+
} = accountObj;
|
|
588
|
+
const data = {
|
|
589
|
+
name: templateName,
|
|
590
|
+
versions: {
|
|
591
|
+
base: {
|
|
592
|
+
content: {
|
|
593
|
+
ANDROID: !isDisableDone(ANDROID) ? {
|
|
594
|
+
...commonDevicePayload,
|
|
595
|
+
title: titleAndroid,
|
|
596
|
+
message: templateMessageAndroid,
|
|
597
|
+
bodyType: templateLayoutType,
|
|
598
|
+
expandableDetails: {
|
|
599
|
+
style: BIG_TEXT,
|
|
600
|
+
message: templateMessageAndroid,
|
|
601
|
+
...androidMediaParams,
|
|
602
|
+
...(isBtnTypeCtaAndroid && {
|
|
603
|
+
ctas: getCtaPayload(ANDROID),
|
|
604
|
+
}),
|
|
605
|
+
},
|
|
606
|
+
custom: [],
|
|
607
|
+
...(deepLinkValueAndroid && {
|
|
608
|
+
ctas: [{type: DEEP_LINK, actionLink: deepLinkValueAndroid}],
|
|
609
|
+
}),
|
|
610
|
+
} : {},
|
|
611
|
+
IOS: !isDisableDone(IOS) ? {
|
|
612
|
+
...commonDevicePayload,
|
|
613
|
+
title: titleIos,
|
|
614
|
+
message: templateMessageIos,
|
|
615
|
+
bodyType: templateLayoutType,
|
|
616
|
+
expandableDetails: {
|
|
617
|
+
style: BIG_TEXT,
|
|
618
|
+
message: templateMessageIos,
|
|
619
|
+
...iosMediaParams,
|
|
620
|
+
...(isBtnTypeCTaIos && {
|
|
621
|
+
ctas: getCtaPayload(IOS),
|
|
622
|
+
}),
|
|
623
|
+
},
|
|
624
|
+
custom: [],
|
|
625
|
+
...(deepLinkValueIos && {
|
|
626
|
+
ctas: [{type: DEEP_LINK, actionLink: deepLinkValueIos}],
|
|
627
|
+
}),
|
|
628
|
+
} : {},
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
type: INAPP,
|
|
633
|
+
definition: {
|
|
634
|
+
accountId: id,
|
|
635
|
+
licenseCode: sourceAccountIdentifier,
|
|
636
|
+
mode: templateMediaType,
|
|
637
|
+
},
|
|
638
|
+
};
|
|
639
|
+
return data;
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
const actionCallback = ({ errorMessage }) => {
|
|
643
|
+
if (!errorMessage) {
|
|
644
|
+
CapNotification.success({
|
|
645
|
+
message: isEditFlow ? formatMessage(messages.inAppEditNotification, {
|
|
646
|
+
name: templateName,
|
|
647
|
+
}) : formatMessage(messages.inAppCreateNotification, {
|
|
648
|
+
name: templateName,
|
|
649
|
+
}),
|
|
650
|
+
});
|
|
651
|
+
actions.clearCreateResponse();
|
|
652
|
+
} else {
|
|
653
|
+
CapNotification.error({
|
|
654
|
+
message: JSON.stringify(errorMessage),
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
const onCreateInApp = () => {
|
|
660
|
+
setSpin(true);
|
|
661
|
+
actions.createInAppTemplate(createPayload(), (resp, errorMessage) => {
|
|
662
|
+
actionCallback({ resp, errorMessage });
|
|
663
|
+
if (!errorMessage) {
|
|
664
|
+
onCreateComplete();
|
|
665
|
+
} else {
|
|
666
|
+
setSpin(false);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
const onEditInApp = () => {
|
|
672
|
+
setSpin(true);
|
|
673
|
+
actions.editTemplate(
|
|
674
|
+
{
|
|
675
|
+
...createPayload(),
|
|
676
|
+
_id: params.id,
|
|
677
|
+
},
|
|
678
|
+
(resp, errorMessage) => {
|
|
679
|
+
actionCallback({ resp, errorMessage });
|
|
680
|
+
if (!errorMessage) {
|
|
681
|
+
onCreateComplete();
|
|
682
|
+
} else {
|
|
683
|
+
setSpin(false);
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
);
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
const onDoneCallback = () => {
|
|
690
|
+
if (isFullMode) {
|
|
691
|
+
if (isEditFlow) {
|
|
692
|
+
return onEditInApp;
|
|
693
|
+
}
|
|
694
|
+
return onCreateInApp;
|
|
695
|
+
}
|
|
696
|
+
return () =>
|
|
697
|
+
getFormData({
|
|
698
|
+
value: createPayload(),
|
|
699
|
+
_id: params && params.id,
|
|
700
|
+
validity: true,
|
|
701
|
+
type: INAPP,
|
|
702
|
+
});
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
return (
|
|
706
|
+
<CapSpin spinning={spin}>
|
|
707
|
+
<CapRow className="cap-inapp-creatives">
|
|
708
|
+
<CapColumn span={14}>
|
|
709
|
+
{isFullMode && createModeContent}
|
|
710
|
+
{/* Creative layout type*/}
|
|
711
|
+
{(isFullMode || !isEditFlow) && (
|
|
712
|
+
<>
|
|
713
|
+
<CapRow className="inapp-creative-layout">
|
|
714
|
+
<CapHeading type="h4">
|
|
715
|
+
<FormattedMessage {...messages.creativeLayout} />
|
|
716
|
+
</CapHeading>
|
|
717
|
+
<CapHeading type="h6" className="inapp-creative-layout-desc">
|
|
718
|
+
<FormattedMessage {...messages.creativeLayoutDesc} />
|
|
719
|
+
</CapHeading>
|
|
720
|
+
</CapRow>
|
|
721
|
+
<CapRadioGroup
|
|
722
|
+
id="inapp-layout-radio"
|
|
723
|
+
options={LAYOUT_RADIO_OPTIONS}
|
|
724
|
+
value={templateLayoutType}
|
|
725
|
+
onChange={onTemplateLayoutTypeChange}
|
|
726
|
+
className="inapp-layout-radio"
|
|
727
|
+
/>
|
|
728
|
+
</>
|
|
729
|
+
)}
|
|
730
|
+
{/* device tab */}
|
|
731
|
+
<CapTab
|
|
732
|
+
panes={PANES.filter(
|
|
733
|
+
(devicePane) => devicePane?.isSupported === true
|
|
734
|
+
)}
|
|
735
|
+
onChange={(value) => {
|
|
736
|
+
setPanes(value);
|
|
737
|
+
}}
|
|
738
|
+
activeKey={panes}
|
|
739
|
+
defaultActiveKey={panes}
|
|
740
|
+
className="inapp-template-device-tab"
|
|
741
|
+
/>
|
|
742
|
+
<div className="inapp-scroll-div" />
|
|
743
|
+
</CapColumn>
|
|
744
|
+
<CapColumn span={10} className="inapp-preview-container">
|
|
745
|
+
{getPreviewSection()}
|
|
746
|
+
</CapColumn>
|
|
747
|
+
</CapRow>
|
|
748
|
+
<div className={`inapp-footer ${!isFullMode && `inapp-footer-lib`}`}>
|
|
749
|
+
{
|
|
750
|
+
<>
|
|
751
|
+
<CapButton
|
|
752
|
+
onClick={onDoneCallback()}
|
|
753
|
+
disabled={isDisableDone(panes)}
|
|
754
|
+
className="inapp-create-btn"
|
|
755
|
+
>
|
|
756
|
+
{isEditFlow ? (
|
|
757
|
+
isFullMode ? (
|
|
758
|
+
<FormattedMessage {...messages.update} />
|
|
759
|
+
) : (
|
|
760
|
+
<FormattedMessage {...globalMessages.done} />
|
|
761
|
+
)
|
|
762
|
+
) : isFullMode ? (
|
|
763
|
+
<FormattedMessage {...messages.create} />
|
|
764
|
+
) : (
|
|
765
|
+
<FormattedMessage {...globalMessages.done} />
|
|
766
|
+
)}
|
|
767
|
+
</CapButton>
|
|
768
|
+
</>
|
|
769
|
+
}
|
|
770
|
+
</div>
|
|
771
|
+
</CapSpin>
|
|
772
|
+
);
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
const mapStateToProps = createStructuredSelector({
|
|
776
|
+
editData: makeSelectInApp(),
|
|
777
|
+
accountData: makeSelectAccount(),
|
|
778
|
+
metaEntities: makeSelectMetaEntities(),
|
|
779
|
+
loadingTags: isLoadingMetaEntities(),
|
|
780
|
+
injectedTags: setInjectedTags(),
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
784
|
+
actions: bindActionCreators(inAppActions, dispatch),
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
export default withCreatives({
|
|
788
|
+
WrappedComponent: injectIntl(InApp),
|
|
789
|
+
mapStateToProps,
|
|
790
|
+
mapDispatchToProps,
|
|
791
|
+
userAuth: true,
|
|
792
|
+
});
|