@capillarytech/creatives-library 7.10.42 → 7.10.44
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/v2Components/TemplatePreview/index.js +2 -2
- package/v2Containers/App/constants.js +4 -1
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +13 -5
- package/v2Containers/Templates/_templates.scss +18 -0
- package/v2Containers/Templates/index.js +51 -33
- package/v2Containers/Templates/messages.js +6 -2
- package/v2Containers/Whatsapp/index.js +108 -86
- package/v2Containers/Whatsapp/index.scss +2 -2
- package/v2Containers/Whatsapp/messages.js +4 -0
package/package.json
CHANGED
|
@@ -195,8 +195,8 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
195
195
|
};
|
|
196
196
|
const whatsappSectionStyle = {
|
|
197
197
|
"padding": '3.5px 0 0',
|
|
198
|
-
'
|
|
199
|
-
'
|
|
198
|
+
'border-radius': '6px',
|
|
199
|
+
'background-color': CAP_G15,
|
|
200
200
|
'width': '88%',
|
|
201
201
|
'left': '10%',
|
|
202
202
|
};
|
|
@@ -47,6 +47,7 @@ export const PREVIEW = 'preview';
|
|
|
47
47
|
|
|
48
48
|
export const VIBER = 'viber';
|
|
49
49
|
export const FACEBOOK = 'facebook';
|
|
50
|
+
export const WHATSAPP = 'whatsapp';
|
|
50
51
|
|
|
51
52
|
export const TRACK_EDIT_SMS = 'editSms';
|
|
52
53
|
export const TRACK_EDIT_EMAIL = 'editEmail';
|
|
@@ -107,4 +108,6 @@ export const FB_AD_CALL_TO_ACTION = {
|
|
|
107
108
|
export const CREATIVES = 'creatives';
|
|
108
109
|
export const LOYALTY = 'loyalty';
|
|
109
110
|
|
|
110
|
-
export const FAILURE = 'FAILURE';
|
|
111
|
+
export const FAILURE = 'FAILURE';
|
|
112
|
+
export const DATE_DISPLAY_FORMAT = 'D MMM YYYY';
|
|
113
|
+
export const TIME_DISPLAY_FORMAT = 'hh:mm A';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
import get from 'lodash/get';
|
|
4
5
|
import { CapHeader, CapIcons, CapLabel, CapSteps } from '@capillarytech/cap-ui-library';
|
|
5
6
|
import moment from 'moment';
|
|
6
7
|
import PropTypes from 'prop-types';
|
|
7
8
|
import messages from './messages';
|
|
8
9
|
import whatsppMsg from '../Whatsapp/messages';
|
|
9
10
|
import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
|
|
10
|
-
import { NO_COMMUNICATION, FTP } from '../App/constants';
|
|
11
|
+
import { NO_COMMUNICATION, FTP, WHATSAPP } from '../App/constants';
|
|
11
12
|
import { isTraiDLTEnable } from '../../utils/common';
|
|
12
13
|
import { formatString } from '../../utils/Formatter';
|
|
13
14
|
import {
|
|
@@ -43,8 +44,15 @@ function SlideBoxHeader(props) {
|
|
|
43
44
|
const mapTemplateCreate = !showTemplateNameHeader && slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
|
|
44
45
|
const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
|
|
45
46
|
const showCreateTraiSMSHeader = isTraiDlt && channel.toLowerCase() === "sms";
|
|
46
|
-
const isWhatsappEdit = channel.toLowerCase() ===
|
|
47
|
+
const isWhatsappEdit = channel.toLowerCase() === WHATSAPP && slidBoxContent === 'editTemplate';
|
|
47
48
|
const whatsappOverview = isWhatsappEdit && isFullMode;
|
|
49
|
+
const headerMessage = whatsappOverview ? messages.whatsappOverview : messages.editMessageContent;
|
|
50
|
+
const {
|
|
51
|
+
whatsappTemplateName,
|
|
52
|
+
whatsappTemplateCategory,
|
|
53
|
+
} = templateData;
|
|
54
|
+
const whatsappName = whatsappTemplateName || templateData?.name;
|
|
55
|
+
const whatsappCategory = whatsappTemplateCategory || get(templateData, `versions.base.content.whatsapp.category`, '');
|
|
48
56
|
|
|
49
57
|
return (
|
|
50
58
|
<div key="creatives-container-slidebox-header-content">
|
|
@@ -72,15 +80,15 @@ function SlideBoxHeader(props) {
|
|
|
72
80
|
)}
|
|
73
81
|
{!showTemplateNameHeader && slidBoxContent === 'editTemplate' && (
|
|
74
82
|
<CapHeader
|
|
75
|
-
title={<FormattedMessage {...
|
|
83
|
+
title={<FormattedMessage {...headerMessage} values={{channel: getChannelLabel(channel)}}/>}
|
|
76
84
|
description={
|
|
77
85
|
isWhatsappEdit && (
|
|
78
86
|
<>
|
|
79
87
|
{renderWhatsappData("label1", <FormattedMessage {...whatsppMsg.templateNameLabel} />)}
|
|
80
|
-
{renderWhatsappData("label2",
|
|
88
|
+
{renderWhatsappData("label2", whatsappName)}
|
|
81
89
|
{renderWhatsappData("label3", <FormattedMessage {...whatsppMsg.labelSeperator} />)}
|
|
82
90
|
{renderWhatsappData("label1", <FormattedMessage {...whatsppMsg.templateCategoryLabel} />)}
|
|
83
|
-
{renderWhatsappData("label2", formatString(
|
|
91
|
+
{renderWhatsappData("label2", formatString(whatsappCategory))}
|
|
84
92
|
{renderWhatsappData("label3", <FormattedMessage {...whatsppMsg.labelSeperator} />)}
|
|
85
93
|
{renderWhatsappData("label1", <FormattedMessage {...whatsppMsg.languageLabel} />)}
|
|
86
94
|
{renderWhatsappData("label2", <FormattedMessage {...whatsppMsg.templateLanguageEnglish} />)}
|
|
@@ -542,3 +542,21 @@
|
|
|
542
542
|
margin: 8px 0;
|
|
543
543
|
white-space: pre-wrap;
|
|
544
544
|
}
|
|
545
|
+
|
|
546
|
+
.delete-template-confirm {
|
|
547
|
+
.ant-modal-footer {
|
|
548
|
+
padding: $CAP_SPACE_16 $CAP_SPACE_24 $CAP_SPACE_24 $CAP_SPACE_24;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
.ant-modal-header {
|
|
552
|
+
padding: $CAP_SPACE_24 $CAP_SPACE_24 $CAP_SPACE_08 $CAP_SPACE_24;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.ant-modal-body {
|
|
556
|
+
padding: 0 $CAP_SPACE_24;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
.ant-modal-close-x {
|
|
560
|
+
padding: $CAP_SPACE_12;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
@@ -22,7 +22,7 @@ import find from 'lodash/find';
|
|
|
22
22
|
import map from 'lodash/map';
|
|
23
23
|
import { bindActionCreators } from 'redux';
|
|
24
24
|
import { Modal, Form} from 'antd';
|
|
25
|
-
import {CapMenu, CapDropdown, CapButton, CapInput, CapIcon, CapRadioCard, CapPopover, CapSpin, CapCustomCard, CapRow, CapSlideBox, CapLink, CapHeading, CapNotification, CapIllustration, CapHeader, CapLabel, CapRadio, CapSelectFilter, CapTag, CapTooltip, CapAlert } from '@capillarytech/cap-ui-library';
|
|
25
|
+
import {CapMenu, CapDropdown, CapButton, CapInput, CapIcon, CapRadioCard, CapPopover, CapSpin, CapCustomCard, CapRow, CapSlideBox, CapLink, CapHeading, CapNotification, CapIllustration, CapHeader, CapLabel, CapRadio, CapSelectFilter, CapTag, CapTooltip, CapAlert, CapModal } from '@capillarytech/cap-ui-library';
|
|
26
26
|
import { makeSelectTemplates, makeSelectTemplatesResponse } from './selectors';
|
|
27
27
|
import { makeSelectCreate as makeSelectCreateSms} from '../Sms/Create/selectors';
|
|
28
28
|
import { makeSelectCreate as makeSelectCreateMobilePush } from '../MobilePush/Create/selectors';
|
|
@@ -116,6 +116,10 @@ const SMS_FILTERS = {
|
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
const WHATSAPP_LOWERCASE = WHATSAPP.toLowerCase();
|
|
119
|
+
const SMS_LOWERCASE = SMS.toLowerCase();
|
|
120
|
+
const MOBILE_PUSH_LOWERCASE = MOBILE_PUSH.toLowerCase();
|
|
121
|
+
const EBILL_LOWERCASE = EBILL.toLowerCase();
|
|
122
|
+
const LINE_LOWERCASE = LINE.toLowerCase();
|
|
119
123
|
export class Templates extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
120
124
|
constructor(props) {
|
|
121
125
|
super(props);
|
|
@@ -426,22 +430,31 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
426
430
|
if ((this.state.channel || '').toLowerCase() !== "sms") {
|
|
427
431
|
CapNotification.error({key: 'somethingWrong', message});
|
|
428
432
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
433
|
+
const { smsActions, mobilepushActions, ebillActions, lineActions, viberActions, facebookActions, whatsappActions } = this.props;
|
|
434
|
+
switch (selectedChannel) {
|
|
435
|
+
case SMS_LOWERCASE:
|
|
436
|
+
smsActions.clearCreateResponse();
|
|
437
|
+
break;
|
|
438
|
+
case MOBILE_PUSH_LOWERCASE:
|
|
439
|
+
mobilepushActions.clearCreateResponse();
|
|
440
|
+
break;
|
|
441
|
+
case EBILL_LOWERCASE:
|
|
442
|
+
ebillActions.clearCreateResponse();
|
|
443
|
+
break;
|
|
444
|
+
case LINE_LOWERCASE:
|
|
445
|
+
lineActions.clearCreateResponse();
|
|
446
|
+
break;
|
|
447
|
+
case VIBER_CHANNEL:
|
|
448
|
+
viberActions.clearCreateResponse();
|
|
449
|
+
break;
|
|
450
|
+
case FACEBOOK_CHANNEL:
|
|
451
|
+
facebookActions.clearCreateResponse();
|
|
452
|
+
break;
|
|
453
|
+
case WHATSAPP_LOWERCASE:
|
|
454
|
+
whatsappActions.clearCreateResponse();
|
|
455
|
+
break;
|
|
456
|
+
default:
|
|
457
|
+
break;
|
|
445
458
|
}
|
|
446
459
|
}
|
|
447
460
|
|
|
@@ -491,7 +504,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
491
504
|
paramsDefault.wecrmId = nextProps.Templates.weCrmAccounts[0].configs.wecrm_app_id;
|
|
492
505
|
paramsDefault.wecrmToken = nextProps.Templates.weCrmAccounts[0].configs.wecrm_token;
|
|
493
506
|
paramsDefault.originalId = nextProps.Templates.weCrmAccounts[0].sourceAccountIdentifier;
|
|
494
|
-
if (
|
|
507
|
+
if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
495
508
|
nextProps.actions.setChannelAccount(
|
|
496
509
|
WHATSAPP,
|
|
497
510
|
nextProps.Templates.weCrmAccounts[0],
|
|
@@ -588,10 +601,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
588
601
|
creativesParams._id = pathname.split('/')[3];
|
|
589
602
|
creativesParams.modeType = pathname.split('/')[4];
|
|
590
603
|
creativesParams.account = pathname.split('/')[5];
|
|
591
|
-
if(this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE){
|
|
604
|
+
if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
|
|
592
605
|
const whatsappSelectedTemplateData = this.selectTemplate(creativesParams._id) || {};
|
|
593
|
-
|
|
594
|
-
creativesParams.
|
|
606
|
+
const { name = '', versions = {} } = whatsappSelectedTemplateData;
|
|
607
|
+
creativesParams.whatsappTemplateName = name;
|
|
608
|
+
creativesParams.whatsappTemplateCategory = get(versions, `base.content.whatsapp.category`, '');
|
|
595
609
|
}
|
|
596
610
|
}
|
|
597
611
|
creativesParams.type = this.state.channel.toUpperCase();
|
|
@@ -786,7 +800,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
786
800
|
</CapMenu.Item>}
|
|
787
801
|
<CapMenu.Item
|
|
788
802
|
className={this.state.channel.toUpperCase() === WECHAT && !template.definition ? `unmap-${channelLowerCase}` : `delete-${channelLowerCase}`}
|
|
789
|
-
onClick={() => this.
|
|
803
|
+
onClick={() => this.toggleDeleteTemplateModal(template)}
|
|
790
804
|
>
|
|
791
805
|
{this.state.channel.toUpperCase() === WECHAT && !template.definition ? <FormattedMessage {...messages.unMapButton} /> : <FormattedMessage {...messages.deleteButton} />}
|
|
792
806
|
</CapMenu.Item>
|
|
@@ -1956,21 +1970,25 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1956
1970
|
);
|
|
1957
1971
|
}
|
|
1958
1972
|
renderDeleteConfirmationModal = () => {
|
|
1959
|
-
const
|
|
1960
|
-
|
|
1973
|
+
const {
|
|
1974
|
+
intl: {
|
|
1975
|
+
formatMessage,
|
|
1976
|
+
} = {},
|
|
1977
|
+
} = this.props;
|
|
1978
|
+
|
|
1979
|
+
const modal = ( <CapModal
|
|
1980
|
+
className="delete-template-confirm"
|
|
1981
|
+
title={formatMessage(messages.areYouSureText)}
|
|
1961
1982
|
visible={this.state.showModal}
|
|
1962
|
-
title={"Alert"}
|
|
1963
1983
|
onOk={this.handleOk}
|
|
1964
1984
|
onCancel={this.handleCancel}
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
{this.props.intl.formatMessage(messages.yesText)}
|
|
1969
|
-
</CapButton>,
|
|
1970
|
-
]}
|
|
1985
|
+
centered
|
|
1986
|
+
okText={formatMessage(messages.yesText)}
|
|
1987
|
+
closeText={formatMessage(messages.cancelText)}
|
|
1971
1988
|
>
|
|
1972
|
-
{
|
|
1973
|
-
</
|
|
1989
|
+
{formatMessage(messages.templateDeleteConfirm)}
|
|
1990
|
+
</CapModal>
|
|
1991
|
+
);
|
|
1974
1992
|
return modal;
|
|
1975
1993
|
};
|
|
1976
1994
|
|
|
@@ -220,7 +220,11 @@ export default defineMessages({
|
|
|
220
220
|
},
|
|
221
221
|
"templateDeleteConfirm": {
|
|
222
222
|
id: `${scope}.templateDeleteConfirm`,
|
|
223
|
-
defaultMessage: `Are you sure you
|
|
223
|
+
defaultMessage: `Are you sure you wish to delete this template?`,
|
|
224
|
+
},
|
|
225
|
+
"areYouSureText": {
|
|
226
|
+
id: `${scope}.areYouSureText`,
|
|
227
|
+
defaultMessage: `Confirm delete template`,
|
|
224
228
|
},
|
|
225
229
|
"cancelText": {
|
|
226
230
|
id: `${scope}.cancelText`,
|
|
@@ -228,7 +232,7 @@ export default defineMessages({
|
|
|
228
232
|
},
|
|
229
233
|
"yesText": {
|
|
230
234
|
id: `${scope}.yesText`,
|
|
231
|
-
defaultMessage: `Yes`,
|
|
235
|
+
defaultMessage: `Yes, delete`,
|
|
232
236
|
},
|
|
233
237
|
"templateSelection": {
|
|
234
238
|
id: `${scope}.templateSelection`,
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
ALL,
|
|
45
45
|
LIBRARY,
|
|
46
46
|
} from './constants';
|
|
47
|
+
import { DATE_DISPLAY_FORMAT, TIME_DISPLAY_FORMAT } from '../App/constants';
|
|
47
48
|
import messages from './messages';
|
|
48
49
|
import withCreatives from '../../hoc/withCreatives';
|
|
49
50
|
import TemplatePreview from '../../v2Components/TemplatePreview';
|
|
@@ -52,6 +53,7 @@ import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
|
|
|
52
53
|
|
|
53
54
|
let varMap = {};
|
|
54
55
|
let editContent = {};
|
|
56
|
+
let timerid;
|
|
55
57
|
|
|
56
58
|
export const Whatsapp = (props) => {
|
|
57
59
|
const {
|
|
@@ -117,9 +119,15 @@ export const Whatsapp = (props) => {
|
|
|
117
119
|
useEffect(() => {
|
|
118
120
|
const accountObj = accountData.selectedWhatsappAccount || {};
|
|
119
121
|
if (!isEmpty(accountObj)) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
const {
|
|
123
|
+
sourceAccountIdentifier = '',
|
|
124
|
+
configs = {},
|
|
125
|
+
name = '',
|
|
126
|
+
} = accountObj;
|
|
127
|
+
const { accessToken = '' } = configs;
|
|
128
|
+
setAccountId(sourceAccountIdentifier);
|
|
129
|
+
setAccessToken(accessToken);
|
|
130
|
+
setAccountName(name);
|
|
123
131
|
}
|
|
124
132
|
}, [accountData.selectedWhatsappAccount]);
|
|
125
133
|
|
|
@@ -134,30 +142,28 @@ export const Whatsapp = (props) => {
|
|
|
134
142
|
}
|
|
135
143
|
//cleanup code
|
|
136
144
|
return () => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
actions.resetEditTemplate();
|
|
146
|
+
varMap = {};
|
|
147
|
+
if (timerid) {
|
|
148
|
+
clearTimeout(timerid);
|
|
140
149
|
}
|
|
141
150
|
};
|
|
142
151
|
}, [paramObj.id]);
|
|
143
152
|
|
|
144
153
|
useEffect(() => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
const {
|
|
155
|
+
name = '',
|
|
156
|
+
versions = {},
|
|
157
|
+
createdAt = '',
|
|
158
|
+
} = editData.templateDetails || templateData || {};
|
|
159
|
+
editContent = get(versions, `base.content.whatsapp`, {});
|
|
149
160
|
if (editContent && !isEmpty(editContent)) {
|
|
150
|
-
|
|
151
|
-
(templateData || {}).name || get(editData, 'templateDetails.name');
|
|
152
|
-
const createdAt =
|
|
153
|
-
(templateData || {}).createdAt ||
|
|
154
|
-
get(editData, 'templateDetails.createdAt');
|
|
155
|
-
setTemplateName(editMessageTitle);
|
|
161
|
+
setTemplateName(name);
|
|
156
162
|
setTemplateDate(createdAt);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
);
|
|
163
|
+
const { category = '', status = WHATSAPP_STATUSES.unsubmitted } =
|
|
164
|
+
editContent;
|
|
165
|
+
setTemplateCategory(category);
|
|
166
|
+
setTemplateStatus(status);
|
|
161
167
|
computeTempMsgArray();
|
|
162
168
|
}
|
|
163
169
|
}, [editData.templateDetails || templateData]);
|
|
@@ -166,27 +172,29 @@ export const Whatsapp = (props) => {
|
|
|
166
172
|
let msg = get(editContent, `languages[0].content`, '');
|
|
167
173
|
const validVarArr = msg.match(validVarRegex) || [];
|
|
168
174
|
const templateMessageArray = [];
|
|
175
|
+
//removing $'' which was added for twilio enter handling
|
|
169
176
|
msg = msg.slice(2, -1);
|
|
177
|
+
//removing Click {{unsubscribe}} to unsubscribe
|
|
170
178
|
msg = msg.replace(
|
|
171
179
|
`Click ${validVarArr[validVarArr.length - 1]} to unsubscribe`,
|
|
172
180
|
'',
|
|
173
181
|
);
|
|
182
|
+
//removing last var added for Click {{unsubscribe}} to unsubscribe
|
|
174
183
|
validVarArr.pop();
|
|
175
184
|
while (msg.length !== 0) {
|
|
185
|
+
//converting content string to an array split at var
|
|
176
186
|
const index = msg.indexOf(validVarArr[0]);
|
|
177
187
|
if (index !== -1) {
|
|
178
|
-
templateMessageArray.push(msg.substring(0, index));
|
|
179
|
-
templateMessageArray.push(validVarArr[0]);
|
|
180
|
-
msg = msg.substring(index + validVarArr[0].length, msg.length);
|
|
181
|
-
validVarArr.shift();
|
|
188
|
+
templateMessageArray.push(msg.substring(0, index)); //push string before var
|
|
189
|
+
templateMessageArray.push(validVarArr[0]); //push var
|
|
190
|
+
msg = msg.substring(index + validVarArr[0].length, msg.length); //remaining str
|
|
191
|
+
validVarArr.shift(); //remove considered var
|
|
182
192
|
} else {
|
|
183
|
-
templateMessageArray.push(msg);
|
|
193
|
+
templateMessageArray.push(msg); //remaining str
|
|
184
194
|
break;
|
|
185
195
|
}
|
|
186
196
|
}
|
|
187
197
|
updateTempMsgArray(templateMessageArray.filter((i) => i === 0 || i));
|
|
188
|
-
//stop spinner
|
|
189
|
-
setSpin(false);
|
|
190
198
|
};
|
|
191
199
|
|
|
192
200
|
useEffect(() => {
|
|
@@ -202,7 +210,7 @@ export const Whatsapp = (props) => {
|
|
|
202
210
|
}
|
|
203
211
|
}
|
|
204
212
|
}
|
|
205
|
-
//setting updatedSmsEditor based on varMap
|
|
213
|
+
//setting updatedSmsEditor state based on varMap
|
|
206
214
|
const arr = [...tempMsgArray];
|
|
207
215
|
for (const key in varMap) {
|
|
208
216
|
if (varMap[key] !== '') {
|
|
@@ -210,6 +218,10 @@ export const Whatsapp = (props) => {
|
|
|
210
218
|
}
|
|
211
219
|
}
|
|
212
220
|
setUpdatedSmsEditor(arr);
|
|
221
|
+
timerid = setTimeout(() => {
|
|
222
|
+
//stop spinner
|
|
223
|
+
setSpin(false);
|
|
224
|
+
}, 500);
|
|
213
225
|
}
|
|
214
226
|
}, [tempMsgArray]);
|
|
215
227
|
|
|
@@ -230,19 +242,18 @@ export const Whatsapp = (props) => {
|
|
|
230
242
|
}
|
|
231
243
|
globalActions.fetchSchemaForEntity(query);
|
|
232
244
|
}
|
|
233
|
-
}, []);
|
|
245
|
+
}, [isEditFlow]);
|
|
234
246
|
|
|
235
247
|
useEffect(() => {
|
|
236
248
|
if (isEditFlow) {
|
|
237
|
-
let tag =
|
|
238
|
-
metaEntities && metaEntities.tags ? metaEntities.tags.standard : [];
|
|
249
|
+
let tag = get(metaEntities, `tags.standard`, []);
|
|
239
250
|
const { type, module } = location.query || {};
|
|
240
251
|
if (type === EMBEDDED && module === LIBRARY && !getDefaultTags) {
|
|
241
252
|
tag = supportedTags;
|
|
242
253
|
}
|
|
243
254
|
updateTags(tag);
|
|
244
255
|
}
|
|
245
|
-
}, [metaEntities]);
|
|
256
|
+
}, [metaEntities, isEditFlow]);
|
|
246
257
|
|
|
247
258
|
const handleOnTagsContextChange = (data) => {
|
|
248
259
|
const { type } = location.query || {};
|
|
@@ -261,8 +272,8 @@ export const Whatsapp = (props) => {
|
|
|
261
272
|
|
|
262
273
|
const onTagSelect = (data) => {
|
|
263
274
|
if (varMap && updatedSmsEditor) {
|
|
264
|
-
|
|
265
|
-
if (numId
|
|
275
|
+
const numId = Number(textAreaId?.slice(textAreaId?.indexOf('_') + 1));
|
|
276
|
+
if (numId != NaN) {
|
|
266
277
|
const arr = [...updatedSmsEditor];
|
|
267
278
|
//when trying to insert tag in empty textarea,{#var#} is replaced with "" and then tag is added
|
|
268
279
|
if (arr[numId]?.match(validVarRegex)?.length > 0) {
|
|
@@ -340,7 +351,7 @@ export const Whatsapp = (props) => {
|
|
|
340
351
|
<CapColumn span={12}>
|
|
341
352
|
<CapTooltip
|
|
342
353
|
placement="bottom"
|
|
343
|
-
title={formatMessage(messages.unsubscribeTextTooltip)}
|
|
354
|
+
title={!isEditFlow && formatMessage(messages.unsubscribeTextTooltip)}
|
|
344
355
|
>
|
|
345
356
|
<CapHeading
|
|
346
357
|
className={
|
|
@@ -611,45 +622,50 @@ export const Whatsapp = (props) => {
|
|
|
611
622
|
//create methods end
|
|
612
623
|
|
|
613
624
|
//edit methods start
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
625
|
+
const getTemplateStatusType = () => {
|
|
626
|
+
switch (templateStatus) {
|
|
627
|
+
case WHATSAPP_STATUSES.approved:
|
|
628
|
+
return 'success';
|
|
629
|
+
case WHATSAPP_STATUSES.rejected:
|
|
630
|
+
return 'error';
|
|
631
|
+
default:
|
|
632
|
+
return 'warning';
|
|
619
633
|
}
|
|
620
|
-
return 'warning';
|
|
621
634
|
};
|
|
622
635
|
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
+
const getTemplateStatusMessage = () => {
|
|
637
|
+
switch (templateStatus) {
|
|
638
|
+
case WHATSAPP_STATUSES.approved:
|
|
639
|
+
return (
|
|
640
|
+
<CapLabel type="label2">
|
|
641
|
+
{formatMessage(messages.approvedStatusMsg)}
|
|
642
|
+
</CapLabel>
|
|
643
|
+
);
|
|
644
|
+
case WHATSAPP_STATUSES.rejected:
|
|
645
|
+
return (
|
|
646
|
+
<CapLabel type="label2">
|
|
647
|
+
{formatMessage(messages.rejectedStatusMsg)}
|
|
648
|
+
</CapLabel>
|
|
649
|
+
);
|
|
650
|
+
default:
|
|
651
|
+
//all cases except approved and rejected, return awaiting approval
|
|
652
|
+
return (
|
|
653
|
+
<>
|
|
654
|
+
<CapLabel type="label2" style={{ fontWeight: 500 }}>
|
|
655
|
+
{formatMessage(messages.awaitingStatusMsg)}
|
|
656
|
+
</CapLabel>
|
|
657
|
+
<CapLabel
|
|
658
|
+
type="label2"
|
|
659
|
+
style={{ marginTop: CAP_SPACE_04, marginBottom: CAP_SPACE_04 }}
|
|
660
|
+
>
|
|
661
|
+
{formatMessage(messages.awaitingStatusDesc, {
|
|
662
|
+
date: moment(templateDate).format(DATE_DISPLAY_FORMAT),
|
|
663
|
+
time: moment(templateDate).format(TIME_DISPLAY_FORMAT),
|
|
664
|
+
})}
|
|
665
|
+
</CapLabel>
|
|
666
|
+
</>
|
|
667
|
+
);
|
|
636
668
|
}
|
|
637
|
-
return (
|
|
638
|
-
<>
|
|
639
|
-
<CapLabel type="label2" style={{ fontWeight: 500 }}>
|
|
640
|
-
{formatMessage(messages.awaitingStatusMsg)}
|
|
641
|
-
</CapLabel>
|
|
642
|
-
<CapLabel
|
|
643
|
-
type="label2"
|
|
644
|
-
style={{ marginTop: CAP_SPACE_04, marginBottom: CAP_SPACE_04 }}
|
|
645
|
-
>
|
|
646
|
-
{formatMessage(messages.awaitingStatusDesc, {
|
|
647
|
-
date: moment(templateDate).format('D MMM YYYY'),
|
|
648
|
-
time: moment(templateDate).format('hh:mm A'),
|
|
649
|
-
})}
|
|
650
|
-
</CapLabel>
|
|
651
|
-
</>
|
|
652
|
-
);
|
|
653
669
|
};
|
|
654
670
|
|
|
655
671
|
// on change event of Text Area
|
|
@@ -671,10 +687,10 @@ export const Whatsapp = (props) => {
|
|
|
671
687
|
const textAreaValue = (idValue) => {
|
|
672
688
|
if (idValue >= 0 && updatedSmsEditor) {
|
|
673
689
|
const value = updatedSmsEditor[idValue];
|
|
690
|
+
//if value is there and it is not a variable return it
|
|
674
691
|
if (value && (value.match(validVarRegex) || []).length === 0) {
|
|
675
692
|
return value;
|
|
676
693
|
}
|
|
677
|
-
return '';
|
|
678
694
|
}
|
|
679
695
|
return '';
|
|
680
696
|
};
|
|
@@ -684,6 +700,7 @@ export const Whatsapp = (props) => {
|
|
|
684
700
|
if (tempMsgArray?.length !== 0) {
|
|
685
701
|
let varCount = 0;
|
|
686
702
|
tempMsgArray.forEach((elem, index) => {
|
|
703
|
+
// if var return textarea else return text
|
|
687
704
|
if (elem.match(validVarRegex)?.length > 0) {
|
|
688
705
|
varCount += 1;
|
|
689
706
|
renderArray.push(
|
|
@@ -717,9 +734,27 @@ export const Whatsapp = (props) => {
|
|
|
717
734
|
return renderArray;
|
|
718
735
|
};
|
|
719
736
|
|
|
737
|
+
const disabledEditTooltipRender = () => {
|
|
738
|
+
switch (templateStatus) {
|
|
739
|
+
case WHATSAPP_STATUSES.approved:
|
|
740
|
+
return '';
|
|
741
|
+
case WHATSAPP_STATUSES.rejected:
|
|
742
|
+
return formatMessage(messages.disabledEditTooltip, {
|
|
743
|
+
status: templateStatus,
|
|
744
|
+
});
|
|
745
|
+
default:
|
|
746
|
+
return formatMessage(messages.disabledEditTooltip, {
|
|
747
|
+
status: formatMessage(messages.disabledEditTooltipStatus),
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
|
|
720
752
|
const editModeContent = (
|
|
721
753
|
<>
|
|
722
|
-
<CapAlert
|
|
754
|
+
<CapAlert
|
|
755
|
+
message={getTemplateStatusMessage()}
|
|
756
|
+
type={getTemplateStatusType()}
|
|
757
|
+
/>
|
|
723
758
|
<CapRow className="whatsapp-render-heading">
|
|
724
759
|
<CapHeader
|
|
725
760
|
title={
|
|
@@ -741,20 +776,7 @@ export const Whatsapp = (props) => {
|
|
|
741
776
|
}
|
|
742
777
|
/>
|
|
743
778
|
</CapRow>
|
|
744
|
-
<CapTooltip
|
|
745
|
-
placement="bottom"
|
|
746
|
-
title={
|
|
747
|
-
templateStatus === WHATSAPP_STATUSES.approved
|
|
748
|
-
? ''
|
|
749
|
-
: templateStatus === WHATSAPP_STATUSES.rejected
|
|
750
|
-
? formatMessage(messages.disabledEditTooltip, {
|
|
751
|
-
status: templateStatus,
|
|
752
|
-
})
|
|
753
|
-
: formatMessage(messages.disabledEditTooltip, {
|
|
754
|
-
status: 'awaiting for approval',
|
|
755
|
-
})
|
|
756
|
-
}
|
|
757
|
-
>
|
|
779
|
+
<CapTooltip placement="bottom" title={disabledEditTooltipRender()}>
|
|
758
780
|
<CapRow
|
|
759
781
|
className={`whatsapp-edit-template-message-input ${
|
|
760
782
|
templateStatus !== WHATSAPP_STATUSES.approved &&
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
text-align: right;
|
|
19
19
|
}
|
|
20
20
|
.whatsapp-create-template-message-input {
|
|
21
|
-
background-color:
|
|
21
|
+
background-color: $CAP_G10;
|
|
22
22
|
padding-top: $CAP_SPACE_16;
|
|
23
23
|
}
|
|
24
24
|
.whatsapp-template-message-error {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
margin-top: 46px;
|
|
36
36
|
}
|
|
37
37
|
.whatsapp-edit-template-message-input {
|
|
38
|
-
background-color:
|
|
38
|
+
background-color: $CAP_G10;
|
|
39
39
|
padding: 0 $CAP_SPACE_16;
|
|
40
40
|
}
|
|
41
41
|
.whatsapp-edit-template-message-heading {
|
|
@@ -218,4 +218,8 @@ export default defineMessages({
|
|
|
218
218
|
id: `${prefix}.disabledEditTooltip`,
|
|
219
219
|
defaultMessage: 'This template is non-editable as this is {status}',
|
|
220
220
|
},
|
|
221
|
+
disabledEditTooltipStatus: {
|
|
222
|
+
id: `${prefix}.disabledEditTooltipStatus`,
|
|
223
|
+
defaultMessage: 'awaiting for approval',
|
|
224
|
+
},
|
|
221
225
|
});
|