@capillarytech/creatives-library 8.0.64 → 8.0.65-alpha.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/package.json +1 -1
- package/v2Containers/Assets/images/whatsappOrZaloAccountIllustration.svg +11 -0
- package/v2Containers/Templates/constants.js +5 -0
- package/v2Containers/Templates/index.js +198 -92
- package/v2Containers/Templates/messages.js +12 -0
- package/v2Containers/Templates/reducer.js +7 -2
- package/v2Containers/Templates/sagas.js +6 -1
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="152" height="152" viewBox="0 0 152 152" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M86.9122 17.3023C106.492 7.08226 130.722 14.6223 141.322 44.7423C148.432 64.9823 149.082 88.5923 137.812 106.942C132.312 115.902 123.992 123.602 112.212 129.052C107.701 131.125 102.981 132.707 98.1322 133.772C97.6822 133.882 97.1622 133.992 96.6822 134.072C78.9322 137.702 59.5622 135.072 43.2022 128.072L42.8522 127.912C28.4122 121.622 16.3222 111.892 9.85221 99.9723C9.83606 99.944 9.8199 99.9125 9.80309 99.8796C9.77827 99.8312 9.75202 99.78 9.72221 99.7323C-0.927788 79.8523 8.75221 66.6223 16.0722 60.1623C18.7689 57.8105 21.8026 55.8757 25.0722 54.4223C34.0723 50.3945 42.7163 45.6142 50.9122 40.1323C62.9722 31.8323 75.7522 23.1323 86.9122 17.3023ZM35.1022 30.6523C35.1022 30.6523 27.7822 38.6523 32.4922 42.8423C36.1322 46.1023 47.4922 40.2323 48.1222 34.7123C48.6322 30.7523 42.4222 23.6723 35.1322 30.6523H35.1022ZM25.2122 46.1223C25.2122 46.1223 21.8422 45.2723 21.9622 49.1923C22.0822 53.1123 25.7522 51.3623 26.8322 50.5823C27.9122 49.8023 29.6322 46.9623 25.2122 46.1223Z" fill="#FFD24B"/>
|
|
3
|
+
<path d="M57.0425 61.592C53.7025 61.502 55.3525 61.242 59.4725 60.382C62.9825 59.652 67.6325 58.492 70.1325 56.702C79.1325 50.262 88.1325 50.122 93.2325 62.242C104.012 87.922 114.522 113.502 99.8525 134.772C99.8525 134.772 103.963 115.032 100.222 104.772C100.222 104.772 93.3525 114.152 82.9025 113.462C82.9025 113.462 99.9025 90.822 91.9025 83.042C91.9025 83.042 72.5125 73.042 74.4325 91.732C74.4325 91.732 76.6125 103.852 80.9825 109.802C80.9825 109.802 73.3325 109.342 69.1225 103.632C69.1225 103.632 66.7425 112.902 69.8825 135.632C69.8825 135.632 55.2025 118.202 68.1125 84.102C70.4025 78.122 84.2125 62.362 57.0425 61.592Z" fill="#103344"/>
|
|
4
|
+
<path d="M69.4523 132.793C66.3123 110.103 69.2123 103.603 69.2123 103.603C72.1223 107.543 76.6723 108.983 79.2123 109.503C79.5447 109.528 79.8631 109.364 80.0346 109.078C80.2061 108.792 80.2014 108.434 80.0223 108.153C76.3623 101.873 74.5323 91.7027 74.5323 91.7027C72.0523 72.0127 89.9823 77.7027 92.6923 81.8127C98.4323 90.6527 87.6323 106.813 83.9723 112.013C83.7754 112.277 83.7369 112.628 83.8718 112.928C84.0067 113.229 84.2938 113.434 84.6223 113.463C94.1323 113.123 100.272 104.743 100.272 104.743C104.012 115.033 99.8023 134.473 99.8023 134.473L99.3723 138.563L69.9123 135.623L69.4523 132.793Z" fill="white"/>
|
|
5
|
+
<path d="M90.2121 132.703C90.2068 135.463 88.2475 137.833 85.5375 138.357C82.8275 138.881 80.1259 137.412 79.0921 134.853C78.8219 134.182 78.6828 133.466 78.6821 132.743C78.6821 129.563 81.2721 123.643 84.4521 123.643C85.7743 123.783 86.9599 124.52 87.6721 125.643C88.0469 126.142 88.3813 126.67 88.6721 127.223C88.698 127.288 88.7281 127.351 88.7621 127.413C89.6281 129.048 90.1231 130.854 90.2121 132.703Z" fill="#A61426"/>
|
|
6
|
+
<path d="M89.8224 131.882C89.822 134.474 88.0962 136.749 85.6001 137.447C83.104 138.146 80.4481 137.097 79.1024 134.882C78.8322 134.211 78.693 133.495 78.6924 132.772C78.6924 129.592 81.2824 123.672 84.4624 123.672C85.7845 123.813 86.9702 124.549 87.6824 125.672C88.0571 126.171 88.3915 126.7 88.6824 127.252C88.7083 127.317 88.7383 127.381 88.7724 127.442C89.3938 128.844 89.7498 130.35 89.8224 131.882Z" fill="#D5192E"/>
|
|
7
|
+
<path d="M89.2124 130.993C89.2124 132.523 88.6045 133.99 87.5224 135.073C86.4403 136.155 84.9727 136.763 83.4424 136.763C81.7946 136.765 80.2265 136.054 79.1424 134.813C78.8722 134.142 78.7331 133.426 78.7324 132.703C78.7324 129.523 81.3224 123.603 84.5024 123.603C85.8246 123.743 87.0102 124.48 87.7224 125.603C88.6118 127.267 89.1207 129.108 89.2124 130.993Z" fill="#ED1D34"/>
|
|
8
|
+
<circle cx="78.2624" cy="58.3127" r="1.34" fill="white"/>
|
|
9
|
+
<circle cx="78.262" cy="58.3118" r="0.68" fill="black"/>
|
|
10
|
+
<ellipse cx="82.5535" cy="126.552" rx="1.51" ry="0.9" transform="rotate(-62.05 82.5535 126.552)" fill="#F47988"/>
|
|
11
|
+
</svg>
|
|
@@ -73,3 +73,8 @@ export const GET_SENDER_DETAILS_FAILURE =
|
|
|
73
73
|
export const GET_CDN_TRANSFORMATION_CONFIG_REQUEST = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_REQUEST';
|
|
74
74
|
export const GET_CDN_TRANSFORMATION_CONFIG_SUCCESS = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_SUCCESS';
|
|
75
75
|
export const GET_CDN_TRANSFORMATION_CONFIG_FAILURE = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_FAILURE';
|
|
76
|
+
|
|
77
|
+
export const ACCOUNT_MAPPING_ON_CHANNEL = {
|
|
78
|
+
whatsapp: 'selectedWhatsappAccount',
|
|
79
|
+
zalo: 'selectedZaloAccount',
|
|
80
|
+
};
|
|
@@ -97,7 +97,7 @@ import {
|
|
|
97
97
|
FACEBOOK as FACEBOOK_CHANNEL,
|
|
98
98
|
CREATE,
|
|
99
99
|
} from '../App/constants';
|
|
100
|
-
import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES } from './constants';
|
|
100
|
+
import {MAX_WHATSAPP_TEMPLATES, WARNING_WHATSAPP_TEMPLATES , ACCOUNT_MAPPING_ON_CHANNEL} from './constants';
|
|
101
101
|
import { COPY_OF } from '../../containers/App/constants';
|
|
102
102
|
import {
|
|
103
103
|
TWILIO_CATEGORY_OPTIONS,
|
|
@@ -126,6 +126,7 @@ import emailIllustration from '../Assets/images/emailIllustration.svg';
|
|
|
126
126
|
import smsIllustration from '../Assets/images/smsIllustration.svg';
|
|
127
127
|
import pushIllustration from '../Assets/images/pushIllustration.svg';
|
|
128
128
|
import whatsappIllustration from '../Assets/images/whatsappIllustration.png';
|
|
129
|
+
import whatsappOrZaloAccountIllustration from '../Assets/images/whatsappOrZaloAccountIllustration.svg';
|
|
129
130
|
import rcsIllustration from '../Assets/images/rcsIllustration.png';
|
|
130
131
|
import zaloillustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
|
|
131
132
|
import inAppIllustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
|
|
@@ -250,6 +251,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
250
251
|
this.delayTimer = 0;
|
|
251
252
|
}
|
|
252
253
|
|
|
254
|
+
getHostName(selectedSourceAccountIdentifier, domainPropertiesData = []) {
|
|
255
|
+
if (isEmpty(domainPropertiesData) || !selectedSourceAccountIdentifier) {
|
|
256
|
+
return '';
|
|
257
|
+
}
|
|
258
|
+
for (const domainData of domainPropertiesData) {
|
|
259
|
+
const { hostName, connectionProperties: { account_sid, wabaId, userid, sourceAccountIdentifier, oa_id } = {}} = domainData?.domainProperties || {};
|
|
260
|
+
// If sourceAccountIdentifier is not present in the domainProperties, then it will try to find in account_sid, wabaId, user_id.
|
|
261
|
+
// wabaId, user_id is, account_sid are for Karix, Gupshup, and Twilio (Whatsapp) respectively and oa_id is for Zalo.
|
|
262
|
+
const sourceAccountIdentifiersArray = [account_sid, wabaId, userid, oa_id, sourceAccountIdentifier];
|
|
263
|
+
if (sourceAccountIdentifiersArray.includes(selectedSourceAccountIdentifier)) {
|
|
264
|
+
this.setState({hostName});
|
|
265
|
+
return hostName;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
253
270
|
componentWillMount() {
|
|
254
271
|
if (this.state.channel === '') {
|
|
255
272
|
let channel = '';
|
|
@@ -612,11 +629,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
612
629
|
if (!isEmpty(nextProps.Templates.templateDetails) && !isEqual(nextProps.Templates.templateDetails, this.props.Templates.templateDetails)) {
|
|
613
630
|
this.setState({ previewTemplate: nextProps.Templates.templateDetails });
|
|
614
631
|
}
|
|
615
|
-
const { weCrmAccounts: weCrmAccountsList = [], senderDetails
|
|
616
|
-
const weCrmChannels = [
|
|
632
|
+
const { weCrmAccounts: weCrmAccountsList = [], senderDetails = {} } = get(nextProps, 'Templates', {});
|
|
633
|
+
const weCrmChannels = [WHATSAPP_LOWERCASE, ZALO_LOWERCASE];
|
|
617
634
|
|
|
618
|
-
|
|
619
|
-
|
|
635
|
+
// Keeping the wechat flow separate as it has different logic for setting the account.
|
|
636
|
+
if (weCrmAccountsList?.length === 1 && this.state?.defaultAccount && selectedChannel === WECHAT_LOWERCASE && !isEmpty(senderDetails?.hostName)) {
|
|
620
637
|
if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
|
|
621
638
|
paramsDefault = {
|
|
622
639
|
name: this.state.searchText,
|
|
@@ -624,38 +641,65 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
624
641
|
};
|
|
625
642
|
}
|
|
626
643
|
|
|
627
|
-
const {
|
|
644
|
+
const { sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
|
|
628
645
|
const {
|
|
629
|
-
token,
|
|
630
646
|
wecrm_app_id,
|
|
631
647
|
wecrm_token
|
|
632
648
|
} = configs || {};
|
|
633
|
-
if (weCrmChannels.includes(selectedChannel)) {
|
|
634
|
-
if ([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
|
|
635
|
-
if (hostName === '') {
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
649
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
paramsDefault.oa_id = sourceAccountIdentifier;
|
|
644
|
-
paramsDefault.token = token;
|
|
645
|
-
paramsDefault.host = hostName || this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName || this.state.hostName;
|
|
646
|
-
}
|
|
647
|
-
} else {
|
|
648
|
-
paramsDefault.wecrmId = wecrm_app_id;
|
|
649
|
-
paramsDefault.wecrmToken = wecrm_token;
|
|
650
|
-
paramsDefault.originalId = sourceAccountIdentifier;
|
|
651
|
-
nextProps.actions.setWeChatAccount(
|
|
652
|
-
weCrmAccountsList[0],
|
|
653
|
-
);
|
|
654
|
-
}
|
|
655
|
-
|
|
650
|
+
const paramsDefault = {
|
|
651
|
+
wecrmId: wecrm_app_id,
|
|
652
|
+
wecrmToken: wecrm_token,
|
|
653
|
+
originalId: sourceAccountIdentifier,
|
|
656
654
|
}
|
|
655
|
+
nextProps.actions.setWeChatAccount(
|
|
656
|
+
weCrmAccountsList[0],
|
|
657
|
+
);
|
|
658
|
+
|
|
657
659
|
this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName: weCrmAccountsList[0].hostName });
|
|
658
|
-
this.getAllTemplates({params: paramsDefault}, true);
|
|
660
|
+
this.getAllTemplates({ params: paramsDefault }, true);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (weCrmAccountsList?.length && this.state?.defaultAccount && (weCrmChannels.includes(selectedChannel))) {
|
|
664
|
+
const isSingleAccount = weCrmAccountsList?.length === 1;
|
|
665
|
+
const selectedAccount = this.props.Templates[ACCOUNT_MAPPING_ON_CHANNEL[selectedChannel]] || {};
|
|
666
|
+
const hostName = this.getHostName(isSingleAccount ? weCrmAccountsList[0]?.sourceAccountIdentifier : selectedAccount?.sourceAccountIdentifier, senderDetails?.domainProperties);
|
|
667
|
+
|
|
668
|
+
if (!isEmpty(hostName)) {
|
|
669
|
+
let paramsDefault = {};
|
|
670
|
+
if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
|
|
671
|
+
paramsDefault = {
|
|
672
|
+
name: this.state.searchText,
|
|
673
|
+
sortBy: this.state.sortBy,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
const {name, sourceAccountIdentifier, configs } = weCrmAccountsList?.[0] || {};
|
|
678
|
+
if (isSingleAccount) {
|
|
679
|
+
weCrmAccountsList[0].hostName = hostName;
|
|
680
|
+
} else {
|
|
681
|
+
selectedAccount.hostName = hostName;
|
|
682
|
+
}
|
|
683
|
+
nextProps.actions.setChannelAccount(selectedChannel?.toUpperCase(), isSingleAccount ? weCrmAccountsList[0] : selectedAccount);
|
|
684
|
+
if (selectedChannel === ZALO_LOWERCASE) {
|
|
685
|
+
paramsDefault.username = name;
|
|
686
|
+
paramsDefault.oa_id = sourceAccountIdentifier;
|
|
687
|
+
paramsDefault.token = configs?.token;
|
|
688
|
+
paramsDefault.host = hostName || this.props.Templates?.selectedZaloAccount?.hostName;
|
|
689
|
+
}
|
|
690
|
+
if (selectedChannel === WHATSAPP_LOWERCASE) {
|
|
691
|
+
paramsDefault.accountId = sourceAccountIdentifier;
|
|
692
|
+
paramsDefault.host = hostName || this.props.Templates?.selectedWhatsappAccount?.hostName;
|
|
693
|
+
}
|
|
694
|
+
this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: isSingleAccount ? weCrmAccountsList[0]?.name : selectedAccount?.name });
|
|
695
|
+
/**
|
|
696
|
+
* Incase of multiple accounts, getAllTemplates is called on selecting the account. It's handled in onAccountSelect function.
|
|
697
|
+
* But for single account, onAccountSelect function won't get executed and getAllTemplates will be excuted.
|
|
698
|
+
*/
|
|
699
|
+
if (weCrmAccountsList?.length === 1) {
|
|
700
|
+
this.getAllTemplates({params: paramsDefault}, true);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
659
703
|
}
|
|
660
704
|
const zaloPreviewUrl = get(nextProps, 'Zalo.zaloTemplatePreviewData.versions.base.content.zalo.previewUrl', '');
|
|
661
705
|
if (zaloPreviewUrl && this.state.channel.toLowerCase() === ZALO_LOWERCASE) {
|
|
@@ -681,6 +725,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
681
725
|
params.sortBy = this.state.sortBy;
|
|
682
726
|
}
|
|
683
727
|
const selectedChannel = this.state.channel.toLowerCase();
|
|
728
|
+
const isZaloOrWhatsapp = [ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel);
|
|
684
729
|
if (selectedChannel === 'wechat') {
|
|
685
730
|
params.wecrmId = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_app_id;
|
|
686
731
|
params.wecrmToken = this.props.Templates.weCrmAccounts[findIndex(this.props.Templates.weCrmAccounts, { name: value})].configs.wecrm_token;
|
|
@@ -700,26 +745,43 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
700
745
|
} else {
|
|
701
746
|
this.setState({ selectedAccountError: false });
|
|
702
747
|
}
|
|
703
|
-
} else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
|
|
748
|
+
} else if ([LINE.toLowerCase(), RCS_LOWERCASE, ZALO_LOWERCASE, WHATSAPP_LOWERCASE].includes(selectedChannel)) {
|
|
704
749
|
const setAcc = this.props?.Templates?.weCrmAccounts?.find((item) => item?.name === this.state.selectedAccount);
|
|
750
|
+
const { domainProperties = [] } = this.props?.Templates?.senderDetails || {};
|
|
751
|
+
let hostName = '';
|
|
752
|
+
if (isZaloOrWhatsapp) {
|
|
753
|
+
hostName = this.getHostName(setAcc?.sourceAccountIdentifier, domainProperties);
|
|
754
|
+
setAcc.hostName = hostName;
|
|
755
|
+
}
|
|
705
756
|
this.props.actions.setChannelAccount(selectedChannel?.toUpperCase(), setAcc);
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
757
|
+
|
|
758
|
+
const {
|
|
759
|
+
name = "",
|
|
760
|
+
sourceAccountIdentifier = "",
|
|
761
|
+
configs: { token = "" } = {},
|
|
762
|
+
} = setAcc || {};
|
|
763
|
+
|
|
764
|
+
if(selectedChannel === ZALO_LOWERCASE && hostName) {
|
|
712
765
|
params.username = name;
|
|
713
766
|
params.oa_id = sourceAccountIdentifier;
|
|
714
767
|
params.token = token;
|
|
715
768
|
params.isAccountSelection = true;
|
|
716
|
-
params.host =
|
|
769
|
+
params.host = hostName;
|
|
770
|
+
}
|
|
771
|
+
if (selectedChannel === WHATSAPP_LOWERCASE && hostName) {
|
|
772
|
+
params.accountId = sourceAccountIdentifier;
|
|
773
|
+
params.host = hostName;
|
|
717
774
|
}
|
|
718
775
|
}
|
|
719
776
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
777
|
+
// Always set activeMode before getAllTemplates call
|
|
778
|
+
this.setState({ activeMode: TEMPLATES_MODE }, () => {
|
|
779
|
+
// Restrict getAllTemplates call only if selectedChannel is ZALO or WHATSAPP and hostName is empty
|
|
780
|
+
if (!(isZaloOrWhatsapp && !params?.host)) {
|
|
781
|
+
console.log(">>> GETALLTEMPLATES onaccount select ", { params });
|
|
782
|
+
this.getAllTemplates({ params, resetPage: true });
|
|
783
|
+
}
|
|
784
|
+
});
|
|
723
785
|
});
|
|
724
786
|
}
|
|
725
787
|
onPaginationChange = () => {
|
|
@@ -797,6 +859,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
797
859
|
|
|
798
860
|
moment.locale(locale);
|
|
799
861
|
};
|
|
862
|
+
|
|
863
|
+
setWhatsappQueryParams = (queryParams, params) => {
|
|
864
|
+
queryParams.accountId = params?.accountId || this.props.Templates?.selectedWhatsappAccount?.sourceAccountIdentifier;
|
|
865
|
+
queryParams.host = params?.host || this.state?.hostName;
|
|
866
|
+
};
|
|
867
|
+
|
|
800
868
|
getAllTemplates = ({params, getNextPage, resetPage}, resetTemplates) => {
|
|
801
869
|
let queryParams = params || {};
|
|
802
870
|
let page = this.state.page;
|
|
@@ -825,6 +893,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
825
893
|
if (([MOBILE_PUSH_LOWERCASE, INAPP_LOWERCASE].includes(channel.toLowerCase())) && !isEmpty(this.props.Templates.selectedWeChatAccount)) {
|
|
826
894
|
queryParams.accountId = this.props.Templates?.selectedWeChatAccount?.id;
|
|
827
895
|
}
|
|
896
|
+
if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
897
|
+
this.setWhatsappQueryParams(queryParams, params);
|
|
898
|
+
}
|
|
828
899
|
this.props.actions.getAllTemplates(channel, queryParams,`${copyOf}`);
|
|
829
900
|
} else if ((resetPage || (page === 1 && this.state.templatesCount === 0) || page <= (this.state.templatesCount / this.state.perPageLimit))) {
|
|
830
901
|
if (getNextPage) {
|
|
@@ -874,6 +945,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
874
945
|
queryParams.token = token;
|
|
875
946
|
queryParams.host = hostName || this.props.Templates?.senderDetails?.hostName ||this.state.hostName;
|
|
876
947
|
}
|
|
948
|
+
if (this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
949
|
+
this.setWhatsappQueryParams(queryParams, params);
|
|
950
|
+
}
|
|
877
951
|
this.setState({ page, templatesCount }, () => {
|
|
878
952
|
queryParams.page = page;
|
|
879
953
|
queryParams.perPage = this.state.perPageLimit;
|
|
@@ -1020,7 +1094,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1020
1094
|
filteredTemplates = this.filterWechatTemplates(templates);
|
|
1021
1095
|
break;
|
|
1022
1096
|
case WHATSAPP:
|
|
1023
|
-
filteredTemplates = this.filterWhatsappTemplates(templates);
|
|
1097
|
+
filteredTemplates = this.state?.hostName ? this.filterWhatsappTemplates(templates) : [];
|
|
1024
1098
|
break;
|
|
1025
1099
|
case LINE:
|
|
1026
1100
|
filteredTemplates = this.filterLineTemplates(templates);
|
|
@@ -1381,16 +1455,21 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1381
1455
|
|
|
1382
1456
|
const accountId = get(this.props, 'Templates.selectedWeChatAccount.uuid');
|
|
1383
1457
|
const accounts = get(this.props, 'Templates.weCrmAccounts');
|
|
1384
|
-
const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates);
|
|
1458
|
+
const noWhatsappZaloTemplates = this.isFullMode() && isEmpty(templates) || !this.state.hostName;
|
|
1385
1459
|
const noFilteredWhatsappZaloTemplates = this.isFullMode() && !isEmpty(templates) && isEmpty(filteredTemplates);
|
|
1386
1460
|
const noApprovedWhatsappZaloTemplates = !this.isFullMode() && isEmpty(filteredTemplates);
|
|
1387
|
-
const showWhatsappIllustration = !isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase);
|
|
1461
|
+
const showWhatsappIllustration = (!isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(channelLowerCase)) || !this.state.hostName ;
|
|
1388
1462
|
const showZaloIllustration = !isEmpty(this.props.Templates.selectedZaloAccount) && [ZALO_LOWERCASE].includes(channelLowerCase);
|
|
1389
1463
|
const showRcsIllustration = channelLowerCase === RCS_LOWERCASE && isEmpty(templates);
|
|
1390
1464
|
const showInAppIllustration = channelLowerCase === INAPP_LOWERCASE && isEmpty(templates);
|
|
1391
1465
|
const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
|
|
1466
|
+
console.log(">>> state ", {showWhatsappIllustration, showZaloIllustration, noLoaderAndSearchText, noApprovedWhatsappZaloTemplates, noFilteredWhatsappZaloTemplates, noWhatsappZaloTemplates, channelLowerCase, host: this.state.hostName, templates: this.props.Templates,
|
|
1467
|
+
mp: (["mobilepush"].includes(this.state.channel.toLowerCase()) &&
|
|
1468
|
+
isEmpty(filteredTemplates) &&
|
|
1469
|
+
isEmpty(this.state.searchText))
|
|
1470
|
+
})
|
|
1392
1471
|
return (<div>
|
|
1393
|
-
{[WECHAT, MOBILE_PUSH, INAPP].includes(currentChannel) && this.showAccountName()}
|
|
1472
|
+
{[WECHAT, MOBILE_PUSH, INAPP, WHATSAPP, ZALO].includes(currentChannel) && this.showAccountName()}
|
|
1394
1473
|
{filterContent}
|
|
1395
1474
|
{[WHATSAPP, ZALO].includes(currentChannel) && this.selectedFilters()}
|
|
1396
1475
|
<CapCustomSkeleton loader={isLoading}>
|
|
@@ -1427,15 +1506,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1427
1506
|
isEmpty(filteredTemplates) &&
|
|
1428
1507
|
isEmpty(this.state.searchText) &&
|
|
1429
1508
|
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
|
|
1430
|
-
<CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
|
|
1509
|
+
<CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel, this.state?.hostName)} />
|
|
1431
1510
|
</div>
|
|
1432
1511
|
)
|
|
1433
1512
|
}
|
|
1434
1513
|
{(showWhatsappIllustration || showZaloIllustration) && (
|
|
1435
1514
|
noLoaderAndSearchText &&
|
|
1436
1515
|
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto' } : {}}>
|
|
1437
|
-
{noWhatsappZaloTemplates && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />}
|
|
1438
|
-
{noFilteredWhatsappZaloTemplates && this.whatsappZaloIllustrationText('noFilteredWhatsappZaloTemplatesTitle', 'noFilteredWhatsappZaloTemplatesDesc')}
|
|
1516
|
+
{noWhatsappZaloTemplates && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel, isEmpty(this.state?.hostName))} />}
|
|
1517
|
+
{noFilteredWhatsappZaloTemplates && this.state?.hostName && this.whatsappZaloIllustrationText('noFilteredWhatsappZaloTemplatesTitle', 'noFilteredWhatsappZaloTemplatesDesc')}
|
|
1439
1518
|
{noApprovedWhatsappZaloTemplates && this.whatsappZaloIllustrationText('noApprovedWhatsappZaloTemplatesTitle', showWhatsappIllustration ? 'noApprovedWhatsappTemplatesDesc' : 'zaloDescIllustration')}
|
|
1440
1519
|
</div>
|
|
1441
1520
|
)
|
|
@@ -1840,6 +1919,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1840
1919
|
}
|
|
1841
1920
|
if (this.state.channel.toLowerCase() === MOBILE_PUSH_LOWERCASE) {
|
|
1842
1921
|
params.accountId = this.props.Templates.selectedWeChatAccount.id;
|
|
1922
|
+
} else if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
1923
|
+
params.accountId = this.props.Templates?.selectedWhatsappAccount?.sourceAccountIdentifier;
|
|
1924
|
+
params.host = this.state?.hostName;
|
|
1843
1925
|
}
|
|
1844
1926
|
this.delay(() => {
|
|
1845
1927
|
this.getAllTemplates({params, resetPage: true});
|
|
@@ -2443,7 +2525,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2443
2525
|
(rcsLoader !== undefined ? rcsLoader : false);
|
|
2444
2526
|
return isLoading;
|
|
2445
2527
|
}
|
|
2446
|
-
getChannelTypeIllustrationInfo = (type) => {
|
|
2528
|
+
getChannelTypeIllustrationInfo = (type, hostNameNotFound) => {
|
|
2447
2529
|
const { isFullMode, intl } = this.props;
|
|
2448
2530
|
const templateIntlMsg = intl.formatMessage(messages.template);
|
|
2449
2531
|
const templateText = isFullMode ? templateIntlMsg : '';
|
|
@@ -2469,16 +2551,28 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2469
2551
|
illustrationImage: pushIllustration,
|
|
2470
2552
|
title: <FormattedMessage {...messages.pushTitleIllustartion} values={{ template: templateText }} />,
|
|
2471
2553
|
};
|
|
2472
|
-
case WHATSAPP:
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2554
|
+
case WHATSAPP: {
|
|
2555
|
+
if (hostNameNotFound) {
|
|
2556
|
+
return {
|
|
2557
|
+
illustrationImage: whatsappOrZaloAccountIllustration,
|
|
2558
|
+
title: <FormattedMessage {...messages.whatsappAccountNotConfiguredTitle} />,
|
|
2559
|
+
description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
|
|
2560
|
+
descriptionPosition: 'bottom',
|
|
2561
|
+
descriptionClassName: 'illustration-desc zalo-illustration',
|
|
2562
|
+
buttonClassName: "zalo-illustration-button",
|
|
2563
|
+
};
|
|
2564
|
+
} else {
|
|
2565
|
+
return {
|
|
2566
|
+
buttonLabel: <FormattedMessage {...messages.newWhatsappTemplate} values={{ template: templateText }} />,
|
|
2567
|
+
onClick: this.createTemplate,
|
|
2568
|
+
illustrationImage: whatsappIllustration,
|
|
2569
|
+
title: <FormattedMessage {...messages.whatsappTitleIllustration} values={{ template: templateText }} />,
|
|
2570
|
+
description: <FormattedMessage {...messages.whatsappDescIllustration} />,
|
|
2571
|
+
descriptionPosition: 'bottom',
|
|
2572
|
+
descriptionClassName: 'illustration-desc',
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2482
2576
|
case RCS:
|
|
2483
2577
|
return {
|
|
2484
2578
|
buttonLabel: <FormattedMessage {...messages.newRCSTemplate} values={{ template: templateText }} />,
|
|
@@ -2489,15 +2583,27 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2489
2583
|
descriptionPosition: 'bottom',
|
|
2490
2584
|
descriptionClassName: 'illustration-desc rcs-illustration',
|
|
2491
2585
|
};
|
|
2492
|
-
case ZALO:
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2586
|
+
case ZALO:{
|
|
2587
|
+
if (hostNameNotFound) {
|
|
2588
|
+
return {
|
|
2589
|
+
illustrationImage: whatsappOrZaloAccountIllustration,
|
|
2590
|
+
title: <FormattedMessage {...messages.zaloAccountNotConfiguredTitle} />,
|
|
2591
|
+
description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
|
|
2592
|
+
descriptionPosition: 'bottom',
|
|
2593
|
+
descriptionClassName: 'illustration-desc zalo-illustration',
|
|
2594
|
+
buttonClassName: "zalo-illustration-button",
|
|
2595
|
+
};
|
|
2596
|
+
} else {
|
|
2597
|
+
return {
|
|
2598
|
+
illustrationImage: zaloillustration,
|
|
2599
|
+
title: <FormattedMessage {...messages.zaloTitleIllustration} />,
|
|
2600
|
+
description: <FormattedMessage {...messages.zaloDescIllustration} />,
|
|
2601
|
+
descriptionPosition: 'bottom',
|
|
2602
|
+
descriptionClassName: 'illustration-desc zalo-illustration',
|
|
2603
|
+
buttonClassName: "zalo-illustration-button",
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2501
2607
|
case INAPP:
|
|
2502
2608
|
return {
|
|
2503
2609
|
illustrationImage: inAppIllustration,
|
|
@@ -2564,10 +2670,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2564
2670
|
const isMobilePushChannel = channel === MOBILE_PUSH;
|
|
2565
2671
|
const isInAppChannel = channel === INAPP;
|
|
2566
2672
|
const isFacebookChannel = channel === FACEBOOK;
|
|
2567
|
-
|
|
2568
|
-
if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
|
|
2673
|
+
if ([WECHAT, MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
|
|
2569
2674
|
forEach(weCrmAccounts, (account) => {
|
|
2570
|
-
if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO].includes(channel)) {
|
|
2675
|
+
if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, INAPP, LINE, ZALO, WHATSAPP].includes(channel)) {
|
|
2571
2676
|
if (query.type === 'embedded' && (!query.module || (query.module && query.module !== 'library'))) {
|
|
2572
2677
|
if (query.source_account_id && account.sourceAccountIdentifier === query.source_account_id) {
|
|
2573
2678
|
accountOptions.push(
|
|
@@ -2650,9 +2755,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2650
2755
|
break;
|
|
2651
2756
|
}
|
|
2652
2757
|
let showNoAccountHeader = isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts;
|
|
2653
|
-
if (channel === WHATSAPP && this.state.hostName === '') {
|
|
2654
|
-
showNoAccountHeader = true;
|
|
2655
|
-
}
|
|
2656
2758
|
if (channel === FACEBOOK && !isEmpty(campaignSettings) ) {
|
|
2657
2759
|
const fbSetting = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
|
|
2658
2760
|
const { orgUnitFacebookPageSettingsMap } = fbSetting[0] || {};
|
|
@@ -2874,7 +2976,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2874
2976
|
);
|
|
2875
2977
|
//TODO -> uncomment the following line
|
|
2876
2978
|
// const isfilterContentVisisble = !isEmpty(this.props.TemplatesList) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError);
|
|
2877
|
-
|
|
2979
|
+
let isfilterContentVisisble = true;
|
|
2878
2980
|
const isWechatEmbedded = !this.props.isFullMode && channel.toUpperCase() === WECHAT;
|
|
2879
2981
|
const channelLowerCase = (channel || '').toLowerCase();
|
|
2880
2982
|
const isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
@@ -2889,7 +2991,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2889
2991
|
className="create-new-link"
|
|
2890
2992
|
/>
|
|
2891
2993
|
)
|
|
2892
|
-
: this.state
|
|
2994
|
+
: this.state?.channel?.toLowerCase() === ZALO_LOWERCASE || (channelLowerCase === WHATSAPP_LOWERCASE && isEmpty(this.state?.hostName)) ? <></> : (
|
|
2893
2995
|
<CapButton
|
|
2894
2996
|
className={`create-new-${channelLowerCase} margin-l-8 margin-b-12`}
|
|
2895
2997
|
type={"primary"}
|
|
@@ -2903,7 +3005,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2903
3005
|
const isWhatsappCountExeeded = templatesCount >= MAX_WHATSAPP_TEMPLATES;
|
|
2904
3006
|
const showWhatsappCountWarning = templatesCount >= WARNING_WHATSAPP_TEMPLATES;
|
|
2905
3007
|
const whatsappCountExceedText = <FormattedMessage {...messages.whatsappMaxTemplates} values={{ maxCount: MAX_WHATSAPP_TEMPLATES }}/>;
|
|
2906
|
-
|
|
3008
|
+
if (([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(this.state?.channel?.toLocaleLowerCase()) && isEmpty(this.state?.hostName))) {
|
|
3009
|
+
isfilterContentVisisble = false;
|
|
3010
|
+
}
|
|
2907
3011
|
const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH, INAPP].includes(this.state.channel.toUpperCase())) && <div className="action-container">
|
|
2908
3012
|
{isfilterContentVisisble && <CapInput.Search
|
|
2909
3013
|
className="search-text"
|
|
@@ -2932,7 +3036,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2932
3036
|
channel.toUpperCase() === ZALO && (
|
|
2933
3037
|
<div className="zalo-filters">
|
|
2934
3038
|
{
|
|
2935
|
-
this.props
|
|
3039
|
+
this.props?.isFullMode && this.state?.hostName ? (
|
|
2936
3040
|
<CapSelectFilter
|
|
2937
3041
|
placement="bottomLeft"
|
|
2938
3042
|
data={ZALO_STATUS_OPTIONS}
|
|
@@ -2951,7 +3055,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2951
3055
|
channel.toUpperCase() === WHATSAPP && (
|
|
2952
3056
|
<div className="whatsapp-filters">
|
|
2953
3057
|
{
|
|
2954
|
-
this.props
|
|
3058
|
+
this.props?.isFullMode && this.state?.hostName ? (
|
|
2955
3059
|
<CapSelectFilter
|
|
2956
3060
|
placement="bottomLeft"
|
|
2957
3061
|
data={STATUS_OPTIONS}
|
|
@@ -2963,18 +3067,20 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2963
3067
|
/>
|
|
2964
3068
|
) : null
|
|
2965
3069
|
}
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
3070
|
+
{this.state?.hostName ? (
|
|
3071
|
+
<CapSelectFilter
|
|
3072
|
+
placement="bottomLeft"
|
|
3073
|
+
data={this.state.hostName === HOST_TWILIO
|
|
3074
|
+
? TWILIO_CATEGORY_OPTIONS
|
|
3075
|
+
: KARIX_GUPSHUP_CATEGORY_OPTIONS}
|
|
3076
|
+
onSelect={this.setWhatsappCategory}
|
|
3077
|
+
selectedValue={this.state.selectedWhatsappCategory}
|
|
3078
|
+
placeholder="Category"
|
|
3079
|
+
showBadge
|
|
3080
|
+
width="105px"
|
|
3081
|
+
overlayStyle={{ overflowY: "hidden" }}
|
|
3082
|
+
/>
|
|
3083
|
+
) : null}
|
|
2978
3084
|
</div>
|
|
2979
3085
|
|
|
2980
3086
|
)
|
|
@@ -3047,7 +3153,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3047
3153
|
}
|
|
3048
3154
|
<div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
|
|
3049
3155
|
{
|
|
3050
|
-
this.state
|
|
3156
|
+
this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && (isWhatsappCountExeeded)? (
|
|
3051
3157
|
<CapTooltip title={whatsappCountExceedText}>
|
|
3052
3158
|
<div className="button-disabled-tooltip-wrapper">
|
|
3053
3159
|
{createButton}
|
|
@@ -354,6 +354,18 @@ export default defineMessages({
|
|
|
354
354
|
id: `${scope}.whatsappDescIllustration`,
|
|
355
355
|
defaultMessage: 'These templates can be reused when creating a\nnew message content.',
|
|
356
356
|
},
|
|
357
|
+
"whatsappAccountNotConfiguredTitle": {
|
|
358
|
+
id: `${scope}.whatsappAccountNotConfiguredTitle`,
|
|
359
|
+
defaultMessage: 'Whatsapp account is not configured',
|
|
360
|
+
},
|
|
361
|
+
"accountNotConfiguredDescription": {
|
|
362
|
+
id: `${scope}.accountNotConfiguredDescription`,
|
|
363
|
+
defaultMessage: 'Please contact your Customer Success Manager to fix the issue.',
|
|
364
|
+
},
|
|
365
|
+
"zaloAccountNotConfiguredTitle": {
|
|
366
|
+
id: `${scope}.zaloAccountNotConfiguredTitle`,
|
|
367
|
+
defaultMessage: 'Zalo account is not configured',
|
|
368
|
+
},
|
|
357
369
|
"zaloTitleIllustration": {
|
|
358
370
|
id: `${scope}.zaloTitleIllustration`,
|
|
359
371
|
defaultMessage: 'There are no approved templates available',
|
|
@@ -180,12 +180,17 @@ function templatesReducer(state = initialState, action) {
|
|
|
180
180
|
return state.set('fetchedOrgLevelCampaignSettings', false);
|
|
181
181
|
case types.GET_SENDER_DETAILS_REQUEST:
|
|
182
182
|
return state.set('senderDetails', { status: 'REQUEST' });
|
|
183
|
-
case types.GET_SENDER_DETAILS_SUCCESS:
|
|
183
|
+
case types.GET_SENDER_DETAILS_SUCCESS: {
|
|
184
|
+
const { channel, domainProperties = {} } = action?.payload || {};
|
|
185
|
+
const isMultiAccountChannel = ['WHATSAPP', 'ZALO'].includes(channel);
|
|
186
|
+
const senderDetailsKey = isMultiAccountChannel ? 'domainProperties' : 'hostName';
|
|
187
|
+
// For Whatsapp and Zalo we need to store domainProperties instead of only hostName
|
|
184
188
|
return state.set('senderDetails', {
|
|
185
189
|
status: 'SUCCESS',
|
|
186
|
-
|
|
190
|
+
[senderDetailsKey]: isMultiAccountChannel ? domainProperties : action?.payload,
|
|
187
191
|
errors: [],
|
|
188
192
|
});
|
|
193
|
+
}
|
|
189
194
|
case types.GET_SENDER_DETAILS_FAILURE:
|
|
190
195
|
return state.set('senderDetails', {
|
|
191
196
|
status: 'FAILURE',
|
|
@@ -161,8 +161,13 @@ export function* getSenderDetails({
|
|
|
161
161
|
if (!apiResponse?.errors?.length) {
|
|
162
162
|
yield put({
|
|
163
163
|
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
164
|
-
payload:
|
|
164
|
+
payload: ['WHATSAPP', 'ZALO'].includes(channel) ?
|
|
165
|
+
{ channel,
|
|
166
|
+
domainProperties: get(apiResponse, `entity.${channel}`, '')
|
|
167
|
+
} :
|
|
168
|
+
get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
|
|
165
169
|
});
|
|
170
|
+
|
|
166
171
|
} else {
|
|
167
172
|
yield put({
|
|
168
173
|
type: types.GET_SENDER_DETAILS_FAILURE,
|