@capillarytech/creatives-library 7.10.45 → 7.10.47
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/assets/images/whatsapp_mobile_android.svg +1 -2041
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -1
- package/v2Containers/CreativesContainer/index.js +3 -1
- package/v2Containers/Templates/_templates.scss +1 -0
- package/v2Containers/Templates/index.js +25 -8
- package/v2Containers/Templates/messages.js +16 -0
- package/v2Containers/Whatsapp/index.js +46 -21
- package/v2Containers/Whatsapp/messages.js +10 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +33270 -5916
- package/v2Containers/Whatsapp/tests/index.test.js +49 -9
- package/v2Containers/Whatsapp/tests/mockData.js +120 -1
- package/v2Containers/Whatsapp/utils.js +8 -25
|
@@ -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
|
|
|
@@ -660,11 +660,13 @@ class Creatives extends React.Component {
|
|
|
660
660
|
});
|
|
661
661
|
}
|
|
662
662
|
handleCloseSlideBox = () => {
|
|
663
|
+
const { currentChannel = '', slidBoxContent = '' } = this.state;
|
|
664
|
+
const reloadTemplates = currentChannel === constants.WHATSAPP && slidBoxContent === 'editTemplate';
|
|
663
665
|
this.setState((prevState) => ({
|
|
664
666
|
...prevState,
|
|
665
667
|
templateData: undefined,
|
|
666
668
|
showSlideBox: false,
|
|
667
|
-
}), this.props.handleCloseCreatives);
|
|
669
|
+
}), () => this.props.handleCloseCreatives(reloadTemplates));
|
|
668
670
|
};
|
|
669
671
|
saveMessage = () => {
|
|
670
672
|
this.setState({ isGetFormData: true });
|
|
@@ -77,7 +77,7 @@ import emailIllustration from '../Assets/images/emailIllustration.svg';
|
|
|
77
77
|
import smsIllustration from '../Assets/images/smsIllustration.svg';
|
|
78
78
|
import pushIllustration from '../Assets/images/pushIllustration.svg';
|
|
79
79
|
import whatsappIllustration from '../Assets/images/whatsappIllustration.png';
|
|
80
|
-
import { CAP_SPACE_16 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
80
|
+
import { CAP_SPACE_16, CAP_SPACE_44 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
81
81
|
import { GA } from '@capillarytech/cap-ui-utils';
|
|
82
82
|
const { timeTracker } = GA;
|
|
83
83
|
const {CapCustomCardList} = CapCustomCard;
|
|
@@ -568,9 +568,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
568
568
|
this.getAllTemplates({getNextPage: true});
|
|
569
569
|
}
|
|
570
570
|
onCreateComplete = (isReloadTemplates) => {
|
|
571
|
-
const isWhatsappEdit = this.state.routeParams?.pathname?.includes(`${WHATSAPP_LOWERCASE}/edit`);
|
|
572
571
|
this.setState({routeParams: null, previewOpen: false}, () => {
|
|
573
|
-
if (this.isFullMode() &&
|
|
572
|
+
if (this.isFullMode() && isReloadTemplates) {
|
|
574
573
|
this.getAllTemplates({params: {}}, true);
|
|
575
574
|
}
|
|
576
575
|
});
|
|
@@ -1001,11 +1000,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1001
1000
|
</CapHeading>
|
|
1002
1001
|
</div> : (
|
|
1003
1002
|
[WHATSAPP_LOWERCASE].includes(this.state.channel.toLowerCase()) &&
|
|
1004
|
-
isEmpty(filteredTemplates) &&
|
|
1005
1003
|
isEmpty(this.state.searchText) &&
|
|
1006
1004
|
!isLoading &&
|
|
1007
|
-
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
|
|
1008
|
-
<CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
|
|
1005
|
+
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto' } : {}}>
|
|
1006
|
+
{isEmpty(templates) && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />}
|
|
1007
|
+
{!isEmpty(templates) && isEmpty(filteredTemplates) && <CapHeader
|
|
1008
|
+
title={
|
|
1009
|
+
<CapHeading type="h3" style={{ textAlign: "center", marginTop: CAP_SPACE_44 }}>
|
|
1010
|
+
{this.props.intl.formatMessage(messages.noFilteredWhatsappTemplatesTitle)}
|
|
1011
|
+
</CapHeading>
|
|
1012
|
+
}
|
|
1013
|
+
description={
|
|
1014
|
+
<CapLabel style={{ textAlign: "center" }}>
|
|
1015
|
+
{this.props.intl.formatMessage(messages.noFilteredWhatsappTemplatesDesc)}
|
|
1016
|
+
</CapLabel>
|
|
1017
|
+
}
|
|
1018
|
+
/>}
|
|
1009
1019
|
</div>
|
|
1010
1020
|
)
|
|
1011
1021
|
}
|
|
@@ -2175,19 +2185,24 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2175
2185
|
|
|
2176
2186
|
selectedFilters = () => {
|
|
2177
2187
|
const { selectedWhatsappStatus, selectedWhatsappCategory } = this.state;
|
|
2188
|
+
const {
|
|
2189
|
+
intl: {
|
|
2190
|
+
formatMessage,
|
|
2191
|
+
},
|
|
2192
|
+
} = this.props;
|
|
2178
2193
|
return (
|
|
2179
2194
|
<CapRow type="flex" align="middle" className="selected-whatsapp-filters">
|
|
2180
2195
|
{
|
|
2181
2196
|
selectedWhatsappStatus ? (
|
|
2182
2197
|
<CapTag closable onClose={() => this.removeWhatsappFilter(WHATSAPP_STATUS)}>
|
|
2183
|
-
|
|
2198
|
+
{formatMessage(messages.status)}: {getWhatsappStatus(selectedWhatsappStatus)?.label || selectedWhatsappStatus}
|
|
2184
2199
|
</CapTag>
|
|
2185
2200
|
) : null
|
|
2186
2201
|
}
|
|
2187
2202
|
{
|
|
2188
2203
|
selectedWhatsappCategory ? (
|
|
2189
2204
|
<CapTag closable onClose={() => this.removeWhatsappFilter(WHATSAPP_CATEGORY)}>
|
|
2190
|
-
|
|
2205
|
+
{formatMessage(messages.category)}: {getWhatsappCategory(selectedWhatsappCategory)?.label || selectedWhatsappCategory}
|
|
2191
2206
|
</CapTag>
|
|
2192
2207
|
) : null
|
|
2193
2208
|
}
|
|
@@ -2332,6 +2347,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2332
2347
|
placeholder="Status"
|
|
2333
2348
|
showBadge={true}
|
|
2334
2349
|
width="90px"
|
|
2350
|
+
overlayStyle={{ overflowY: "hidden" }}
|
|
2335
2351
|
/>
|
|
2336
2352
|
<CapSelectFilter
|
|
2337
2353
|
placement="bottomLeft"
|
|
@@ -2341,6 +2357,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2341
2357
|
placeholder="Category"
|
|
2342
2358
|
showBadge={true}
|
|
2343
2359
|
width="105px"
|
|
2360
|
+
overlayStyle={{ overflowY: "hidden" }}
|
|
2344
2361
|
/>
|
|
2345
2362
|
</div>
|
|
2346
2363
|
|
|
@@ -342,6 +342,14 @@ export default defineMessages({
|
|
|
342
342
|
id: `${scope}.whatsappDescIllustration`,
|
|
343
343
|
defaultMessage: 'These templates can be reused when creating a\nnew message content.',
|
|
344
344
|
},
|
|
345
|
+
"noFilteredWhatsappTemplatesTitle": {
|
|
346
|
+
id: `${scope}.noFilteredWhatsappTemplatesTitle`,
|
|
347
|
+
defaultMessage: 'Sorry, we couldn’t find any matches',
|
|
348
|
+
},
|
|
349
|
+
"noFilteredWhatsappTemplatesDesc": {
|
|
350
|
+
id: `${scope}.noFilteredWhatsappTemplatesDesc`,
|
|
351
|
+
defaultMessage: 'Please try searching with another term or apply different filter',
|
|
352
|
+
},
|
|
345
353
|
"smsTitleIllustartion": {
|
|
346
354
|
id: `${scope}.smsTitleIllustartion`,
|
|
347
355
|
defaultMessage: 'Create an SMS {template}',
|
|
@@ -426,4 +434,12 @@ export default defineMessages({
|
|
|
426
434
|
id: `${scope}.whatsappMaxTemplates`,
|
|
427
435
|
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
436
|
},
|
|
437
|
+
"status": {
|
|
438
|
+
id: `${scope}.status`,
|
|
439
|
+
defaultMessage: 'Status',
|
|
440
|
+
},
|
|
441
|
+
"category": {
|
|
442
|
+
id: `${scope}.category`,
|
|
443
|
+
defaultMessage: 'Category',
|
|
444
|
+
},
|
|
429
445
|
});
|
|
@@ -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;
|
|
@@ -90,9 +91,8 @@ export const Whatsapp = (props) => {
|
|
|
90
91
|
//for edit only
|
|
91
92
|
const [isEditFlow, setEditFlow] = useState(false);
|
|
92
93
|
const [templateDate, setTemplateDate] = useState('');
|
|
93
|
-
const [templateStatus, setTemplateStatus] = useState(
|
|
94
|
-
|
|
95
|
-
);
|
|
94
|
+
const [templateStatus, setTemplateStatus] = useState();
|
|
95
|
+
const [templateRejectionReason, setTemplateRejectionReason] = useState(null);
|
|
96
96
|
const [tempMsgArray, updateTempMsgArray] = useState([]);
|
|
97
97
|
const [updatedSmsEditor, setUpdatedSmsEditor] = useState([]);
|
|
98
98
|
//for tag only
|
|
@@ -146,9 +146,6 @@ export const Whatsapp = (props) => {
|
|
|
146
146
|
return () => {
|
|
147
147
|
actions.resetEditTemplate();
|
|
148
148
|
varMap = {};
|
|
149
|
-
if (timerid) {
|
|
150
|
-
clearTimeout(timerid);
|
|
151
|
-
}
|
|
152
149
|
};
|
|
153
150
|
}, [paramObj.id]);
|
|
154
151
|
|
|
@@ -162,10 +159,14 @@ export const Whatsapp = (props) => {
|
|
|
162
159
|
if (editContent && !isEmpty(editContent)) {
|
|
163
160
|
setTemplateName(name);
|
|
164
161
|
setTemplateDate(createdAt);
|
|
165
|
-
const {
|
|
166
|
-
|
|
162
|
+
const {
|
|
163
|
+
category = '',
|
|
164
|
+
status = WHATSAPP_STATUSES.unsubmitted,
|
|
165
|
+
rejection_reason = null,
|
|
166
|
+
} = editContent;
|
|
167
167
|
setTemplateCategory(category);
|
|
168
168
|
setTemplateStatus(status);
|
|
169
|
+
setTemplateRejectionReason(rejection_reason);
|
|
169
170
|
computeTempMsgArray();
|
|
170
171
|
}
|
|
171
172
|
}, [editData.templateDetails || templateData]);
|
|
@@ -220,13 +221,15 @@ export const Whatsapp = (props) => {
|
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
223
|
setUpdatedSmsEditor(arr);
|
|
223
|
-
timerid = setTimeout(() => {
|
|
224
|
-
//stop spinner
|
|
225
|
-
setSpin(false);
|
|
226
|
-
}, 500);
|
|
227
224
|
}
|
|
228
225
|
}, [tempMsgArray]);
|
|
229
226
|
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (tempMsgArray?.length && !loadingTags) {
|
|
229
|
+
setSpin(false);
|
|
230
|
+
}
|
|
231
|
+
}, [tempMsgArray, loadingTags]);
|
|
232
|
+
|
|
230
233
|
// tag Code start from here
|
|
231
234
|
useEffect(() => {
|
|
232
235
|
//fetching tags
|
|
@@ -624,6 +627,17 @@ export const Whatsapp = (props) => {
|
|
|
624
627
|
//create methods end
|
|
625
628
|
|
|
626
629
|
//edit methods start
|
|
630
|
+
const computeTemplateRejectionReason = () => {
|
|
631
|
+
switch (templateRejectionReason) {
|
|
632
|
+
case 'TAG_CONTENT_MISMATCH':
|
|
633
|
+
return formatMessage(messages.tagContentMismatchError);
|
|
634
|
+
case 'INVALID_FORMAT':
|
|
635
|
+
return formatMessage(messages.invalidFormatError);
|
|
636
|
+
default:
|
|
637
|
+
return '';
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
|
|
627
641
|
const getTemplateStatusType = () => {
|
|
628
642
|
switch (templateStatus) {
|
|
629
643
|
case WHATSAPP_STATUSES.approved:
|
|
@@ -645,9 +659,17 @@ export const Whatsapp = (props) => {
|
|
|
645
659
|
);
|
|
646
660
|
case WHATSAPP_STATUSES.rejected:
|
|
647
661
|
return (
|
|
648
|
-
|
|
649
|
-
{
|
|
650
|
-
|
|
662
|
+
<>
|
|
663
|
+
<CapLabel type="label2" style={{ fontWeight: 500 }}>
|
|
664
|
+
{formatMessage(messages.rejectedStatusMsg)}
|
|
665
|
+
</CapLabel>
|
|
666
|
+
<CapLabel
|
|
667
|
+
type="label2"
|
|
668
|
+
style={{ margin: `${CAP_SPACE_04} 0 ${CAP_SPACE_04}` }}
|
|
669
|
+
>
|
|
670
|
+
{computeTemplateRejectionReason()}
|
|
671
|
+
</CapLabel>
|
|
672
|
+
</>
|
|
651
673
|
);
|
|
652
674
|
default:
|
|
653
675
|
//all cases except approved and rejected, return awaiting approval
|
|
@@ -658,7 +680,7 @@ export const Whatsapp = (props) => {
|
|
|
658
680
|
</CapLabel>
|
|
659
681
|
<CapLabel
|
|
660
682
|
type="label2"
|
|
661
|
-
style={{
|
|
683
|
+
style={{ margin: `${CAP_SPACE_04} 0 ${CAP_SPACE_04}` }}
|
|
662
684
|
>
|
|
663
685
|
{formatMessage(messages.awaitingStatusDesc, {
|
|
664
686
|
date: moment(templateDate).format(DATE_DISPLAY_FORMAT),
|
|
@@ -753,10 +775,12 @@ export const Whatsapp = (props) => {
|
|
|
753
775
|
|
|
754
776
|
const editModeContent = (
|
|
755
777
|
<>
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
778
|
+
{templateStatus && (
|
|
779
|
+
<CapAlert
|
|
780
|
+
message={getTemplateStatusMessage()}
|
|
781
|
+
type={getTemplateStatusType()}
|
|
782
|
+
/>
|
|
783
|
+
)}
|
|
760
784
|
<CapRow className="whatsapp-render-heading">
|
|
761
785
|
<CapHeader
|
|
762
786
|
title={
|
|
@@ -858,6 +882,7 @@ const mapStateToProps = createStructuredSelector({
|
|
|
858
882
|
editData: makeSelectWhatsapp(),
|
|
859
883
|
accountData: makeSelectAccount(),
|
|
860
884
|
metaEntities: makeSelectMetaEntities(),
|
|
885
|
+
loadingTags: isLoadingMetaEntities(),
|
|
861
886
|
injectedTags: setInjectedTags(),
|
|
862
887
|
});
|
|
863
888
|
|
|
@@ -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',
|