@capillarytech/creatives-library 8.0.87-alpha.21 → 8.0.87-alpha.22

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 (55) hide show
  1. package/containers/Templates/constants.js +6 -0
  2. package/containers/Templates/index.js +44 -24
  3. package/package.json +1 -1
  4. package/services/api.js +20 -10
  5. package/services/tests/api.test.js +5 -1
  6. package/utils/commonUtils.js +64 -10
  7. package/utils/tests/commonUtil.test.js +108 -3
  8. package/utils/tests/transformerUtils.test.js +2127 -0
  9. package/v2Components/CapImageUpload/index.js +13 -10
  10. package/v2Components/CapVideoUpload/index.js +12 -9
  11. package/v2Components/CapWhatsappCTA/messages.js +4 -0
  12. package/v2Components/CapWhatsappCarouselButton/constant.js +56 -0
  13. package/v2Components/CapWhatsappCarouselButton/index.js +446 -0
  14. package/v2Components/CapWhatsappCarouselButton/index.scss +39 -0
  15. package/v2Components/CapWhatsappCarouselButton/tests/index.test.js +237 -0
  16. package/v2Components/FormBuilder/constants.js +8 -0
  17. package/v2Components/FormBuilder/index.js +2 -2
  18. package/v2Components/TemplatePreview/_templatePreview.scss +20 -0
  19. package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +4 -0
  20. package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +4 -0
  21. package/v2Components/TemplatePreview/index.js +160 -105
  22. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
  23. package/v2Containers/CreativesContainer/SlideBoxContent.js +0 -6
  24. package/v2Containers/CreativesContainer/index.js +100 -7
  25. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +3 -0
  26. package/v2Containers/Email/index.js +0 -1
  27. package/v2Containers/EmailWrapper/components/EmailWrapperView.js +192 -0
  28. package/v2Containers/EmailWrapper/constants.js +11 -1
  29. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +343 -0
  30. package/v2Containers/EmailWrapper/index.js +116 -300
  31. package/v2Containers/EmailWrapper/mockdata/mockdata.js +119 -0
  32. package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +214 -0
  33. package/v2Containers/EmailWrapper/tests/index.test.js +101 -0
  34. package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +601 -0
  35. package/v2Containers/MobilePush/Edit/index.js +0 -1
  36. package/v2Containers/MobilepushWrapper/index.js +1 -2
  37. package/v2Containers/Sms/Create/index.js +0 -1
  38. package/v2Containers/SmsWrapper/index.js +0 -2
  39. package/v2Containers/Templates/_templates.scss +47 -0
  40. package/v2Containers/Templates/index.js +55 -5
  41. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +177 -156
  42. package/v2Containers/Whatsapp/constants.js +87 -1
  43. package/v2Containers/Whatsapp/index.js +715 -190
  44. package/v2Containers/Whatsapp/index.scss +52 -1
  45. package/v2Containers/Whatsapp/messages.js +38 -2
  46. package/v2Containers/Whatsapp/styles.scss +5 -0
  47. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +27722 -90751
  48. package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +6 -0
  49. package/v2Containers/Whatsapp/tests/mockData.js +3 -7
  50. package/v2Containers/Whatsapp/tests/utils.test.js +178 -1
  51. package/v2Containers/Whatsapp/utils.js +52 -0
  52. package/v2Containers/Zalo/index.js +47 -15
  53. package/v2Containers/Zalo/index.scss +8 -0
  54. package/v2Containers/Zalo/messages.js +4 -0
  55. package/v2Containers/mockdata.js +2 -0
@@ -44,6 +44,7 @@ function CapImageUpload(props) {
44
44
  imageData,
45
45
  channel,
46
46
  channelSpecificStyle,
47
+ showReUploadButton = true,
47
48
  } = props;
48
49
  const {
49
50
  formatMessage,
@@ -224,16 +225,18 @@ function CapImageUpload(props) {
224
225
  </>
225
226
  );
226
227
  }
227
- return (
228
- <CapButton
229
- className="dragger-button re-upload"
230
- type="flat"
231
- onClick={onReUpload}
232
- style={channelSpecificStyle ? { marginTop: '-16px'} : {}}
233
- >
234
- <FormattedMessage {...messages.imageReUpload} />
235
- </CapButton>
236
- );
228
+ if (showReUploadButton) {
229
+ return (
230
+ <CapButton
231
+ className="dragger-button re-upload"
232
+ type="flat"
233
+ onClick={onReUpload}
234
+ style={channelSpecificStyle ? { marginTop: '-16px'} : {}}
235
+ >
236
+ <FormattedMessage {...messages.imageReUpload} />
237
+ </CapButton>
238
+ );
239
+ }
237
240
  }, [isImageError, imageSrc]);
