@capillarytech/creatives-library 8.0.145 → 8.0.146

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.
Files changed (45) hide show
  1. package/initialReducer.js +0 -2
  2. package/package.json +1 -1
  3. package/services/api.js +0 -5
  4. package/services/tests/api.test.js +0 -17
  5. package/v2Components/MobilePushPreviewV2/index.js +0 -8
  6. package/v2Components/NavigationBar/saga.js +1 -1
  7. package/v2Components/NavigationBar/tests/saga.test.js +2 -2
  8. package/v2Components/TemplatePreview/index.js +2 -28
  9. package/v2Components/TemplatePreview/messages.js +0 -4
  10. package/v2Components/TestAndPreviewSlidebox/PreviewSection.js +1 -1
  11. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +1 -1
  12. package/v2Containers/CreativesContainer/SlideBoxContent.js +8 -26
  13. package/v2Containers/CreativesContainer/index.js +10 -64
  14. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -5
  15. package/v2Containers/Email/index.js +1 -1
  16. package/v2Containers/InApp/actions.js +0 -7
  17. package/v2Containers/InApp/constants.js +1 -8
  18. package/v2Containers/InApp/index.js +53 -76
  19. package/v2Containers/InApp/reducer.js +0 -17
  20. package/v2Containers/InApp/sagas.js +0 -27
  21. package/v2Containers/InApp/selectors.js +1 -23
  22. package/v2Containers/InApp/tests/index.test.js +9 -0
  23. package/v2Containers/InApp/tests/reducer.test.js +0 -33
  24. package/v2Containers/InApp/tests/sagas.test.js +1 -57
  25. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
  26. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
  27. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -2
  28. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -9
  29. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -18
  30. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -4
  31. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +0 -35
  32. package/v2Components/TemplatePreview/assets/images/empty_android.svg +0 -8
  33. package/v2Components/TemplatePreview/assets/images/empty_ios.svg +0 -5
  34. package/v2Components/TestAndPreviewSlidebox/tests/PreviewSection.test.js +0 -99
  35. package/v2Containers/BeePopupEditor/constants.js +0 -10
  36. package/v2Containers/BeePopupEditor/index.js +0 -169
  37. package/v2Containers/BeePopupEditor/tests/index.test.js +0 -628
  38. package/v2Containers/InApp/tests/selector.test.js +0 -612
  39. package/v2Containers/InappAdvanced/index.js +0 -459
  40. package/v2Containers/InappAdvanced/index.scss +0 -11
  41. package/v2Containers/InappAdvanced/tests/index.test.js +0 -442
  42. package/v2Containers/InappWrapper/_inappWrapper.scss +0 -19
  43. package/v2Containers/InappWrapper/index.js +0 -195
  44. package/v2Containers/InappWrapper/messages.js +0 -38
  45. package/v2Containers/InappWrapper/tests/index.test.js +0 -247
