@capillarytech/creatives-library 8.0.87-alpha.2 → 8.0.87-alpha.20
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/initialState.js +1 -0
- package/package.json +1 -1
- package/services/api.js +9 -10
- package/utils/transformerUtils.js +509 -0
- package/v2Components/CapWhatsappCTA/messages.js +0 -4
- package/v2Components/FormBuilder/index.js +7 -3
- package/v2Components/TemplatePreview/_templatePreview.scss +0 -9
- package/v2Components/TemplatePreview/index.js +104 -169
- package/v2Containers/Cap/actions.js +8 -0
- package/v2Containers/Cap/constants.js +4 -0
- package/v2Containers/Cap/reducer.js +6 -0
- package/v2Containers/Cap/sagas.js +23 -0
- package/v2Containers/Cap/selectors.js +6 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +11 -1
- package/v2Containers/CreativesContainer/constants.js +3 -0
- package/v2Containers/CreativesContainer/index.js +77 -88
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +25 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +2 -0
- package/v2Containers/Email/index.js +1 -0
- package/v2Containers/EmailWrapper/index.js +2 -0
- package/v2Containers/MobilePush/Create/index.js +1 -0
- package/v2Containers/MobilePush/Edit/index.js +1 -0
- package/v2Containers/MobilepushWrapper/index.js +2 -1
- package/v2Containers/Sms/Create/index.js +1 -0
- package/v2Containers/Sms/Edit/index.js +1 -0
- package/v2Containers/SmsWrapper/index.js +2 -0
- package/v2Containers/Templates/_templates.scss +0 -35
- package/v2Containers/Templates/index.js +5 -64
- package/v2Containers/TemplatesV2/index.js +7 -0
- package/v2Containers/Whatsapp/constants.js +1 -83
- package/v2Containers/Whatsapp/index.js +182 -709
- package/v2Containers/Whatsapp/index.scss +1 -52
- package/v2Containers/Whatsapp/messages.js +2 -38
- package/v2Containers/Whatsapp/utils.js +0 -34
- package/v2Containers/mockdata.js +3 -0
- package/v2Components/CapWhatsappCarouselButton/constant.js +0 -51
- package/v2Components/CapWhatsappCarouselButton/index.js +0 -446
- package/v2Components/CapWhatsappCarouselButton/index.scss +0 -39
- package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +0 -4
- package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +0 -4
package/initialState.js
CHANGED
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -118,7 +118,7 @@ function request(url, options, handleUnauthorizedStatus) {
|
|
|
118
118
|
.catch((error) => error);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
function getAPICallObject(method, body, isFileUpload = false, loadCampaignHeaders = false, orgUnitId = false) {
|
|
121
|
+
function getAPICallObject(method, body, isFileUpload = false, loadCampaignHeaders = false, orgUnitId = false, allowOrgInProd = false) {
|
|
122
122
|
const token = loadItem('token');
|
|
123
123
|
const orgID = loadItem('orgID');
|
|
124
124
|
const user = loadItem('user');
|
|
@@ -145,8 +145,8 @@ function getAPICallObject(method, body, isFileUpload = false, loadCampaignHeader
|
|
|
145
145
|
headers['X-CAP-REMOTE-USER'] = user.refID;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
if (process.env.NODE_ENV !==
|
|
149
|
-
headers[
|
|
148
|
+
if ((allowOrgInProd || process.env.NODE_ENV !== "production") && orgID !== undefined) {
|
|
149
|
+
headers["X-CAP-API-AUTH-ORG-ID"] = orgID;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
if (process.env.NODE_ENV !== 'production' && token !== undefined) {
|
|
@@ -520,13 +520,7 @@ export const checkBulkDuplicates = (data) => {
|
|
|
520
520
|
export const createWhatsappTemplate = ({payload, gupshupMediaFile }) => {
|
|
521
521
|
const data = new FormData();
|
|
522
522
|
data.append('payload', JSON.stringify(payload));
|
|
523
|
-
|
|
524
|
-
gupshupMediaFile.forEach((file, index) => {
|
|
525
|
-
data.append(`gupshupMediaFile_${index}`, file);
|
|
526
|
-
});
|
|
527
|
-
} else {
|
|
528
|
-
data.append('gupshupMediaFile', gupshupMediaFile);
|
|
529
|
-
}
|
|
523
|
+
data.append('gupshupMediaFile', gupshupMediaFile);
|
|
530
524
|
const url = `${API_ENDPOINT}/templates/WHATSAPP`;
|
|
531
525
|
return request(url, getAPICallObject('POST', data, true));
|
|
532
526
|
};
|
|
@@ -575,4 +569,9 @@ export const getLiquidTags = (content) => {
|
|
|
575
569
|
return request(url, getAPICallObject("POST", { content }, false, true));
|
|
576
570
|
};
|
|
577
571
|
|
|
572
|
+
export const createCentralCommsMetaId = (payload, metaId = 'TRANSACTION') => {
|
|
573
|
+
const url = `${API_ENDPOINT}/common/central-comms/meta-id/${metaId}`;
|
|
574
|
+
return request(url, getAPICallObject('POST', payload, false, false, false, true));
|
|
575
|
+
};
|
|
576
|
+
|
|
578
577
|
export {request, getAPICallObject};
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
// Import channel constants from the existing constants file
|
|
2
|
+
import {
|
|
3
|
+
SMS,
|
|
4
|
+
EMAIL,
|
|
5
|
+
MOBILE_PUSH,
|
|
6
|
+
WHATSAPP,
|
|
7
|
+
PUSH,
|
|
8
|
+
ZALO
|
|
9
|
+
} from "../v2Containers/CreativesContainer/constants";
|
|
10
|
+
|
|
11
|
+
// Transforms the channel payload based on the channel type
|
|
12
|
+
/**
|
|
13
|
+
* General transformer function that handles different channel types
|
|
14
|
+
* @param {Object} data - The input data
|
|
15
|
+
* @param {Object} options - Additional options for transformation
|
|
16
|
+
* @returns {Object} - Transformed payload based on channel type
|
|
17
|
+
*/
|
|
18
|
+
export const transformChannelPayload = (data, options = {}) => {
|
|
19
|
+
const channel = data.channel?.toUpperCase();
|
|
20
|
+
|
|
21
|
+
switch (channel) {
|
|
22
|
+
case SMS:
|
|
23
|
+
return transformSmsPayload(data, options);
|
|
24
|
+
case MOBILE_PUSH:
|
|
25
|
+
return transformMpushPayload(data, options);
|
|
26
|
+
case EMAIL:
|
|
27
|
+
return transformEmailPayload(data, options);
|
|
28
|
+
case WHATSAPP:
|
|
29
|
+
return transformWhatsappPayload(data, options);
|
|
30
|
+
case ZALO:
|
|
31
|
+
return transformZaloPayload(data, options);
|
|
32
|
+
default:
|
|
33
|
+
return data; // Return unchanged for unsupported channels
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Transforms SMS data to the required payload format
|
|
38
|
+
* @param {Object} smsData - Current SMS data
|
|
39
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
40
|
+
* @returns {Object} - Transformed SMS payload
|
|
41
|
+
*/
|
|
42
|
+
const transformSmsPayload = (smsData, options = {}) => {
|
|
43
|
+
const { channel, loyaltyMetaData = {} } = options;
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
actionId,
|
|
47
|
+
ouId,
|
|
48
|
+
clientName,
|
|
49
|
+
module,
|
|
50
|
+
transformedMessageDetails = {}
|
|
51
|
+
} = loyaltyMetaData;
|
|
52
|
+
|
|
53
|
+
const { smsDeliverySettings } = transformedMessageDetails;
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
centralCommsPayload: {
|
|
57
|
+
ouId: ouId || -1,
|
|
58
|
+
sourceEntityId: actionId,
|
|
59
|
+
channel: SMS,
|
|
60
|
+
module,
|
|
61
|
+
smsMessageContent: {
|
|
62
|
+
channel: SMS,
|
|
63
|
+
message: smsData.messageBody || ""
|
|
64
|
+
},
|
|
65
|
+
smsDeliverySettings: smsDeliverySettings || {},
|
|
66
|
+
executionParams: {},
|
|
67
|
+
clientName: clientName || "EMF"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Transforms Email data to the required payload format
|
|
73
|
+
* @param {Object} emailData - Current email data
|
|
74
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
75
|
+
* @returns {Object} - Transformed Email payload
|
|
76
|
+
*/
|
|
77
|
+
const transformEmailPayload = (emailData, options = {}) => {
|
|
78
|
+
const { loyaltyMetaData = {} } = options;
|
|
79
|
+
|
|
80
|
+
const {
|
|
81
|
+
actionId,
|
|
82
|
+
ouId,
|
|
83
|
+
clientName,
|
|
84
|
+
module,
|
|
85
|
+
transformedMessageDetails = {}
|
|
86
|
+
} = loyaltyMetaData;
|
|
87
|
+
|
|
88
|
+
const { emailDeliverySettings = {} } = transformedMessageDetails;
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
centralCommsPayload: {
|
|
92
|
+
ouId: ouId || -1,
|
|
93
|
+
sourceEntityId: actionId,
|
|
94
|
+
channel: EMAIL,
|
|
95
|
+
module,
|
|
96
|
+
emailMessageContent: {
|
|
97
|
+
channel: EMAIL,
|
|
98
|
+
messageBody: emailData.emailBody || "",
|
|
99
|
+
messageSubject: emailData.emailSubject || ""
|
|
100
|
+
},
|
|
101
|
+
emailDeliverySettings: emailDeliverySettings || {},
|
|
102
|
+
executionParams: {},
|
|
103
|
+
clientName: clientName || "EMF"
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Transforms Mobile Push data to the required payload format
|
|
109
|
+
* @param {Object} mpushData - Current mobile push data
|
|
110
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
111
|
+
* @returns {Object} - Transformed Mobile Push payload
|
|
112
|
+
*/
|
|
113
|
+
const transformMpushPayload = (mpushData, options = {}) => {
|
|
114
|
+
const { loyaltyMetaData = {} } = options;
|
|
115
|
+
|
|
116
|
+
const {
|
|
117
|
+
actionId,
|
|
118
|
+
ouId,
|
|
119
|
+
clientName,
|
|
120
|
+
module,
|
|
121
|
+
transformedMessageDetails = {}
|
|
122
|
+
} = loyaltyMetaData;
|
|
123
|
+
|
|
124
|
+
const { mobilePushDeliverySettings = {} } = transformedMessageDetails;
|
|
125
|
+
|
|
126
|
+
// Set default values for androidContent if not provided
|
|
127
|
+
const androidContent = mpushData.androidContent || {};
|
|
128
|
+
|
|
129
|
+
// Set default values for iosContent if needed
|
|
130
|
+
const iosContent = mpushData.iosContent || {
|
|
131
|
+
type: androidContent.type || "TEXT",
|
|
132
|
+
deviceType: "IOS",
|
|
133
|
+
title: mpushData.messageSubject || "",
|
|
134
|
+
message: ""
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
centralCommsPayload: {
|
|
139
|
+
channel: PUSH,
|
|
140
|
+
ouId: ouId || -1,
|
|
141
|
+
sourceEntityId: actionId,
|
|
142
|
+
clientName: clientName || "VENENO",
|
|
143
|
+
module,
|
|
144
|
+
mpushMessageContent: {
|
|
145
|
+
channel: PUSH,
|
|
146
|
+
messageSubject: mpushData.messageSubject || "",
|
|
147
|
+
androidContent: {
|
|
148
|
+
type: androidContent.type || "TEXT",
|
|
149
|
+
deviceType: "ANDROID",
|
|
150
|
+
title: androidContent.title || "",
|
|
151
|
+
message: androidContent.message || "",
|
|
152
|
+
cta: {
|
|
153
|
+
type: "EXTERNAL_URL",
|
|
154
|
+
actionText: null,
|
|
155
|
+
templateCtaId: null,
|
|
156
|
+
actionLink: androidContent.cta?.actionLink || ""
|
|
157
|
+
},
|
|
158
|
+
expandableDetails: {
|
|
159
|
+
style: androidContent.expandableDetails?.style || "BIG_TEXT",
|
|
160
|
+
message: androidContent.expandableDetails?.message || "",
|
|
161
|
+
ctas: androidContent.expandableDetails?.ctas || [],
|
|
162
|
+
image: androidContent.expandableDetails?.image || "",
|
|
163
|
+
categoryId: androidContent.expandableDetails?.categoryId || ""
|
|
164
|
+
},
|
|
165
|
+
customProperties: androidContent.custom || {}
|
|
166
|
+
},
|
|
167
|
+
iosContent: {
|
|
168
|
+
type: iosContent.type || "TEXT",
|
|
169
|
+
deviceType: "IOS",
|
|
170
|
+
title: iosContent.title || "",
|
|
171
|
+
message: iosContent.message || "",
|
|
172
|
+
cta: {
|
|
173
|
+
type: "EXTERNAL_URL",
|
|
174
|
+
actionText: null,
|
|
175
|
+
templateCtaId: null,
|
|
176
|
+
actionLink: iosContent.cta?.actionLink || ""
|
|
177
|
+
},
|
|
178
|
+
expandableDetails: {
|
|
179
|
+
style: iosContent.expandableDetails?.style || "BIG_TEXT",
|
|
180
|
+
message: iosContent.expandableDetails?.message || "",
|
|
181
|
+
ctas: iosContent.expandableDetails?.ctas || [],
|
|
182
|
+
image: iosContent.expandableDetails?.image || "",
|
|
183
|
+
categoryId: iosContent.expandableDetails?.categoryId || ""
|
|
184
|
+
},
|
|
185
|
+
customProperties: iosContent.custom || {}
|
|
186
|
+
},
|
|
187
|
+
accountId: mpushData.accountId || 0
|
|
188
|
+
},
|
|
189
|
+
mpushDeliverySettings: mobilePushDeliverySettings || {}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Transforms WhatsApp data to the required payload format
|
|
195
|
+
* @param {Object} whatsappData - Current WhatsApp data
|
|
196
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
197
|
+
* @returns {Object} - Transformed WhatsApp payload
|
|
198
|
+
*/
|
|
199
|
+
const transformWhatsappPayload = (whatsappData, options = {}) => {
|
|
200
|
+
const { loyaltyMetaData = {} } = options;
|
|
201
|
+
|
|
202
|
+
const {
|
|
203
|
+
actionId,
|
|
204
|
+
ouId,
|
|
205
|
+
clientName,
|
|
206
|
+
module,
|
|
207
|
+
transformedMessageDetails = {}
|
|
208
|
+
} = loyaltyMetaData;
|
|
209
|
+
|
|
210
|
+
const { whatsappDeliverySettings = {} } = transformedMessageDetails;
|
|
211
|
+
|
|
212
|
+
// Get template configurations or set defaults
|
|
213
|
+
const templateConfigs = whatsappData.templateConfigs || {};
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
centralCommsPayload: {
|
|
217
|
+
ouId: ouId || -1,
|
|
218
|
+
sourceEntityId: actionId,
|
|
219
|
+
channel: WHATSAPP,
|
|
220
|
+
module,
|
|
221
|
+
whatsappMessageContent: {
|
|
222
|
+
messageBody: whatsappData.messageBody || "",
|
|
223
|
+
accountId: whatsappData.accountId || 0,
|
|
224
|
+
templateConfigs,
|
|
225
|
+
channel: WHATSAPP
|
|
226
|
+
},
|
|
227
|
+
whatsappDeliverySettings: whatsappDeliverySettings || {},
|
|
228
|
+
executionParams: {},
|
|
229
|
+
clientName: clientName || "VENENO"
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Transforms Zalo data to the required payload format
|
|
235
|
+
* @param {Object} zaloData - Current Zalo data
|
|
236
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
237
|
+
* @returns {Object} - Transformed Zalo payload
|
|
238
|
+
*/
|
|
239
|
+
const transformZaloPayload = (zaloData, options = {}) => {
|
|
240
|
+
const { loyaltyMetaData = {} } = options;
|
|
241
|
+
|
|
242
|
+
const {
|
|
243
|
+
actionId,
|
|
244
|
+
ouId,
|
|
245
|
+
clientName,
|
|
246
|
+
module,
|
|
247
|
+
transformedMessageDetails = {}
|
|
248
|
+
} = loyaltyMetaData;
|
|
249
|
+
|
|
250
|
+
const { zaloDeliverySettings = {} } = transformedMessageDetails;
|
|
251
|
+
|
|
252
|
+
// Get template configurations or set defaults
|
|
253
|
+
const templateConfigs = zaloData.templateConfigs || {};
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
centralCommsPayload: {
|
|
257
|
+
ouId: ouId || -1,
|
|
258
|
+
sourceEntityId: actionId,
|
|
259
|
+
channel: ZALO,
|
|
260
|
+
module,
|
|
261
|
+
zaloMessageContent: {
|
|
262
|
+
channel: ZALO,
|
|
263
|
+
messageBody: zaloData.messageBody || "",
|
|
264
|
+
accountId: zaloData.accountId || "",
|
|
265
|
+
accountName: zaloData.accountName || "",
|
|
266
|
+
templateConfigs,
|
|
267
|
+
token: zaloData.token || ""
|
|
268
|
+
},
|
|
269
|
+
zaloDeliverySettings: zaloDeliverySettings || {},
|
|
270
|
+
executionParams: {},
|
|
271
|
+
clientName: clientName || "VENENO"
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// Checks if the template has changed
|
|
277
|
+
export const getTemplateDiffState = (channel, oldData, newData) => {
|
|
278
|
+
switch (channel.toUpperCase()) {
|
|
279
|
+
case SMS:
|
|
280
|
+
return checkSmsDiff(oldData, newData);
|
|
281
|
+
case EMAIL:
|
|
282
|
+
return checkEmailDiff(oldData, newData);
|
|
283
|
+
case MOBILE_PUSH:
|
|
284
|
+
case PUSH:
|
|
285
|
+
return checkPushDiff(oldData, newData);
|
|
286
|
+
case WHATSAPP:
|
|
287
|
+
return checkWhatsappDiff(oldData, newData);
|
|
288
|
+
case ZALO:
|
|
289
|
+
return checkZaloDiff(oldData, newData);
|
|
290
|
+
default:
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Checks differences between old and new SMS data
|
|
296
|
+
* @param {Object} oldData - Previous SMS template data
|
|
297
|
+
* @param {Object} newData - Updated SMS template data
|
|
298
|
+
* @returns {Boolean} - Whether the template has changed
|
|
299
|
+
*/
|
|
300
|
+
const checkSmsDiff = (oldData, newData) => {
|
|
301
|
+
// Extract old message content
|
|
302
|
+
const oldMessage =
|
|
303
|
+
oldData?.transformedMessageDetails?.smsMessageContent?.message || "";
|
|
304
|
+
|
|
305
|
+
// Extract new message content
|
|
306
|
+
const newMessage = newData?.messageBody || "";
|
|
307
|
+
|
|
308
|
+
// Compare message content
|
|
309
|
+
return oldMessage !== newMessage;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Checks differences between old and new Email data
|
|
313
|
+
* @param {Object} oldData - Previous Email template data
|
|
314
|
+
* @param {Object} newData - Updated Email template data
|
|
315
|
+
* @returns {Boolean} - Whether the template has changed
|
|
316
|
+
*/
|
|
317
|
+
const checkEmailDiff = (oldData, newData) => {
|
|
318
|
+
// Extract old email content
|
|
319
|
+
const oldEmailBody =
|
|
320
|
+
oldData?.transformedMessageDetails?.emailMessageContent?.messageBody || "";
|
|
321
|
+
const oldEmailSubject =
|
|
322
|
+
oldData?.transformedMessageDetails?.emailMessageContent?.messageSubject ||
|
|
323
|
+
"";
|
|
324
|
+
|
|
325
|
+
// Extract new email content
|
|
326
|
+
const newEmailBody = newData?.emailBody || "";
|
|
327
|
+
const newEmailSubject = newData?.emailSubject || "";
|
|
328
|
+
|
|
329
|
+
// Compare both subject and body
|
|
330
|
+
return oldEmailBody !== newEmailBody || oldEmailSubject !== newEmailSubject;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Checks differences between old and new Push data
|
|
334
|
+
* @param {Object} oldData - Previous Push template data
|
|
335
|
+
* @param {Object} newData - Updated Push template data
|
|
336
|
+
* @returns {Boolean} - Whether the template has changed
|
|
337
|
+
*/
|
|
338
|
+
const checkPushDiff = (oldData, newData) => {
|
|
339
|
+
// Extract old push content
|
|
340
|
+
const oldAndroidContent =
|
|
341
|
+
oldData?.transformedMessageDetails?.mpushMessageContent?.androidContent ||
|
|
342
|
+
{};
|
|
343
|
+
const oldIosContent =
|
|
344
|
+
oldData?.transformedMessageDetails?.mpushMessageContent?.iosContent || {};
|
|
345
|
+
const oldSubject =
|
|
346
|
+
oldData?.transformedMessageDetails?.mpushMessageContent?.messageSubject ||
|
|
347
|
+
"";
|
|
348
|
+
|
|
349
|
+
// Extract new push content
|
|
350
|
+
const newAndroidContent = newData?.androidContent || {};
|
|
351
|
+
const newIosContent = newData?.iosContent || {};
|
|
352
|
+
const newSubject = newData?.messageSubject || "";
|
|
353
|
+
|
|
354
|
+
// Compare subject
|
|
355
|
+
if (oldSubject !== newSubject) return true;
|
|
356
|
+
|
|
357
|
+
// Compare Android content
|
|
358
|
+
if (oldAndroidContent.title !== newAndroidContent.title) return true;
|
|
359
|
+
if (oldAndroidContent.message !== newAndroidContent.message) return true;
|
|
360
|
+
if (oldAndroidContent.cta?.actionLink !== newAndroidContent.cta?.actionLink)
|
|
361
|
+
return true;
|
|
362
|
+
|
|
363
|
+
// Compare iOS content
|
|
364
|
+
if (oldIosContent.title !== newIosContent.title) return true;
|
|
365
|
+
if (oldIosContent.message !== newIosContent.message) return true;
|
|
366
|
+
if (oldIosContent.cta?.actionLink !== newIosContent.cta?.actionLink)
|
|
367
|
+
return true;
|
|
368
|
+
|
|
369
|
+
return false;
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* Checks differences between old and new WhatsApp data
|
|
373
|
+
* @param {Object} oldData - Previous WhatsApp template data
|
|
374
|
+
* @param {Object} newData - Updated WhatsApp template data
|
|
375
|
+
* @returns {Boolean} - Whether the template has changed
|
|
376
|
+
*/
|
|
377
|
+
const checkWhatsappDiff = (oldData, newData) => {
|
|
378
|
+
// Extract old WhatsApp content
|
|
379
|
+
const oldMessage =
|
|
380
|
+
oldData?.transformedMessageDetails?.whatsappMessageContent?.messageBody ||
|
|
381
|
+
"";
|
|
382
|
+
const oldTemplateConfigs =
|
|
383
|
+
oldData?.transformedMessageDetails?.whatsappMessageContent
|
|
384
|
+
?.templateConfigs || {};
|
|
385
|
+
|
|
386
|
+
// Extract new WhatsApp content
|
|
387
|
+
const newMessage = newData?.messageBody || "";
|
|
388
|
+
const newTemplateConfigs = newData?.templateConfigs || {};
|
|
389
|
+
|
|
390
|
+
// Compare message content
|
|
391
|
+
if (oldMessage !== newMessage) return true;
|
|
392
|
+
|
|
393
|
+
// If new data has template configs but old data doesn't, there is a change
|
|
394
|
+
if (
|
|
395
|
+
Object.keys(newTemplateConfigs).length > 0 &&
|
|
396
|
+
Object.keys(oldTemplateConfigs).length === 0
|
|
397
|
+
) {
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// If both have template configs, perform detailed comparison
|
|
402
|
+
if (
|
|
403
|
+
Object.keys(newTemplateConfigs).length > 0 &&
|
|
404
|
+
Object.keys(oldTemplateConfigs).length > 0
|
|
405
|
+
) {
|
|
406
|
+
// Compare template names and IDs
|
|
407
|
+
if (oldTemplateConfigs.id !== newTemplateConfigs.id) return true;
|
|
408
|
+
if (oldTemplateConfigs.name !== newTemplateConfigs.name) return true;
|
|
409
|
+
if (oldTemplateConfigs.template !== newTemplateConfigs.template)
|
|
410
|
+
return true;
|
|
411
|
+
|
|
412
|
+
// Compare template variables
|
|
413
|
+
if (
|
|
414
|
+
JSON.stringify(oldTemplateConfigs.varMapped) !==
|
|
415
|
+
JSON.stringify(newTemplateConfigs.varMapped)
|
|
416
|
+
)
|
|
417
|
+
return true;
|
|
418
|
+
|
|
419
|
+
// Compare media settings
|
|
420
|
+
if (
|
|
421
|
+
JSON.stringify(oldTemplateConfigs.whatsappMedia) !==
|
|
422
|
+
JSON.stringify(newTemplateConfigs.whatsappMedia)
|
|
423
|
+
)
|
|
424
|
+
return true;
|
|
425
|
+
|
|
426
|
+
// Compare other template properties
|
|
427
|
+
if (oldTemplateConfigs.category !== newTemplateConfigs.category)
|
|
428
|
+
return true;
|
|
429
|
+
if (oldTemplateConfigs.language !== newTemplateConfigs.language)
|
|
430
|
+
return true;
|
|
431
|
+
if (oldTemplateConfigs.buttonType !== newTemplateConfigs.buttonType)
|
|
432
|
+
return true;
|
|
433
|
+
if (
|
|
434
|
+
JSON.stringify(oldTemplateConfigs.buttons) !==
|
|
435
|
+
JSON.stringify(newTemplateConfigs.buttons)
|
|
436
|
+
)
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Check if account details have changed
|
|
441
|
+
if (
|
|
442
|
+
oldData?.transformedMessageDetails?.whatsappMessageContent?.accountId !==
|
|
443
|
+
newData?.accountId
|
|
444
|
+
)
|
|
445
|
+
return true;
|
|
446
|
+
if (
|
|
447
|
+
oldData?.transformedMessageDetails?.whatsappMessageContent
|
|
448
|
+
?.sourceAccountIdentifier !== newData?.sourceAccountIdentifier
|
|
449
|
+
)
|
|
450
|
+
return true;
|
|
451
|
+
|
|
452
|
+
return false;
|
|
453
|
+
};
|
|
454
|
+
/**
|
|
455
|
+
* Checks differences between old and new Zalo data
|
|
456
|
+
* @param {Object} oldData - Previous Zalo template data
|
|
457
|
+
* @param {Object} newData - Updated Zalo template data
|
|
458
|
+
* @returns {Boolean} - Whether the template has changed
|
|
459
|
+
*/
|
|
460
|
+
const checkZaloDiff = (oldData, newData) => {
|
|
461
|
+
// Extract old Zalo content
|
|
462
|
+
const oldTemplateConfigs =
|
|
463
|
+
oldData?.transformedMessageDetails?.zaloMessageContent?.templateConfigs ||
|
|
464
|
+
{};
|
|
465
|
+
const oldAccountId =
|
|
466
|
+
oldData?.transformedMessageDetails?.zaloMessageContent?.accountId || "";
|
|
467
|
+
const oldToken =
|
|
468
|
+
oldData?.transformedMessageDetails?.zaloMessageContent?.token || "";
|
|
469
|
+
|
|
470
|
+
// Extract new Zalo content
|
|
471
|
+
const newTemplateConfigs = newData?.templateConfigs || {};
|
|
472
|
+
const newAccountId = newData?.accountId || "";
|
|
473
|
+
const newToken = newData?.token || "";
|
|
474
|
+
|
|
475
|
+
// Compare account ID
|
|
476
|
+
if (oldAccountId !== newAccountId) return true;
|
|
477
|
+
|
|
478
|
+
// Compare token
|
|
479
|
+
if (oldToken !== newToken) return true;
|
|
480
|
+
|
|
481
|
+
// If new data has template configs but old data doesn't, there is a change
|
|
482
|
+
if (
|
|
483
|
+
Object.keys(newTemplateConfigs).length > 0 &&
|
|
484
|
+
Object.keys(oldTemplateConfigs).length === 0
|
|
485
|
+
) {
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// If both have template configs, perform detailed comparison
|
|
490
|
+
if (
|
|
491
|
+
Object.keys(newTemplateConfigs).length > 0 &&
|
|
492
|
+
Object.keys(oldTemplateConfigs).length > 0
|
|
493
|
+
) {
|
|
494
|
+
// Compare template IDs and names
|
|
495
|
+
if (oldTemplateConfigs.id !== newTemplateConfigs.id) return true;
|
|
496
|
+
if (oldTemplateConfigs.name !== newTemplateConfigs.name) return true;
|
|
497
|
+
if (oldTemplateConfigs.template !== newTemplateConfigs.template)
|
|
498
|
+
return true;
|
|
499
|
+
|
|
500
|
+
// Compare template variables
|
|
501
|
+
if (
|
|
502
|
+
JSON.stringify(oldTemplateConfigs.varMapped) !==
|
|
503
|
+
JSON.stringify(newTemplateConfigs.varMapped)
|
|
504
|
+
)
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return false;
|
|
509
|
+
};
|
|
@@ -44,7 +44,7 @@ import EDMEditor from "../Edmeditor";
|
|
|
44
44
|
import BeeEditor from '../../v2Containers/BeeEditor';
|
|
45
45
|
import CustomPopOver from '../CustomPopOver';
|
|
46
46
|
import messages from './messages';
|
|
47
|
-
import { makeSelectMetaEntities, selectCurrentOrgDetails, selectLiquidStateDetails } from "../../v2Containers/Cap/selectors";
|
|
47
|
+
import { makeSelectMetaEntities, selectCurrentOrgDetails, selectLiquidStateDetails, selectMetaTagsStatus } from "../../v2Containers/Cap/selectors";
|
|
48
48
|
import * as actions from "../../v2Containers/Cap/actions";
|
|
49
49
|
import './_formBuilder.scss';
|
|
50
50
|
import {updateCharCount, checkUnicode} from "../../utils/smsCharCountV2";
|
|
@@ -56,6 +56,7 @@ import { OUTBOUND } from './constants';
|
|
|
56
56
|
import { GET_TRANSLATION_MAPPED } from '../../containers/TagList/constants';
|
|
57
57
|
import moment from 'moment';
|
|
58
58
|
import { CUSTOMER_BARCODE_TAG , COPY_OF, ENTRY_TRIGGER_TAG_REGEX} from '../../containers/App/constants';
|
|
59
|
+
import { REQUEST } from '../../v2Containers/Cap/constants'
|
|
59
60
|
import { hasLiquidSupportFeature, isEmailUnsubscribeTagMandatory } from '../../utils/common';
|
|
60
61
|
import { isUrl } from '../../v2Containers/Line/Container/Wrapper/utils';
|
|
61
62
|
import { bindActionCreators } from 'redux';
|
|
@@ -1082,6 +1083,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1082
1083
|
}
|
|
1083
1084
|
});}
|
|
1084
1085
|
}
|
|
1086
|
+
|
|
1085
1087
|
saveForm(saveForm) {
|
|
1086
1088
|
if (this.props.isNewVersionFlow && !saveForm) {
|
|
1087
1089
|
this.props.getValidationData();
|
|
@@ -3793,7 +3795,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3793
3795
|
|
|
3794
3796
|
|
|
3795
3797
|
return (
|
|
3796
|
-
<CapSpin spinning={Boolean(this.liquidFlow && this.props.liquidExtractionInProgress)} tip={this.props.intl.formatMessage(messages.liquidSpinText)} >
|
|
3798
|
+
<CapSpin spinning={Boolean((this.liquidFlow && this.props.liquidExtractionInProgress) || this.props.metaIdStatus === REQUEST)} tip={this.props.intl.formatMessage(messages.liquidSpinText)} >
|
|
3797
3799
|
<CapRow>
|
|
3798
3800
|
{this.props.schema && this.renderForm()}
|
|
3799
3801
|
<SlideBox
|
|
@@ -3827,6 +3829,7 @@ FormBuilder.defaultProps = {
|
|
|
3827
3829
|
isNewVersionFlow: false,
|
|
3828
3830
|
userLocale: localStorage.getItem('jlocale') || 'en',
|
|
3829
3831
|
showLiquidErrorInFooter: () => {},
|
|
3832
|
+
metaIdStatus: false,
|
|
3830
3833
|
};
|
|
3831
3834
|
|
|
3832
3835
|
FormBuilder.propTypes = {
|
|
@@ -3874,12 +3877,13 @@ FormBuilder.propTypes = {
|
|
|
3874
3877
|
isFullMode: PropTypes.bool,
|
|
3875
3878
|
currentOrgDetails: PropTypes.object,
|
|
3876
3879
|
liquidExtractionInProgress: PropTypes.bool,
|
|
3877
|
-
showLiquidErrorInFooter: PropTypes.func
|
|
3880
|
+
showLiquidErrorInFooter: PropTypes.func
|
|
3878
3881
|
};
|
|
3879
3882
|
|
|
3880
3883
|
const mapStateToProps = createStructuredSelector({
|
|
3881
3884
|
currentOrgDetails: selectCurrentOrgDetails(),
|
|
3882
3885
|
liquidExtractionInProgress: selectLiquidStateDetails(),
|
|
3886
|
+
metaIdStatus: selectMetaTagsStatus(),
|
|
3883
3887
|
metaEntities: makeSelectMetaEntities(),
|
|
3884
3888
|
});
|
|
3885
3889
|
|
|
@@ -567,10 +567,6 @@
|
|
|
567
567
|
font-size: 10px;
|
|
568
568
|
font-family: 'open-sans';
|
|
569
569
|
}
|
|
570
|
-
&.message-pop-carousel {
|
|
571
|
-
position: relative;
|
|
572
|
-
margin-right: 4px;
|
|
573
|
-
}
|
|
574
570
|
}
|
|
575
571
|
}
|
|
576
572
|
.android-push-message-Container, .iphone-push-message-Container{
|
|
@@ -751,11 +747,6 @@
|
|
|
751
747
|
width: 153px;
|
|
752
748
|
}
|
|
753
749
|
}
|
|
754
|
-
|
|
755
|
-
.msg-container-carousel {
|
|
756
|
-
display: flex;
|
|
757
|
-
flex-direction: column;
|
|
758
|
-
}
|
|
759
750
|
}
|
|
760
751
|
|
|
761
752
|
.align-center {
|