@capillarytech/creatives-library 8.0.87-alpha.17 → 8.0.87-alpha.19

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.87-alpha.17",
4
+ "version": "8.0.87-alpha.19",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
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 !== 'production' && orgID !== undefined) {
149
- headers['X-CAP-API-AUTH-ORG-ID'] = orgID;
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) {
@@ -569,9 +569,9 @@ export const getLiquidTags = (content) => {
569
569
  return request(url, getAPICallObject("POST", { content }, false, true));
570
570
  };
571
571
 
572
- export const createCentralCommsMetaId = (payload) => {
573
- const url = `${API_ENDPOINT}/common/central-comms/meta-id/TRANSACTION`;
574
- return request(url, getAPICallObject('POST', payload));
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
575
  };
576
576
 
577
577
  export {request, getAPICallObject};
@@ -1,10 +1,45 @@
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
+ };
1
36
  /**
2
37
  * Transforms SMS data to the required payload format
3
38
  * @param {Object} smsData - Current SMS data
4
39
  * @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
5
40
  * @returns {Object} - Transformed SMS payload
6
41
  */
7
- export const transformSmsPayload = (smsData, options = {}) => {
42
+ const transformSmsPayload = (smsData, options = {}) => {
8
43
  const { channel, loyaltyMetaData = {} } = options;
9
44
 
10
45
  const {
@@ -24,10 +59,10 @@ export const transformSmsPayload = (smsData, options = {}) => {
24
59
  centralCommsPayload: {
25
60
  ouId: ouId || -1,
26
61
  sourceEntityId: actionId,
27
- channel: "SMS",
62
+ channel: SMS,
28
63
  module,
29
64
  smsMessageContent: {
30
- channel: "SMS",
65
+ channel: SMS,
31
66
  message: smsData.messageBody || ""
32
67
  },
33
68
  smsDeliverySettings: smsDeliverySettings || {},
@@ -36,14 +71,13 @@ export const transformSmsPayload = (smsData, options = {}) => {
36
71
  }
37
72
  };
38
73
  };
39
-
40
74
  /**
41
75
  * Transforms Email data to the required payload format
42
76
  * @param {Object} emailData - Current email data
43
77
  * @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
44
78
  * @returns {Object} - Transformed Email payload
45
79
  */
46
- export const transformEmailPayload = (emailData, options = {}) => {
80
+ const transformEmailPayload = (emailData, options = {}) => {
47
81
  const { loyaltyMetaData = {} } = options;
48
82
 
49
83
  const {
@@ -63,10 +97,10 @@ export const transformEmailPayload = (emailData, options = {}) => {
63
97
  centralCommsPayload: {
64
98
  ouId: ouId || -1,
65
99
  sourceEntityId: actionId,
66
- channel: "EMAIL",
100
+ channel: EMAIL,
67
101
  module,
68
102
  emailMessageContent: {
69
- channel: "EMAIL",
103
+ channel: EMAIL,
70
104
  messageBody: emailData.emailBody || "",
71
105
  messageSubject: emailData.emailSubject || ""
72
106
  },
@@ -76,14 +110,13 @@ export const transformEmailPayload = (emailData, options = {}) => {
76
110
  }
77
111
  };
78
112
  };
79
-
80
113
  /**
81
114
  * Transforms Mobile Push data to the required payload format
82
115
  * @param {Object} mpushData - Current mobile push data
83
116
  * @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
84
117
  * @returns {Object} - Transformed Mobile Push payload
85
118
  */
86
- export const transformMpushPayload = (mpushData, options = {}) => {
119
+ const transformMpushPayload = (mpushData, options = {}) => {
87
120
  const { loyaltyMetaData = {} } = options;
88
121
 
89
122
  const {
@@ -112,13 +145,13 @@ export const transformMpushPayload = (mpushData, options = {}) => {
112
145
 
113
146
  return {
114
147
  centralCommsPayload: {
115
- channel: "PUSH",
148
+ channel: PUSH,
116
149
  ouId: ouId || -1,
117
150
  sourceEntityId: actionId,
118
151
  clientName: clientName || "VENENO",
119
152
  module,
120
153
  mpushMessageContent: {
121
- channel: "PUSH",
154
+ channel: PUSH,
122
155
  messageSubject: mpushData.messageSubject || "",
123
156
  androidContent: {
124
157
  type: androidContent.type || "TEXT",
@@ -162,29 +195,17 @@ export const transformMpushPayload = (mpushData, options = {}) => {
162
195
  },
163
196
  accountId: mpushData.accountId || 0
164
197
  },
165
- mpushDeliverySettings: mobilePushDeliverySettings || {
166
- additionalSettings: {
167
- useTinyUrl: false,
168
- encryptUrl: false,
169
- linkTrackingEnabled: false,
170
- userSubscriptionDisabled: false
171
- },
172
- channelSettings: {
173
- channel: "PUSH",
174
- domainGatewayMapId: options.domainGatewayMapId || 1
175
- }
176
- }
198
+ mpushDeliverySettings: mobilePushDeliverySettings || {}
177
199
  }
178
200
  };
179
201
  };
180
-
181
202
  /**
182
203
  * Transforms WhatsApp data to the required payload format
183
204
  * @param {Object} whatsappData - Current WhatsApp data
184
205
  * @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
185
206
  * @returns {Object} - Transformed WhatsApp payload
186
207
  */
187
- export const transformWhatsappPayload = (whatsappData, options = {}) => {
208
+ const transformWhatsappPayload = (whatsappData, options = {}) => {
188
209
  const { loyaltyMetaData = {} } = options;
189
210
 
190
211
  const {
@@ -207,51 +228,297 @@ export const transformWhatsappPayload = (whatsappData, options = {}) => {
207
228
  centralCommsPayload: {
208
229
  ouId: ouId || -1,
209
230
  sourceEntityId: actionId,
210
- channel: "WHATSAPP",
231
+ channel: WHATSAPP,
211
232
  module,
212
233
  whatsappMessageContent: {
213
234
  messageBody: whatsappData.messageBody || "",
214
235
  accountId: whatsappData.accountId || 0,
215
236
  templateConfigs,
216
- channel: "WHATSAPP"
237
+ channel: WHATSAPP
217
238
  },
218
- whatsappDeliverySettings: whatsappDeliverySettings || {
219
- additionalSettings: {
220
- encryptUrl: false,
221
- linkTrackingEnabled: false,
222
- useTinyUrl: false
223
- },
224
- channelSettings: {
225
- channel: "WHATSAPP",
226
- senderMobNum: whatsappData.senderMobNum || "",
227
- domainId: whatsappData.domainId || 0
228
- }
239
+ whatsappDeliverySettings: whatsappDeliverySettings || {},
240
+ executionParams: {},
241
+ clientName: clientName || "VENENO"
242
+ }
243
+ };
244
+ };
245
+ /**
246
+ * Transforms Zalo data to the required payload format
247
+ * @param {Object} zaloData - Current Zalo data
248
+ * @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
249
+ * @returns {Object} - Transformed Zalo payload
250
+ */
251
+ const transformZaloPayload = (zaloData, options = {}) => {
252
+ const { loyaltyMetaData = {} } = options;
253
+
254
+ const {
255
+ actionId,
256
+ actionName,
257
+ ouId,
258
+ clientName,
259
+ module,
260
+ metaId,
261
+ setMetaId = () => {},
262
+ transformedMessageDetails = {}
263
+ } = loyaltyMetaData;
264
+
265
+ const { zaloDeliverySettings = {} } = transformedMessageDetails;
266
+
267
+ // Get template configurations or set defaults
268
+ const templateConfigs = zaloData.templateConfigs || {};
269
+
270
+ return {
271
+ centralCommsPayload: {
272
+ ouId: ouId || -1,
273
+ sourceEntityId: actionId,
274
+ channel: ZALO,
275
+ module,
276
+ zaloMessageContent: {
277
+ channel: ZALO,
278
+ messageBody: zaloData.messageBody || "",
279
+ accountId: zaloData.accountId || "",
280
+ accountName: zaloData.accountName || "",
281
+ templateConfigs,
282
+ token: zaloData.token || ""
229
283
  },
284
+ zaloDeliverySettings: zaloDeliverySettings || {},
230
285
  executionParams: {},
231
286
  clientName: clientName || "VENENO"
232
287
  }
233
288
  };
234
289
  };
235
290
 
291
+ // Checks if the template has changed
292
+ export const getTemplateDiffState = (channel, oldData, newData) => {
293
+ switch (channel.toUpperCase()) {
294
+ case SMS:
295
+ return checkSmsDiff(oldData, newData);
296
+ case EMAIL:
297
+ return checkEmailDiff(oldData, newData);
298
+ case MOBILE_PUSH:
299
+ case PUSH:
300
+ return checkPushDiff(oldData, newData);
301
+ case WHATSAPP:
302
+ return checkWhatsappDiff(oldData, newData);
303
+ case ZALO:
304
+ return checkZaloDiff(oldData, newData);
305
+ default:
306
+ return false;
307
+ }
308
+ };
236
309
  /**
237
- * General transformer function that handles different channel types
238
- * @param {Object} data - The input data
239
- * @param {Object} options - Additional options for transformation
240
- * @returns {Object} - Transformed payload based on channel type
310
+ * Checks differences between old and new SMS data
311
+ * @param {Object} oldData - Previous SMS template data
312
+ * @param {Object} newData - Updated SMS template data
313
+ * @returns {Boolean} - Whether the template has changed
241
314
  */
242
- export const transformChannelPayload = (data, options = {}) => {
243
- const channel = data.channel?.toUpperCase();
315
+ const checkSmsDiff = (oldData, newData) => {
316
+ // Extract old message content
317
+ const oldMessage =
318
+ oldData?.transformedMessageDetails?.smsMessageContent?.message || "";
244
319
 
245
- switch (channel) {
246
- case "SMS":
247
- return transformSmsPayload(data, options);
248
- case "MOBILEPUSH":
249
- return transformMpushPayload(data, options);
250
- case "EMAIL":
251
- return transformEmailPayload(data, options);
252
- case "WHATSAPP":
253
- return transformWhatsappPayload(data, options);
254
- default:
255
- return data; // Return unchanged for unsupported channels
320
+ // Extract new message content
321
+ const newMessage = newData?.messageBody || "";
322
+
323
+ // Compare message content
324
+ return oldMessage !== newMessage;
325
+ };
326
+ /**
327
+ * Checks differences between old and new Email data
328
+ * @param {Object} oldData - Previous Email template data
329
+ * @param {Object} newData - Updated Email template data
330
+ * @returns {Boolean} - Whether the template has changed
331
+ */
332
+ const checkEmailDiff = (oldData, newData) => {
333
+ // Extract old email content
334
+ const oldEmailBody =
335
+ oldData?.transformedMessageDetails?.emailMessageContent?.messageBody || "";
336
+ const oldEmailSubject =
337
+ oldData?.transformedMessageDetails?.emailMessageContent?.messageSubject ||
338
+ "";
339
+
340
+ // Extract new email content
341
+ const newEmailBody = newData?.emailBody || "";
342
+ const newEmailSubject = newData?.emailSubject || "";
343
+
344
+ // Compare both subject and body
345
+ return oldEmailBody !== newEmailBody || oldEmailSubject !== newEmailSubject;
346
+ };
347
+ /**
348
+ * Checks differences between old and new Push data
349
+ * @param {Object} oldData - Previous Push template data
350
+ * @param {Object} newData - Updated Push template data
351
+ * @returns {Boolean} - Whether the template has changed
352
+ */
353
+ const checkPushDiff = (oldData, newData) => {
354
+ // Extract old push content
355
+ const oldAndroidContent =
356
+ oldData?.transformedMessageDetails?.mpushMessageContent?.androidContent ||
357
+ {};
358
+ const oldIosContent =
359
+ oldData?.transformedMessageDetails?.mpushMessageContent?.iosContent || {};
360
+ const oldSubject =
361
+ oldData?.transformedMessageDetails?.mpushMessageContent?.messageSubject ||
362
+ "";
363
+
364
+ // Extract new push content
365
+ const newAndroidContent = newData?.androidContent || {};
366
+ const newIosContent = newData?.iosContent || {};
367
+ const newSubject = newData?.messageSubject || "";
368
+
369
+ // Compare subject
370
+ if (oldSubject !== newSubject) return true;
371
+
372
+ // Compare Android content
373
+ if (oldAndroidContent.title !== newAndroidContent.title) return true;
374
+ if (oldAndroidContent.message !== newAndroidContent.message) return true;
375
+ if (oldAndroidContent.cta?.actionLink !== newAndroidContent.cta?.actionLink)
376
+ return true;
377
+
378
+ // Compare iOS content
379
+ if (oldIosContent.title !== newIosContent.title) return true;
380
+ if (oldIosContent.message !== newIosContent.message) return true;
381
+ if (oldIosContent.cta?.actionLink !== newIosContent.cta?.actionLink)
382
+ return true;
383
+
384
+ return false;
385
+ };
386
+ /**
387
+ * Checks differences between old and new WhatsApp data
388
+ * @param {Object} oldData - Previous WhatsApp template data
389
+ * @param {Object} newData - Updated WhatsApp template data
390
+ * @returns {Boolean} - Whether the template has changed
391
+ */
392
+ const checkWhatsappDiff = (oldData, newData) => {
393
+ // Extract old WhatsApp content
394
+ const oldMessage =
395
+ oldData?.transformedMessageDetails?.whatsappMessageContent?.messageBody ||
396
+ "";
397
+ const oldTemplateConfigs =
398
+ oldData?.transformedMessageDetails?.whatsappMessageContent
399
+ ?.templateConfigs || {};
400
+
401
+ // Extract new WhatsApp content
402
+ const newMessage = newData?.messageBody || "";
403
+ const newTemplateConfigs = newData?.templateConfigs || {};
404
+
405
+ // Compare message content
406
+ if (oldMessage !== newMessage) return true;
407
+
408
+ // If new data has template configs but old data doesn't, there is a change
409
+ if (
410
+ Object.keys(newTemplateConfigs).length > 0 &&
411
+ Object.keys(oldTemplateConfigs).length === 0
412
+ ) {
413
+ return true;
256
414
  }
415
+
416
+ // If both have template configs, perform detailed comparison
417
+ if (
418
+ Object.keys(newTemplateConfigs).length > 0 &&
419
+ Object.keys(oldTemplateConfigs).length > 0
420
+ ) {
421
+ // Compare template names and IDs
422
+ if (oldTemplateConfigs.id !== newTemplateConfigs.id) return true;
423
+ if (oldTemplateConfigs.name !== newTemplateConfigs.name) return true;
424
+ if (oldTemplateConfigs.template !== newTemplateConfigs.template)
425
+ return true;
426
+
427
+ // Compare template variables
428
+ if (
429
+ JSON.stringify(oldTemplateConfigs.varMapped) !==
430
+ JSON.stringify(newTemplateConfigs.varMapped)
431
+ )
432
+ return true;
433
+
434
+ // Compare media settings
435
+ if (
436
+ JSON.stringify(oldTemplateConfigs.whatsappMedia) !==
437
+ JSON.stringify(newTemplateConfigs.whatsappMedia)
438
+ )
439
+ return true;
440
+
441
+ // Compare other template properties
442
+ if (oldTemplateConfigs.category !== newTemplateConfigs.category)
443
+ return true;
444
+ if (oldTemplateConfigs.language !== newTemplateConfigs.language)
445
+ return true;
446
+ if (oldTemplateConfigs.buttonType !== newTemplateConfigs.buttonType)
447
+ return true;
448
+ if (
449
+ JSON.stringify(oldTemplateConfigs.buttons) !==
450
+ JSON.stringify(newTemplateConfigs.buttons)
451
+ )
452
+ return true;
453
+ }
454
+
455
+ // Check if account details have changed
456
+ if (
457
+ oldData?.transformedMessageDetails?.whatsappMessageContent?.accountId !==
458
+ newData?.accountId
459
+ )
460
+ return true;
461
+ if (
462
+ oldData?.transformedMessageDetails?.whatsappMessageContent
463
+ ?.sourceAccountIdentifier !== newData?.sourceAccountIdentifier
464
+ )
465
+ return true;
466
+
467
+ return false;
468
+ };
469
+ /**
470
+ * Checks differences between old and new Zalo data
471
+ * @param {Object} oldData - Previous Zalo template data
472
+ * @param {Object} newData - Updated Zalo template data
473
+ * @returns {Boolean} - Whether the template has changed
474
+ */
475
+ const checkZaloDiff = (oldData, newData) => {
476
+ // Extract old Zalo content
477
+ const oldTemplateConfigs =
478
+ oldData?.transformedMessageDetails?.zaloMessageContent?.templateConfigs ||
479
+ {};
480
+ const oldAccountId =
481
+ oldData?.transformedMessageDetails?.zaloMessageContent?.accountId || "";
482
+ const oldToken =
483
+ oldData?.transformedMessageDetails?.zaloMessageContent?.token || "";
484
+
485
+ // Extract new Zalo content
486
+ const newTemplateConfigs = newData?.templateConfigs || {};
487
+ const newAccountId = newData?.accountId || "";
488
+ const newToken = newData?.token || "";
489
+
490
+ // Compare account ID
491
+ if (oldAccountId !== newAccountId) return true;
492
+
493
+ // Compare token
494
+ if (oldToken !== newToken) return true;
495
+
496
+ // If new data has template configs but old data doesn't, there is a change
497
+ if (
498
+ Object.keys(newTemplateConfigs).length > 0 &&
499
+ Object.keys(oldTemplateConfigs).length === 0
500
+ ) {
501
+ return true;
502
+ }
503
+
504
+ // If both have template configs, perform detailed comparison
505
+ if (
506
+ Object.keys(newTemplateConfigs).length > 0 &&
507
+ Object.keys(oldTemplateConfigs).length > 0
508
+ ) {
509
+ // Compare template IDs and names
510
+ if (oldTemplateConfigs.id !== newTemplateConfigs.id) return true;
511
+ if (oldTemplateConfigs.name !== newTemplateConfigs.name) return true;
512
+ if (oldTemplateConfigs.template !== newTemplateConfigs.template)
513
+ return true;
514
+
515
+ // Compare template variables
516
+ if (
517
+ JSON.stringify(oldTemplateConfigs.varMapped) !==
518
+ JSON.stringify(newTemplateConfigs.varMapped)
519
+ )
520
+ return true;
521
+ }
522
+
523
+ return false;
257
524
  };
@@ -3877,8 +3877,7 @@ FormBuilder.propTypes = {
3877
3877
  isFullMode: PropTypes.bool,
3878
3878
  currentOrgDetails: PropTypes.object,
3879
3879
  liquidExtractionInProgress: PropTypes.bool,
3880
- showLiquidErrorInFooter: PropTypes.func,
3881
- loyaltyMetaData: PropTypes.object
3880
+ showLiquidErrorInFooter: PropTypes.func
3882
3881
  };
3883
3882
 
3884
3883
  const mapStateToProps = createStructuredSelector({
@@ -189,13 +189,13 @@ const getTopbarData = (parentModule) => {
189
189
  export function* createCentralCommsMetaId(action) {
190
190
  try {
191
191
  const result = yield call(Api.createCentralCommsMetaId, action?.data);
192
- if (result) {
192
+ if (result?.status?.code === 200) {
193
193
  if (action?.callback) {
194
194
  yield call(action?.callback, result);
195
195
  }
196
196
  yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_SUCCESS, result });
197
197
  } else {
198
- yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_FAILURE });
198
+ yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_FAILURE, error: result?.message });
199
199
  }
200
200
  } catch (error) {
201
201
  yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_FAILURE, error });
@@ -517,7 +517,6 @@ export function SlideBoxContent(props) {
517
517
  onCreateComplete={onCreateComplete}
518
518
  smsRegister={smsRegister}
519
519
  eventContextTags={eventContextTags}
520
- loyaltyMetaData={loyaltyMetaData}
521
520
  messageDetails={messageDetails}
522
521
  />
523
522
  )}
@@ -587,7 +586,6 @@ export function SlideBoxContent(props) {
587
586
  smsRegister={smsRegister}
588
587
  onShowTemplates={onShowTemplates}
589
588
  eventContextTags={eventContextTags}
590
- loyaltyMetaData={loyaltyMetaData}
591
589
  messageDetails={messageDetails}
592
590
  />
593
591
  )}
@@ -622,7 +620,6 @@ export function SlideBoxContent(props) {
622
620
  showLiquidErrorInFooter={showLiquidErrorInFooter}
623
621
  eventContextTags={eventContextTags}
624
622
  isLoyaltyModule={isLoyaltyModule}
625
- loyaltyMetaData={loyaltyMetaData}
626
623
  messageDetails={messageDetails}
627
624
  />
628
625
  )}
@@ -654,7 +651,6 @@ export function SlideBoxContent(props) {
654
651
  showLiquidErrorInFooter={showLiquidErrorInFooter}
655
652
  eventContextTags={eventContextTags}
656
653
  isLoyaltyModule={isLoyaltyModule}
657
- loyaltyMetaData={loyaltyMetaData}
658
654
  messageDetails={messageDetails}
659
655
  />
660
656
  )}
@@ -682,7 +678,6 @@ export function SlideBoxContent(props) {
682
678
  hideTestAndPreviewBtn={hideTestAndPreviewBtn}
683
679
  creativesMode={creativesMode}
684
680
  eventContextTags={eventContextTags}
685
- loyaltyMetaData={loyaltyMetaData}
686
681
  messageDetails={messageDetails}
687
682
  />
688
683
  }
@@ -713,7 +708,6 @@ export function SlideBoxContent(props) {
713
708
  hideTestAndPreviewBtn={hideTestAndPreviewBtn}
714
709
  onTestContentClicked={onTestContentClicked}
715
710
  eventContextTags={eventContextTags}
716
- loyaltyMetaData={loyaltyMetaData}
717
711
  messageDetails={messageDetails}
718
712
  />
719
713
  }
@@ -949,6 +943,7 @@ SlideBoxContent.propTypes = {
949
943
  weChatTemplateType: PropTypes.string,
950
944
  onWechatTemplateChange: PropTypes.func,
951
945
  selectedWeChatAccount: PropTypes.object,
946
+ loyaltyMetaData: PropTypes.object,
952
947
  onWeChatMaptemplateStepChange: PropTypes.func,
953
948
  weChatMaptemplateStep: PropTypes.string,
954
949
  onFacebookSubmit: PropTypes.func,
@@ -965,6 +960,6 @@ SlideBoxContent.propTypes = {
965
960
  moduleType: PropTypes.string,
966
961
  showLiquidErrorInFooter: PropTypes.bool,
967
962
  creativesMode: PropTypes.string,
968
- hostName: PropTypes.string,
963
+ hostName: PropTypes.string
969
964
  };
970
965
  export default SlideBoxContent;
@@ -17,7 +17,7 @@ export const FTP = "FTP";
17
17
  export const NO_COMMUNICATION = "NO_COMMUNICATION";
18
18
  export const VIBER = "VIBER";
19
19
  export const WHATSAPP = "WHATSAPP";
20
- export const SMALL_CASE_WHATSAPP = "whatsapp";
20
+ export const PUSH = "PUSH";
21
21
  export const RCS = "RCS";
22
22
  export const ZALO = "ZALO";
23
23
  export const INAPP = "INAPP";
@@ -25,6 +25,8 @@ export const PREVIEW = "preview";
25
25
  export const EDIT_TEMPLATE = "editTemplate";
26
26
  export const JOURNEY = "journey";
27
27
 
28
+ export const LOYALTY_SUPPORTED_ACTION = "SEND_COMMUNICATION_ACTION";
29
+
28
30
  export const SHOW_CONTANER_LOADER = "app/CreativesContainer/SHOW_CONTANER_LOADER";
29
31
  export const HIDE_CONTAINER_LOADER = "app/CreativesContainer/HIDE_CONTAINER_LOADER";
30
32
 
@@ -59,7 +59,10 @@ import {
59
59
  } from '@capillarytech/cap-ui-library/styled/variables';
60
60
  import { DAEMON } from '@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes';
61
61
 
62
- import { transformChannelPayload } from "../../utils/transformerUtils";
62
+ import {
63
+ transformChannelPayload,
64
+ // getTemplateDiffState
65
+ } from "../../utils/transformerUtils";
63
66
 
64
67
  const classPrefix = 'add-creatives-section';
65
68
  const CREATIVES_CONTAINER = 'creativesContainer';
@@ -459,8 +462,8 @@ export class Creatives extends React.Component {
459
462
  };
460
463
  break;
461
464
  }
462
- case constants.SMALL_CASE_WHATSAPP:
463
- case constants.WHATSAPP: {
465
+ case constants.WHATSAPP:
466
+ case constants.WHATSAPP?.toLowerCase(): {
464
467
  const {
465
468
  messageBody = '',
466
469
  templateConfigs: {
@@ -1030,13 +1033,19 @@ export class Creatives extends React.Component {
1030
1033
  processCentralCommsMetaId = (channel, creativesData) => {
1031
1034
  // Create the payload for the centralcommnsmetaId API call
1032
1035
  const { isLoyaltyModule, loyaltyMetaData } = this.props;
1033
- const { actionName, setMetaId = () => {} } = this.props.loyaltyMetaData;
1036
+ const { actionName, setMetaId = () => {} } = this.props.loyaltyMetaData || {};
1034
1037
  const { formatMessage } = this.props.intl;
1035
1038
 
1039
+ // const isTemplateModified = getTemplateDiffState(
1040
+ // channel,
1041
+ // loyaltyMetaData,
1042
+ // creativesData
1043
+ // );
1036
1044
  if (
1037
1045
  loyaltyMetaData
1038
1046
  && isLoyaltyModule
1039
- && actionName === "SEND_COMMUNICATION_ACTION"
1047
+ // && isTemplateModified
1048
+ && actionName === constants.LOYALTY_SUPPORTED_ACTION
1040
1049
  ) {
1041
1050
  const payload = transformChannelPayload(creativesData, {
1042
1051
  channel,
@@ -1045,7 +1054,7 @@ export class Creatives extends React.Component {
1045
1054
 
1046
1055
  // Callback function to handle API response
1047
1056
  const handleMetaIDResult = (result) => {
1048
- if (result.status.code === 200) {
1057
+ if (result?.status?.code === 200) {
1049
1058
  setMetaId(result?.response?.data?.id);
1050
1059
  this.props.getCreativesData(creativesData);
1051
1060
  } else {
@@ -2748,7 +2748,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2748
2748
  forwardedTags={this.props?.forwardedTags}
2749
2749
  isLoyaltyModule={this.props?.isLoyaltyModule}
2750
2750
  messageDetails={this.props?.messageDetails}
2751
- loyaltyMetaData={this.props?.loyaltyMetaData}
2752
2751
  /> : ''}
2753
2752
  </Col>
2754
2753
  </Row>
@@ -229,7 +229,6 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
229
229
  eventContextTags,
230
230
  // Flag to enable loyalty module specific features in the email editor
231
231
  isLoyaltyModule,
232
- loyaltyMetaData = {},
233
232
  messageDetails = {},
234
233
  } = this.props;
235
234
  const {
@@ -305,7 +304,6 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
305
304
  moduleType={moduleType}
306
305
  eventContextTags={eventContextTags}
307
306
  isLoyaltyModule={isLoyaltyModule}
308
- loyaltyMetaData={loyaltyMetaData}
309
307
  messageDetails={messageDetails}
310
308
  />}
311
309
  {!isShowEmailCreate && (
@@ -1809,7 +1809,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1809
1809
  hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
1810
1810
  isFullMode={this.props.isFullMode}
1811
1811
  eventContextTags={this.props?.eventContextTags}
1812
- loyaltyMetaData={this.props?.loyaltyMetaData}
1813
1812
  messageDetails={this.props?.messageDetails}
1814
1813
  />
1815
1814
  </CapColumn>
@@ -1991,7 +1991,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1991
1991
  hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
1992
1992
  isFullMode={this.props.isFullMode}
1993
1993
  eventContextTags={this.props?.eventContextTags}
1994
- loyaltyMetaData={this.props?.loyaltyMetaData}
1995
1994
  messageDetails={this.props?.messageDetails}
1996
1995
  />}
1997
1996
  </CapColumn>
@@ -72,7 +72,7 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
72
72
  }
73
73
 
74
74
  render() {
75
- const {mobilePushCreateMode, step, getFormData, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail, onPreviewContentClicked, onTestContentClicked, templateData, eventContextTags = [], loyaltyMetaData = {}, messageDetails = {}} = this.props;
75
+ const {mobilePushCreateMode, step, getFormData, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail, onPreviewContentClicked, onTestContentClicked, templateData, eventContextTags = [], messageDetails = {}} = this.props;
76
76
  const {templateName} = this.state;
77
77
  const isShowMobilepushCreate = !isEmpty(mobilePushCreateMode);
78
78
  return (
@@ -120,7 +120,6 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
120
120
  templateData={templateData}
121
121
  hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
122
122
  eventContextTags={eventContextTags}
123
- loyaltyMetaData={loyaltyMetaData}
124
123
  messageDetails={messageDetails}
125
124
  />
126
125
 
@@ -994,7 +994,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
994
994
  onTestContentClicked={this.props.onTestContentClicked}
995
995
  onPreviewContentClicked={this.props.onPreviewContentClicked}
996
996
  eventContextTags={this.props?.eventContextTags}
997
- loyaltyMetaData={this.props?.loyaltyMetaData}
998
997
  messageDetails={this.props?.messageDetails}
999
998
  />
1000
999
  </CapColumn>
@@ -992,7 +992,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
992
992
  onPreviewContentClicked={this.props.onPreviewContentClicked}
993
993
  onTestContentClicked={this.props.onTestContentClicked}
994
994
  eventContextTags={this.props?.eventContextTags}
995
- loyaltyMetaData={this.props?.loyaltyMetaData}
996
995
  messageDetails={this.props?.messageDetails}
997
996
  />
998
997
  </CapColumn>
@@ -30,7 +30,6 @@ const SmsWrapper = (props) => {
30
30
  smsRegister,
31
31
  onShowTemplates,
32
32
  eventContextTags,
33
- loyaltyMetaData = {},
34
33
  messageDetails = {},
35
34
  } = props;
36
35
 
@@ -48,7 +47,6 @@ const SmsWrapper = (props) => {
48
47
  onPreviewContentClicked,
49
48
  onTestContentClicked,
50
49
  eventContextTags,
51
- loyaltyMetaData,
52
50
  messageDetails,
53
51
  };
54
52
  const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
@@ -102,7 +102,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
102
102
 
103
103
  const { actionName = ''} = loyaltyMetaData;
104
104
  if (isLoyaltyModule && actionName === 'SEND_COMMUNICATION_ACTION') {
105
- commonChannels.push('whatsapp');
105
+ commonChannels.push('whatsapp', 'zalo');
106
106
  }
107
107
 
108
108
  // we only show channels which other than commonChannels