@capillarytech/creatives-library 8.0.108 → 8.0.109
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 -4
- package/utils/cdnTransformation.js +1 -1
- package/utils/tests/__snapshots__/cdnTransformation.test.js.snap +9 -9
- package/utils/tests/cdnTransformation.mockdata.js +27 -28
- package/utils/tests/transformerUtils.test.js +2127 -0
- package/utils/transformerUtils.js +421 -0
- package/v2Components/FormBuilder/index.js +7 -3
- 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/Cap/tests/saga.test.js +90 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +5 -1
- package/v2Containers/CreativesContainer/constants.js +14 -1
- package/v2Containers/CreativesContainer/index.js +50 -2
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +2 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +25 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +2 -0
- package/v2Containers/MobilePush/Create/index.js +1 -0
- package/v2Containers/Sms/Edit/index.js +1 -0
- package/v2Containers/TemplatesV2/index.js +8 -1
- package/v2Containers/Whatsapp/constants.js +2 -0
- package/v2Containers/Whatsapp/index.js +7 -3
- package/v2Containers/Zalo/index.js +5 -2
- package/v2Containers/mockdata.js +3 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
// Import channel constants from the existing constants file
|
|
2
|
+
import { isEqual } from "lodash";
|
|
3
|
+
import {
|
|
4
|
+
SMS,
|
|
5
|
+
EMAIL,
|
|
6
|
+
MOBILE_PUSH,
|
|
7
|
+
WHATSAPP,
|
|
8
|
+
PUSH,
|
|
9
|
+
ZALO,
|
|
10
|
+
EMF,
|
|
11
|
+
VENENO,
|
|
12
|
+
TEXT,
|
|
13
|
+
IOS,
|
|
14
|
+
ANDROID,
|
|
15
|
+
EXTERNAL_URL,
|
|
16
|
+
BIG_TEXT
|
|
17
|
+
} from "../v2Containers/CreativesContainer/constants";
|
|
18
|
+
|
|
19
|
+
// Creates a base payload structure common to all channels
|
|
20
|
+
const createBasePayload = (channelType, metadata = {}) => {
|
|
21
|
+
const { actionId, ouId, clientName, module } = metadata;
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
centralCommsPayload: {
|
|
25
|
+
ouId: ouId || -1,
|
|
26
|
+
sourceEntityId: actionId,
|
|
27
|
+
channel: channelType,
|
|
28
|
+
module,
|
|
29
|
+
executionParams: {},
|
|
30
|
+
clientName:
|
|
31
|
+
clientName || ([SMS, EMAIL].includes(channelType) ? EMF : VENENO)
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Transforms the channel payload based on the channel type
|
|
37
|
+
/**
|
|
38
|
+
* General transformer function that handles different channel types
|
|
39
|
+
* @param {Object} data - The input data
|
|
40
|
+
* @param {Object} options - Additional options for transformation
|
|
41
|
+
* @returns {Object} - Transformed payload based on channel type
|
|
42
|
+
*/
|
|
43
|
+
export const transformChannelPayload = (data, options = {}) => {
|
|
44
|
+
const channel = data.channel?.toUpperCase();
|
|
45
|
+
|
|
46
|
+
switch (channel) {
|
|
47
|
+
case SMS:
|
|
48
|
+
return transformSmsPayload(data, options);
|
|
49
|
+
case MOBILE_PUSH:
|
|
50
|
+
return transformMpushPayload(data, options);
|
|
51
|
+
case EMAIL:
|
|
52
|
+
return transformEmailPayload(data, options);
|
|
53
|
+
case WHATSAPP:
|
|
54
|
+
return transformWhatsappPayload(data, options);
|
|
55
|
+
case ZALO:
|
|
56
|
+
return transformZaloPayload(data, options);
|
|
57
|
+
default:
|
|
58
|
+
return data; // Return unchanged for unsupported channels
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Transforms SMS data to the required payload format
|
|
63
|
+
* @param {Object} smsData - Current SMS data
|
|
64
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
65
|
+
* @returns {Object} - Transformed SMS payload
|
|
66
|
+
*/
|
|
67
|
+
const transformSmsPayload = (smsData, options = {}) => {
|
|
68
|
+
const { loyaltyMetaData = {} } = options;
|
|
69
|
+
const { transformedMessageDetails = {} } = loyaltyMetaData;
|
|
70
|
+
const { smsDeliverySettings } = transformedMessageDetails;
|
|
71
|
+
|
|
72
|
+
// Get base payload structure
|
|
73
|
+
const payload = createBasePayload(SMS, loyaltyMetaData);
|
|
74
|
+
|
|
75
|
+
// Add SMS-specific properties
|
|
76
|
+
payload.centralCommsPayload.smsMessageContent = {
|
|
77
|
+
channel: SMS,
|
|
78
|
+
// Override the message property if messageBody exists
|
|
79
|
+
message: smsData?.messageBody || "",
|
|
80
|
+
...smsData
|
|
81
|
+
};
|
|
82
|
+
payload.centralCommsPayload.smsDeliverySettings = smsDeliverySettings || {};
|
|
83
|
+
|
|
84
|
+
return payload;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Transforms Email data to the required payload format
|
|
88
|
+
* @param {Object} emailData - Current email data
|
|
89
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
90
|
+
* @returns {Object} - Transformed Email payload
|
|
91
|
+
*/
|
|
92
|
+
const transformEmailPayload = (emailData, options = {}) => {
|
|
93
|
+
const { loyaltyMetaData = {} } = options;
|
|
94
|
+
const { transformedMessageDetails = {} } = loyaltyMetaData;
|
|
95
|
+
const { emailDeliverySettings = {} } = transformedMessageDetails;
|
|
96
|
+
|
|
97
|
+
// Get base payload structure
|
|
98
|
+
const payload = createBasePayload(EMAIL, loyaltyMetaData);
|
|
99
|
+
|
|
100
|
+
// Add Email-specific properties
|
|
101
|
+
payload.centralCommsPayload.emailMessageContent = {
|
|
102
|
+
channel: EMAIL,
|
|
103
|
+
messageBody: emailData?.emailBody || "",
|
|
104
|
+
messageSubject: emailData?.emailSubject || "",
|
|
105
|
+
...emailData
|
|
106
|
+
};
|
|
107
|
+
payload.centralCommsPayload.emailDeliverySettings =
|
|
108
|
+
emailDeliverySettings || {};
|
|
109
|
+
|
|
110
|
+
return payload;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Transforms Mobile Push data to the required payload format
|
|
114
|
+
* @param {Object} mpushData - Current mobile push data
|
|
115
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
116
|
+
* @returns {Object} - Transformed Mobile Push payload
|
|
117
|
+
*/
|
|
118
|
+
const transformMpushPayload = (mpushData, options = {}) => {
|
|
119
|
+
const { loyaltyMetaData = {} } = options;
|
|
120
|
+
const { transformedMessageDetails = {} } = loyaltyMetaData;
|
|
121
|
+
const { mobilePushDeliverySettings = {} } = transformedMessageDetails;
|
|
122
|
+
|
|
123
|
+
// Get default values for Android and iOS content
|
|
124
|
+
const androidContent = mpushData?.androidContent || {};
|
|
125
|
+
const iosContent = mpushData?.iosContent || {
|
|
126
|
+
type: androidContent?.type || TEXT,
|
|
127
|
+
deviceType: IOS,
|
|
128
|
+
title: mpushData?.messageSubject || "",
|
|
129
|
+
message: ""
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// Get base payload structure
|
|
133
|
+
const payload = createBasePayload(PUSH, loyaltyMetaData);
|
|
134
|
+
|
|
135
|
+
// Add Mobile Push-specific properties with spread operator
|
|
136
|
+
payload.centralCommsPayload.mpushMessageContent = {
|
|
137
|
+
channel: PUSH,
|
|
138
|
+
messageSubject: mpushData?.messageSubject || "",
|
|
139
|
+
androidContent: {
|
|
140
|
+
type: TEXT,
|
|
141
|
+
deviceType: ANDROID,
|
|
142
|
+
...androidContent,
|
|
143
|
+
cta: {
|
|
144
|
+
type: EXTERNAL_URL,
|
|
145
|
+
actionText: null,
|
|
146
|
+
templateCtaId: null,
|
|
147
|
+
...(androidContent?.cta || {})
|
|
148
|
+
},
|
|
149
|
+
expandableDetails: {
|
|
150
|
+
style: BIG_TEXT,
|
|
151
|
+
...androidContent?.expandableDetails
|
|
152
|
+
},
|
|
153
|
+
customProperties: androidContent?.custom || {}
|
|
154
|
+
},
|
|
155
|
+
iosContent: {
|
|
156
|
+
type: TEXT,
|
|
157
|
+
deviceType: IOS,
|
|
158
|
+
...iosContent,
|
|
159
|
+
cta: {
|
|
160
|
+
type: EXTERNAL_URL,
|
|
161
|
+
actionText: null,
|
|
162
|
+
templateCtaId: null,
|
|
163
|
+
...(iosContent?.cta || {})
|
|
164
|
+
},
|
|
165
|
+
expandableDetails: {
|
|
166
|
+
style: BIG_TEXT,
|
|
167
|
+
...iosContent?.expandableDetails
|
|
168
|
+
},
|
|
169
|
+
customProperties: iosContent?.custom || {}
|
|
170
|
+
},
|
|
171
|
+
accountId: mpushData?.accountId || 0
|
|
172
|
+
};
|
|
173
|
+
payload.centralCommsPayload.mpushDeliverySettings =
|
|
174
|
+
mobilePushDeliverySettings || {};
|
|
175
|
+
|
|
176
|
+
return payload;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Transforms WhatsApp data to the required payload format
|
|
180
|
+
* @param {Object} whatsappData - Current WhatsApp data
|
|
181
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
182
|
+
* @returns {Object} - Transformed WhatsApp payload
|
|
183
|
+
*/
|
|
184
|
+
const transformWhatsappPayload = (whatsappData, options = {}) => {
|
|
185
|
+
const { loyaltyMetaData = {} } = options;
|
|
186
|
+
const { transformedMessageDetails = {} } = loyaltyMetaData;
|
|
187
|
+
const { whatsappDeliverySettings = {} } = transformedMessageDetails;
|
|
188
|
+
|
|
189
|
+
// Get base payload structure
|
|
190
|
+
const payload = createBasePayload(WHATSAPP, loyaltyMetaData);
|
|
191
|
+
|
|
192
|
+
// Add WhatsApp-specific properties
|
|
193
|
+
payload.centralCommsPayload.whatsappMessageContent = {
|
|
194
|
+
channel: WHATSAPP,
|
|
195
|
+
messageBody: "",
|
|
196
|
+
...whatsappData,
|
|
197
|
+
// Ensure templateConfigs is preserved (it might contain complex nested objects)
|
|
198
|
+
templateConfigs: whatsappData?.templateConfigs || {}
|
|
199
|
+
};
|
|
200
|
+
payload.centralCommsPayload.whatsappDeliverySettings =
|
|
201
|
+
whatsappDeliverySettings || {};
|
|
202
|
+
|
|
203
|
+
return payload;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Transforms Zalo data to the required payload format
|
|
207
|
+
* @param {Object} zaloData - Current Zalo data
|
|
208
|
+
* @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
|
|
209
|
+
* @returns {Object} - Transformed Zalo payload
|
|
210
|
+
*/
|
|
211
|
+
const transformZaloPayload = (zaloData, options = {}) => {
|
|
212
|
+
const { loyaltyMetaData = {} } = options;
|
|
213
|
+
const { transformedMessageDetails = {} } = loyaltyMetaData;
|
|
214
|
+
const { zaloDeliverySettings = {} } = transformedMessageDetails;
|
|
215
|
+
|
|
216
|
+
// Get base payload structure
|
|
217
|
+
const payload = createBasePayload(ZALO, loyaltyMetaData);
|
|
218
|
+
|
|
219
|
+
// Add Zalo-specific properties
|
|
220
|
+
payload.centralCommsPayload.zaloMessageContent = {
|
|
221
|
+
channel: ZALO,
|
|
222
|
+
messageBody: "",
|
|
223
|
+
accountId: "",
|
|
224
|
+
accountName: "",
|
|
225
|
+
token: "",
|
|
226
|
+
...zaloData,
|
|
227
|
+
// Ensure templateConfigs is preserved (it might contain complex nested objects)
|
|
228
|
+
templateConfigs: zaloData?.templateConfigs || {}
|
|
229
|
+
};
|
|
230
|
+
payload.centralCommsPayload.zaloDeliverySettings = zaloDeliverySettings || {};
|
|
231
|
+
|
|
232
|
+
return payload;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// Checks if the template has changed
|
|
236
|
+
export const getTemplateDiffState = (channel, oldData, newData) => {
|
|
237
|
+
switch (channel.toUpperCase()) {
|
|
238
|
+
case SMS:
|
|
239
|
+
return checkSmsDiff(oldData, newData);
|
|
240
|
+
case EMAIL:
|
|
241
|
+
return checkEmailDiff(oldData, newData);
|
|
242
|
+
case MOBILE_PUSH:
|
|
243
|
+
case PUSH:
|
|
244
|
+
return checkPushDiff(oldData, newData);
|
|
245
|
+
case WHATSAPP:
|
|
246
|
+
return checkWhatsappDiff(oldData, newData);
|
|
247
|
+
case ZALO:
|
|
248
|
+
return checkZaloDiff(oldData, newData);
|
|
249
|
+
default:
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Checks differences between old and new SMS data
|
|
255
|
+
* @param {Object} oldData - Previous SMS template data
|
|
256
|
+
* @param {Object} newData - Updated SMS template data
|
|
257
|
+
* @returns {Boolean} - Whether the template has changed
|
|
258
|
+
*/
|
|
259
|
+
const checkSmsDiff = (oldData, newData) => {
|
|
260
|
+
// Extract old message content
|
|
261
|
+
const oldMessage =
|
|
262
|
+
oldData?.transformedMessageDetails?.smsMessageContent?.message || "";
|
|
263
|
+
|
|
264
|
+
// Extract new message content
|
|
265
|
+
const newMessage = newData?.messageBody || "";
|
|
266
|
+
|
|
267
|
+
// Compare message content
|
|
268
|
+
return oldMessage !== newMessage;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Checks differences between old and new Email data
|
|
272
|
+
* @param {Object} oldData - Previous Email template data
|
|
273
|
+
* @param {Object} newData - Updated Email template data
|
|
274
|
+
* @returns {Boolean} - Whether the template has changed
|
|
275
|
+
*/
|
|
276
|
+
const checkEmailDiff = (oldData, newData) => {
|
|
277
|
+
// Extract old email content
|
|
278
|
+
const oldEmailBody =
|
|
279
|
+
oldData?.transformedMessageDetails?.emailMessageContent?.messageBody || "";
|
|
280
|
+
const oldEmailSubject =
|
|
281
|
+
oldData?.transformedMessageDetails?.emailMessageContent?.messageSubject ||
|
|
282
|
+
"";
|
|
283
|
+
|
|
284
|
+
// Extract new email content
|
|
285
|
+
const newEmailBody = newData?.emailBody || "";
|
|
286
|
+
const newEmailSubject = newData?.emailSubject || "";
|
|
287
|
+
|
|
288
|
+
// Check if subject has changed
|
|
289
|
+
if (oldEmailSubject !== newEmailSubject) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Use lodash's isEqual for deep comparison of email body content --> more efficient for complex HTML content
|
|
294
|
+
return !isEqual(oldEmailBody, newEmailBody);
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Checks differences between old and new Push data
|
|
298
|
+
* @param {Object} oldData - Previous Push template data
|
|
299
|
+
* @param {Object} newData - Updated Push template data
|
|
300
|
+
* @returns {Boolean} - Whether the template has changed
|
|
301
|
+
*/
|
|
302
|
+
const checkPushDiff = (oldData, newData) => {
|
|
303
|
+
// Extract old push content
|
|
304
|
+
const oldAndroidContent =
|
|
305
|
+
oldData?.transformedMessageDetails?.mpushMessageContent?.androidContent ||
|
|
306
|
+
{};
|
|
307
|
+
const oldIosContent =
|
|
308
|
+
oldData?.transformedMessageDetails?.mpushMessageContent?.iosContent || {};
|
|
309
|
+
const oldSubject =
|
|
310
|
+
oldData?.transformedMessageDetails?.mpushMessageContent?.messageSubject ||
|
|
311
|
+
"";
|
|
312
|
+
|
|
313
|
+
// Extract new push content
|
|
314
|
+
const newAndroidContent = newData?.androidContent || {};
|
|
315
|
+
const newIosContent = newData?.iosContent || {};
|
|
316
|
+
const newSubject = newData?.messageSubject || "";
|
|
317
|
+
|
|
318
|
+
// Compare subject
|
|
319
|
+
if (oldSubject !== newSubject) return true;
|
|
320
|
+
|
|
321
|
+
// Compare Android content
|
|
322
|
+
if (oldAndroidContent.title !== newAndroidContent.title) return true;
|
|
323
|
+
if (oldAndroidContent.message !== newAndroidContent.message) return true;
|
|
324
|
+
if (oldAndroidContent.cta?.actionLink !== newAndroidContent.cta?.actionLink) {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Compare iOS content
|
|
329
|
+
if (oldIosContent.title !== newIosContent.title) return true;
|
|
330
|
+
if (oldIosContent.message !== newIosContent.message) return true;
|
|
331
|
+
if (oldIosContent.cta?.actionLink !== newIosContent.cta?.actionLink) {
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return false;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* Checks differences between old and new WhatsApp data
|
|
339
|
+
* @param {Object} oldData - Previous WhatsApp template data
|
|
340
|
+
* @param {Object} newData - Updated WhatsApp template data
|
|
341
|
+
* @returns {Boolean} - Whether the template has changed
|
|
342
|
+
*/
|
|
343
|
+
const checkWhatsappDiff = (oldData, newData) => {
|
|
344
|
+
// Extract old WhatsApp content
|
|
345
|
+
const oldMessage =
|
|
346
|
+
oldData?.transformedMessageDetails?.whatsappMessageContent?.messageBody ||
|
|
347
|
+
"";
|
|
348
|
+
const oldTemplateConfigs =
|
|
349
|
+
oldData?.transformedMessageDetails?.whatsappMessageContent
|
|
350
|
+
?.templateConfigs || {};
|
|
351
|
+
|
|
352
|
+
// Extract new WhatsApp content
|
|
353
|
+
const newMessage = newData?.messageBody || "";
|
|
354
|
+
const newTemplateConfigs = newData?.templateConfigs || {};
|
|
355
|
+
|
|
356
|
+
// Compare message content
|
|
357
|
+
if (oldMessage !== newMessage) return true;
|
|
358
|
+
|
|
359
|
+
// Compare account IDs for quick rejection
|
|
360
|
+
if (
|
|
361
|
+
oldData?.transformedMessageDetails?.whatsappMessageContent?.accountId !==
|
|
362
|
+
newData?.accountId
|
|
363
|
+
) {
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Compare source account identifiers for quick rejection
|
|
368
|
+
if (
|
|
369
|
+
oldData?.transformedMessageDetails?.whatsappMessageContent
|
|
370
|
+
?.sourceAccountIdentifier !== newData?.sourceAccountIdentifier
|
|
371
|
+
) {
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// If template configs have different structures, they've changed
|
|
376
|
+
if (
|
|
377
|
+
Object.keys(newTemplateConfigs).length !==
|
|
378
|
+
Object.keys(oldTemplateConfigs).length
|
|
379
|
+
) {
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Use deep comparison for template configs
|
|
384
|
+
return !isEqual(oldTemplateConfigs, newTemplateConfigs);
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Checks differences between old and new Zalo data
|
|
388
|
+
* @param {Object} oldData - Previous Zalo template data
|
|
389
|
+
* @param {Object} newData - Updated Zalo template data
|
|
390
|
+
* @returns {Boolean} - Whether the template has changed
|
|
391
|
+
*/
|
|
392
|
+
const checkZaloDiff = (oldData, newData) => {
|
|
393
|
+
// Extract old Zalo content
|
|
394
|
+
const oldTemplateConfigs =
|
|
395
|
+
oldData?.transformedMessageDetails?.zaloMessageContent?.templateConfigs ||
|
|
396
|
+
{};
|
|
397
|
+
const oldAccountId =
|
|
398
|
+
oldData?.transformedMessageDetails?.zaloMessageContent?.accountId || "";
|
|
399
|
+
const oldToken =
|
|
400
|
+
oldData?.transformedMessageDetails?.zaloMessageContent?.token || "";
|
|
401
|
+
|
|
402
|
+
// Extract new Zalo content
|
|
403
|
+
const newTemplateConfigs = newData?.templateConfigs || {};
|
|
404
|
+
const newAccountId = newData?.accountId || "";
|
|
405
|
+
const newToken = newData?.token || "";
|
|
406
|
+
|
|
407
|
+
// Compare simple properties for quick rejection
|
|
408
|
+
if (oldAccountId !== newAccountId) return true;
|
|
409
|
+
if (oldToken !== newToken) return true;
|
|
410
|
+
|
|
411
|
+
// If template configs have different structures, they've changed
|
|
412
|
+
if (
|
|
413
|
+
Object.keys(newTemplateConfigs).length !==
|
|
414
|
+
Object.keys(oldTemplateConfigs).length
|
|
415
|
+
) {
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Use deep comparison for template configs
|
|
420
|
+
return !isEqual(oldTemplateConfigs, newTemplateConfigs);
|
|
421
|
+
};
|
|
@@ -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, selectMetaDataStatus } 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 { GLOBAL_CONVERT_OPTIONS, 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.metaDataStatus === 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
|
+
metaDataStatus: "",
|
|
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
|
+
metaDataStatus: selectMetaDataStatus(),
|
|
3883
3887
|
metaEntities: makeSelectMetaEntities(),
|
|
3884
3888
|
});
|
|
3885
3889
|
|
|
@@ -63,3 +63,7 @@ export const DEFAULT_MODULE = 'creatives';
|
|
|
63
63
|
export const GET_LIQUID_TAGS_FAILURE = 'cap/GET_LIQUID_TAGS_FAILURE_V2';
|
|
64
64
|
export const GET_LIQUID_TAGS_REQUEST = 'cap/GET_LIQUID_TAGS_REQUEST_V2';
|
|
65
65
|
export const GET_LIQUID_TAGS_SUCCESS = 'cap/GET_LIQUID_TAGS_SUCCESS_V2';
|
|
66
|
+
|
|
67
|
+
export const CREATE_CENTRAL_COMMS_META_ID_FAILURE = 'cap/CREATE_CENTRAL_COMMS_META_ID_FAILURE_V2';
|
|
68
|
+
export const CREATE_CENTRAL_COMMS_META_ID_REQUEST = 'cap/CREATE_CENTRAL_COMMS_META_ID_REQUEST_V2';
|
|
69
|
+
export const CREATE_CENTRAL_COMMS_META_ID_SUCCESS = 'cap/CREATE_CENTRAL_COMMS_META_ID_SUCCESS_V2';
|
|
@@ -199,6 +199,12 @@ function capReducer(state = fromJS(initialState.cap), action) {
|
|
|
199
199
|
return state
|
|
200
200
|
.set('demoVideoAndLinkJSONStatus', types.FAILURE)
|
|
201
201
|
.set('demoVideoAndLinkJSONError', action?.error);
|
|
202
|
+
case types.CREATE_CENTRAL_COMMS_META_ID_REQUEST:
|
|
203
|
+
return state.set('metaDataStatus', types.REQUEST);
|
|
204
|
+
case types.CREATE_CENTRAL_COMMS_META_ID_SUCCESS:
|
|
205
|
+
return state.set('metaDataStatus', types.SUCCESS);
|
|
206
|
+
case types.CREATE_CENTRAL_COMMS_META_ID_FAILURE:
|
|
207
|
+
return state.set('metaDataStatus', types.FAILURE);
|
|
202
208
|
default:
|
|
203
209
|
return state;
|
|
204
210
|
}
|
|
@@ -186,6 +186,22 @@ const getTopbarData = (parentModule) => {
|
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
+
export function* createCentralCommsMetaId(action) {
|
|
190
|
+
try {
|
|
191
|
+
const result = yield call(Api.createCentralCommsMetaId, action?.data);
|
|
192
|
+
if (result?.status?.code === 200) {
|
|
193
|
+
if (action?.callback) {
|
|
194
|
+
yield call(action?.callback, result);
|
|
195
|
+
}
|
|
196
|
+
yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_SUCCESS, result });
|
|
197
|
+
} else {
|
|
198
|
+
yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_FAILURE, error: result?.message });
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_FAILURE, error });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
189
205
|
function* getTopbarMenuData(params) {
|
|
190
206
|
const {parentModule} = params;
|
|
191
207
|
try {
|
|
@@ -225,6 +241,10 @@ export function* watchLiquidEntity() {
|
|
|
225
241
|
yield takeLatest(types.GET_LIQUID_TAGS_REQUEST, getLiquidTags);
|
|
226
242
|
}
|
|
227
243
|
|
|
244
|
+
export function* watchMetaId() {
|
|
245
|
+
yield takeLatest(types.CREATE_CENTRAL_COMMS_META_ID_REQUEST, createCentralCommsMetaId);
|
|
246
|
+
}
|
|
247
|
+
|
|
228
248
|
function* watchForOrgChange() {
|
|
229
249
|
yield takeLatest(types.SWITCH_ORG_REQUEST, switchOrg);
|
|
230
250
|
}
|
|
@@ -257,6 +277,7 @@ export default [
|
|
|
257
277
|
watchGetTopbarMenuData,
|
|
258
278
|
watchForGetVideosConfig,
|
|
259
279
|
watchLiquidEntity,
|
|
280
|
+
watchMetaId,
|
|
260
281
|
];
|
|
261
282
|
|
|
262
283
|
|
|
@@ -268,6 +289,7 @@ export function* capSagaForFetchSchemaForEntity() {
|
|
|
268
289
|
export function* capSagaLiquidEntity() {
|
|
269
290
|
yield all([
|
|
270
291
|
watchLiquidEntity(),
|
|
292
|
+
watchMetaId(),
|
|
271
293
|
]);
|
|
272
294
|
};
|
|
273
295
|
|
|
@@ -279,5 +301,6 @@ export function* v2CapSagas() {
|
|
|
279
301
|
watchForFetchUserInfo(),
|
|
280
302
|
watchGetTopbarMenuData(),
|
|
281
303
|
watchForGetVideosConfig(),
|
|
304
|
+
watchMetaId(),
|
|
282
305
|
]);
|
|
283
306
|
}
|
|
@@ -72,6 +72,11 @@ const selectLiquidStateDetails = () => createSelector(
|
|
|
72
72
|
(globalState) => globalState.get('fetchingLiquidTags')
|
|
73
73
|
);
|
|
74
74
|
|
|
75
|
+
const selectMetaDataStatus = () => createSelector(
|
|
76
|
+
selectCapDomain,
|
|
77
|
+
(globalState) => globalState.get('metaDataStatus')
|
|
78
|
+
);
|
|
79
|
+
|
|
75
80
|
const makeSelectFetchingSchema = () => createSelector(
|
|
76
81
|
selectCapDomain,
|
|
77
82
|
(globalState) => globalState.get('fetchingSchema')
|
|
@@ -113,4 +118,5 @@ export {
|
|
|
113
118
|
makeSelectFetchingSchemaError,
|
|
114
119
|
makeSelectDemoVideoAndLink,
|
|
115
120
|
selectLiquidStateDetails,
|
|
121
|
+
selectMetaDataStatus,
|
|
116
122
|
};
|
|
@@ -40,6 +40,7 @@ exports[`<Cap /> should render correct component 1`] = `
|
|
|
40
40
|
"changeOrg": [Function],
|
|
41
41
|
"clearMetaEntities": [Function],
|
|
42
42
|
"clearTopbarMenuData": [Function],
|
|
43
|
+
"createCentralCommsMetaId": [Function],
|
|
43
44
|
"fetchSchemaForEntity": [Function],
|
|
44
45
|
"getLiquidTags": [Function],
|
|
45
46
|
"getSupportVideosConfig": [Function],
|