@capillarytech/creatives-library 8.0.139-alpha.2 → 8.0.140
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/containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/initialReducer.js +2 -0
- package/package.json +1 -1
- package/services/api.js +5 -0
- package/translations/en.json +1 -0
- package/utils/content.js +15 -0
- package/utils/tests/tagValidations.test.js +112 -0
- package/v2Components/FormBuilder/index.js +13 -1
- package/v2Components/FormBuilder/messages.js +4 -0
- package/v2Components/MobilePushPreviewV2/index.js +8 -0
- package/v2Components/TemplatePreview/assets/images/empty_android.svg +8 -0
- package/v2Components/TemplatePreview/assets/images/empty_ios.svg +5 -0
- package/v2Components/TemplatePreview/index.js +28 -2
- package/v2Containers/BeeEditor/index.js +1 -0
- package/v2Containers/BeePopupEditor/constants.js +10 -0
- package/v2Containers/BeePopupEditor/index.js +169 -0
- package/v2Containers/Cap/constants.js +7 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +26 -8
- package/v2Containers/CreativesContainer/index.js +12 -2
- package/v2Containers/Email/index.js +16 -0
- package/v2Containers/Email/messages.js +4 -0
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +5 -0
- package/v2Containers/InApp/actions.js +7 -0
- package/v2Containers/InApp/constants.js +5 -1
- package/v2Containers/InApp/index.js +76 -53
- package/v2Containers/InApp/reducer.js +17 -0
- package/v2Containers/InApp/sagas.js +27 -0
- package/v2Containers/InApp/selectors.js +23 -1
- package/v2Containers/InappAdvanced/index.js +459 -0
- package/v2Containers/InappAdvanced/index.scss +11 -0
- package/v2Containers/InappWrapper/_inappWrapper.scss +19 -0
- package/v2Containers/InappWrapper/index.js +192 -0
- package/v2Containers/InappWrapper/messages.js +38 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +25 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +5 -6
- package/v2Containers/MobilePushNew/index.js +14 -14
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +111 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +8 -0
- package/v2Containers/Templates/index.js +5 -0
- package/v2Containers/Templates/sagas.js +4 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +132 -0
|
@@ -0,0 +1,459 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.inapp-wrapper {
|
|
2
|
+
|
|
3
|
+
.ant-radio-group.cap-radioCard-v2 {
|
|
4
|
+
.ant-radio-button-wrapper{
|
|
5
|
+
width: 284px;
|
|
6
|
+
height: 258px;
|
|
7
|
+
}
|
|
8
|
+
.ant-card-body {
|
|
9
|
+
padding: 1rem;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
.template-name-inapp {
|
|
14
|
+
width: 580px;
|
|
15
|
+
margin-bottom: 1.5rem;
|
|
16
|
+
.ant-input {
|
|
17
|
+
height: 40px;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* InappWrapper
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
import PropTypes from "prop-types";
|
|
7
|
+
import React, { useState } from "react";
|
|
8
|
+
import { connect } from "react-redux";
|
|
9
|
+
import { FormattedMessage } from "react-intl";
|
|
10
|
+
import CapRadioCard from "@capillarytech/cap-ui-library/CapRadioCard";
|
|
11
|
+
import CapInput from "@capillarytech/cap-ui-library/CapInput";
|
|
12
|
+
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
13
|
+
import ComponentWithLabelHOC from "@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC";
|
|
14
|
+
import styled from "styled-components";
|
|
15
|
+
import InApp from "../InApp/index";
|
|
16
|
+
import InappAdvanced from "../InappAdvanced/index";
|
|
17
|
+
import messages from "./messages";
|
|
18
|
+
import "./_inappWrapper.scss";
|
|
19
|
+
|
|
20
|
+
const CapRadioCardWithLabel = ComponentWithLabelHOC(CapRadioCard);
|
|
21
|
+
const CardContainer = styled.div`
|
|
22
|
+
margin-top: 16px;
|
|
23
|
+
.component-with-label-label {
|
|
24
|
+
margin-bottom: unset;
|
|
25
|
+
}
|
|
26
|
+
.ant-radio-group {
|
|
27
|
+
.ant-radio-button-wrapper {
|
|
28
|
+
&:first-child {
|
|
29
|
+
margin-left: unset;
|
|
30
|
+
margin-top: unset;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
export function InappWrapper(props) {
|
|
36
|
+
const {
|
|
37
|
+
inAppCreateMode,
|
|
38
|
+
step,
|
|
39
|
+
getFormData,
|
|
40
|
+
setIsLoadingContent,
|
|
41
|
+
isGetFormData,
|
|
42
|
+
query,
|
|
43
|
+
isFullMode,
|
|
44
|
+
showTemplateName,
|
|
45
|
+
type,
|
|
46
|
+
onValidationFail,
|
|
47
|
+
templateData,
|
|
48
|
+
onInAppModeChange,
|
|
49
|
+
onEnterTemplateName,
|
|
50
|
+
onRemoveTemplateName,
|
|
51
|
+
forwardedTags,
|
|
52
|
+
selectedOfferDetails,
|
|
53
|
+
onCreateComplete,
|
|
54
|
+
} = props;
|
|
55
|
+
const [templateName, setTemplateName] = useState("");
|
|
56
|
+
const modes = [
|
|
57
|
+
{
|
|
58
|
+
title: <FormattedMessage {...messages.basicEditor} />,
|
|
59
|
+
icon: <CapIcon type="notepad-material" />,
|
|
60
|
+
content: <FormattedMessage {...messages.basicEditorDesc} />,
|
|
61
|
+
value: "basicEditor",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: <FormattedMessage {...messages.dndEditor} />,
|
|
65
|
+
icon: <CapIcon type="draggable" />,
|
|
66
|
+
content: <FormattedMessage {...messages.dndEditorDesc} />,
|
|
67
|
+
value: "beeEditor",
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const onChange = (e) => {
|
|
72
|
+
onInAppModeChange(e.target.value);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
function onTemplateNameChange(event) {
|
|
76
|
+
setTemplateName(event.target.value);
|
|
77
|
+
if (event.target.value && onEnterTemplateName) {
|
|
78
|
+
onEnterTemplateName();
|
|
79
|
+
} else if (onRemoveTemplateName) {
|
|
80
|
+
onRemoveTemplateName();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className="inapp-wrapper">
|
|
86
|
+
{step === "modeSelection" ? (
|
|
87
|
+
<div>
|
|
88
|
+
{isFullMode && (
|
|
89
|
+
<CapInput
|
|
90
|
+
className="template-name-inapp"
|
|
91
|
+
label={<FormattedMessage {...messages.creativeName} />}
|
|
92
|
+
onChange={onTemplateNameChange}
|
|
93
|
+
value={templateName}
|
|
94
|
+
labelPosition="top"
|
|
95
|
+
size="default"
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
<CardContainer>
|
|
99
|
+
<CapRadioCardWithLabel
|
|
100
|
+
label={<FormattedMessage {...messages.modeDesc} />}
|
|
101
|
+
panes={modes}
|
|
102
|
+
cardHeight={"120px"}
|
|
103
|
+
onChange={onChange}
|
|
104
|
+
selected={inAppCreateMode}
|
|
105
|
+
/>
|
|
106
|
+
</CardContainer>
|
|
107
|
+
</div>
|
|
108
|
+
) : (
|
|
109
|
+
<div>
|
|
110
|
+
{inAppCreateMode === 'basicEditor' && (
|
|
111
|
+
<InApp
|
|
112
|
+
getFormData={getFormData}
|
|
113
|
+
setIsLoadingContent={setIsLoadingContent}
|
|
114
|
+
defaultData={{ "template-name": templateName }}
|
|
115
|
+
location={{
|
|
116
|
+
pathname: `/inapp/create`,
|
|
117
|
+
query,
|
|
118
|
+
search: '',
|
|
119
|
+
}}
|
|
120
|
+
params={{ mode: inAppCreateMode }}
|
|
121
|
+
isFullMode={isFullMode}
|
|
122
|
+
isGetFormData={isGetFormData}
|
|
123
|
+
showTemplateName={showTemplateName}
|
|
124
|
+
route={{ name: "inapp" }}
|
|
125
|
+
getDefaultTags={type}
|
|
126
|
+
onValidationFail={onValidationFail}
|
|
127
|
+
templateData={templateData}
|
|
128
|
+
templateName={templateName}
|
|
129
|
+
setTemplateName={setTemplateName}
|
|
130
|
+
forwardedTags={forwardedTags}
|
|
131
|
+
selectedOfferDetails={selectedOfferDetails}
|
|
132
|
+
onCreateComplete={onCreateComplete}
|
|
133
|
+
/>
|
|
134
|
+
)}
|
|
135
|
+
{inAppCreateMode === 'beeEditor' && (
|
|
136
|
+
<InappAdvanced
|
|
137
|
+
getFormData={getFormData}
|
|
138
|
+
setIsLoadingContent={setIsLoadingContent}
|
|
139
|
+
defaultData={{ "template-name": templateName }}
|
|
140
|
+
location={{
|
|
141
|
+
pathname: `/inapp/create`,
|
|
142
|
+
query,
|
|
143
|
+
search: '',
|
|
144
|
+
}}
|
|
145
|
+
params={{ mode: inAppCreateMode }}
|
|
146
|
+
isFullMode={isFullMode}
|
|
147
|
+
isGetFormData={isGetFormData}
|
|
148
|
+
showTemplateName={showTemplateName}
|
|
149
|
+
route={{ name: "inapp" }}
|
|
150
|
+
getDefaultTags={type}
|
|
151
|
+
onValidationFail={onValidationFail}
|
|
152
|
+
templateData={templateData}
|
|
153
|
+
templateName={templateName}
|
|
154
|
+
setTemplateName={setTemplateName}
|
|
155
|
+
forwardedTags={forwardedTags}
|
|
156
|
+
selectedOfferDetails={selectedOfferDetails}
|
|
157
|
+
onCreateComplete={onCreateComplete}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
</div>
|
|
161
|
+
)}
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
InappWrapper.propTypes = {
|
|
167
|
+
onInAppModeChange: PropTypes.func,
|
|
168
|
+
inAppCreateMode: PropTypes.string,
|
|
169
|
+
step: PropTypes.string,
|
|
170
|
+
getFormData: PropTypes.string,
|
|
171
|
+
setIsLoadingContent: PropTypes.func,
|
|
172
|
+
onEnterTemplateName: PropTypes.func,
|
|
173
|
+
onRemoveTemplateName: PropTypes.func,
|
|
174
|
+
isGetFormData: PropTypes.bool,
|
|
175
|
+
query: PropTypes.object,
|
|
176
|
+
isFullMode: PropTypes.bool,
|
|
177
|
+
showTemplateName: PropTypes.func,
|
|
178
|
+
type: PropTypes.string,
|
|
179
|
+
onValidationFail: PropTypes.func,
|
|
180
|
+
forwardedTags: PropTypes.object,
|
|
181
|
+
templateData: PropTypes.object,
|
|
182
|
+
selectedOfferDetails: PropTypes.object,
|
|
183
|
+
onCreateComplete: PropTypes.func,
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
function mapDispatchToProps(dispatch) {
|
|
187
|
+
return {
|
|
188
|
+
dispatch,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export default connect(null, mapDispatchToProps)(InappWrapper);
|