@capillarytech/creatives-library 7.12.72 → 7.12.74
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
CHANGED
|
@@ -1,91 +1,154 @@
|
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
2
|
+
/* eslint-disable no-unused-expressions */
|
|
1
3
|
import { parse } from 'node-html-parser';
|
|
2
4
|
|
|
3
|
-
// const sample = {
|
|
4
|
-
// versions: {
|
|
5
|
-
// base: {
|
|
6
|
-
// activeTab: "en",
|
|
7
|
-
// en: {
|
|
8
|
-
// "lang_id": 69,
|
|
9
|
-
// "iso_code": "en",
|
|
10
|
-
// "language": "English",
|
|
11
|
-
// "template-content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional //EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">\n<head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><!--[if !mso]><!--><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><!--<![endif]-->\n\t<title></title>\n\t<!--[if !mso]><!--><!--<![endif]-->\n\t<style type=\"text/css\">body {\n margin: 0;\n padding: 0; }\n\ntable,\ntd,\ntr {\n vertical-align: top;\n border-collapse: collapse; }\n\n* {\n line-height: inherit; }\n\na[x-apple-data-detectors=true] {\n color: inherit !important;\n text-decoration: none !important; }\n\t</style>\n\t<style id=\"media-query\" type=\"text/css\">@media (max-width: 520px) {\n .block-grid,\n.col {\n min-width: 320px !important;\n max-width: 100% !important;\n display: block !important;\n }\n\n .block-grid {\n width: 100% !important;\n }\n\n .col {\n width: 100% !important;\n }\n\n .col > div {\n margin: 0 auto;\n }\n\n img.fullwidth,\nimg.fullwidthOnMobile {\n max-width: 100% !important;\n }\n\n .no-stack .col {\n min-width: 0 !important;\n display: table-cell !important;\n }\n\n .no-stack.two-up .col {\n width: 50% !important;\n }\n\n .no-stack .col.num4 {\n width: 33% !important;\n }\n\n .no-stack .col.num8 {\n width: 66% !important;\n }\n\n .no-stack .col.num4 {\n width: 33% !important;\n }\n\n .no-stack .col.num3 {\n width: 25% !important;\n }\n\n .no-stack .col.num6 {\n width: 50% !important;\n }\n\n .no-stack .col.num9 {\n width: 75% !important;\n }\n\n .video-block {\n max-width: none !important;\n }\n\n .mobile_hide {\n min-height: 0px;\n max-height: 0px;\n max-width: 0px;\n display: none;\n overflow: hidden;\n font-size: 0px;\n }\n\n .desktop_hide {\n display: block !important;\n max-height: none !important;\n }\n}\n\t</style>\n</head>\n<body class=\"clean-body\" style=\"margin: 0; padding: 0; -webkit-text-size-adjust: 100%; background-color: #FFFFFF;\"><!--[if IE]><div class=\"ie-browser\"><![endif]-->\n<p>asdf</p>\n\n<table bgcolor=\"#FFFFFF\" cellpadding=\"0\" cellspacing=\"0\" class=\"nl-container\" role=\"presentation\" style=\"background-color:#ffffff; border-collapse:collapse; border-spacing:0; margin:0 auto; min-width:320px; mso-table-lspace:0pt; mso-table-rspace:0pt; table-layout:fixed; vertical-align:top; width:100%\" valign=\"top\">\n\t<tbody>\n\t\t<tr style=\"vertical-align:top\" valign=\"top\">\n\t\t\t<td style=\"vertical-align:top; word-break:break-word\"><!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=\"center\" style=\"background-color:#FFFFFF\"><![endif]-->\n\t\t\t<div style=\"background-color:transparent\">\n\t\t\t<div class=\"block-grid\" style=\"background-color:transparent; margin-bottom:0px; margin-left:0px; margin-right:0px; margin-top:0px; max-width:500px; min-width:320px; overflow-wrap:break-word; word-break:break-word; word-wrap:break-word\">\n\t\t\t<div style=\"background-color:transparent; border-collapse:collapse; display:table; width:100%\"><!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:transparent;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:500px\"><tr class=\"layout-full-width\" style=\"background-color:transparent\"><![endif]--><!--[if (mso)|(IE)]><td align=\"center\" width=\"500\" style=\"background-color:transparent;width:500px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->\n\t\t\t<div class=\"col num12\" style=\"display:table-cell; max-width:500px; min-width:320px; vertical-align:top; width:500px\">\n\t\t\t<div style=\"width:100% !important\"><!--[if (!mso)&(!IE)]><!-->\n\t\t\t<div style=\"border-bottom:0px solid transparent; border-left:0px solid transparent; border-right:0px solid transparent; border-top:0px solid transparent; padding-bottom:5px; padding-left:0px; padding-right:0px; padding-top:5px\"><!--<![endif]--><!--[if (!mso)&(!IE)]><!--></div>\n\t\t\t<!--<![endif]--></div>\n\t\t\t</div>\n\t\t\t<!--[if (mso)|(IE)]></td></tr></table><![endif]--><!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]--></div>\n\t\t\t</div>\n\t\t\t</div>\n\t\t\t<!--[if (mso)|(IE)]></td></tr></table><![endif]--></td>\n\t\t</tr>\n\t</tbody>\n</table>\n<!--[if (IE)]></div><![endif]--></body>\n</html>\n",
|
|
12
|
-
// "drag_drop_id": "",
|
|
13
|
-
// "tabKey": "5",
|
|
14
|
-
// },
|
|
15
|
-
// selectedLanguages: [
|
|
16
|
-
// "en",
|
|
17
|
-
// ],
|
|
18
|
-
// base: true,
|
|
19
|
-
// tabKey: "5",
|
|
20
|
-
// subject: "asdf",
|
|
21
|
-
// },
|
|
22
|
-
// history: [
|
|
23
|
-
// {
|
|
24
|
-
// activeTab: "en",
|
|
25
|
-
// en: {
|
|
26
|
-
// "lang_id": 69,
|
|
27
|
-
// "iso_code": "en",
|
|
28
|
-
// "language": "English",
|
|
29
|
-
// "template-content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional //EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">\n<head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><!--[if !mso]><!--><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><!--<![endif]-->\n\t<title></title>\n\t<!--[if !mso]><!--><!--<![endif]-->\n\t<style type=\"text/css\">body {\n margin: 0;\n padding: 0; }\n\ntable,\ntd,\ntr {\n vertical-align: top;\n border-collapse: collapse; }\n\n* {\n line-height: inherit; }\n\na[x-apple-data-detectors=true] {\n color: inherit !important;\n text-decoration: none !important; }\n\t</style>\n\t<style id=\"media-query\" type=\"text/css\">@media (max-width: 520px) {\n .block-grid,\n.col {\n min-width: 320px !important;\n max-width: 100% !important;\n display: block !important;\n }\n\n .block-grid {\n width: 100% !important;\n }\n\n .col {\n width: 100% !important;\n }\n\n .col > div {\n margin: 0 auto;\n }\n\n img.fullwidth,\nimg.fullwidthOnMobile {\n max-width: 100% !important;\n }\n\n .no-stack .col {\n min-width: 0 !important;\n display: table-cell !important;\n }\n\n .no-stack.two-up .col {\n width: 50% !important;\n }\n\n .no-stack .col.num4 {\n width: 33% !important;\n }\n\n .no-stack .col.num8 {\n width: 66% !important;\n }\n\n .no-stack .col.num4 {\n width: 33% !important;\n }\n\n .no-stack .col.num3 {\n width: 25% !important;\n }\n\n .no-stack .col.num6 {\n width: 50% !important;\n }\n\n .no-stack .col.num9 {\n width: 75% !important;\n }\n\n .video-block {\n max-width: none !important;\n }\n\n .mobile_hide {\n min-height: 0px;\n max-height: 0px;\n max-width: 0px;\n display: none;\n overflow: hidden;\n font-size: 0px;\n }\n\n .desktop_hide {\n display: block !important;\n max-height: none !important;\n }\n}\n\t</style>\n</head>\n<body class=\"clean-body\" style=\"margin: 0; padding: 0; -webkit-text-size-adjust: 100%; background-color: #FFFFFF;\"><!--[if IE]><div class=\"ie-browser\"><![endif]-->\n<p>asdf</p>\n\n<table bgcolor=\"#FFFFFF\" cellpadding=\"0\" cellspacing=\"0\" class=\"nl-container\" role=\"presentation\" style=\"background-color:#ffffff; border-collapse:collapse; border-spacing:0; margin:0 auto; min-width:320px; mso-table-lspace:0pt; mso-table-rspace:0pt; table-layout:fixed; vertical-align:top; width:100%\" valign=\"top\">\n\t<tbody>\n\t\t<tr style=\"vertical-align:top\" valign=\"top\">\n\t\t\t<td style=\"vertical-align:top; word-break:break-word\"><!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=\"center\" style=\"background-color:#FFFFFF\"><![endif]-->\n\t\t\t<div style=\"background-color:transparent\">\n\t\t\t<div class=\"block-grid\" style=\"background-color:transparent; margin-bottom:0px; margin-left:0px; margin-right:0px; margin-top:0px; max-width:500px; min-width:320px; overflow-wrap:break-word; word-break:break-word; word-wrap:break-word\">\n\t\t\t<div style=\"background-color:transparent; border-collapse:collapse; display:table; width:100%\"><!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:transparent;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:500px\"><tr class=\"layout-full-width\" style=\"background-color:transparent\"><![endif]--><!--[if (mso)|(IE)]><td align=\"center\" width=\"500\" style=\"background-color:transparent;width:500px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->\n\t\t\t<div class=\"col num12\" style=\"display:table-cell; max-width:500px; min-width:320px; vertical-align:top; width:500px\">\n\t\t\t<div style=\"width:100% !important\"><!--[if (!mso)&(!IE)]><!-->\n\t\t\t<div style=\"border-bottom:0px solid transparent; border-left:0px solid transparent; border-right:0px solid transparent; border-top:0px solid transparent; padding-bottom:5px; padding-left:0px; padding-right:0px; padding-top:5px\"><!--<![endif]--><!--[if (!mso)&(!IE)]><!--></div>\n\t\t\t<!--<![endif]--></div>\n\t\t\t</div>\n\t\t\t<!--[if (mso)|(IE)]></td></tr></table><![endif]--><!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]--></div>\n\t\t\t</div>\n\t\t\t</div>\n\t\t\t<!--[if (mso)|(IE)]></td></tr></table><![endif]--></td>\n\t\t</tr>\n\t</tbody>\n</table>\n<!--[if (IE)]></div><![endif]--></body>\n</html>\n",
|
|
30
|
-
// "drag_drop_id": "",
|
|
31
|
-
// "tabKey": "5",
|
|
32
|
-
// },
|
|
33
|
-
// selectedLanguages: [
|
|
34
|
-
// "en",
|
|
35
|
-
// ],
|
|
36
|
-
// base: true,
|
|
37
|
-
// tabKey: "5",
|
|
38
|
-
// subject: "asdf",
|
|
39
|
-
// },
|
|
40
|
-
// ],
|
|
41
|
-
// },
|
|
42
|
-
// type: "EMAIL",
|
|
43
|
-
// name: "asdf",
|
|
44
|
-
// };
|
|
45
|
-
|
|
46
|
-
|
|
47
5
|
// https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=100,height=100,quality=75,fit=cover,g=top,format=auto/intouch_creative_assets/005710a7-6412-44fe-a19f-e72456b1.jpg
|
|
48
6
|
|
|
49
|
-
const CDN_BASE_URL = `https://storage.crm.n.content-cdn.io
|
|
7
|
+
const CDN_BASE_URL = `https://storage.crm.n.content-cdn.io`;
|
|
8
|
+
const CDN_TRANSFORMATION_URL_SUFFIX = `/cdn-cgi/image/`;
|
|
50
9
|
const QUALITY = 75;
|
|
51
|
-
const regex = /intouch_creative_assets
|
|
10
|
+
const regex = /https:\/\/.*intouch_creative_assets.*(?:jpg|png|jpeg|gif)$/;
|
|
11
|
+
const INTOUCH_CREATIVE_ASSETS = 'intouch_creative_assets';
|
|
52
12
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (isAsset) {
|
|
59
|
-
const height = element.getAttribute('height');
|
|
60
|
-
const width = element.getAttribute('width');
|
|
61
|
-
const [, assetKey] = imageSrc.split(regex);
|
|
13
|
+
/**
|
|
14
|
+
* getCdnUrl : utility function to replace and return s3/cdn url with cdn url.
|
|
15
|
+
*/
|
|
16
|
+
export const getCdnUrl = ({url, height, width, transformationEnabled = false, reduceQuality = true}) => {
|
|
17
|
+
if (!url.includes(INTOUCH_CREATIVE_ASSETS)) return url;
|
|
62
18
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
newUrl +=
|
|
72
|
-
element.setAttribute('src', newUrl);
|
|
19
|
+
const [, assetKey] = url.split(INTOUCH_CREATIVE_ASSETS);
|
|
20
|
+
let newUrl = `${CDN_BASE_URL}`;
|
|
21
|
+
if (transformationEnabled || reduceQuality) {
|
|
22
|
+
newUrl += CDN_TRANSFORMATION_URL_SUFFIX;
|
|
23
|
+
if (height) {
|
|
24
|
+
newUrl += `height=${height},`;
|
|
25
|
+
}
|
|
26
|
+
if (width) {
|
|
27
|
+
newUrl += `width=${width},`;
|
|
73
28
|
}
|
|
74
|
-
|
|
75
|
-
|
|
29
|
+
newUrl += `quality=${QUALITY}`;
|
|
30
|
+
}
|
|
31
|
+
newUrl += `/intouch_creative_assets${assetKey}`;
|
|
32
|
+
return newUrl;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param {*} htmlContents
|
|
38
|
+
* @returns htmlContents with updated urls in image tag
|
|
39
|
+
*/
|
|
40
|
+
export const updateImagesInHtml = (htmlContents) => {
|
|
41
|
+
const copiedHtmlContents = htmlContents;
|
|
42
|
+
try {
|
|
43
|
+
const root = parse(htmlContents);
|
|
44
|
+
root.querySelectorAll('img').forEach((element) => {
|
|
45
|
+
const imageSrc = element.getAttribute('src');
|
|
46
|
+
const isAsset = regex.test(imageSrc);
|
|
47
|
+
if (isAsset) {
|
|
48
|
+
const height = element.getAttribute('height');
|
|
49
|
+
const width = element.getAttribute('width');
|
|
50
|
+
const newUrl = getCdnUrl({url: imageSrc, height, width, transformationEnabled: true, reduceQuality: true});
|
|
51
|
+
element.setAttribute('src', newUrl);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return root.toString();
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.log('An error occured while updating images in html', e);
|
|
57
|
+
return copiedHtmlContents; //return received input directly in case an exception is thrown
|
|
58
|
+
}
|
|
76
59
|
};
|
|
77
60
|
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param {*} contents
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
78
66
|
export const transformEmailTemplates = (contents) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
|
|
67
|
+
const contentsCopy = cloneDeep(contents);
|
|
68
|
+
try {
|
|
69
|
+
const base = contentsCopy?.versions?.base;
|
|
70
|
+
const languages = base?.selectedLanguages;
|
|
71
|
+
languages?.forEach((lang) => {
|
|
72
|
+
const htmlContents = base?.[lang]?.['template-content'];
|
|
73
|
+
const newHtmlContents = updateImagesInHtml(htmlContents);
|
|
74
|
+
base[lang]['template-content'] = newHtmlContents;
|
|
75
|
+
});
|
|
76
|
+
return contentsCopy;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.log('Some error has occured while transforming email templates', e);
|
|
79
|
+
return contents; //return received input directly in case an exception is thrown
|
|
80
|
+
}
|
|
91
81
|
};
|
|
82
|
+
|
|
83
|
+
// export const transformRcsTemplates = (contents) => {
|
|
84
|
+
// const contentsCopy = cloneDeep(contents);
|
|
85
|
+
// }
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
// {
|
|
89
|
+
// "name": "test 1",
|
|
90
|
+
// "versions": {
|
|
91
|
+
// "base": {
|
|
92
|
+
// "content": {
|
|
93
|
+
// "RCS": {
|
|
94
|
+
// "cardContent": [
|
|
95
|
+
// {
|
|
96
|
+
// "title": "asdf",
|
|
97
|
+
// "description": "asdf",
|
|
98
|
+
// "mediaType": "NONE"
|
|
99
|
+
// }
|
|
100
|
+
// ],
|
|
101
|
+
// "cardSettings": {
|
|
102
|
+
// "cardOrientation": "VERTICAL"
|
|
103
|
+
// },
|
|
104
|
+
// "cardType": "STANDALONE",
|
|
105
|
+
// "contentType": "RICHCARD",
|
|
106
|
+
// "smsFallBackContent": {
|
|
107
|
+
// "message": ""
|
|
108
|
+
// }
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
// },
|
|
113
|
+
// "type": "RCS"
|
|
114
|
+
// }
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
// {
|
|
118
|
+
// "name": "test 2",
|
|
119
|
+
// "versions": {
|
|
120
|
+
// "base": {
|
|
121
|
+
// "content": {
|
|
122
|
+
// "RCS": {
|
|
123
|
+
// "cardContent": [
|
|
124
|
+
// {
|
|
125
|
+
// "title": "asdfasdf",
|
|
126
|
+
// "description": "asdfadsf",
|
|
127
|
+
// "mediaType": "IMAGE",
|
|
128
|
+
// "suggestions": [
|
|
129
|
+
// {
|
|
130
|
+
// "type": "CTA",
|
|
131
|
+
// "text": "fasdf",
|
|
132
|
+
// "url": "https://www.google.com"
|
|
133
|
+
// }
|
|
134
|
+
// ],
|
|
135
|
+
// "media": {
|
|
136
|
+
// "mediaUrl": "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/820a9ff9-ad5b-410e-b471-75c2e1a9.jpg",
|
|
137
|
+
// "height": "MEDIUM"
|
|
138
|
+
// }
|
|
139
|
+
// }
|
|
140
|
+
// ],
|
|
141
|
+
// "cardSettings": {
|
|
142
|
+
// "cardOrientation": "VERTICAL"
|
|
143
|
+
// },
|
|
144
|
+
// "cardType": "STANDALONE",
|
|
145
|
+
// "contentType": "RICHCARD",
|
|
146
|
+
// "smsFallBackContent": {
|
|
147
|
+
// "message": "asdf"
|
|
148
|
+
// }
|
|
149
|
+
// }
|
|
150
|
+
// }
|
|
151
|
+
// }
|
|
152
|
+
// },
|
|
153
|
+
// "type": "RCS"
|
|
154
|
+
// }
|
|
@@ -33,6 +33,7 @@ import { CREATIVE } from '../Facebook/constants';
|
|
|
33
33
|
import { LOYALTY } from '../App/constants';
|
|
34
34
|
import { WHATSAPP_STATUSES } from '../Whatsapp/constants';
|
|
35
35
|
|
|
36
|
+
import {updateImagesInHtml} from '../../utils/cdnTransformation';
|
|
36
37
|
|
|
37
38
|
const classPrefix = 'add-creatives-section';
|
|
38
39
|
const CREATIVES_CONTAINER = 'creativesContainer';
|
|
@@ -369,15 +370,15 @@ export class Creatives extends React.Component {
|
|
|
369
370
|
const {
|
|
370
371
|
messageBody = '',
|
|
371
372
|
templateConfigs: {
|
|
373
|
+
id,
|
|
372
374
|
name,
|
|
373
375
|
template,
|
|
374
376
|
varMapped,
|
|
375
|
-
category,
|
|
376
377
|
language,
|
|
378
|
+
category,
|
|
379
|
+
mediaType,
|
|
377
380
|
buttonType = 'NONE',
|
|
378
381
|
buttons = [],
|
|
379
|
-
mediaType = 'TEXT',
|
|
380
|
-
whatsappMedia: { url: imageUrl = '' } = {},
|
|
381
382
|
} = {},
|
|
382
383
|
} = templateData;
|
|
383
384
|
const modifiedButtons = cloneDeep(buttons).map((btn) => {
|
|
@@ -388,13 +389,9 @@ export class Creatives extends React.Component {
|
|
|
388
389
|
}
|
|
389
390
|
return btn;
|
|
390
391
|
});
|
|
391
|
-
for (const key in varMapped) {
|
|
392
|
-
if (key.includes('_unsubscribe')) {
|
|
393
|
-
delete varMapped[key];
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
392
|
const unsubscribeRegex = /Click {{unsubscribe}} to unsubscribe/g;
|
|
397
393
|
creativesTemplateData = {
|
|
394
|
+
_id: id,
|
|
398
395
|
type: constants.WHATSAPP,
|
|
399
396
|
edit: true,
|
|
400
397
|
name,
|
|
@@ -406,7 +403,6 @@ export class Creatives extends React.Component {
|
|
|
406
403
|
category,
|
|
407
404
|
varMapped,
|
|
408
405
|
mediaType,
|
|
409
|
-
imageUrl,
|
|
410
406
|
buttonType,
|
|
411
407
|
buttons: modifiedButtons,
|
|
412
408
|
languages: [
|
|
@@ -456,7 +452,8 @@ export class Creatives extends React.Component {
|
|
|
456
452
|
return templateData || null;
|
|
457
453
|
}
|
|
458
454
|
|
|
459
|
-
getCreativesData = (channel, template, templateRecords) => {
|
|
455
|
+
getCreativesData = (channel, template, templateRecords) => {
|
|
456
|
+
//from creatives to consumers
|
|
460
457
|
let templateData = { channel };
|
|
461
458
|
switch (channel) {
|
|
462
459
|
case constants.SMS:
|
|
@@ -495,7 +492,8 @@ export class Creatives extends React.Component {
|
|
|
495
492
|
if (!html_content) {
|
|
496
493
|
emailBase = templateRecords.base;
|
|
497
494
|
}
|
|
498
|
-
|
|
495
|
+
const newHtmlContent = updateImagesInHtml(html_content);
|
|
496
|
+
templateData = {...templateData, ...emailBase, emailBody: newHtmlContent, emailSubject: (emailBase && emailBase.subject) ? emailBase.subject : ''};
|
|
499
497
|
delete templateData.html_content;
|
|
500
498
|
delete templateData.subject;
|
|
501
499
|
}
|
|
@@ -587,63 +585,43 @@ export class Creatives extends React.Component {
|
|
|
587
585
|
case constants.WHATSAPP:
|
|
588
586
|
if (template.value) {
|
|
589
587
|
const { Templates, templateData: templateDataProps } = this.props;
|
|
590
|
-
const selectedWhatsappAccount = Templates?.selectedWhatsappAccount;
|
|
591
588
|
const { accountDetails: selectedAccountDetails, accountId: selectedAccountId } = templateDataProps || {};
|
|
589
|
+
const selectedWhatsappAccount = Templates?.selectedWhatsappAccount;
|
|
592
590
|
const accountDetails = (selectedWhatsappAccount ? selectedWhatsappAccount : selectedAccountDetails);
|
|
593
591
|
const accountId = selectedAccountId || (selectedWhatsappAccount?.id || '');
|
|
594
592
|
const { versions } = template.value;
|
|
595
593
|
const {
|
|
596
594
|
languages = [{}],
|
|
597
|
-
mediaType
|
|
598
|
-
category
|
|
599
|
-
templateEditor
|
|
600
|
-
varMapped
|
|
595
|
+
mediaType,
|
|
596
|
+
category,
|
|
597
|
+
templateEditor,
|
|
598
|
+
varMapped,
|
|
601
599
|
buttonType = 'NONE',
|
|
602
600
|
buttons = [],
|
|
603
|
-
imageUrl = '',
|
|
604
601
|
} = cloneDeep(versions.base.content.whatsapp);
|
|
605
|
-
|
|
606
602
|
const modifiedButtons = cloneDeep(buttons).map((btn) => {
|
|
607
603
|
if (btn.type === 'PHONE_NUMBER') {
|
|
608
604
|
btn.phoneNumber = btn.phone_number;
|
|
609
605
|
delete btn.phone_number;
|
|
610
|
-
|
|
611
|
-
const dynamicUrlPayload = btn.url.match(/{{(.*?)}}/g);
|
|
612
|
-
btn.dynamicUrlPayload = dynamicUrlPayload.length === 1 ? dynamicUrlPayload[0] : '';
|
|
606
|
+
return btn;
|
|
613
607
|
}
|
|
614
608
|
return btn;
|
|
615
609
|
});
|
|
616
|
-
|
|
617
|
-
//to send {{unsubscribe}} to backend inside varMapped
|
|
618
|
-
const unsubscribeRegex = /Click {{unsubscribe}} to unsubscribe/g;
|
|
619
|
-
if (
|
|
620
|
-
languages[0].content?.match(unsubscribeRegex)?.length > 0 &&
|
|
621
|
-
Object.keys(varMapped)?.every(
|
|
622
|
-
(key) => !key?.includes("_unsubscribe")
|
|
623
|
-
)
|
|
624
|
-
) {
|
|
625
|
-
varMapped[`{{${Object.keys(varMapped).length + 1}}}_unsubscribe`] =
|
|
626
|
-
"{{unsubscribe}}";
|
|
627
|
-
}
|
|
628
|
-
|
|
629
610
|
templateData = {
|
|
630
611
|
channel,
|
|
631
612
|
accountId,
|
|
632
613
|
accountName: accountDetails?.name || '',
|
|
633
614
|
messageBody: languages[0].content,
|
|
634
615
|
templateConfigs: {
|
|
635
|
-
id: template
|
|
616
|
+
id: template._id,
|
|
636
617
|
name: template?.value?.name,
|
|
637
618
|
template: templateEditor,
|
|
638
619
|
varMapped,
|
|
639
620
|
category,
|
|
640
621
|
language: languages[0].language,
|
|
641
|
-
buttonType,
|
|
642
|
-
buttons: modifiedButtons,
|
|
643
622
|
mediaType,
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
},
|
|
623
|
+
buttonType,
|
|
624
|
+
buttons : modifiedButtons,
|
|
647
625
|
},
|
|
648
626
|
};
|
|
649
627
|
}
|
|
@@ -81,6 +81,9 @@ import Templates from '../Templates';
|
|
|
81
81
|
import SmsTraiEdit from '../SmsTrai/Edit';
|
|
82
82
|
import TagList from '../TagList';
|
|
83
83
|
import { validateTags } from '../../utils/tagValidations';
|
|
84
|
+
|
|
85
|
+
import { getCdnUrl } from '../../utils/cdnTransformation';
|
|
86
|
+
|
|
84
87
|
const { Group: CapCheckboxGroup } = CapCheckbox;
|
|
85
88
|
export const Rcs = (props) => {
|
|
86
89
|
const {
|
|
@@ -900,7 +903,7 @@ export const Rcs = (props) => {
|
|
|
900
903
|
...(suggestions.length > 0 && { suggestions }),
|
|
901
904
|
...(!isMediaTypeNone && {
|
|
902
905
|
media: {
|
|
903
|
-
mediaUrl: rcsImageSrc,
|
|
906
|
+
mediaUrl: getCdnUrl({url: rcsImageSrc}),
|
|
904
907
|
height: MEDIUM,
|
|
905
908
|
},
|
|
906
909
|
}),
|