238
241
 
239
242
  return (
@@ -39,6 +39,7 @@ function CapVideoUpload(props) {
39
39
  errorMessage,
40
40
  showVideoNameAndDuration = true,
41
41
  formClassName = 'video-form',
42
+ showReUploadButton = true,
42
43
  } = props;
43
44
  const [isVideoError, updateVideoErrorMessage] = useState(false);
44
45
  const [isVideo, updateVideoStatus] = useState(false);
@@ -246,15 +247,17 @@ function CapVideoUpload(props) {
246
247
  const videoDurationValue = moment('1900-01-01 00:00:00').add(videoDuration, 'seconds').format("HH.mm.ss"); // to get the duration of video
247
248
  return (
248
249
  <Fragment key={videoSrc}>
249
- <div style={{ overflow: 'hidden' }}>
250
- <CapButton
251
- className="dragger-button video-reupload"
252
- type="flat"
253
- onClick={onReUpload}
254
- >
255
- <FormattedMessage {...messages.imageReUpload} />
256
- </CapButton>
257
- </div>
250
+ {showReUploadButton && (
251
+ <div style={{ overflow: 'hidden' }}>
252
+ <CapButton
253
+ className="dragger-button video-reupload"
254
+ type="flat"
255
+ onClick={onReUpload}
256
+ >
257
+ <FormattedMessage {...messages.imageReUpload} />
258
+ </CapButton>
259
+ </div>
260
+ )}
258
261
  <div className={showVideoNameAndDuration ? 'video-panel' : 'video-panel-wp'}>
259
262
  <video
260
263
  width="230"
@@ -104,4 +104,8 @@ export default defineMessages({
104
104
  id: `${prefix}.whatsappCtaTagListRevert`,
105
105
  defaultMessage: 'Reset website URL label to default value',
106
106
  },
107
+ url: {
108
+ id: `${prefix}.url`,
109
+ defaultMessage: 'URL',
110
+ },
107
111
  });
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import capWhatsappCTAMsg from '../CapWhatsappCTA/messages';
4
+ import capWhatsappMsg from '../../v2Containers/Whatsapp/messages';
5
+
6
+ export const PHONE_NUMBER = 'PHONE_NUMBER';
7
+ export const URL = 'URL';
8
+ export const QUICK_REPLY = 'QUICK_REPLY';
9
+ export const STATIC_URL = 'STATIC_URL';
10
+ export const BTN_MAX_LENGTH = 20;
11
+ export const PHONE_NUMBER_MAX_LENGTH = 15;
12
+ export const URL_MAX_LENGTH = 2000;
13
+ export const carouselButtonOptions = (carouselIndex) => {
14
+ return [
15
+ {
16
+ value: PHONE_NUMBER,
17
+ label: <FormattedMessage {...capWhatsappCTAMsg.ctaPhoneNo} />,
18
+ disabled: carouselIndex > 0,
19
+ },
20
+ {
21
+ value: URL,
22
+ label: <FormattedMessage {...capWhatsappCTAMsg.url} />,
23
+ disabled: carouselIndex > 0,
24
+ },
25
+ {
26
+ value: QUICK_REPLY,
27
+ label: <FormattedMessage {...capWhatsappMsg.btnTypeQuickReply} />,
28
+ disabled: carouselIndex > 0,
29
+ },
30
+ ];
31
+ };
32
+
33
+ export const INITIAL_CAROUSEL_PHONE_NUMBER_DATA = {
34
+ buttonType: PHONE_NUMBER,
35
+ text: '',
36
+ phone_number: '',
37
+ isSaved: false,
38
+ textError: "",
39
+ };
40
+
41
+ export const INITIAL_CAROUSEL_URL_DATA = {
42
+ buttonType: URL,
43
+ text: '',
44
+ urlType: STATIC_URL,
45
+ url: '',
46
+ isSaved: false,
47
+ textError: "",
48
+ urlError: "",
49
+ };
50
+
51
+ export const INITIAL_CAROUSEL_QUICK_REPLY_DATA = {
52
+ text: "",
53
+ buttonType: QUICK_REPLY,
54
+ isSaved: false,
55
+ textError: "",
56
+ };
@@ -0,0 +1,446 @@
1
+ import React, { useState } from "react";
2
+ import { injectIntl } from "react-intl";
3
+ import PhoneInput from 'react-phone-input-2';
4
+ import { cloneDeep } from "lodash";
5
+ import 'react-phone-input-2/lib/style.css';
6
+ import CapRow from "@capillarytech/cap-ui-library/CapRow";
7
+ import CapRadioGroup from "@capillarytech/cap-ui-library/CapRadioGroup";
8
+ import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
9
+ import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
10
+ import CapInput from "@capillarytech/cap-ui-library/CapInput";
11
+ import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
12
+ import CapTooltipWithInfo from "@capillarytech/cap-ui-library/CapTooltipWithInfo";
13
+ import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
14
+ import CapButton from "@capillarytech/cap-ui-library/CapButton";
15
+ import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
16
+ import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
17
+ import { CAP_SPACE_04 } from "@capillarytech/cap-ui-library/styled/variables";
18
+ import TagList from "../../v2Containers/TagList";
19
+ import {
20
+ carouselButtonOptions,
21
+ INITIAL_CAROUSEL_PHONE_NUMBER_DATA,
22
+ INITIAL_CAROUSEL_QUICK_REPLY_DATA,
23
+ INITIAL_CAROUSEL_URL_DATA,
24
+ PHONE_NUMBER,
25
+ URL,
26
+ BTN_MAX_LENGTH,
27
+ PHONE_NUMBER_MAX_LENGTH,
28
+ URL_MAX_LENGTH,
29
+ QUICK_REPLY,
30
+ } from "./constant";
31
+ import capWhatsappMsg from '../../v2Containers/Whatsapp/messages';
32
+ import capWhatsappCTAMsg from '../CapWhatsappCTA/messages';
33
+ import {
34
+ KARIX_GUPSHUP_URL_OPTIONS, TWILIO_URL_OPTIONS, DYNAMIC_URL, STATIC_URL,
35
+ } from "../CapWhatsappCTA/constants";
36
+ import globalMessages from '../../v2Containers/Cap/messages';
37
+ import { isUrl, isValidText } from '../../v2Containers/Line/Container/Wrapper/utils';
38
+ import { HOST_TWILIO } from "../../v2Containers/Whatsapp/constants";
39
+ import "./index.scss";
40
+
41
+ export const CapWhatsappCarouselButton = (props) => {
42
+ const {
43
+ intl,
44
+ carouselData = [],
45
+ setCarouselData,
46
+ carouselIndex = 0,
47
+ hostName = '',
48
+ isEditFlow = false,
49
+ tags = [],
50
+ injectedTags = {},
51
+ selectedOfferDetails = [],
52
+ } = props;
53
+ const { formatMessage } = intl;
54
+ const buttonData = carouselData[carouselIndex]?.buttons || [];
55
+ const invalidVarRegex = /{{(.*?)}}/g;
56
+
57
+ const handleButtonType = ({ target: { value } }, buttonIndex) => {
58
+ const cloneCarouselData = cloneDeep(carouselData);
59
+ const dataMap = {
60
+ [PHONE_NUMBER]: INITIAL_CAROUSEL_PHONE_NUMBER_DATA,
61
+ [URL]: INITIAL_CAROUSEL_URL_DATA,
62
+ [QUICK_REPLY]: INITIAL_CAROUSEL_QUICK_REPLY_DATA,
63
+ };
64
+
65
+ const updatedCarouselData = cloneCarouselData.map((carousel) => {
66
+ carousel.buttons[buttonIndex] = dataMap[value] || {};
67
+ return carousel;
68
+ });
69
+
70
+ setCarouselData(updatedCarouselData);
71
+ };
72
+
73
+ const onValueChange = (buttonIndex, fields = []) => {
74
+ const updatedButtonData = cloneDeep(buttonData);
75
+ fields.forEach((field) => {
76
+ updatedButtonData[buttonIndex][field?.fieldName] = field?.value;
77
+ });
78
+ setCarouselData(
79
+ carouselData.map((item, index) => index === carouselIndex
80
+ ? { ...item, buttons: updatedButtonData }
81
+ : item)
82
+ );
83
+ };
84
+
85
+ const onTagSelect = (data, index, url) => {
86
+ onValueChange(index, [{fieldName: 'url', value: url.replace('{{1}}', `{{${data}}}`)}]);
87
+ };
88
+
89
+ const revertTagSelect = (index, url) => {
90
+ onValueChange(index, [{fieldName: 'url', value: url.replace(invalidVarRegex, `{{1}}`)}]);
91
+ };
92
+
93
+ const renderLength = (len, max) => (
94
+ <CapHeading type="label1" className="whatsapp-render-btn-length">
95
+ {formatMessage(capWhatsappMsg.templateMessageLength, {
96
+ currentLength: len,
97
+ maxLength: max,
98
+ })}
99
+ </CapHeading>
100
+ );
101
+
102
+ const onUrlChange = ({ target = {} }, urlType, buttonIndex) => {
103
+ let { value = '' } = target;
104
+ if (urlType === DYNAMIC_URL) {
105
+ value = value.replace(invalidVarRegex, '');
106
+ value = `${value}{{1}}`;
107
+ }
108
+ let errorMessage = false;
109
+ if (!isUrl(value)) {
110
+ errorMessage = formatMessage(capWhatsappCTAMsg.ctaWebsiteUrlErrorMessage);
111
+ } else if (
112
+ urlType === STATIC_URL
113
+ && value.match(invalidVarRegex)?.length > 0
114
+ ) {
115
+ errorMessage = formatMessage(capWhatsappCTAMsg.staticUrlWithVarErrorMessage);
116
+ }
117
+ onValueChange(buttonIndex, [{fieldName: 'url', value}, {fieldName: 'urlError', value: errorMessage}]);
118
+ };
119
+
120
+ const onButtonTextChange = (value, buttonIndex) => {
121
+ let errorMessage = '';
122
+ if (!isValidText(value)) {
123
+ errorMessage = formatMessage(capWhatsappCTAMsg.ctaButtonErrorMessage);
124
+ }
125
+ onValueChange(buttonIndex, [{fieldName: 'text', value}, {fieldName: 'textError', value: errorMessage}]);
126
+ };
127
+
128
+ const ctaSaveDisabled = (index) => {
129
+ const {
130
+ buttonType, text, phone_number, url, textError, urlError,
131
+ } = buttonData[index] || {};
132
+ if (text === '' || textError) {
133
+ return true;
134
+ } if (buttonType === PHONE_NUMBER && phone_number.length < 5) {
135
+ return true;
136
+ } if (buttonType === URL && (url === '' || urlError)) {
137
+ return true;
138
+ }
139
+ return false;
140
+ };
141
+
142
+ const handleSaveButton = (buttonIndex) => {
143
+ onValueChange(buttonIndex, [{fieldName: 'isSaved', value: true}]);
144
+ };
145
+
146
+ const handleEditButton = (buttonIndex) => {
147
+ onValueChange(buttonIndex, [{fieldName: 'isSaved', value: false}]);
148
+ };
149
+
150
+ const handleDeleteButton = (buttonIndex) => {
151
+ setCarouselData((prevData) => prevData.map((carousel) => ({
152
+ ...carousel,
153
+ buttons: carousel.buttons.filter((_, index) => index !== buttonIndex),
154
+ })));
155
+ };
156
+
157
+ const addCarouselButton = () => {
158
+ setCarouselData(
159
+ carouselData.map((item, index) => index === carouselIndex
160
+ ? { ...item, buttons: [...buttonData, INITIAL_CAROUSEL_PHONE_NUMBER_DATA] }
161
+ : item)
162
+ );
163
+ };
164
+
165
+ const renderButtonContent = (buttonType, buttonIndex) => (
166
+ <>
167
+ <CapRow className="text-box-container">
168
+ <CapColumn span={24}>
169
+ {/* Button text */}
170
+ <CapHeading type="h4" className="cta-label">
171
+ {formatMessage(capWhatsappCTAMsg.ctaButtonText)}
172
+ <CapTooltipWithInfo
173
+ infoIconProps={{
174
+ style: { marginLeft: CAP_SPACE_04 },
175
+ }}
176
+ autoAdjustOverflow
177
+ placement="right"
178
+ title={formatMessage(capWhatsappCTAMsg.ctaButtonTextTooltip)}
179
+ />
180
+ </CapHeading>
181
+ <CapInput
182
+ className="whatsapp-cta-button-text"
183
+ onChange={({ target: { value } }) => onButtonTextChange(value, buttonIndex)}
184
+ placeholder={formatMessage(capWhatsappCTAMsg.ctaButtonTextPlaceholder)}
185
+ value={buttonData[buttonIndex].text}
186
+ size="large"
187
+ maxLength={BTN_MAX_LENGTH}
188
+ errorMessage={buttonData[buttonIndex]?.textError}
189
+ />
190
+ {renderLength(buttonData[buttonIndex]?.text?.length, BTN_MAX_LENGTH)}
191
+ </CapColumn>
192
+ </CapRow>
193
+ {buttonType === PHONE_NUMBER && (
194
+ <CapRow className="text-box-container">
195
+ <CapColumn span={24}>
196
+ {/* phone number */}
197
+ <CapHeading type="h4" className="cta-label">
198
+ {formatMessage(capWhatsappCTAMsg.ctaPhoneNo)}
199
+ </CapHeading>
200
+ <PhoneInput
201
+ placeholder={formatMessage(capWhatsappCTAMsg.ctaPhoneNoPlaceholder)}
202
+ autoFormat={false}
203
+ countryCodeEditable={false}
204
+ value={buttonData[buttonIndex].phone_number}
205
+ onChange={(value) => onValueChange(buttonIndex, [{fieldName: 'phone_number', value}])}
206
+ country="in"
207
+ className="cta-phone-number carousel-button-phone-number"
208
+ />
209
+ {renderLength(buttonData[buttonIndex]?.phone_number.length, PHONE_NUMBER_MAX_LENGTH)}
210
+ </CapColumn>
211
+ </CapRow>
212
+ )}
213
+ {buttonType === URL
214
+ && (
215
+ <CapRow className="text-box-container">
216
+ <CapColumn span={6}>
217
+ {/* URL Type */}
218
+ <CapHeading type="h4" className="cta-label">
219
+ {formatMessage(capWhatsappCTAMsg.ctaWebsiteType)}
220
+ </CapHeading>
221
+ <CapSelect
222
+ id="whatsapp-carousel-button-url-type"
223
+ options={
224
+ hostName === HOST_TWILIO
225
+ ? TWILIO_URL_OPTIONS
226
+ : KARIX_GUPSHUP_URL_OPTIONS
227
+ }
228
+ onChange={(value) => onValueChange(buttonIndex, [{fieldName: 'urlType', value}])}
229
+ value={buttonData[buttonIndex]?.urlType}
230
+ />
231
+ </CapColumn>
232
+ <CapColumn span={18}>
233
+ {/* cta url */}
234
+ <CapHeading type="h4" className="cta-label">
235
+ {formatMessage(capWhatsappCTAMsg.ctaWebsiteUrl)}
236
+ {buttonData[buttonIndex]?.urlType === DYNAMIC_URL && (
237
+ <CapTooltipWithInfo
238
+ infoIconProps={{
239
+ style: { marginLeft: CAP_SPACE_04 },
240
+ }}
241
+ autoAdjustOverflow
242
+ placement="right"
243
+ title={formatMessage(capWhatsappCTAMsg.dynamicUrlTooltip, { one: '{{1}}' })}
244
+ />
245
+ )}
246
+ </CapHeading>
247
+ <CapInput
248
+ className="whatsapp-cta-url"
249
+ onChange={(event) => onUrlChange(event, buttonData[buttonIndex]?.urlType, buttonIndex)}
250
+ placeholder={
251
+ buttonData[buttonIndex]?.urlType === DYNAMIC_URL
252
+ ? formatMessage(capWhatsappCTAMsg.ctaDynamicPlaceholder)
253
+ : formatMessage(capWhatsappCTAMsg.ctaStaticPlaceholder)
254
+ }
255
+ value={buttonData[buttonIndex]?.url}
256
+ size="large"
257
+ maxLength={URL_MAX_LENGTH}
258
+ errorMessage={buttonData[buttonIndex]?.urlError || ''}
259
+ />
260
+ {renderLength(buttonData[buttonIndex]?.url?.length, URL_MAX_LENGTH)}
261
+ </CapColumn>
262
+ </CapRow>
263
+ )
264
+ }
265
+ {/* it render save and delete button */}
266
+ <CapRow className="whatsapp-cta-save-delete-btn whatsapp-carousel-save-edit-btn">
267
+ <CapTooltip
268
+ title={
269
+ ctaSaveDisabled(buttonIndex)
270
+ && formatMessage(capWhatsappCTAMsg.ctaSaveDisabled)
271
+ }
272
+ placement="bottom"
273
+ >
274
+ <div className="button-disabled-tooltip-wrapper">
275
+ <CapButton
276
+ onClick={() => {
277
+ handleSaveButton(buttonIndex);
278
+ }}
279
+ disabled={ctaSaveDisabled(buttonIndex)}
280
+ className="whatsapp-cta-save-btn"
281
+ >
282
+ {formatMessage(globalMessages.save)}
283
+ </CapButton>
284
+ {buttonData.length > 1 && buttonIndex > 0 && parseInt(carouselIndex, 10) === 0 && (
285
+ <CapButton
286
+ onClick={() => {
287
+ handleDeleteButton(buttonIndex);
288
+ }}
289
+ className="whatsapp-cta-delete-btn whatsapp-carousel-delete-button"
290
+ type="secondary"
291
+ >
292
+ {formatMessage(globalMessages.delete)}
293
+ </CapButton>
294
+ )}
295
+ </div>
296
+ </CapTooltip>
297
+ </CapRow>
298
+ </>
299
+ );
300
+
301
+ const isCarouselAddButtonDisable = buttonData?.length === 1 && !buttonData?.[0]?.isSaved;
302
+
303
+ return (
304
+ <CapRow>
305
+ {buttonData.map((button, index) => {
306
+ const isPhoneNumberType = button?.buttonType === PHONE_NUMBER;
307
+ const isURLtype = button?.buttonType === URL;
308
+ if (button.isSaved || isEditFlow) {
309
+ return (
310
+ <CapRow
311
+ key={`${button.buttonType}_${index}`}
312
+ className={`cap-whatsapp-saved-cta cap-whatsapp-saved-carousel-button margin-t-12 ${isEditFlow ? 'margin-l-0' : ''}`}
313
+ align="middle"
314
+ type="flex"
315
+ >
316
+ <CapColumn
317
+ span={1}
318
+ className={`${isPhoneNumberType ? 'whatsapp-saved-cta-phone-icon' : ''}`}
319
+ >
320
+ <CapIcon size="s" type={isPhoneNumberType ? 'call' : isURLtype ? 'launch' : 'six-dots'} />
321
+ </CapColumn>
322
+ <CapColumn span={6}>
323
+ <CapLabel
324
+ type="label2"
325
+ className="whatsapp-saved-cta-button-text"
326
+ >
327
+ {button?.text}
328
+ </CapLabel>
329
+ </CapColumn>
330
+ {isPhoneNumberType && (
331
+ <CapColumn span={10} align="left">
332
+ <CapLabel className="phone">
333
+ {button?.phone_number}
334
+ </CapLabel>
335
+ </CapColumn>
336
+ )}
337
+ {isURLtype && (
338
+ <>
339
+ <CapColumn span={3}>
340
+ <CapLabel className="url-type" type="label2">
341
+ {button?.urlType === STATIC_URL
342
+ ? formatMessage(capWhatsappCTAMsg.ctaWebsiteTypeStatic)
343
+ : formatMessage(capWhatsappCTAMsg.ctaWebsiteTypeDynamic)}
344
+ </CapLabel>
345
+ </CapColumn>
346
+ <CapTooltip title={button?.url} placement="top">
347
+ <CapColumn span={7} className="margin-r-0">
348
+ <CapLabel className="url">{button?.url}</CapLabel>
349
+ </CapColumn>
350
+ </CapTooltip>
351
+ </>
352
+ )}
353
+ {!isEditFlow && (
354
+ <>
355
+ <CapColumn
356
+ span={1}
357
+ className="whatsapp-saved-cta-edit-icon"
358
+ onClick={() => handleEditButton(index)}
359
+ >
360
+ <CapIcon size="s" type="edit" />
361
+ </CapColumn>
362
+ {parseInt(carouselIndex, 10) === 0 && (
363
+ <CapColumn span={1}>
364
+ <CapButton type="flat" className="whatsapp-carousel-delete-icon-btn" onClick={() => handleDeleteButton(index)} disabled={buttonData?.length === 1}>
365
+ <CapIcon size="s" type="delete" />
366
+ </CapButton>
367
+ </CapColumn>
368
+ )}
369
+ </>
370
+ )}
371
+ {isEditFlow && button?.urlType === DYNAMIC_URL && button?.url.includes('{{1}}') && (
372
+ <CapColumn>
373
+ <TagList
374
+ className="whatsapp-cta-taglist"
375
+ label={formatMessage(capWhatsappCTAMsg.whatsappCtaTagListLabel)}
376
+ onTagSelect={(data) => onTagSelect(data, index, button?.url)}
377
+ tags={tags}
378
+ injectedTags={injectedTags}
379
+ selectedOfferDetails={selectedOfferDetails}
380
+ />
381
+ </CapColumn>
382
+ )}
383
+ {isEditFlow && button?.urlType === DYNAMIC_URL && !button?.url.includes('{{1}}') && (
384
+ <CapColumn
385
+ span={1}
386
+ onClick={() => revertTagSelect(index, button?.url)}
387
+ className="whatsapp-cta-tag-revert"
388
+ >
389
+ <CapTooltip
390
+ title={formatMessage(capWhatsappCTAMsg.whatsappCtaTagListRevert)}
391
+ placement="top"
392
+ >
393
+ <CapIcon size="s" type="return" />
394
+ </CapTooltip>
395
+ </CapColumn>
396
+ )}
397
+ </CapRow>
398
+ );
399
+ } return (
400
+ <CapRow
401
+ key={`${button.buttonType}_${index}`}
402
+ className="cap-whatsapp-carousel-button"
403
+ >
404
+ <CapLabel type="label16" className="button-type-heading">{formatMessage(capWhatsappMsg.buttonType)}</CapLabel>
405
+ <CapRadioGroup
406
+ id="carousel-button-radio"
407
+ options={carouselButtonOptions(carouselIndex)}
408
+ value={button.buttonType}
409
+ onChange={(e) => handleButtonType(e, index)}
410
+ className="whatsapp-media-radio"
411
+ />
412
+ {renderButtonContent(button.buttonType, index)}
413
+ </CapRow>
414
+ );
415
+ })}
416
+ <CapRow>
417
+ {/* user can add only two button in the first carousel in other carousel user dont allow to add buttons */}
418
+ {buttonData?.length < 2 && !isEditFlow && parseInt(carouselIndex, 10) === 0 && (
419
+ <CapRow>
420
+ <CapTooltip
421
+ title={
422
+ isCarouselAddButtonDisable ? formatMessage(capWhatsappCTAMsg.ctaAddDisabled) : ""
423
+ }
424
+ placement="right"
425
+ >
426
+ <div className="button-disabled-tooltip-wrapper">
427
+ <CapButton
428
+ type="flat"
429
+ id="whatsapp-quick-reply-add-button"
430
+ disabled={isCarouselAddButtonDisable}
431
+ className="margin-t-12 margin-l-24"
432
+ isAddBtn
433
+ onClick={addCarouselButton}
434
+ >
435
+ {formatMessage(capWhatsappCTAMsg.addButton)}
436
+ </CapButton>
437
+ </div>
438
+ </CapTooltip>
439
+ </CapRow>
440
+ )}
441
+ </CapRow>
442
+ </CapRow>
443
+ );
444
+ };
445
+
446
+ export default injectIntl(CapWhatsappCarouselButton);
@@ -0,0 +1,39 @@
1
+ @import "~@capillarytech/cap-ui-library/styles/_variables";
2
+
3
+ .cap-whatsapp-carousel-button {
4
+ border: solid 0.063rem $CAP_G06;
5
+ padding: $CAP_SPACE_24;
6
+ border-radius: 0.285rem;
7
+ margin-top: $CAP_SPACE_12;
8
+ .button-type-heading {
9
+ margin-bottom: $CAP_SPACE_12;
10
+ }
11
+ .carousel-button-phone-number {
12
+ .form-control {
13
+ width: 100%;
14
+ }
15
+ }
16
+ .text-box-container {
17
+ margin-top: $CAP_SPACE_16;
18
+ }
19
+ #whatsapp-carousel-button-url-type {
20
+ width: 90%;
21
+ }
22
+ .whatsapp-carousel-save-edit-btn {
23
+ margin-top: $CAP_SPACE_24;
24
+ }
25
+ .whatsapp-carousel-delete-button {
26
+ margin-left: $CAP_SPACE_12;
27
+ }
28
+ }
29
+
30
+ .cap-whatsapp-saved-carousel-button {
31
+ width: 100%;
32
+ margin-left: 0;
33
+ margin-top: $CAP_SPACE_12;
34
+ .whatsapp-carousel-delete-icon-btn {
35
+ padding: 0;
36
+ margin: 0;
37
+ height: auto;
38
+ }
39
+ }