@capillarytech/creatives-library 8.0.99 → 8.0.100
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
|
@@ -52,7 +52,7 @@ import { checkSupport, extractNames, preprocessHtml, validateIfTagClosed } from
|
|
|
52
52
|
import { SMS, MOBILE_PUSH, LINE, ENABLE_AI_SUGGESTIONS,AI_CONTENT_BOT_DISABLED, EMAIL, LIQUID_SUPPORTED_CHANNELS } from '../../v2Containers/CreativesContainer/constants';
|
|
53
53
|
import globalMessages from '../../v2Containers/Cap/messages';
|
|
54
54
|
import { convert } from 'html-to-text';
|
|
55
|
-
import { OUTBOUND } from './constants';
|
|
55
|
+
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';
|
|
@@ -1092,7 +1092,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1092
1092
|
const templateContent = this.state.formData?.base?.en?.["template-content"] || "";
|
|
1093
1093
|
//Converts given HTML content to plain text string.
|
|
1094
1094
|
const content = convert(
|
|
1095
|
-
templateContent
|
|
1095
|
+
templateContent, GLOBAL_CONVERT_OPTIONS
|
|
1096
1096
|
);
|
|
1097
1097
|
/*
|
|
1098
1098
|
The `handleResult` function is used as a callback for `getLiquidTags` to handle the results post-processing.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SMS,
|
|
3
|
+
MOBILE_PUSH,
|
|
4
|
+
EMAIL
|
|
5
|
+
} from "../../v2Containers/CreativesContainer/constants";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Transform form data to API payload format
|
|
9
|
+
* @param {object} formData - The form data from the UI
|
|
10
|
+
* @param {string} channel - The communication channel (EMAIL, SMS, WECHAT, MOBILE_PUSH)
|
|
11
|
+
* @param {object} params - Additional parameters like sourceEntityId, ouId, etc.
|
|
12
|
+
* @returns {object} - The formatted API payload
|
|
13
|
+
*/
|
|
14
|
+
export const transformFormDataToAPIPayload = (
|
|
15
|
+
formData,
|
|
16
|
+
loyaltyMetaData = {}
|
|
17
|
+
) => {
|
|
18
|
+
console.log("**** # transformDataToAPIPyaload: ", {
|
|
19
|
+
formData,
|
|
20
|
+
loyaltyMetaData
|
|
21
|
+
});
|
|
22
|
+
const {
|
|
23
|
+
actionId,
|
|
24
|
+
actionName,
|
|
25
|
+
ouId,
|
|
26
|
+
clientName,
|
|
27
|
+
module,
|
|
28
|
+
metaId,
|
|
29
|
+
setMetaId = () => {},
|
|
30
|
+
channel,
|
|
31
|
+
transformedMessageDetails
|
|
32
|
+
} = loyaltyMetaData;
|
|
33
|
+
|
|
34
|
+
const { emailDeliverySettings } = transformedMessageDetails;
|
|
35
|
+
const upperCaseChannel = channel.toUpperCase();
|
|
36
|
+
|
|
37
|
+
// Base response structure
|
|
38
|
+
const response = {
|
|
39
|
+
ouId: ouId || -1,
|
|
40
|
+
sourceEntityId: actionId,
|
|
41
|
+
channel: upperCaseChannel || this.props.schema.channel.toUpperCase(),
|
|
42
|
+
module,
|
|
43
|
+
executionParams: {},
|
|
44
|
+
clientName: clientName || "EMF"
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
switch (upperCaseChannel) {
|
|
48
|
+
case EMAIL: {
|
|
49
|
+
const subject = formData["template-subject"] || "";
|
|
50
|
+
const htmlContent = formData?.base?.en?.["template-content"] || "";
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
...response,
|
|
54
|
+
emailDeliverySettings: emailDeliverySettings || {},
|
|
55
|
+
emailMessageContent: {
|
|
56
|
+
channel: EMAIL,
|
|
57
|
+
messageBody: htmlContent,
|
|
58
|
+
messageSubject: subject
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
case SMS: {
|
|
64
|
+
// Extract SMS content from formData
|
|
65
|
+
const smsContent = formData["sms-editor"] || "";
|
|
66
|
+
const templateId = formData.template_id || "";
|
|
67
|
+
const templateName = formData.template_name || "";
|
|
68
|
+
const header = formData.header || "";
|
|
69
|
+
const varMapped = formData["var-mapped"] || {};
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
...response,
|
|
73
|
+
smsDeliverySettings: {
|
|
74
|
+
additionalSettings: {
|
|
75
|
+
skipRateLimit: false
|
|
76
|
+
},
|
|
77
|
+
channelSettings: {
|
|
78
|
+
channel: SMS,
|
|
79
|
+
senderId: header || ""
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
smsMessageContent: {
|
|
83
|
+
channel: SMS,
|
|
84
|
+
messageBody: smsContent,
|
|
85
|
+
templateId,
|
|
86
|
+
templateName,
|
|
87
|
+
varMapped
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case MOBILE_PUSH: {
|
|
93
|
+
// Extract Mobile Push content
|
|
94
|
+
const androidContent = formData.ANDROID || {};
|
|
95
|
+
const iosContent = formData.IOS || {};
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
...response,
|
|
99
|
+
mobilePushDeliverySettings: {
|
|
100
|
+
additionalSettings: {
|
|
101
|
+
skipRateLimit: false
|
|
102
|
+
},
|
|
103
|
+
channelSettings: {
|
|
104
|
+
channel: MOBILE_PUSH
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
mobilePushMessageContent: {
|
|
108
|
+
channel: MOBILE_PUSH,
|
|
109
|
+
androidContent: {
|
|
110
|
+
title: androidContent.title || "",
|
|
111
|
+
body: androidContent.message || "",
|
|
112
|
+
type: androidContent.type || "TEXT",
|
|
113
|
+
custom: androidContent.custom || {}
|
|
114
|
+
},
|
|
115
|
+
iosContent: {
|
|
116
|
+
title: iosContent.title || "",
|
|
117
|
+
body: iosContent.message || "",
|
|
118
|
+
type: iosContent.type || "TEXT",
|
|
119
|
+
custom: iosContent.custom || {}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// case WECHAT: {
|
|
126
|
+
// // Extract WeChat content
|
|
127
|
+
// const wechatContent = formData.content || {};
|
|
128
|
+
|
|
129
|
+
// return {
|
|
130
|
+
// ...response,
|
|
131
|
+
// wechatDeliverySettings: {
|
|
132
|
+
// additionalSettings: {
|
|
133
|
+
// skipRateLimit: false
|
|
134
|
+
// },
|
|
135
|
+
// channelSettings: {
|
|
136
|
+
// channel: WECHAT
|
|
137
|
+
// }
|
|
138
|
+
// },
|
|
139
|
+
// wechatMessageContent: {
|
|
140
|
+
// channel: WECHAT,
|
|
141
|
+
// messageBody: wechatContent.body || "",
|
|
142
|
+
// templateId: wechatContent.templateId || "",
|
|
143
|
+
// templateName: wechatContent.templateName || "",
|
|
144
|
+
// varMapped: wechatContent.varMapped || {}
|
|
145
|
+
// }
|
|
146
|
+
// };
|
|
147
|
+
// }
|
|
148
|
+
|
|
149
|
+
default:
|
|
150
|
+
return response;
|
|
151
|
+
}
|
|
152
|
+
};
|