@@ -1,459 +0,0 @@
1
- import React, { useState, useEffect } from "react";
2
- import isEmpty from 'lodash/isEmpty';
3
- import get from 'lodash/get';
4
- import { bindActionCreators } from "redux";
5
- import { createStructuredSelector } from "reselect";
6
- import { injectIntl, FormattedMessage } from "react-intl";
7
- import { DAEMON } from '@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes';
8
- import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
9
- import CapSpin from "@capillarytech/cap-ui-library/CapSpin";
10
- import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
11
- import CapRow from "@capillarytech/cap-ui-library/CapRow";
12
- import CapButton from "@capillarytech/cap-ui-library/CapButton";
13
- import CapTab from "@capillarytech/cap-ui-library/CapTab";
14
- import CapNotification from "@capillarytech/cap-ui-library/CapNotification";
15
- import {
16
- makeSelectInApp,
17
- makeSelectAccount,
18
- makeSelectBeePopupBuilderTokenFetching,
19
- makeSelectBeePopupBuilderToken,
20
- } from "../InApp/selectors";
21
- import {
22
- isLoadingMetaEntities,
23
- makeSelectMetaEntities,
24
- setInjectedTags,
25
- selectCurrentOrgDetails,
26
- } from "../Cap/selectors";
27
- import * as inAppActions from "../InApp/actions";
28
- import '../InApp/index.scss';
29
- import './index.scss';
30
- import messages from "../InApp/messages";
31
- import globalMessages from "../Cap/messages";
32
- import withCreatives from "../../hoc/withCreatives";
33
-
34
- import {
35
- ANDROID,
36
- DEVICE_SUPPORTED,
37
- INAPP_MESSAGE_LAYOUT_TYPES,
38
- IOS,
39
- LAYOUT_RADIO_OPTIONS,
40
- } from "../InApp/constants";
41
- import { INAPP, SMS } from "../CreativesContainer/constants";
42
- import {
43
- ALL, TAG, EMBEDDED, DEFAULT, FULL, LIBRARY,
44
- } from "../Whatsapp/constants";
45
- import BeePopupEditor from "../BeePopupEditor";
46
- import injectReducer from '../../utils/injectReducer';
47
- import v2InAppReducer from '../InApp/reducer';
48
- import { v2InAppSagas } from '../InApp/sagas';
49
- import injectSaga from '../../utils/injectSaga';
50
-
51
- let editContent = {};
52
-
53
- export const InappAdvanced = (props) => {
54
- const {
55
- intl,
56
- actions,
57
- isFullMode,
58
- onCreateComplete,
59
- params,
60
- templateData = {},
61
- editData = {},
62
- accountData = {},
63
- globalActions,
64
- location,
65
- getDefaultTags,
66
- supportedTags,
67
- metaEntities,
68
- injectedTags,
69
- getFormData,
70
- templateName,
71
- setTemplateName,
72
- beePopupBuilderTokenFetching,
73
- beePopupBuilderToken,
74
- } = props || {};
75
-
76
- const { formatMessage } = intl;
77
- const [androidBeeJson, setAndroidBeeJson] = useState('{}');
78
- const [androidBeeHtml, setAndroidBeeHtml] = useState(null);
79
- const [iosBeeJson, setIosBeeJson] = useState('{}');
80
- const [iosBeeHtml, setIosBeeHtml] = useState(null);
81
- const [beeInstance, setBeeInstance] = useState(null);
82
-
83
- const [templateLayoutType, setTemplateLayoutType] = useState(
84
- INAPP_MESSAGE_LAYOUT_TYPES.MODAL
85
- );
86
- const [accountId, setAccountId] = useState("");
87
- const [accessToken, setAccessToken] = useState("");
88
- const [accountName, setAccountName] = useState("");
89
- const [spin, setSpin] = useState(false);
90
- const [panes, setPanes] = useState(ANDROID);
91
- //for tag only
92
- const [tags, updateTags] = useState([]);
93
- //for edit only
94
- const [isEditFlow, setEditFlow] = useState(false);
95
- const [templateDate, setTemplateDate] = useState("");
96
-
97
- //fetching bee popup builder token
98
- useEffect(() => {
99
- actions.getBeePopupBuilderToken();
100
- }, []);
101
-
102
- //gets account details
103
- useEffect(() => {
104
- const accountObj = accountData?.selectedWeChatAccount || {};
105
- if (!isEmpty(accountObj)) {
106
- const {
107
- sourceAccountIdentifier = "",
108
- configs = {},
109
- name = "",
110
- } = accountObj;
111
- const isAndroidSupported = configs?.android === DEVICE_SUPPORTED;
112
- // DEVICE_SUPPORTED is '1', which indicates if the particular account is supported, and '0' if the devive is not supported
113
- //get deep link keys in an array
114
- setPanes(isAndroidSupported ? ANDROID : IOS);
115
- setAccountId(sourceAccountIdentifier);
116
- setAccessToken(configs?.accessToken || "");
117
- setAccountName(name);
118
- }
119
- }, [accountData?.selectedWeChatAccount]);
120
-
121
- useEffect(() => {
122
- const {
123
- name = "",
124
- versions = {},
125
- createdAt = "",
126
- } = isFullMode ? editData?.templateDetails || {} : templateData || {};
127
- editContent = get(versions, `base.content`, {});
128
- if (editContent && !isEmpty(editContent)) {
129
- setEditFlow(true);
130
- setTemplateName(name);
131
- setTemplateDate(createdAt);
132
- setTemplateLayoutType(editContent?.ANDROID?.bodyType);
133
- const androidContent = editContent?.ANDROID;
134
- if (!isEmpty(androidContent)) {
135
- const {
136
- beeJson: androidJson,
137
- beeHtml: androidHtml,
138
- } = androidContent || {};
139
- setAndroidBeeJson(androidJson);
140
- setAndroidBeeHtml(androidHtml);
141
- }
142
- const iosContent = editContent?.IOS;
143
- if (!isEmpty(iosContent)) {
144
- const {
145
- beeJson: iosJson,
146
- beeHtml: iosHtml,
147
- } = iosContent || {};
148
- setIosBeeJson(iosJson);
149
- setIosBeeHtml(iosHtml);
150
- }
151
- }
152
- }, [editData.templateDetails || templateData]);
153
-
154
- // tag Code start from here
155
- useEffect(() => {
156
- //fetching tags
157
- const { type, module } = location.query || {};
158
- const isEmbedded = type === EMBEDDED;
159
- const context = isEmbedded ? module : DEFAULT;
160
- const embedded = isEmbedded ? type : FULL;
161
- const query = {
162
- layout: SMS,
163
- type: TAG,
164
- context,
165
- embedded,
166
- };
167
- if (getDefaultTags) {
168
- query.context = getDefaultTags;
169
- }
170
- globalActions.fetchSchemaForEntity(query);
171
- }, []);
172
-
173
- useEffect(() => {
174
- let tag = get(metaEntities, `tags.standard`, []);
175
- const { type, module } = location.query || {};
176
- if (type === EMBEDDED && module === LIBRARY && !getDefaultTags) {
177
- tag = supportedTags;
178
- }
179
- updateTags(tag);
180
- }, [metaEntities]);
181
-
182
- const handleOnTagsContextChange = (data) => {
183
- const { type } = location.query || {};
184
- const tempData = (data || '').toLowerCase();
185
- const isEmbedded = type === EMBEDDED;
186
- const embedded = isEmbedded ? type : FULL;
187
- const context = tempData === ALL ? DEFAULT : tempData;
188
- const query = {
189
- layout: SMS,
190
- type: TAG,
191
- context,
192
- embedded,
193
- };
194
- globalActions.fetchSchemaForEntity(query);
195
- };
196
-
197
- const onTemplateLayoutTypeChange = (value) => {
198
- setTemplateLayoutType(value);
199
- };
200
-
201
- const saveBeeInstance = (instance) => {
202
- setBeeInstance(instance);
203
- };
204
-
205
- const saveBeeData = (json, html, device) => {
206
- if (device === ANDROID) {
207
- setAndroidBeeJson(json);
208
- setAndroidBeeHtml(html);
209
- } else {
210
- setIosBeeJson(json);
211
- setIosBeeHtml(html);
212
- }
213
- };
214
-
215
- const PANES = [
216
- {
217
- content: (
218
- <CapSpin spinning={beePopupBuilderTokenFetching}>
219
- {beePopupBuilderToken?.uuid && panes === ANDROID && (
220
- <BeePopupEditor
221
- uid={beePopupBuilderToken?.uuid}
222
- tokenData={beePopupBuilderToken}
223
- id="androidBeePopupBuilder"
224
- saveBeeData={saveBeeData}
225
- saveBeeInstance={saveBeeInstance}
226
- templateLayoutType={templateLayoutType}
227
- tags={tags}
228
- onContextChange={handleOnTagsContextChange}
229
- moduleFilterEnabled={isFullMode}
230
- beeJson={androidBeeJson}
231
- beeHtml={androidBeeHtml}
232
- device={ANDROID}
233
- />
234
- )}
235
- </CapSpin>
236
- ),
237
- tab: <FormattedMessage {...messages.Android} />,
238
- key: ANDROID,
239
- isSupported: get(accountData, 'selectedWeChatAccount.configs.android') === DEVICE_SUPPORTED,
240
- },
241
- {
242
- content: (
243
- <CapSpin spinning={beePopupBuilderTokenFetching}>
244
- {beePopupBuilderToken?.uuid && panes === IOS && (
245
- <BeePopupEditor
246
- uid={beePopupBuilderToken?.uuid}
247
- tokenData={beePopupBuilderToken}
248
- id="iosBeePopupBuilder"
249
- saveBeeData={saveBeeData}
250
- saveBeeInstance={saveBeeInstance}
251
- templateLayoutType={templateLayoutType}
252
- tags={tags}
253
- onContextChange={handleOnTagsContextChange}
254
- moduleFilterEnabled={isFullMode}
255
- beeJson={iosBeeJson}
256
- beeHtml={iosBeeHtml}
257
- device={IOS}
258
- />
259
- )}
260
- </CapSpin>
261
- ),
262
- tab: <FormattedMessage {...messages.Ios} />,
263
- key: IOS,
264
- isSupported: get(accountData, 'selectedWeChatAccount.configs.ios') === DEVICE_SUPPORTED,
265
- },
266
- ];
267
-
268
- const createPayload = () => {
269
- const commonDevicePayload = {
270
- luid: "{{luid}}",
271
- cuid: "{{cuid}}",
272
- communicationId: "{{communicationId}}",
273
- isBEEeditor: true,
274
- };
275
- const accountObj = accountData?.selectedWeChatAccount || {};
276
- const {
277
- sourceAccountIdentifier = "",
278
- id,
279
- } = accountObj;
280
- const data = {
281
- name: templateName,
282
- versions: {
283
- base: {
284
- content: {
285
- ANDROID: {
286
- ...commonDevicePayload,
287
- bodyType: templateLayoutType,
288
- beeJson: androidBeeJson,
289
- beeHtml: androidBeeHtml,
290
- } || {},
291
- IOS: {
292
- ...commonDevicePayload,
293
- bodyType: templateLayoutType,
294
- beeJson: iosBeeJson,
295
- beeHtml: iosBeeHtml,
296
- custom: [],
297
- } || {},
298
- },
299
- },
300
- },
301
- type: INAPP,
302
- definition: {
303
- accountId: id,
304
- licenseCode: sourceAccountIdentifier,
305
- },
306
- };
307
- return data;
308
- };
309
-
310
- const actionCallback = ({ errorMessage }) => {
311
- if (!errorMessage) {
312
- CapNotification.success({
313
- message: isEditFlow ? formatMessage(messages.inAppEditNotification, {
314
- name: templateName,
315
- }) : formatMessage(messages.inAppCreateNotification, {
316
- name: templateName,
317
- }),
318
- });
319
- actions.clearCreateResponse();
320
- } else {
321
- CapNotification.error({
322
- message: JSON.stringify(errorMessage),
323
- });
324
- }
325
- };
326
-
327
- const onCreateInApp = () => {
328
- setSpin(true);
329
- actions.createInAppTemplate(createPayload(), (resp, errorMessage) => {
330
- actionCallback({ resp, errorMessage });
331
- if (!errorMessage) {
332
- onCreateComplete();
333
- } else {
334
- setSpin(false);
335
- }
336
- });
337
- };
338
-
339
- const onEditInApp = () => {
340
- setSpin(true);
341
- actions.editTemplate(
342
- {
343
- ...createPayload(),
344
- _id: params?.id,
345
- },
346
- (resp, errorMessage) => {
347
- actionCallback({ resp, errorMessage });
348
- if (!errorMessage) {
349
- onCreateComplete();
350
- } else {
351
- setSpin(false);
352
- }
353
- },
354
- );
355
- };
356
-
357
- const onDoneCallback = () => {
358
- if (isFullMode) {
359
- if (isEditFlow) {
360
- return onEditInApp;
361
- }
362
- return onCreateInApp;
363
- }
364
- return () => getFormData({
365
- value: createPayload(),
366
- _id: params && params.id,
367
- validity: true,
368
- type: INAPP,
369
- });
370
- };
371
-
372
- return (
373
- <CapSpin spinning={spin}>
374
- <CapRow className="cap-inapp-creatives">
375
- {/* Creative layout type*/}
376
- {(isFullMode || !isEditFlow) && (
377
- <>
378
- <CapRow className="inapp-creative-layout">
379
- <CapHeading type="h4">
380
- <FormattedMessage {...messages.creativeLayout} />
381
- </CapHeading>
382
- <CapHeading type="h6" className="inapp-creative-layout-desc">
383
- <FormattedMessage {...messages.creativeLayoutDesc} />
384
- </CapHeading>
385
- </CapRow>
386
- <CapSelect
387
- id="inapp-layout-dropdown"
388
- options={LAYOUT_RADIO_OPTIONS}
389
- value={templateLayoutType}
390
- onChange={onTemplateLayoutTypeChange}
391
- />
392
- </>
393
- )}
394
- {/* device tab */}
395
- <CapTab
396
- panes={PANES.filter(
397
- (devicePane) => devicePane?.isSupported === true
398
- )}
399
- onChange={(value) => {
400
- setPanes(value);
401
- }}
402
- activeKey={panes}
403
- defaultActiveKey={panes}
404
- className="inapp-template-device-tab"
405
- />
406
- <div className="inapp-scroll-div" />
407
- </CapRow>
408
- <div className={`inapp-footer ${!isFullMode && `inapp-footer-lib`}`}>
409
- {
410
- <>
411
- <CapButton
412
- onClick={onDoneCallback()}
413
- className="inapp-create-btn"
414
- >
415
- {isEditFlow ? (
416
- isFullMode ? (
417
- <FormattedMessage {...messages.update} />
418
- ) : (
419
- <FormattedMessage {...globalMessages.done} />
420
- )
421
- ) : isFullMode ? (
422
- <FormattedMessage {...messages.create} />
423
- ) : (
424
- <FormattedMessage {...globalMessages.done} />
425
- )}
426
- </CapButton>
427
- </>
428
- }
429
- </div>
430
- </CapSpin>
431
- );
432
- };
433
-
434
- const mapStateToProps = createStructuredSelector({
435
- editData: makeSelectInApp(),
436
- accountData: makeSelectAccount(),
437
- metaEntities: makeSelectMetaEntities(),
438
- loadingTags: isLoadingMetaEntities(),
439
- injectedTags: setInjectedTags(),
440
- currentOrgDetails: selectCurrentOrgDetails(),
441
- beePopupBuilderTokenFetching: makeSelectBeePopupBuilderTokenFetching(),
442
- beePopupBuilderToken: makeSelectBeePopupBuilderToken(),
443
- });
444
-
445
- const mapDispatchToProps = (dispatch) => ({
446
- actions: bindActionCreators(inAppActions, dispatch),
447
- });
448
-
449
- const withReducer = injectReducer({ key: 'inapp', reducer: v2InAppReducer });
450
- const withInAppSaga = injectSaga({ key: 'inapp', saga: v2InAppSagas, mode: DAEMON });
451
-
452
- export default withCreatives({
453
- WrappedComponent: injectIntl(InappAdvanced),
454
- mapStateToProps,
455
- mapDispatchToProps,
456
- userAuth: true,
457
- sagas: [withInAppSaga],
458
- reducers: [withReducer],
459
- });
@@ -1,11 +0,0 @@
1
- @import '~@capillarytech/cap-ui-library/styles/_variables.scss';
2
- .cap-inapp-creatives {
3
- #inapp-layout-dropdown {
4
- width: 20.5rem;
5
- }
6
- .inapp-creative-layout {
7
- margin-top: $CAP_SPACE_04;
8
- margin-bottom: $CAP_SPACE_08;
9
- }
10
- }
11
-