@capillarytech/creatives-library 7.10.50 → 7.10.51
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/utils/v2common.js +0 -13
- package/v2Components/TemplatePreview/assets/images/whatsapp_mobile_android.svg +1 -2041
- package/v2Components/TemplatePreview/index.js +39 -28
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +2 -3
- package/v2Containers/CreativesContainer/index.js +7 -46
- package/v2Containers/Templates/_templates.scss +0 -14
- package/v2Containers/Templates/index.js +42 -74
- package/v2Containers/Templates/messages.js +8 -4
- package/v2Containers/TemplatesV2/index.js +4 -11
- package/v2Containers/Whatsapp/index.js +16 -84
- package/v2Containers/Whatsapp/messages.js +0 -9
- 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
|
@@ -51,11 +51,9 @@ import withCreatives from '../../hoc/withCreatives';
|
|
|
51
51
|
import TemplatePreview from '../../v2Components/TemplatePreview';
|
|
52
52
|
import TagList from '../TagList';
|
|
53
53
|
import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
|
|
54
|
-
import { validateTags } from '../../utils/tagValidations';
|
|
55
54
|
|
|
56
55
|
let varMap = {};
|
|
57
56
|
let editContent = {};
|
|
58
|
-
let tagValidationResponse = {};
|
|
59
57
|
|
|
60
58
|
export const Whatsapp = (props) => {
|
|
61
59
|
const {
|
|
@@ -75,7 +73,6 @@ export const Whatsapp = (props) => {
|
|
|
75
73
|
metaEntities,
|
|
76
74
|
injectedTags,
|
|
77
75
|
loadingTags,
|
|
78
|
-
getFormData
|
|
79
76
|
} = props || {};
|
|
80
77
|
const { formatMessage } = intl;
|
|
81
78
|
const { TextArea } = CapInput;
|
|
@@ -94,16 +91,13 @@ export const Whatsapp = (props) => {
|
|
|
94
91
|
//for edit only
|
|
95
92
|
const [isEditFlow, setEditFlow] = useState(false);
|
|
96
93
|
const [templateDate, setTemplateDate] = useState('');
|
|
97
|
-
const [templateStatus, setTemplateStatus] = useState(
|
|
98
|
-
WHATSAPP_STATUSES.unsubmitted,
|
|
99
|
-
);
|
|
94
|
+
const [templateStatus, setTemplateStatus] = useState();
|
|
100
95
|
const [templateRejectionReason, setTemplateRejectionReason] = useState(null);
|
|
101
96
|
const [tempMsgArray, updateTempMsgArray] = useState([]);
|
|
102
97
|
const [updatedSmsEditor, setUpdatedSmsEditor] = useState([]);
|
|
103
98
|
//for tag only
|
|
104
99
|
const [tags, updateTags] = useState([]);
|
|
105
100
|
const [textAreaId, updateTextAreaId] = useState();
|
|
106
|
-
const [isTagValidationError, updateIsTagValidationError] = useState(false);
|
|
107
101
|
|
|
108
102
|
const validVarRegex = /{{([1-9]|1[0-9])}}/g;
|
|
109
103
|
|
|
@@ -114,8 +108,7 @@ export const Whatsapp = (props) => {
|
|
|
114
108
|
width: 100%;
|
|
115
109
|
margin-left: -32px;
|
|
116
110
|
padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
|
|
119
112
|
.ant-btn {
|
|
120
113
|
margin-right: ${CAP_SPACE_16};
|
|
121
114
|
}
|
|
@@ -147,6 +140,7 @@ export const Whatsapp = (props) => {
|
|
|
147
140
|
setSpin(true);
|
|
148
141
|
actions.getTemplateDetails(id);
|
|
149
142
|
}
|
|
143
|
+
setEditFlow(true);
|
|
150
144
|
}
|
|
151
145
|
//cleanup code
|
|
152
146
|
return () => {
|
|
@@ -160,10 +154,9 @@ export const Whatsapp = (props) => {
|
|
|
160
154
|
name = '',
|
|
161
155
|
versions = {},
|
|
162
156
|
createdAt = '',
|
|
163
|
-
} =
|
|
157
|
+
} = editData.templateDetails || templateData || {};
|
|
164
158
|
editContent = get(versions, `base.content.whatsapp`, {});
|
|
165
159
|
if (editContent && !isEmpty(editContent)) {
|
|
166
|
-
setEditFlow(true);
|
|
167
160
|
setTemplateName(name);
|
|
168
161
|
setTemplateDate(createdAt);
|
|
169
162
|
const {
|
|
@@ -267,27 +260,6 @@ export const Whatsapp = (props) => {
|
|
|
267
260
|
}
|
|
268
261
|
}, [metaEntities, isEditFlow]);
|
|
269
262
|
|
|
270
|
-
//performs tag validation
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
if (
|
|
273
|
-
!isFullMode &&
|
|
274
|
-
updatedSmsEditor?.length > 0 &&
|
|
275
|
-
!updatedSmsEditor.join('').match(validVarRegex)
|
|
276
|
-
) {
|
|
277
|
-
tagValidationResponse =
|
|
278
|
-
validateTags({
|
|
279
|
-
content: updatedSmsEditor.join(''),
|
|
280
|
-
tagsParam: tags,
|
|
281
|
-
injectedTagsParams: injectedTags,
|
|
282
|
-
location,
|
|
283
|
-
tagModule: getDefaultTags,
|
|
284
|
-
}) || {};
|
|
285
|
-
updateIsTagValidationError(
|
|
286
|
-
tagValidationResponse.unsupportedTags.length > 0,
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
}, [updatedSmsEditor, tags]);
|
|
290
|
-
|
|
291
263
|
const handleOnTagsContextChange = (data) => {
|
|
292
264
|
const { type } = location.query || {};
|
|
293
265
|
const isEmbedded = type === EMBEDDED;
|
|
@@ -495,16 +467,13 @@ export const Whatsapp = (props) => {
|
|
|
495
467
|
languages: [
|
|
496
468
|
{
|
|
497
469
|
language: 'en',
|
|
498
|
-
content:
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
: `$'${templateMessage}\nClick {{${
|
|
502
|
-
addedVarCount + 1 }}} to unsubscribe'`,
|
|
470
|
+
content: `$'${templateMessage}\nClick {{${
|
|
471
|
+
addedVarCount + 1
|
|
472
|
+
}}} to unsubscribe'`,
|
|
503
473
|
},
|
|
504
474
|
],
|
|
505
|
-
mediaType: '
|
|
506
|
-
varMapped:
|
|
507
|
-
templateEditor: templateMessage,
|
|
475
|
+
mediaType: 'text',
|
|
476
|
+
varMapped: {},
|
|
508
477
|
accountId,
|
|
509
478
|
accessToken,
|
|
510
479
|
accountName,
|
|
@@ -549,15 +518,6 @@ export const Whatsapp = (props) => {
|
|
|
549
518
|
}
|
|
550
519
|
};
|
|
551
520
|
|
|
552
|
-
const saveToMessage = () => {
|
|
553
|
-
getFormData({
|
|
554
|
-
value: createPayload(),
|
|
555
|
-
_id: params?.paramObj?.id,
|
|
556
|
-
validity: true,
|
|
557
|
-
type: 'WHATSAPP',
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
|
|
561
521
|
const isDisableDone = () => {
|
|
562
522
|
//if template name is not entered
|
|
563
523
|
if (templateName.trim() === '' || templateNameError) {
|
|
@@ -813,23 +773,14 @@ export const Whatsapp = (props) => {
|
|
|
813
773
|
}
|
|
814
774
|
};
|
|
815
775
|
|
|
816
|
-
const tagValidationErrorMessage = () => {
|
|
817
|
-
const { unsupportedTags = [] } = tagValidationResponse;
|
|
818
|
-
let tagError = '';
|
|
819
|
-
if (unsupportedTags.length > 0) {
|
|
820
|
-
tagError = formatMessage(messages.unsupportedTagsValidationError, {
|
|
821
|
-
unsupportedTags,
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
return <CapError>{tagError}</CapError>;
|
|
825
|
-
};
|
|
826
|
-
|
|
827
776
|
const editModeContent = (
|
|
828
777
|
<>
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
778
|
+
{templateStatus && (
|
|
779
|
+
<CapAlert
|
|
780
|
+
message={getTemplateStatusMessage()}
|
|
781
|
+
type={getTemplateStatusType()}
|
|
782
|
+
/>
|
|
783
|
+
)}
|
|
833
784
|
<CapRow className="whatsapp-render-heading">
|
|
834
785
|
<CapHeader
|
|
835
786
|
title={
|
|
@@ -863,7 +814,6 @@ export const Whatsapp = (props) => {
|
|
|
863
814
|
</CapTooltip>
|
|
864
815
|
|
|
865
816
|
{renderMessageLength()}
|
|
866
|
-
{isTagValidationError && tagValidationErrorMessage()}
|
|
867
817
|
</>
|
|
868
818
|
);
|
|
869
819
|
//edit methods end
|
|
@@ -884,19 +834,12 @@ export const Whatsapp = (props) => {
|
|
|
884
834
|
<TemplatePreview
|
|
885
835
|
channel={WHATSAPP}
|
|
886
836
|
content={{ templateMsg }}
|
|
837
|
+
whatsappContentLen={isEditFlow ? updatedSmsEditor.join('').length : templateMessage.length}
|
|
887
838
|
whatsappAccountName={accountName}
|
|
888
839
|
/>
|
|
889
840
|
);
|
|
890
841
|
};
|
|
891
842
|
|
|
892
|
-
const isEditDoneDisabled = () => {
|
|
893
|
-
return isTagValidationError || Object.values(varMap).some( (inputValue) => {
|
|
894
|
-
if (inputValue === '') {
|
|
895
|
-
return true;
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
|
|
900
843
|
return (
|
|
901
844
|
<CapSpin spinning={spin}>
|
|
902
845
|
<CapRow>
|
|
@@ -931,17 +874,6 @@ export const Whatsapp = (props) => {
|
|
|
931
874
|
</CapButton>
|
|
932
875
|
</>
|
|
933
876
|
)}
|
|
934
|
-
{!isFullMode && isEditFlow && (
|
|
935
|
-
<>
|
|
936
|
-
<CapButton
|
|
937
|
-
onClick={saveToMessage}
|
|
938
|
-
disabled={isEditDoneDisabled()}
|
|
939
|
-
className="whatsapp-create-btn"
|
|
940
|
-
>
|
|
941
|
-
<FormattedMessage {...messages.done} />
|
|
942
|
-
</CapButton>
|
|
943
|
-
</>
|
|
944
|
-
)}
|
|
945
877
|
</WhatsappFooter>
|
|
946
878
|
</CapSpin>
|
|
947
879
|
);
|
|
@@ -232,13 +232,4 @@ export default defineMessages({
|
|
|
232
232
|
id: `${prefix}.disabledEditTooltipStatus`,
|
|
233
233
|
defaultMessage: 'awaiting for approval',
|
|
234
234
|
},
|
|
235
|
-
done: {
|
|
236
|
-
id: `${prefix}.done`,
|
|
237
|
-
defaultMessage: 'Done',
|
|
238
|
-
},
|
|
239
|
-
unsupportedTagsValidationError: {
|
|
240
|
-
id: `${prefix}.unsupportedTagsValidationError`,
|
|
241
|
-
defaultMessage:
|
|
242
|
-
'Unsupported tags: {unsupportedTags}. Please remove them from this message.',
|
|
243
|
-
},
|
|
244
235
|
});
|