@capillarytech/creatives-library 7.10.45 → 7.10.46
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/CreativesContainer/SlideBoxHeader.js +1 -1
- package/v2Containers/Templates/_templates.scss +1 -0
- package/v2Containers/Templates/index.js +45 -18
- package/v2Containers/Templates/messages.js +8 -0
- package/v2Containers/Whatsapp/index.js +41 -15
- package/v2Containers/Whatsapp/messages.js +10 -0
- package/v2Containers/Whatsapp/utils.js +8 -25
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@ function SlideBoxHeader(props) {
|
|
|
50
50
|
const {
|
|
51
51
|
whatsappTemplateName,
|
|
52
52
|
whatsappTemplateCategory,
|
|
53
|
-
} = templateData;
|
|
53
|
+
} = templateData || {};
|
|
54
54
|
const whatsappName = whatsappTemplateName || templateData?.name;
|
|
55
55
|
const whatsappCategory = whatsappTemplateCategory || get(templateData, `versions.base.content.whatsapp.category`, '');
|
|
56
56
|
|
|
@@ -706,10 +706,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
isStatusMatching = (status, selectedWhatsappStatus) => {
|
|
709
|
-
if
|
|
710
|
-
|
|
709
|
+
if(this.props.isFullMode && selectedWhatsappStatus) {
|
|
710
|
+
if ( [WHATSAPP_STATUSES.unsubmitted, WHATSAPP_STATUSES.pending].includes(status) ) {
|
|
711
|
+
return selectedWhatsappStatus === WHATSAPP_STATUSES.awaitingApproval;
|
|
712
|
+
}
|
|
713
|
+
return selectedWhatsappStatus === status;
|
|
714
|
+
}
|
|
715
|
+
else if (!this.props.isFullMode){
|
|
716
|
+
return status === WHATSAPP_STATUSES.approved;
|
|
711
717
|
}
|
|
712
|
-
|
|
718
|
+
return true;
|
|
713
719
|
}
|
|
714
720
|
|
|
715
721
|
filterWhatsappTemplates = (templates) => {
|
|
@@ -719,9 +725,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
719
725
|
|
|
720
726
|
// if status or category filter is applied, filter templates which match these filters
|
|
721
727
|
return (
|
|
722
|
-
selectedWhatsappStatus
|
|
723
|
-
? this.isStatusMatching(status, selectedWhatsappStatus)
|
|
724
|
-
: true
|
|
728
|
+
this.isStatusMatching(status, selectedWhatsappStatus)
|
|
725
729
|
) && (
|
|
726
730
|
selectedWhatsappCategory
|
|
727
731
|
? category === selectedWhatsappCategory
|
|
@@ -751,6 +755,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
751
755
|
const channelLowerCase = stateChannel.toLowerCase();
|
|
752
756
|
let filteredTemplates = templates;
|
|
753
757
|
let isTraiDltFeature = false;
|
|
758
|
+
console.log("getTemplateDataForGrid", currentChannel);
|
|
754
759
|
switch (currentChannel) {
|
|
755
760
|
case WECHAT:
|
|
756
761
|
filteredTemplates = this.filterWechatTemplates(templates);
|
|
@@ -2175,19 +2180,24 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2175
2180
|
|
|
2176
2181
|
selectedFilters = () => {
|
|
2177
2182
|
const { selectedWhatsappStatus, selectedWhatsappCategory } = this.state;
|
|
2183
|
+
const {
|
|
2184
|
+
intl: {
|
|
2185
|
+
formatMessage,
|
|
2186
|
+
},
|
|
2187
|
+
} = this.props;
|
|
2178
2188
|
return (
|
|
2179
2189
|
<CapRow type="flex" align="middle" className="selected-whatsapp-filters">
|
|
2180
2190
|
{
|
|
2181
2191
|
selectedWhatsappStatus ? (
|
|
2182
2192
|
<CapTag closable onClose={() => this.removeWhatsappFilter(WHATSAPP_STATUS)}>
|
|
2183
|
-
|
|
2193
|
+
{formatMessage(messages.status)}: {getWhatsappStatus(selectedWhatsappStatus)?.label || selectedWhatsappStatus}
|
|
2184
2194
|
</CapTag>
|
|
2185
2195
|
) : null
|
|
2186
2196
|
}
|
|
2187
2197
|
{
|
|
2188
2198
|
selectedWhatsappCategory ? (
|
|
2189
2199
|
<CapTag closable onClose={() => this.removeWhatsappFilter(WHATSAPP_CATEGORY)}>
|
|
2190
|
-
|
|
2200
|
+
{formatMessage(messages.category)}: {getWhatsappCategory(selectedWhatsappCategory)?.label || selectedWhatsappCategory}
|
|
2191
2201
|
</CapTag>
|
|
2192
2202
|
) : null
|
|
2193
2203
|
}
|
|
@@ -2290,7 +2300,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2290
2300
|
type={"primary"}
|
|
2291
2301
|
disabled={this.isCreateDisabled()}
|
|
2292
2302
|
style={{marginLeft: '8px', marginBottom: '12px'}}
|
|
2293
|
-
onClick={this.createTemplate}
|
|
2303
|
+
onClick={this.createTemplate}
|
|
2304
|
+
target={channelLowerCase === WHATSAPP_LOWERCASE && !this.props.isFullMode ? "_blank" : null}
|
|
2305
|
+
>
|
|
2294
2306
|
{ this.props.intl.formatMessage((isTraiDltFeature && channel.toUpperCase() === SMS ) ? messages.uploadTemplate : messages.createNewActionButton) }
|
|
2295
2307
|
</CapButton>);
|
|
2296
2308
|
|
|
@@ -2324,15 +2336,19 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2324
2336
|
{
|
|
2325
2337
|
channel.toUpperCase() === WHATSAPP && (
|
|
2326
2338
|
<div className="whatsapp-filters">
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2339
|
+
{
|
|
2340
|
+
this.props.isFullMode ? (
|
|
2341
|
+
<CapSelectFilter
|
|
2342
|
+
placement="bottomLeft"
|
|
2343
|
+
data={STATUS_OPTIONS}
|
|
2344
|
+
onSelect={this.setWhatsappStatus}
|
|
2345
|
+
selectedValue={this.state.selectedWhatsappStatus}
|
|
2346
|
+
placeholder="Status"
|
|
2347
|
+
showBadge={true}
|
|
2348
|
+
width="90px"
|
|
2349
|
+
/>
|
|
2350
|
+
) : null
|
|
2351
|
+
}
|
|
2336
2352
|
<CapSelectFilter
|
|
2337
2353
|
placement="bottomLeft"
|
|
2338
2354
|
data={CATEGORY_OPTIONS}
|
|
@@ -2464,10 +2480,21 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2464
2480
|
|
|
2465
2481
|
<CapRow>
|
|
2466
2482
|
<Pagination onPageChange={templates.length ? this.onPaginationChange : () => {}} paginationSelector="pagination-container">
|
|
2483
|
+
|
|
2484
|
+
{
|
|
2485
|
+
channel.toLowerCase() === WHATSAPP_LOWERCASE ? (
|
|
2486
|
+
<CapAlert message={whatsappCountExceedText} type="info" />
|
|
2487
|
+
) : null
|
|
2488
|
+
}
|
|
2467
2489
|
{this.getTemplateDataForGrid({isLoading, loadingTip, channel: this.state.channel, templates: this.props.TemplatesList, filterContent, handlers: {handlePreviewClick: this.handlePreviewClick, handleEditClick: this.handleEditClick}})}
|
|
2468
2490
|
</Pagination>
|
|
2469
2491
|
{(((this.state.selectedAccount !== '' && !isEmpty(this.props.Templates.selectedWeChatAccount) && this.state.channel.toLowerCase() === 'wechat') || this.state.channel.toLowerCase() !== 'wechat') && isEmpty(this.props.TemplatesList)) && !this.props.Templates.getAllTemplatesInProgress && !isEmpty(this.state.searchText) &&
|
|
2470
2492
|
<div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
|
|
2493
|
+
{
|
|
2494
|
+
channel.toLowerCase() === WHATSAPP_LOWERCASE ? (
|
|
2495
|
+
<CapAlert message={whatsappCountExceedText} type="info" />
|
|
2496
|
+
) : null
|
|
2497
|
+
}
|
|
2471
2498
|
<CapHeading type="h6">{this.props.intl.formatMessage(messages.noTemplatesFound)}</CapHeading>
|
|
2472
2499
|
</div>}
|
|
2473
2500
|
</CapRow>
|
|
@@ -426,4 +426,12 @@ export default defineMessages({
|
|
|
426
426
|
id: `${scope}.whatsappMaxTemplates`,
|
|
427
427
|
defaultMessage: 'WhatsApp allows {maxCount} approved templates. To accommodate new approved templates either delete the existing one or reach out to Capillary POC to increase the limit.',
|
|
428
428
|
},
|
|
429
|
+
"status": {
|
|
430
|
+
id: `${scope}.status`,
|
|
431
|
+
defaultMessage: 'Status',
|
|
432
|
+
},
|
|
433
|
+
"category": {
|
|
434
|
+
id: `${scope}.category`,
|
|
435
|
+
defaultMessage: 'Category',
|
|
436
|
+
},
|
|
429
437
|
});
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
CAP_WHITE,
|
|
30
30
|
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
31
31
|
import { makeSelectWhatsapp, makeSelectAccount } from './selectors';
|
|
32
|
+
import { isLoadingMetaEntities } from '../Cap/selectors';
|
|
32
33
|
import * as WhatsappActions from './actions';
|
|
33
34
|
import './index.scss';
|
|
34
35
|
import {
|
|
@@ -53,7 +54,6 @@ import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
|
|
|
53
54
|
|
|
54
55
|
let varMap = {};
|
|
55
56
|
let editContent = {};
|
|
56
|
-
let timerid;
|
|
57
57
|
|
|
58
58
|
export const Whatsapp = (props) => {
|
|
59
59
|
const {
|
|
@@ -72,6 +72,7 @@ export const Whatsapp = (props) => {
|
|
|
72
72
|
supportedTags,
|
|
73
73
|
metaEntities,
|
|
74
74
|
injectedTags,
|
|
75
|
+
loadingTags,
|
|
75
76
|
} = props || {};
|
|
76
77
|
const { formatMessage } = intl;
|
|
77
78
|
const { TextArea } = CapInput;
|
|
@@ -93,6 +94,7 @@ export const Whatsapp = (props) => {
|
|
|
93
94
|
const [templateStatus, setTemplateStatus] = useState(
|
|
94
95
|
WHATSAPP_STATUSES.unsubmitted,
|
|
95
96
|
);
|
|
97
|
+
const [templateRejectionReason, setTemplateRejectionReason] = useState(null);
|
|
96
98
|
const [tempMsgArray, updateTempMsgArray] = useState([]);
|
|
97
99
|
const [updatedSmsEditor, setUpdatedSmsEditor] = useState([]);
|
|
98
100
|
//for tag only
|
|
@@ -108,7 +110,8 @@ export const Whatsapp = (props) => {
|
|
|
108
110
|
width: 100%;
|
|
109
111
|
margin-left: -32px;
|
|
110
112
|
padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
|
|
111
|
-
|
|
113
|
+
z-index: 1;
|
|
114
|
+
|
|
112
115
|
.ant-btn {
|
|
113
116
|
margin-right: ${CAP_SPACE_16};
|
|
114
117
|
}
|
|
@@ -146,9 +149,6 @@ export const Whatsapp = (props) => {
|
|
|
146
149
|
return () => {
|
|
147
150
|
actions.resetEditTemplate();
|
|
148
151
|
varMap = {};
|
|
149
|
-
if (timerid) {
|
|
150
|
-
clearTimeout(timerid);
|
|
151
|
-
}
|
|
152
152
|
};
|
|
153
153
|
}, [paramObj.id]);
|
|
154
154
|
|
|
@@ -162,10 +162,14 @@ export const Whatsapp = (props) => {
|
|
|
162
162
|
if (editContent && !isEmpty(editContent)) {
|
|
163
163
|
setTemplateName(name);
|
|
164
164
|
setTemplateDate(createdAt);
|
|
165
|
-
const {
|
|
166
|
-
|
|
165
|
+
const {
|
|
166
|
+
category = '',
|
|
167
|
+
status = WHATSAPP_STATUSES.unsubmitted,
|
|
168
|
+
rejection_reason = null,
|
|
169
|
+
} = editContent;
|
|
167
170
|
setTemplateCategory(category);
|
|
168
171
|
setTemplateStatus(status);
|
|
172
|
+
setTemplateRejectionReason(rejection_reason);
|
|
169
173
|
computeTempMsgArray();
|
|
170
174
|
}
|
|
171
175
|
}, [editData.templateDetails || templateData]);
|
|
@@ -220,13 +224,15 @@ export const Whatsapp = (props) => {
|
|
|
220
224
|
}
|
|
221
225
|
}
|
|
222
226
|
setUpdatedSmsEditor(arr);
|
|
223
|
-
timerid = setTimeout(() => {
|
|
224
|
-
//stop spinner
|
|
225
|
-
setSpin(false);
|
|
226
|
-
}, 500);
|
|
227
227
|
}
|
|
228
228
|
}, [tempMsgArray]);
|
|
229
229
|
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
if (tempMsgArray?.length && !loadingTags) {
|
|
232
|
+
setSpin(false);
|
|
233
|
+
}
|
|
234
|
+
}, [tempMsgArray, loadingTags]);
|
|
235
|
+
|
|
230
236
|
// tag Code start from here
|
|
231
237
|
useEffect(() => {
|
|
232
238
|
//fetching tags
|
|
@@ -624,6 +630,17 @@ export const Whatsapp = (props) => {
|
|
|
624
630
|
//create methods end
|
|
625
631
|
|
|
626
632
|
//edit methods start
|
|
633
|
+
const computeTemplateRejectionReason = () => {
|
|
634
|
+
switch (templateRejectionReason) {
|
|
635
|
+
case 'TAG_CONTENT_MISMATCH':
|
|
636
|
+
return formatMessage(messages.tagContentMismatchError);
|
|
637
|
+
case 'INVALID_FORMAT':
|
|
638
|
+
return formatMessage(messages.invalidFormatError);
|
|
639
|
+
default:
|
|
640
|
+
return '';
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
|
|
627
644
|
const getTemplateStatusType = () => {
|
|
628
645
|
switch (templateStatus) {
|
|
629
646
|
case WHATSAPP_STATUSES.approved:
|
|
@@ -645,9 +662,17 @@ export const Whatsapp = (props) => {
|
|
|
645
662
|
);
|
|
646
663
|
case WHATSAPP_STATUSES.rejected:
|
|
647
664
|
return (
|
|
648
|
-
|
|
649
|
-
{
|
|
650
|
-
|
|
665
|
+
<>
|
|
666
|
+
<CapLabel type="label2" style={{ fontWeight: 500 }}>
|
|
667
|
+
{formatMessage(messages.rejectedStatusMsg)}
|
|
668
|
+
</CapLabel>
|
|
669
|
+
<CapLabel
|
|
670
|
+
type="label2"
|
|
671
|
+
style={{ margin: `${CAP_SPACE_04} 0 ${CAP_SPACE_04}` }}
|
|
672
|
+
>
|
|
673
|
+
{computeTemplateRejectionReason()}
|
|
674
|
+
</CapLabel>
|
|
675
|
+
</>
|
|
651
676
|
);
|
|
652
677
|
default:
|
|
653
678
|
//all cases except approved and rejected, return awaiting approval
|
|
@@ -658,7 +683,7 @@ export const Whatsapp = (props) => {
|
|
|
658
683
|
</CapLabel>
|
|
659
684
|
<CapLabel
|
|
660
685
|
type="label2"
|
|
661
|
-
style={{
|
|
686
|
+
style={{ margin: `${CAP_SPACE_04} 0 ${CAP_SPACE_04}` }}
|
|
662
687
|
>
|
|
663
688
|
{formatMessage(messages.awaitingStatusDesc, {
|
|
664
689
|
date: moment(templateDate).format(DATE_DISPLAY_FORMAT),
|
|
@@ -858,6 +883,7 @@ const mapStateToProps = createStructuredSelector({
|
|
|
858
883
|
editData: makeSelectWhatsapp(),
|
|
859
884
|
accountData: makeSelectAccount(),
|
|
860
885
|
metaEntities: makeSelectMetaEntities(),
|
|
886
|
+
loadingTags: isLoadingMetaEntities(),
|
|
861
887
|
injectedTags: setInjectedTags(),
|
|
862
888
|
});
|
|
863
889
|
|
|
@@ -197,6 +197,16 @@ export default defineMessages({
|
|
|
197
197
|
id: `${prefix}.rejectedStatusMsg`,
|
|
198
198
|
defaultMessage: 'This template has been rejected',
|
|
199
199
|
},
|
|
200
|
+
tagContentMismatchError: {
|
|
201
|
+
id: `${prefix}.tagContentMismatchError`,
|
|
202
|
+
defaultMessage:
|
|
203
|
+
'TAG CONTENT MISMATCH: The language and/or template category selected don’t match the template content.',
|
|
204
|
+
},
|
|
205
|
+
invalidFormatError: {
|
|
206
|
+
id: `${prefix}.invalidFormatError`,
|
|
207
|
+
defaultMessage:
|
|
208
|
+
'INVALID FORMAT: Placeholders or other elements were formatted incorrectly.',
|
|
209
|
+
},
|
|
200
210
|
awaitingStatusMsg: {
|
|
201
211
|
id: `${prefix}.awaitingStatusMsg`,
|
|
202
212
|
defaultMessage: 'This template is awaiting approval',
|
|
@@ -16,37 +16,20 @@ export const getWhatsappContent = (template) => {
|
|
|
16
16
|
content: {
|
|
17
17
|
[WHATSAPP.toLowerCase()]: {
|
|
18
18
|
languages = [{}],
|
|
19
|
-
'var-mapped': varMapped = {},
|
|
20
19
|
} = {},
|
|
21
20
|
} = {},
|
|
22
21
|
} = {},
|
|
23
22
|
} = {},
|
|
24
23
|
} = template;
|
|
24
|
+
//removing $'' which was added for twilio enter handling
|
|
25
25
|
let text = languages[0]?.content?.slice(2, -1) || '';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (openIndex > -1) {
|
|
34
|
-
// Number inside the current braces
|
|
35
|
-
const varDigit = text.substring(openIndex + 2, closeIndex);
|
|
36
|
-
// Var mapped value corresponding to current digit inside braces
|
|
37
|
-
const mappedValue = varMapped[varDigit];
|
|
38
|
-
let lengthDifference = 0;
|
|
39
|
-
if(mappedValue) {
|
|
40
|
-
// repacing the number inside braces with mapped value
|
|
41
|
-
text = text.slice(0, openIndex) + mappedValue + text.slice(closeIndex + 2);
|
|
42
|
-
lengthDifference = (mappedValue?.length - (varDigit?.length + 4));
|
|
43
|
-
}
|
|
44
|
-
// incrementing the searchStartIndex by difference between the length of mapped value and length of braces {{xx}}
|
|
45
|
-
searchStartIndex = closeIndex + lengthDifference + 2;
|
|
46
|
-
} else {
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
26
|
+
const validVarRegex = /{{([1-9]|1[0-9])}}/g;
|
|
27
|
+
const validVarArr = text.match(validVarRegex) || [];
|
|
28
|
+
//removing Click {{unsubscribe}} to unsubscribe
|
|
29
|
+
text = text.replace(
|
|
30
|
+
`${validVarArr[validVarArr.length - 1]}`,
|
|
31
|
+
'{{unsubscribe}}',
|
|
32
|
+
);
|
|
50
33
|
return text;
|
|
51
34
|
}
|
|
52
35
|
|