@capillarytech/creatives-library 9.0.14-beta.0 → 9.0.14
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/constants/unified.js +0 -3
- package/package.json +1 -1
- package/services/api.js +10 -0
- package/services/tests/api.test.js +83 -0
- package/utils/common.js +0 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/WhatsAppPreviewContent.js +5 -3
- package/v2Components/CommonTestAndPreview/index.js +7 -0
- package/v2Components/FormBuilder/_formBuilder.scss +0 -5
- package/v2Components/FormBuilder/index.js +4479 -41
- package/v2Components/NavigationBar/index.js +27 -0
- package/v2Components/NavigationBar/messages.js +4 -0
- package/v2Components/NavigationBar/tests/index.test.js +19 -0
- package/v2Components/NewCallTask/index.js +6 -1
- package/v2Components/TemplatePreview/index.js +4 -2
- package/v2Containers/Cap/index.js +3 -1
- package/v2Containers/CommunicationFlow/CommunicationFlow.js +130 -20
- package/v2Containers/CommunicationFlow/CommunicationFlow.scss +154 -0
- package/v2Containers/CommunicationFlow/CommunicationFlowCard.js +240 -0
- package/v2Containers/CommunicationFlow/DemoPage.js +47 -0
- package/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +369 -2
- package/v2Containers/CommunicationFlow/Tests/CommunicationFlowCard.test.js +619 -0
- package/v2Containers/CommunicationFlow/Tests/DemoPage.test.js +77 -0
- package/v2Containers/CommunicationFlow/Tests/getContentBody.test.js +933 -0
- package/v2Containers/CommunicationFlow/constants.js +45 -10
- package/v2Containers/CommunicationFlow/index.js +5 -2
- package/v2Containers/CommunicationFlow/messages.js +20 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +94 -31
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.scss +14 -11
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/ChannelSelectionStep.test.js +1144 -32
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +183 -0
- package/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/CommunicationStrategyStep.js +3 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +39 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +6 -2
- package/v2Containers/CommunicationFlow/utils/getContentBody.js +369 -0
- package/v2Containers/CommunicationFlow/utils/getContentBody.scss +19 -0
- package/v2Containers/CommunicationFlow/utils/getEnabledSteps.js +1 -1
- package/v2Containers/CreativesContainer/constants.js +6 -0
- package/v2Containers/CreativesContainer/index.js +68 -1
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +2 -2
- package/v2Containers/Templates/index.js +2 -2
- package/v2Containers/TemplatesV2/index.js +9 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +41 -34
- package/v2Components/FormBuilder/Classic.js +0 -4487
- package/v2Components/FormBuilder/Functional/FormBuilderShell.js +0 -371
- package/v2Components/FormBuilder/Functional/channels/registry.js +0 -17
- package/v2Components/FormBuilder/Functional/channels/sms/buildSubmitPayload.js +0 -9
- package/v2Components/FormBuilder/Functional/channels/sms/config.js +0 -30
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +0 -46
- package/v2Components/FormBuilder/Functional/channels/sms/getLiquidContent.js +0 -13
- package/v2Components/FormBuilder/Functional/channels/sms/index.js +0 -22
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +0 -52
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getLiquidContent.test.js +0 -25
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +0 -87
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +0 -89
- package/v2Components/FormBuilder/Functional/constants.js +0 -42
- package/v2Components/FormBuilder/Functional/core/schema/fieldRegistry.js +0 -38
- package/v2Components/FormBuilder/Functional/core/schema/initializeFormState.js +0 -85
- package/v2Components/FormBuilder/Functional/core/store/formReducer.js +0 -81
- package/v2Components/FormBuilder/Functional/core/store/selectors.js +0 -30
- package/v2Components/FormBuilder/Functional/core/store/toLegacyFormData.js +0 -91
- package/v2Components/FormBuilder/Functional/index.js +0 -26
- package/v2Components/FormBuilder/Functional/layout/FieldSlot.js +0 -59
- package/v2Components/FormBuilder/Functional/layout/SchemaForm.js +0 -31
- package/v2Components/FormBuilder/Functional/layout/Section.js +0 -116
- package/v2Components/FormBuilder/Functional/renderers/smsRenderers.js +0 -258
- package/v2Components/FormBuilder/Functional/tests/channelRegistry.test.js +0 -21
- package/v2Components/FormBuilder/Functional/tests/fieldRegistry.test.js +0 -65
- package/v2Components/FormBuilder/Functional/tests/fieldSlot.test.js +0 -97
- package/v2Components/FormBuilder/Functional/tests/fixtures/smsParityCases.js +0 -192
- package/v2Components/FormBuilder/Functional/tests/formReducer.test.js +0 -129
- package/v2Components/FormBuilder/Functional/tests/initializeFormState.test.js +0 -132
- package/v2Components/FormBuilder/Functional/tests/schemaForm.test.js +0 -40
- package/v2Components/FormBuilder/Functional/tests/section.test.js +0 -99
- package/v2Components/FormBuilder/Functional/tests/selectors.test.js +0 -67
- package/v2Components/FormBuilder/Functional/tests/sms.crossFlowParity.test.js +0 -155
- package/v2Components/FormBuilder/Functional/tests/sms.liquid.test.js +0 -172
- package/v2Components/FormBuilder/Functional/tests/sms.rollout.test.js +0 -122
- package/v2Components/FormBuilder/Functional/tests/sms.shell.parity.test.js +0 -329
- package/v2Components/FormBuilder/Functional/tests/smsRenderers.test.js +0 -160
- package/v2Components/FormBuilder/Functional/tests/toLegacyFormData.test.js +0 -95
- package/v2Components/FormBuilder/tests/__snapshots__/sms.characterization.test.js.snap +0 -114
- package/v2Components/FormBuilder/tests/entryGate.test.js +0 -106
- package/v2Components/FormBuilder/tests/sms.characterization.test.js +0 -336
package/constants/unified.js
CHANGED
|
@@ -45,9 +45,6 @@ export const GIFT_CARDS = 'GIFT_CARDS';
|
|
|
45
45
|
export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
46
46
|
export const ENABLE_NEW_MPUSH = 'ENABLE_NEW_MPUSH';
|
|
47
47
|
export const ENABLE_NEW_EDITOR_FLOW_INAPP = 'ENABLE_NEW_EDITOR_FLOW_INAPP';
|
|
48
|
-
// Per-channel flag for the FormBuilder V3 migration. Routes SMS templates to the
|
|
49
|
-
// new functional FormBuilder; later channels get their own flags (…_MPUSH, …_EMAIL).
|
|
50
|
-
export const ENABLE_NEW_FORMBUILDER_SMS = 'ENABLE_NEW_FORMBUILDER_SMS';
|
|
51
48
|
export const SUPPORT_CK_EDITOR = 'SUPPORT_CK_EDITOR';
|
|
52
49
|
export const CUSTOM_TAG = 'CustomTagMessage';
|
|
53
50
|
export const CUSTOMER_EXTENDED_FIELD = 'Customer extended fields';
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -693,6 +693,16 @@ export const createCentralCommsMetaId = (payload, metaType = TRANSACTION) => {
|
|
|
693
693
|
return request(url, getAPICallObject('POST', payload, false, false, false, true));
|
|
694
694
|
};
|
|
695
695
|
|
|
696
|
+
export const getCentralCommsMetaIds = (metaIds, metaType = TRANSACTION) => {
|
|
697
|
+
const url = `${API_ENDPOINT}/common/central-comms/meta-id/${metaType}?metaIds=${metaIds}`;
|
|
698
|
+
return request(url, getAPICallObject('GET', null, false, false, false, true));
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
export const bulkClaimAndApprove = (payload, metaType = TRANSACTION) => {
|
|
702
|
+
const url = `${API_ENDPOINT}/common/central-comms/bulk-claim-approve/${metaType}`;
|
|
703
|
+
return request(url, getAPICallObject('POST', payload, false, false, false, true));
|
|
704
|
+
};
|
|
705
|
+
|
|
696
706
|
export const updateMetaConfig = (payload, metaType = TRANSACTION, metaId) => {
|
|
697
707
|
const url = `${API_ENDPOINT}/common/central-comms/meta-id/${metaType}/${metaId}`;
|
|
698
708
|
return request(url, getAPICallObject('PATCH', payload, false, false, false, true));
|
|
@@ -1092,6 +1092,8 @@ import {
|
|
|
1092
1092
|
unarchiveTemplate,
|
|
1093
1093
|
bulkArchiveTemplates,
|
|
1094
1094
|
bulkUnarchiveTemplates,
|
|
1095
|
+
getCentralCommsMetaIds,
|
|
1096
|
+
bulkClaimAndApprove,
|
|
1095
1097
|
} from '../api';
|
|
1096
1098
|
|
|
1097
1099
|
describe('archiveTemplate', () => {
|
|
@@ -1145,3 +1147,84 @@ describe('bulkUnarchiveTemplates', () => {
|
|
|
1145
1147
|
expect(lastCall[1].method).toBe('PUT');
|
|
1146
1148
|
});
|
|
1147
1149
|
});
|
|
1150
|
+
|
|
1151
|
+
describe('getCentralCommsMetaIds', () => {
|
|
1152
|
+
beforeEach(() => {
|
|
1153
|
+
global.fetch = jest.fn().mockReturnValue(Promise.resolve({
|
|
1154
|
+
status: 200,
|
|
1155
|
+
json: () => Promise.resolve({ status: 200, response: [] }),
|
|
1156
|
+
}));
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
afterEach(() => {
|
|
1160
|
+
jest.restoreAllMocks();
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
it('should return a Promise', () => {
|
|
1164
|
+
const result = getCentralCommsMetaIds('1,2,3');
|
|
1165
|
+
expect(result).toBeInstanceOf(Promise);
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
it('should call GET on central-comms/meta-id endpoint with default TRANSACTION type', () => {
|
|
1169
|
+
getCentralCommsMetaIds('1,2,3');
|
|
1170
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1171
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1172
|
+
expect(lastCall[0]).toContain('central-comms/meta-id/TRANSACTION');
|
|
1173
|
+
expect(lastCall[0]).toContain('metaIds=1,2,3');
|
|
1174
|
+
expect(lastCall[1].method).toBe('GET');
|
|
1175
|
+
});
|
|
1176
|
+
|
|
1177
|
+
it('should use provided metaType in URL', () => {
|
|
1178
|
+
getCentralCommsMetaIds('4,5', 'EVENT');
|
|
1179
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1180
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1181
|
+
expect(lastCall[0]).toContain('central-comms/meta-id/EVENT');
|
|
1182
|
+
});
|
|
1183
|
+
|
|
1184
|
+
it('should handle fetch failure', async () => {
|
|
1185
|
+
global.fetch.mockRejectedValue({ error: 'Network error' });
|
|
1186
|
+
const result = await getCentralCommsMetaIds('1,2,3');
|
|
1187
|
+
expect(result).toEqual({ error: 'Network error' });
|
|
1188
|
+
});
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
describe('bulkClaimAndApprove', () => {
|
|
1192
|
+
beforeEach(() => {
|
|
1193
|
+
global.fetch = jest.fn().mockReturnValue(Promise.resolve({
|
|
1194
|
+
status: 200,
|
|
1195
|
+
json: () => Promise.resolve({ status: 200, response: { success: true } }),
|
|
1196
|
+
}));
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
afterEach(() => {
|
|
1200
|
+
jest.restoreAllMocks();
|
|
1201
|
+
});
|
|
1202
|
+
|
|
1203
|
+
it('should return a Promise', () => {
|
|
1204
|
+
const result = bulkClaimAndApprove({ ids: ['1', '2'] });
|
|
1205
|
+
expect(result).toBeInstanceOf(Promise);
|
|
1206
|
+
});
|
|
1207
|
+
|
|
1208
|
+
it('should call POST on central-comms/bulk-claim-approve endpoint with default TRANSACTION type', () => {
|
|
1209
|
+
const payload = { ids: ['1', '2'] };
|
|
1210
|
+
bulkClaimAndApprove(payload);
|
|
1211
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1212
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1213
|
+
expect(lastCall[0]).toContain('central-comms/bulk-claim-approve/TRANSACTION');
|
|
1214
|
+
expect(lastCall[1].method).toBe('POST');
|
|
1215
|
+
expect(lastCall[1].body).toBe(JSON.stringify(payload));
|
|
1216
|
+
});
|
|
1217
|
+
|
|
1218
|
+
it('should use provided metaType in URL', () => {
|
|
1219
|
+
bulkClaimAndApprove({ ids: ['3'] }, 'EVENT');
|
|
1220
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1221
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1222
|
+
expect(lastCall[0]).toContain('central-comms/bulk-claim-approve/EVENT');
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
it('should handle fetch failure', async () => {
|
|
1226
|
+
global.fetch.mockRejectedValue({ error: 'Network error' });
|
|
1227
|
+
const result = await bulkClaimAndApprove({ ids: ['1'] });
|
|
1228
|
+
expect(result).toEqual({ error: 'Network error' });
|
|
1229
|
+
});
|
|
1230
|
+
});
|
package/utils/common.js
CHANGED
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
SUPPORT_CK_EDITOR,
|
|
27
27
|
ENABLE_NEW_MPUSH,
|
|
28
28
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
29
|
-
ENABLE_NEW_FORMBUILDER_SMS,
|
|
30
29
|
SUPPORT_ENGAGEMENT_MODULE,
|
|
31
30
|
ENABLE_CREATIVES_ARCHIVAL,
|
|
32
31
|
} from '../constants/unified';
|
|
@@ -163,13 +162,6 @@ export const hasNewEditorFlowInAppEnabled = Auth.hasFeatureAccess.bind(
|
|
|
163
162
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
164
163
|
);
|
|
165
164
|
|
|
166
|
-
// FormBuilder V3 — per-org flag that routes the SMS channel to the new
|
|
167
|
-
// functional FormBuilder. Off => the legacy class implementation (Classic).
|
|
168
|
-
export const hasNewFormBuilderEnabledForSms = Auth.hasFeatureAccess.bind(
|
|
169
|
-
null,
|
|
170
|
-
ENABLE_NEW_FORMBUILDER_SMS,
|
|
171
|
-
);
|
|
172
|
-
|
|
173
165
|
//filtering tags based on scope
|
|
174
166
|
export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
|
|
175
167
|
(tag) => !tagsToFilter?.includes(tag?.definition?.value)
|
|
@@ -17,7 +17,7 @@ import CapTooltip from '@capillarytech/cap-ui-library/CapTooltip';
|
|
|
17
17
|
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
18
18
|
import { ANDROID, IOS } from '../constants';
|
|
19
19
|
import messages from '../messages';
|
|
20
|
-
import { getWhatsappQuickReply, getWhatsappCarouselButtonView } from '../../../v2Containers/Whatsapp/utils';
|
|
20
|
+
import { getWhatsappQuickReply, getWhatsappCarouselButtonView, getWhatsappDocPreview } from '../../../v2Containers/Whatsapp/utils';
|
|
21
21
|
import { QUICK_REPLY, PHONE_NUMBER, WHATSAPP_CATEGORIES, TEMPLATE_VARIABLE_REGEX } from '../../../v2Containers/Whatsapp/constants';
|
|
22
22
|
import videoPlay from '../../../assets/videoPlay.svg';
|
|
23
23
|
import whatsappImageEmptyPreview from '../../TemplatePreview/assets/images/empty_image_preview.svg';
|
|
@@ -258,8 +258,10 @@ const WhatsAppPreviewContent = ({
|
|
|
258
258
|
|
|
259
259
|
{/* Document Preview */}
|
|
260
260
|
{content?.docPreview && (
|
|
261
|
-
<CapRow
|
|
262
|
-
{content.docPreview
|
|
261
|
+
<CapRow className="whatsapp-image">
|
|
262
|
+
{React.isValidElement(content.docPreview)
|
|
263
|
+
? content.docPreview
|
|
264
|
+
: getWhatsappDocPreview(content.docPreview)}
|
|
263
265
|
</CapRow>
|
|
264
266
|
)}
|
|
265
267
|
|
|
@@ -394,6 +394,13 @@ const CommonTestAndPreview = (props) => {
|
|
|
394
394
|
return '';
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
// WHATSAPP channel - return template message string (content is a complex object with JSX nodes,
|
|
398
|
+
// JSON.stringify would crash; the preview uses the content prop directly via WhatsAppPreviewContent)
|
|
399
|
+
if (channel === CHANNELS.WHATSAPP) {
|
|
400
|
+
if (typeof content === 'string') return content;
|
|
401
|
+
return content?.templateMsg || '';
|
|
402
|
+
}
|
|
403
|
+
|
|
397
404
|
// For SMS and other string-based channels, return content as-is if it's already a string
|
|
398
405
|
// Don't stringify strings as it adds unnecessary quotes
|
|
399
406
|
if (channel === CHANNELS.SMS && typeof content === 'string') {
|
|
@@ -46,11 +46,6 @@
|
|
|
46
46
|
.error .error-message{
|
|
47
47
|
top: revert;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
.sms-message-content .component-with-label-error-message {
|
|
51
|
-
margin-top: -$CAP_SPACE_04;
|
|
52
|
-
margin-bottom: $CAP_SPACE_08;
|
|
53
|
-
}
|
|
54
49
|
.tabs-error {
|
|
55
50
|
.ant-tabs-ink-bar .ant-tabs-ink-bar-animated {
|
|
56
51
|
background-color: #F34F56;
|