@capillarytech/creatives-library 8.0.353-alpha.3 → 8.0.353-alpha.4
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 +1 -1
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +14 -132
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +0 -163
- package/v2Components/CommonTestAndPreview/index.js +7 -47
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +0 -364
- package/v2Components/FormBuilder/index.js +160 -63
- package/v2Containers/CreativesContainer/index.js +60 -24
- package/v2Containers/Email/index.js +1 -1
- package/v2Containers/Templates/_templates.scss +0 -77
- package/v2Containers/Templates/index.js +2 -75
- package/v2Containers/Viber/constants.js +0 -19
- package/v2Containers/Viber/index.js +47 -714
- package/v2Containers/Viber/index.scss +0 -148
- package/v2Containers/Viber/messages.js +0 -116
- package/v2Containers/Viber/tests/index.test.js +0 -80
package/package.json
CHANGED
|
@@ -14,14 +14,7 @@ import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
|
14
14
|
import CapImage from '@capillarytech/cap-ui-library/CapImage';
|
|
15
15
|
import CapTooltip from '@capillarytech/cap-ui-library/CapTooltip';
|
|
16
16
|
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
17
|
-
import {
|
|
18
|
-
ANDROID,
|
|
19
|
-
IOS,
|
|
20
|
-
ANDROID_DEVICE_NAME,
|
|
21
|
-
IOS_DEVICE_NAME,
|
|
22
|
-
VIBER_ACCOUNT_NAME,
|
|
23
|
-
MEDIA_TYPE_CAROUSEL,
|
|
24
|
-
} from '../constants';
|
|
17
|
+
import { ANDROID, IOS, ANDROID_DEVICE_NAME, IOS_DEVICE_NAME, VIBER_ACCOUNT_NAME } from '../constants';
|
|
25
18
|
import messages from '../messages';
|
|
26
19
|
import videoPlay from '../../../assets/videoPlay.svg';
|
|
27
20
|
|
|
@@ -29,9 +22,6 @@ import videoPlay from '../../../assets/videoPlay.svg';
|
|
|
29
22
|
const smsMobileAndroid = require('../../../assets/Android.png');
|
|
30
23
|
const smsMobileIos = require('../../../assets/iOS.png');
|
|
31
24
|
|
|
32
|
-
const getTrimmedText = (value = '') => (value ?? '').trim();
|
|
33
|
-
const hasTrimmedText = (value = '') => Boolean(getTrimmedText(value));
|
|
34
|
-
|
|
35
25
|
const ViberPreviewContent = ({
|
|
36
26
|
content,
|
|
37
27
|
device,
|
|
@@ -53,34 +43,7 @@ const ViberPreviewContent = ({
|
|
|
53
43
|
imageURL = '',
|
|
54
44
|
videoParams = {},
|
|
55
45
|
buttonText = '',
|
|
56
|
-
type = '',
|
|
57
|
-
cards = [],
|
|
58
|
-
showCarouselEditorPreview = false,
|
|
59
46
|
} = viberContent;
|
|
60
|
-
const hasCarouselContent = type === MEDIA_TYPE_CAROUSEL;
|
|
61
|
-
|
|
62
|
-
const cardHasMeaningfulContent = (card) => {
|
|
63
|
-
if (!card || typeof card !== 'object') return false;
|
|
64
|
-
if (hasTrimmedText(card?.text)) return true;
|
|
65
|
-
if (hasTrimmedText(card?.mediaUrl)) return true;
|
|
66
|
-
const buttons = card?.buttons ?? [];
|
|
67
|
-
return buttons.some((button) => hasTrimmedText(button?.title));
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const hasMeaningfulCarousel =
|
|
71
|
-
hasCarouselContent &&
|
|
72
|
-
Array.isArray(cards) &&
|
|
73
|
-
cards.length > 0 &&
|
|
74
|
-
cards.some(cardHasMeaningfulContent);
|
|
75
|
-
|
|
76
|
-
const showCarouselInPreview =
|
|
77
|
-
hasCarouselContent && (Boolean(showCarouselEditorPreview) || hasMeaningfulCarousel);
|
|
78
|
-
|
|
79
|
-
const previewCarouselCards =
|
|
80
|
-
hasCarouselContent && Array.isArray(cards) && cards.length ? cards : hasCarouselContent ? [{}] : [];
|
|
81
|
-
|
|
82
|
-
const trimmedMessageContent = getTrimmedText(messageContent);
|
|
83
|
-
const trimmedButtonText = getTrimmedText(buttonText);
|
|
84
47
|
|
|
85
48
|
// Get account name (first letter for icon)
|
|
86
49
|
const accountIcon = (accountName || brandName || 'V')[0]?.toUpperCase();
|
|
@@ -136,15 +99,8 @@ const ViberPreviewContent = ({
|
|
|
136
99
|
);
|
|
137
100
|
}
|
|
138
101
|
|
|
139
|
-
// Check if there's any content to display
|
|
140
|
-
const hasContent =
|
|
141
|
-
trimmedMessageContent
|
|
142
|
-
|| hasTrimmedText(imageURL)
|
|
143
|
-
|| videoParams?.viberVideoSrc
|
|
144
|
-
|| trimmedButtonText
|
|
145
|
-
|| hasMeaningfulCarousel
|
|
146
|
-
|| (hasCarouselContent && showCarouselEditorPreview)
|
|
147
|
-
);
|
|
102
|
+
// Check if there's any content to display
|
|
103
|
+
const hasContent = messageContent || imageURL || videoParams?.viberVideoSrc || buttonText;
|
|
148
104
|
|
|
149
105
|
// Render normal Viber preview
|
|
150
106
|
return (
|
|
@@ -171,23 +127,21 @@ const ViberPreviewContent = ({
|
|
|
171
127
|
{hasContent && (
|
|
172
128
|
<CapRow className={`viber-message-container ${device !== ANDROID ? 'viber-message-container-ios' : ''}`}>
|
|
173
129
|
{/* Brand Name Display (from TemplatePreview line 1136) */}
|
|
174
|
-
<CapRow className=
|
|
130
|
+
<CapRow className="msg-container viber-preview">
|
|
175
131
|
{/* Account Icon (from TemplatePreview line 1146-1160) */}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
</CapRow>
|
|
180
|
-
)}
|
|
132
|
+
<CapRow className="viber-account-icon">
|
|
133
|
+
{accountIcon}
|
|
134
|
+
</CapRow>
|
|
181
135
|
|
|
182
136
|
{/* Message Bubble (from TemplatePreview line 1161-1223) */}
|
|
183
|
-
<CapRow className=
|
|
137
|
+
<CapRow className="message-pop align-left viber-message-pop">
|
|
184
138
|
{/* Text Viber preview */}
|
|
185
|
-
{
|
|
139
|
+
{messageContent && (
|
|
186
140
|
<CapLabel type="label15" className="viber-message-text">{messageContent}</CapLabel>
|
|
187
141
|
)}
|
|
188
142
|
|
|
189
143
|
{/* Image Viber preview */}
|
|
190
|
-
{
|
|
144
|
+
{imageURL && (
|
|
191
145
|
<CapImage
|
|
192
146
|
src={imageURL}
|
|
193
147
|
className="viber-image-preview"
|
|
@@ -217,78 +171,16 @@ const ViberPreviewContent = ({
|
|
|
217
171
|
)}
|
|
218
172
|
|
|
219
173
|
{/* Button Viber preview */}
|
|
220
|
-
{
|
|
174
|
+
{buttonText && (
|
|
221
175
|
<CapLabel className="viber-button-base">
|
|
222
176
|
<p className="viber-button-card-text">
|
|
223
177
|
{buttonText}
|
|
224
178
|
</p>
|
|
225
179
|
</CapLabel>
|
|
226
180
|
)}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
<CapRow className="viber-carousel-message-pop">
|
|
231
|
-
{trimmedMessageContent ? (
|
|
232
|
-
<CapLabel
|
|
233
|
-
type="label15"
|
|
234
|
-
className="message-pop-item align-left viber-message-text viber-carousel-message-box-text"
|
|
235
|
-
>
|
|
236
|
-
{messageContent}
|
|
237
|
-
</CapLabel>
|
|
238
|
-
) : (
|
|
239
|
-
<CapRow className="viber-carousel-message-box-placeholder" />
|
|
240
|
-
)}
|
|
241
|
-
<CapLabel type="label1" className="viber-carousel-message-timestamp">
|
|
242
|
-
{timestamp}
|
|
243
|
-
</CapLabel>
|
|
244
|
-
</CapRow>
|
|
245
|
-
|
|
246
|
-
<CapRow className="viber-carousel-cards-pop">
|
|
247
|
-
<CapRow className="viber-carousel-preview-scroll">
|
|
248
|
-
{previewCarouselCards?.map((card, index) => (
|
|
249
|
-
<CapRow className="viber-carousel-preview-card" key={`viber-carousel-preview-card-${index}`}>
|
|
250
|
-
{hasTrimmedText(card?.mediaUrl) ? (
|
|
251
|
-
<CapImage
|
|
252
|
-
src={card?.mediaUrl}
|
|
253
|
-
className="viber-carousel-preview-image"
|
|
254
|
-
alt="Viber carousel card"
|
|
255
|
-
/>
|
|
256
|
-
) : (
|
|
257
|
-
<CapRow className="viber-carousel-preview-image-placeholder" />
|
|
258
|
-
)}
|
|
259
|
-
<CapRow className="viber-carousel-preview-card-body">
|
|
260
|
-
{hasTrimmedText(card?.text) ? (
|
|
261
|
-
<CapLabel type="label15" className="viber-carousel-preview-text">
|
|
262
|
-
{card?.text}
|
|
263
|
-
</CapLabel>
|
|
264
|
-
) : (
|
|
265
|
-
<CapLabel type="label15" className="viber-carousel-preview-text-placeholder" />
|
|
266
|
-
)}
|
|
267
|
-
{(card?.buttons?.filter((cardButton) => hasTrimmedText(cardButton?.title)) ?? [])
|
|
268
|
-
.slice(0, 2)
|
|
269
|
-
.map((cardButton, btnIndex) => {
|
|
270
|
-
const trimmedCardButtonTitle = getTrimmedText(cardButton?.title);
|
|
271
|
-
return (
|
|
272
|
-
<CapLabel
|
|
273
|
-
className={`viber-carousel-preview-button ${btnIndex === 1 ? 'viber-carousel-preview-button-secondary' : ''}`}
|
|
274
|
-
key={`viber-carousel-preview-btn-${index}-${btnIndex}-${trimmedCardButtonTitle}`}
|
|
275
|
-
>
|
|
276
|
-
{trimmedCardButtonTitle}
|
|
277
|
-
</CapLabel>
|
|
278
|
-
);
|
|
279
|
-
})}
|
|
280
|
-
</CapRow>
|
|
281
|
-
</CapRow>
|
|
282
|
-
))}
|
|
283
|
-
</CapRow>
|
|
284
|
-
</CapRow>
|
|
285
|
-
</>
|
|
286
|
-
)}
|
|
287
|
-
{!showCarouselInPreview && (
|
|
288
|
-
<CapLabel type="label1" className="viber-timestamp">
|
|
289
|
-
{timestamp}
|
|
290
|
-
</CapLabel>
|
|
291
|
-
)}
|
|
181
|
+
<CapLabel type="label1" className="viber-timestamp">
|
|
182
|
+
{timestamp}
|
|
183
|
+
</CapLabel>
|
|
292
184
|
<CapRow className="empty-placeholder" />
|
|
293
185
|
</CapRow>
|
|
294
186
|
|
|
@@ -322,16 +214,6 @@ ViberPreviewContent.propTypes = {
|
|
|
322
214
|
viberVideoPreviewImg: PropTypes.string,
|
|
323
215
|
}),
|
|
324
216
|
buttonText: PropTypes.string,
|
|
325
|
-
type: PropTypes.string,
|
|
326
|
-
cards: PropTypes.arrayOf(PropTypes.shape({
|
|
327
|
-
text: PropTypes.string,
|
|
328
|
-
mediaUrl: PropTypes.string,
|
|
329
|
-
buttons: PropTypes.arrayOf(PropTypes.shape({
|
|
330
|
-
title: PropTypes.string,
|
|
331
|
-
action: PropTypes.string,
|
|
332
|
-
})),
|
|
333
|
-
})),
|
|
334
|
-
showCarouselEditorPreview: PropTypes.bool,
|
|
335
217
|
}),
|
|
336
218
|
}),
|
|
337
219
|
device: PropTypes.oneOf([ANDROID, IOS]),
|
|
@@ -2116,8 +2116,6 @@
|
|
|
2116
2116
|
flex: 1;
|
|
2117
2117
|
display: flex;
|
|
2118
2118
|
flex-direction: column;
|
|
2119
|
-
overflow-y: auto;
|
|
2120
|
-
-webkit-overflow-scrolling: touch;
|
|
2121
2119
|
padding: 0 $CAP_SPACE_16;
|
|
2122
2120
|
background-color: #ffffff;
|
|
2123
2121
|
margin-left: $CAP_SPACE_06;
|
|
@@ -2143,12 +2141,6 @@
|
|
|
2143
2141
|
margin-top: $CAP_SPACE_16;
|
|
2144
2142
|
width: 68%;
|
|
2145
2143
|
|
|
2146
|
-
&.viber-preview-carousel {
|
|
2147
|
-
width: 100%;
|
|
2148
|
-
margin-left: $CAP_SPACE_12;
|
|
2149
|
-
max-height: none;
|
|
2150
|
-
}
|
|
2151
|
-
|
|
2152
2144
|
// Account icon (from TemplatePreview line 1146-1160)
|
|
2153
2145
|
.viber-account-icon {
|
|
2154
2146
|
width: $CAP_SPACE_20;
|
|
@@ -2177,18 +2169,6 @@
|
|
|
2177
2169
|
border-radius: $CAP_SPACE_04;
|
|
2178
2170
|
padding: $CAP_SPACE_04;
|
|
2179
2171
|
|
|
2180
|
-
&.viber-message-pop-carousel {
|
|
2181
|
-
width: 100%;
|
|
2182
|
-
left: 0;
|
|
2183
|
-
margin-top: 0;
|
|
2184
|
-
padding: 0;
|
|
2185
|
-
background: transparent;
|
|
2186
|
-
display: flex;
|
|
2187
|
-
flex-direction: column;
|
|
2188
|
-
align-items: flex-start;
|
|
2189
|
-
gap: $CAP_SPACE_06;
|
|
2190
|
-
}
|
|
2191
|
-
|
|
2192
2172
|
// Text Viber preview (from TemplatePreview line 1166-1174)
|
|
2193
2173
|
.viber-message-text {
|
|
2194
2174
|
margin: 0.107rem $CAP_SPACE_06 $CAP_SPACE_01 0.5rem;
|
|
@@ -2260,149 +2240,6 @@
|
|
|
2260
2240
|
}
|
|
2261
2241
|
}
|
|
2262
2242
|
|
|
2263
|
-
.viber-carousel-message-pop,
|
|
2264
|
-
.viber-carousel-cards-pop {
|
|
2265
|
-
width: 100%;
|
|
2266
|
-
background: $CAP_G08;
|
|
2267
|
-
border-radius: $CAP_SPACE_06;
|
|
2268
|
-
padding: $CAP_SPACE_08;
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
.viber-carousel-message-pop {
|
|
2272
|
-
margin-top: 0;
|
|
2273
|
-
width: 68%;
|
|
2274
|
-
border-radius: 0 $CAP_SPACE_06 $CAP_SPACE_06 $CAP_SPACE_06;
|
|
2275
|
-
}
|
|
2276
|
-
|
|
2277
|
-
.viber-carousel-cards-pop {
|
|
2278
|
-
margin-top: 0;
|
|
2279
|
-
width: 100%;
|
|
2280
|
-
background: transparent;
|
|
2281
|
-
border: none;
|
|
2282
|
-
border-radius: 0;
|
|
2283
|
-
padding: 0;
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
.viber-carousel-message-box {
|
|
2287
|
-
width: 100%;
|
|
2288
|
-
min-height: 2.25rem;
|
|
2289
|
-
height: auto;
|
|
2290
|
-
border-radius: $CAP_SPACE_04;
|
|
2291
|
-
background: transparent;
|
|
2292
|
-
padding: 0 $CAP_SPACE_08;
|
|
2293
|
-
display: flex;
|
|
2294
|
-
align-items: center;
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
.viber-carousel-message-box-text {
|
|
2298
|
-
color: $CAP_G01;
|
|
2299
|
-
margin: 0.107rem $CAP_SPACE_06 $CAP_SPACE_01 0.5rem;
|
|
2300
|
-
white-space: normal;
|
|
2301
|
-
word-break: break-word;
|
|
2302
|
-
overflow: visible;
|
|
2303
|
-
width: 100%;
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
|
-
.viber-carousel-message-box-placeholder {
|
|
2307
|
-
width: 100%;
|
|
2308
|
-
height: 0.875rem;
|
|
2309
|
-
border-radius: $CAP_SPACE_04;
|
|
2310
|
-
background: $CAP_G07;
|
|
2311
|
-
}
|
|
2312
|
-
|
|
2313
|
-
.viber-carousel-message-timestamp,
|
|
2314
|
-
.viber-carousel-cards-timestamp {
|
|
2315
|
-
display: block;
|
|
2316
|
-
text-align: right;
|
|
2317
|
-
margin-top: $CAP_SPACE_06;
|
|
2318
|
-
color: $CAP_G04;
|
|
2319
|
-
}
|
|
2320
|
-
|
|
2321
|
-
.viber-carousel-preview-scroll {
|
|
2322
|
-
display: flex;
|
|
2323
|
-
width: 100%;
|
|
2324
|
-
overflow-x: auto;
|
|
2325
|
-
overflow-y: visible;
|
|
2326
|
-
|
|
2327
|
-
scrollbar-width: none;
|
|
2328
|
-
-webkit-overflow-scrolling: touch;
|
|
2329
|
-
|
|
2330
|
-
&::-webkit-scrollbar {
|
|
2331
|
-
display: none;
|
|
2332
|
-
}
|
|
2333
|
-
|
|
2334
|
-
.viber-carousel-preview-card {
|
|
2335
|
-
flex: 0 0 68%;
|
|
2336
|
-
min-width: 68%;
|
|
2337
|
-
margin-right: $CAP_SPACE_08;
|
|
2338
|
-
background: $CAP_G09;
|
|
2339
|
-
border: 1px solid $CAP_G07;
|
|
2340
|
-
border-radius: $CAP_SPACE_12;
|
|
2341
|
-
overflow: hidden;
|
|
2342
|
-
display: flex;
|
|
2343
|
-
flex-direction: column;
|
|
2344
|
-
|
|
2345
|
-
&:last-child {
|
|
2346
|
-
margin-right: 0;
|
|
2347
|
-
}
|
|
2348
|
-
|
|
2349
|
-
.viber-carousel-preview-card-body {
|
|
2350
|
-
padding: $CAP_SPACE_08;
|
|
2351
|
-
display: flex;
|
|
2352
|
-
flex-direction: column;
|
|
2353
|
-
gap: $CAP_SPACE_06;
|
|
2354
|
-
}
|
|
2355
|
-
|
|
2356
|
-
.viber-carousel-preview-image {
|
|
2357
|
-
width: 100%;
|
|
2358
|
-
height: 10rem;
|
|
2359
|
-
object-fit: cover;
|
|
2360
|
-
border-radius: 0;
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
.viber-carousel-preview-image-placeholder {
|
|
2364
|
-
width: 100%;
|
|
2365
|
-
height: 10rem;
|
|
2366
|
-
border-radius: 0;
|
|
2367
|
-
background: $CAP_G07;
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
.viber-carousel-preview-text {
|
|
2371
|
-
color: $CAP_G01;
|
|
2372
|
-
line-height: 1.3;
|
|
2373
|
-
white-space: normal;
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
.viber-carousel-preview-text-placeholder {
|
|
2377
|
-
width: 100%;
|
|
2378
|
-
height: 0.875rem;
|
|
2379
|
-
border-radius: $CAP_SPACE_04;
|
|
2380
|
-
background: $CAP_G07;
|
|
2381
|
-
min-height: 0.875rem;
|
|
2382
|
-
}
|
|
2383
|
-
|
|
2384
|
-
.viber-carousel-preview-button {
|
|
2385
|
-
color: $CAP_WHITE;
|
|
2386
|
-
background: $CAP_PURPLE01;
|
|
2387
|
-
border-radius: $CAP_SPACE_12;
|
|
2388
|
-
text-align: center;
|
|
2389
|
-
width: 100%;
|
|
2390
|
-
display: flex;
|
|
2391
|
-
align-items: center;
|
|
2392
|
-
justify-content: center;
|
|
2393
|
-
min-height: 1.5rem;
|
|
2394
|
-
padding: $CAP_SPACE_06 $CAP_SPACE_08;
|
|
2395
|
-
white-space: normal;
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
.viber-carousel-preview-button-secondary {
|
|
2399
|
-
color: $CAP_PURPLE01;
|
|
2400
|
-
background: transparent;
|
|
2401
|
-
border: none;
|
|
2402
|
-
}
|
|
2403
|
-
}
|
|
2404
|
-
}
|
|
2405
|
-
|
|
2406
2243
|
.empty-placeholder {
|
|
2407
2244
|
height: $CAP_SPACE_08;
|
|
2408
2245
|
}
|
|
@@ -1554,8 +1554,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1554
1554
|
let imageData = null;
|
|
1555
1555
|
let videoData = null;
|
|
1556
1556
|
let buttonData = null;
|
|
1557
|
-
let cardsData = [];
|
|
1558
|
-
let messageType = '';
|
|
1559
1557
|
let accountId = null;
|
|
1560
1558
|
let accountDetails = null;
|
|
1561
1559
|
let scenarioKey = '';
|
|
@@ -1570,8 +1568,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1570
1568
|
imageData = formDataObj.image || null;
|
|
1571
1569
|
videoData = formDataObj.video || null;
|
|
1572
1570
|
buttonData = formDataObj.button || null;
|
|
1573
|
-
cardsData = formDataObj.cards || [];
|
|
1574
|
-
messageType = formDataObj.type || '';
|
|
1575
1571
|
accountId = formDataObj.accountId || null;
|
|
1576
1572
|
accountDetails = formDataObj.accountDetails || null;
|
|
1577
1573
|
scenarioKey = formDataObj.scenarioKey || VIBER_API_SCENARIO_KEY;
|
|
@@ -1598,8 +1594,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1598
1594
|
url: formDataObj?.buttonURL || '',
|
|
1599
1595
|
};
|
|
1600
1596
|
}
|
|
1601
|
-
cardsData = viberPreview.cards || formDataObj?.cards || [];
|
|
1602
|
-
messageType = viberPreview.type || formDataObj?.type || '';
|
|
1603
1597
|
// Extract account info from parent formDataObj if available
|
|
1604
1598
|
accountId = formDataObj.accountId || null;
|
|
1605
1599
|
accountDetails = formDataObj.accountDetails || null;
|
|
@@ -1642,10 +1636,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1642
1636
|
text: messageText,
|
|
1643
1637
|
};
|
|
1644
1638
|
|
|
1645
|
-
if (messageType === CHANNELS.VIBER) {
|
|
1646
|
-
messageType = '';
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
1639
|
// Add image if present
|
|
1650
1640
|
if (imageData && imageData.url) {
|
|
1651
1641
|
viberContent.image = {
|
|
@@ -1674,19 +1664,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1674
1664
|
}
|
|
1675
1665
|
}
|
|
1676
1666
|
|
|
1677
|
-
if (messageType === MEDIA_TYPE_CAROUSEL || (Array.isArray(cardsData) && cardsData.length)) {
|
|
1678
|
-
viberContent.type = MEDIA_TYPE_CAROUSEL;
|
|
1679
|
-
viberContent.cards = (cardsData || []).map((card) => ({
|
|
1680
|
-
text: card?.text || '',
|
|
1681
|
-
mediaUrl: card?.mediaUrl || '',
|
|
1682
|
-
buttons: (card?.buttons || []).map((button) => ({
|
|
1683
|
-
title: button?.title || '',
|
|
1684
|
-
action: button?.action || '',
|
|
1685
|
-
})),
|
|
1686
|
-
}));
|
|
1687
|
-
delete viberContent.button;
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
1667
|
// Resolve tags in text if custom values are provided
|
|
1691
1668
|
if (customValuesObj && Object.keys(customValuesObj).length > 0 && viberContent.text) {
|
|
1692
1669
|
viberContent.text = resolveTagsInText(viberContent.text, customValuesObj);
|
|
@@ -2033,13 +2010,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
2033
2010
|
// Only use previewDataHtml if preview call was made
|
|
2034
2011
|
if (hasPreviewCallBeenMade && previewDataHtml?.resolvedBody) {
|
|
2035
2012
|
resolvedContent = previewDataHtml.resolvedBody;
|
|
2036
|
-
if (typeof resolvedContent === 'string') {
|
|
2037
|
-
try {
|
|
2038
|
-
resolvedContent = JSON.parse(resolvedContent);
|
|
2039
|
-
} catch (e) {
|
|
2040
|
-
resolvedContent = null;
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
2013
|
}
|
|
2044
2014
|
|
|
2045
2015
|
// Parse content if it's a string
|
|
@@ -2051,25 +2021,15 @@ const CommonTestAndPreview = (props) => {
|
|
|
2051
2021
|
parsedViberContent = {};
|
|
2052
2022
|
}
|
|
2053
2023
|
}
|
|
2054
|
-
//
|
|
2024
|
+
// Use resolvedContent if available (from preview call), otherwise use raw content
|
|
2055
2025
|
if (resolvedContent && typeof resolvedContent === 'object') {
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
viberPreviewContent: {
|
|
2061
|
-
...base.viberPreviewContent,
|
|
2062
|
-
...resolvedContent.viberPreviewContent,
|
|
2063
|
-
...(resolvedContent.messageContent != null && typeof resolvedContent.messageContent === 'string'
|
|
2064
|
-
? { messageContent: resolvedContent.messageContent }
|
|
2065
|
-
: {}),
|
|
2066
|
-
},
|
|
2067
|
-
};
|
|
2068
|
-
if (base.accountName && !contentObj.accountName) {
|
|
2069
|
-
contentObj.accountName = base.accountName;
|
|
2026
|
+
contentObj = { ...resolvedContent };
|
|
2027
|
+
// Merge in accountName and brandName from raw content if not in resolvedContent
|
|
2028
|
+
if (parsedViberContent?.accountName && !contentObj.accountName) {
|
|
2029
|
+
contentObj.accountName = parsedViberContent.accountName;
|
|
2070
2030
|
}
|
|
2071
|
-
if (
|
|
2072
|
-
contentObj.brandName =
|
|
2031
|
+
if (parsedViberContent?.brandName && !contentObj.brandName) {
|
|
2032
|
+
contentObj.brandName = parsedViberContent.brandName;
|
|
2073
2033
|
}
|
|
2074
2034
|
} else {
|
|
2075
2035
|
// Use raw content if no preview call was made or resolvedContent is not available
|