@capillarytech/creatives-library 8.0.87-alpha.2 → 8.0.87-alpha.20

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 (41) hide show
  1. package/initialState.js +1 -0
  2. package/package.json +1 -1
  3. package/services/api.js +9 -10
  4. package/utils/transformerUtils.js +509 -0
  5. package/v2Components/CapWhatsappCTA/messages.js +0 -4
  6. package/v2Components/FormBuilder/index.js +7 -3
  7. package/v2Components/TemplatePreview/_templatePreview.scss +0 -9
  8. package/v2Components/TemplatePreview/index.js +104 -169
  9. package/v2Containers/Cap/actions.js +8 -0
  10. package/v2Containers/Cap/constants.js +4 -0
  11. package/v2Containers/Cap/reducer.js +6 -0
  12. package/v2Containers/Cap/sagas.js +23 -0
  13. package/v2Containers/Cap/selectors.js +6 -0
  14. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  15. package/v2Containers/CreativesContainer/SlideBoxContent.js +11 -1
  16. package/v2Containers/CreativesContainer/constants.js +3 -0
  17. package/v2Containers/CreativesContainer/index.js +77 -88
  18. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +25 -0
  19. package/v2Containers/CreativesContainer/tests/index.test.js +2 -0
  20. package/v2Containers/Email/index.js +1 -0
  21. package/v2Containers/EmailWrapper/index.js +2 -0
  22. package/v2Containers/MobilePush/Create/index.js +1 -0
  23. package/v2Containers/MobilePush/Edit/index.js +1 -0
  24. package/v2Containers/MobilepushWrapper/index.js +2 -1
  25. package/v2Containers/Sms/Create/index.js +1 -0
  26. package/v2Containers/Sms/Edit/index.js +1 -0
  27. package/v2Containers/SmsWrapper/index.js +2 -0
  28. package/v2Containers/Templates/_templates.scss +0 -35
  29. package/v2Containers/Templates/index.js +5 -64
  30. package/v2Containers/TemplatesV2/index.js +7 -0
  31. package/v2Containers/Whatsapp/constants.js +1 -83
  32. package/v2Containers/Whatsapp/index.js +182 -709
  33. package/v2Containers/Whatsapp/index.scss +1 -52
  34. package/v2Containers/Whatsapp/messages.js +2 -38
  35. package/v2Containers/Whatsapp/utils.js +0 -34
  36. package/v2Containers/mockdata.js +3 -0
  37. package/v2Components/CapWhatsappCarouselButton/constant.js +0 -51
  38. package/v2Components/CapWhatsappCarouselButton/index.js +0 -446
  39. package/v2Components/CapWhatsappCarouselButton/index.scss +0 -39
  40. package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +0 -4
  41. package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +0 -4
@@ -5,7 +5,7 @@ import React, { useState, useEffect, useCallback } from 'react';
5
5
  import { bindActionCreators } from 'redux';
6
6
  import { createStructuredSelector } from 'reselect';
7
7
  import { injectIntl, FormattedMessage } from 'react-intl';
8
- import { get, isEmpty, cloneDeep, isEqual, set } from 'lodash';
8
+ import { get, isEmpty, cloneDeep, isEqual } from 'lodash';
9
9
  import styled from 'styled-components';
10
10
  import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
11
11
  import CapRow from '@capillarytech/cap-ui-library/CapRow';
@@ -26,10 +26,6 @@ import CapAlert from '@capillarytech/cap-ui-library/CapAlert';
26
26
  import CapCheckbox from '@capillarytech/cap-ui-library/CapCheckbox';
27
27
  import CapLink from '@capillarytech/cap-ui-library/CapLink';
28
28
  import CapAskAira from '@capillarytech/cap-ui-library/CapAskAira';
29
- import CapCard from '@capillarytech/cap-ui-library/CapCard';
30
- import CapTab from '@capillarytech/cap-ui-library/CapTab';
31
- import CapDivider from '@capillarytech/cap-ui-library/CapDivider';
32
- import CapInfoNote from '@capillarytech/cap-ui-library/CapInfoNote';
33
29
  import moment from 'moment';
34
30
 
35
31
  import {
@@ -37,8 +33,6 @@ import {
37
33
  CAP_SPACE_24,
38
34
  CAP_SPACE_32,
39
35
  CAP_WHITE,
40
- FONT_COLOR_02,
41
- FONT_COLOR_01,
42
36
  } from '@capillarytech/cap-ui-library/styled/variables';
43
37
  import { makeSelectWhatsapp, makeSelectAccount } from './selectors';
44
38
  import {
@@ -86,13 +80,6 @@ import {
86
80
  OTP_CONFIG_URI,
87
81
  WHATSAPP_CATEGORIES,
88
82
  AI_CONTENT_BOT_DISABLED,
89
- mediaTypeOptions,
90
- carouselMediaOptions,
91
- CAROUSEL_INITIAL_DATA,
92
- MAX_CAROUSEL_ALLOWED,
93
- BODY_TEXT,
94
- QUICK_REPLY,
95
- CAROUSEL_TEXT,
96
83
  ICS_CATEGORY_OPTIONS,
97
84
  CORRECT_TEMPLATE_FORMAT_URL,
98
85
  CATEGORY_OPTIONS_MAP,
@@ -118,8 +105,6 @@ import { getWhatsappDocPreview } from './utils';
118
105
  import CapWhatsappQuickReply from '../../v2Components/CapWhatsappQuickReply';
119
106
  import injectSaga from '../../utils/injectSaga';
120
107
  import injectReducer from '../../utils/injectReducer';
121
- import CapWhatsappCarouselButton from '../../v2Components/CapWhatsappCarouselButton';
122
- import { INITIAL_CAROUSEL_PHONE_NUMBER_DATA, INITIAL_CAROUSEL_URL_DATA, INITIAL_CAROUSEL_QUICK_REPLY_DATA } from '../../v2Components/CapWhatsappCarouselButton/constant';
123
108
 
124
109
  import { v2WhatsappSagas } from './sagas';
125
110
  import v2WhatsappReducer from './reducer';
@@ -154,7 +139,6 @@ export const Whatsapp = (props) => {
154
139
  } = props || {};
155
140
  const { formatMessage } = intl;
156
141
  const { TextArea } = CapInput;
157
- const defaultActiveIndex = "0";
158
142
  const [templateName, setTemplateName] = useState('');
159
143
  const [templateNameError, setTemplateNameError] = useState(false);
160
144
  const [templateCategory, setTemplateCategory] = useState(
@@ -216,14 +200,9 @@ export const Whatsapp = (props) => {
216
200
  useState(false);
217
201
  const [showUrlPreview, setShowUrlPreview] = useState(false);
218
202
  const [previewUrl, setPreviewUrl] = useState('');
219
- const [carouselMediaType, setCarouselMediaType] = useState('image');
220
- const [carouselData, setCarouselData] = useState(CAROUSEL_INITIAL_DATA);
221
- const [activeIndex, setActiveIndex] = useState(defaultActiveIndex);
222
- const [carouselValidateTag, setCarouselValidateTag] = useState(false);
223
203
 
224
204
  const validVarRegex = /{{([1-9]|1[0-9])}}/g;
225
205
  const headerValidVarRegex = /{{(1)}}/g;
226
- const carouselBodyVarRegex = /{{[1-5]}}/g;
227
206
  const previewUrlMatchingRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])/g;
228
207
 
229
208
  const { accessibleFeatures = [] } = currentOrgDetails || {};
@@ -236,7 +215,6 @@ export const Whatsapp = (props) => {
236
215
  const isMediaTypeImage = templateMediaType === WHATSAPP_MEDIA_TYPES.IMAGE;
237
216
  const isMediaTypeVideo = templateMediaType === WHATSAPP_MEDIA_TYPES.VIDEO;
238
217
  const isMediaTypeDoc = templateMediaType === WHATSAPP_MEDIA_TYPES.DOCUMENT;
239
- const isMediaTypeCarousel = templateMediaType === WHATSAPP_MEDIA_TYPES.CAROUSEL;
240
218
  const isHostIsNotTwilio = host !== HOST_TWILIO;
241
219
  const WhatsappFooter = styled.div`
242
220
  background-color: ${CAP_WHITE};
@@ -313,9 +291,8 @@ export const Whatsapp = (props) => {
313
291
  buttons = [],
314
292
  videoPreviewImg = '',
315
293
  whatsappDocParams = {},
316
- whatsappMedia: { header = '', footer = '', headerVarMapped = [] } = {},
294
+ whatsappMedia: { header = '', footer = '' } = {},
317
295
  isPreviewUrl = false,
318
- carouselData : editCarouselData = [],
319
296
  } = editContent;
320
297
  setTemplateCategory(category);
321
298
  setTemplateStatus(status);
@@ -340,12 +317,6 @@ export const Whatsapp = (props) => {
340
317
  setTemplateFooter(footer);
341
318
  setTemplateHeader(header);
342
319
  setShowUrlPreview(isPreviewUrl);
343
- if (mediaType === WHATSAPP_MEDIA_TYPES.CAROUSEL) {
344
- const updatedCarouselData = handleCarouselData(editCarouselData);
345
- setCarouselData(updatedCarouselData);
346
- setCarouselMediaType(updatedCarouselData?.[0]?.mediaType)
347
- setCarouselValidateTag(!carouselValidateTag);
348
- }
349
320
  if (btnType === WHATSAPP_BUTTON_TYPES.CTA && buttons.length > 0) {
350
321
  setCtadata(
351
322
  buttons.map((cta) => {
@@ -377,42 +348,11 @@ export const Whatsapp = (props) => {
377
348
  }
378
349
  computeTempMsgArray();
379
350
  if (header && (mediaType === WHATSAPP_MEDIA_TYPES.TEXT && isHostIsNotTwilio)) {
380
- const { clonedVarMap, updatedText, tempData } = computeTextMessage(header, headerVarMapped, headerValidVarRegex);
381
- setTempHeaderData(tempData);
382
- setHeaderVarMappedData(clonedVarMap);
383
- setUpdatedHeaderData(updatedText);
351
+ computeHeaderMsgArray();
384
352
  }
385
353
  }
386
354
  }, [editData.templateDetails || templateData]);
387
355
 
388
- const handleCarouselData = (carouselData = []) => {
389
- return (
390
- carouselData.map((carousel) => {
391
- const { clonedVarMap, updatedText, tempData } = computeTextMessage(carousel?.bodyText, carousel?.varMap, carouselBodyVarRegex);
392
- return {
393
- ...carousel,
394
- updatedBodyText: updatedText,
395
- textAreaId: '',
396
- varMap: clonedVarMap,
397
- tempBodyData: tempData,
398
- carouselTagValidationErr: false,
399
- carouselTagValidationErrMessage: {},
400
- ...(carousel.mediaType === 'image' && {
401
- imageSrc: carousel?.imageUrl,
402
- }),
403
- ...(carousel.mediaType === 'video' && {
404
- videoSrc: carousel?.videoUrl,
405
- videoPreviewImg,
406
- }),
407
- buttons: carousel?.buttons?.map((button) => ({
408
- ...button,
409
- buttonType: button?.type,
410
- })),
411
- };
412
- })
413
- );
414
- };
415
-
416
356
  const converStringToVarArr = (validVarArr, content) => {
417
357
  const templateVarArray = [];
418
358
  while (content?.length !== 0) {
@@ -431,32 +371,34 @@ export const Whatsapp = (props) => {
431
371
  return templateVarArray;
432
372
  }
433
373
 
434
- const computeTextMessage = (msg, varMap, regex) => {
435
- const validVarArr = msg?.match(regex) || [];
374
+ const computeHeaderMsgArray = () => {
375
+ let msg = get(editContent, `whatsappMedia.header`, '');
376
+ const validVarArr = msg?.match(headerValidVarRegex) || [];
436
377
  //conerting msg string to variable arr
437
378
  const templateHeaderArray = converStringToVarArr(validVarArr, msg);
379
+ setTempHeaderData(templateHeaderArray);
438
380
  if (templateHeaderArray?.length !== 0) {
439
- let clonedVarMap = {};
440
- if (!isEmpty(varMap)) {
441
- clonedVarMap = cloneDeep(varMap);
381
+ let headerVarMap = {};
382
+ const {
383
+ whatsappMedia: { headerVarMapped = {} },
384
+ } = editContent;
385
+ if (!isEmpty(headerVarMapped)) {
386
+ headerVarMap = cloneDeep(headerVarMapped);
442
387
  } else {
443
388
  templateHeaderArray?.forEach((headerValue, i) => {
444
- if (headerValue?.match(regex)?.length > 0) {
445
- clonedVarMap[`${headerValue}_${i}`] = '';
389
+ if (headerValue?.match(headerValidVarRegex)?.length > 0) {
390
+ headerVarMap[`${headerValue}_${i}`] = '';
446
391
  }
447
392
  })
448
393
  }
449
394
  const arr = [...templateHeaderArray];
450
- for (const key in clonedVarMap) {
451
- if (clonedVarMap[key] !== '') {
452
- arr[key.slice(key.indexOf('_') + 1)] = clonedVarMap[key];
395
+ for (const key in headerVarMap) {
396
+ if (headerVarMap[key] !== '') {
397
+ arr[key.slice(key.indexOf('_') + 1)] = headerVarMap[key];
453
398
  }
454
399
  }
455
- return {
456
- clonedVarMap,
457
- updatedText: arr,
458
- tempData: templateHeaderArray,
459
- }
400
+ setHeaderVarMappedData(headerVarMap);
401
+ setUpdatedHeaderData(arr);
460
402
  }
461
403
  };
462
404
 
@@ -573,8 +515,6 @@ export const Whatsapp = (props) => {
573
515
  if (type === HEADER_TEXT) {
574
516
  headerTagValidationResponse = validationResponse;
575
517
  updateIsHeaderTagValidationError(unsupportedTagsLengthCheck);
576
- } else if (type === CAROUSEL_TEXT) {
577
- return [{fieldName: "carouselTagValidationErrMessage", value: validationResponse}, {fieldName: "carouselTagValidationErr", value: unsupportedTagsLengthCheck}];
578
518
  } else {
579
519
  tagValidationResponse = validationResponse;
580
520
  updateIsTagValidationError(unsupportedTagsLengthCheck);
@@ -626,15 +566,6 @@ export const Whatsapp = (props) => {
626
566
  tagValidation(updatedHeaderData, headerValidVarRegex, HEADER_TEXT);
627
567
  }, [updatedHeaderData, tags]);
628
568
 
629
- useEffect(() => {
630
- if (!isFullMode && tags?.length && carouselData?.length) {
631
- carouselData?.forEach((carousel, carouselIndex) => {
632
- const tagFields = tagValidation(carousel?.updatedBodyText, carouselBodyVarRegex, CAROUSEL_TEXT) || [];
633
- handleCarouselValueChange(carouselIndex, tagFields);
634
- })
635
- }
636
- }, [carouselValidateTag, tags])
637
-
638
569
  const handleOnTagsContextChange = (data) => {
639
570
  const { type } = location.query || {};
640
571
  const isEmbedded = type === EMBEDDED;
@@ -658,7 +589,6 @@ export const Whatsapp = (props) => {
658
589
  updatedData = [],
659
590
  areaId = "",
660
591
  regex,
661
- carouselIndex,
662
592
  } = tagSelectData;
663
593
  if (mapData && updatedData) {
664
594
  const numId = Number(areaId?.slice(areaId?.indexOf("_") + 1));
@@ -670,26 +600,15 @@ export const Whatsapp = (props) => {
670
600
  }
671
601
  const messageData = `${arr[numId]}{{${data}}}`;
672
602
  arr[numId] = messageData;
673
- switch (type) {
674
- case HEADER_TEXT:
675
- setHeaderVarMappedData((prevState) => ({
676
- ...prevState,
677
- [areaId]: messageData,
678
- }));
679
- setUpdatedHeaderData(arr);
680
- break;
681
- case CAROUSEL_TEXT:
682
- const carouselVarMap = carouselData?.[carouselIndex]?.varMap || {};
683
- carouselVarMap[areaId] = messageData;
684
- let tagFields = []
685
- if (!isFullMode) {
686
- tagFields = tagValidation(arr, carouselBodyVarRegex, CAROUSEL_TEXT) || [];
687
- }
688
- handleCarouselValueChange(carouselIndex, [...tagFields, {fieldName: "varMap", value: carouselVarMap}, {fieldName: "updatedBodyText", value: arr}])
689
- break;
690
- default:
691
- varMap[areaId] = messageData;
692
- setUpdatedSmsEditor(arr);
603
+ if (type === HEADER_TEXT) {
604
+ setHeaderVarMappedData((prevState) => ({
605
+ ...prevState,
606
+ [areaId]: messageData,
607
+ }));
608
+ setUpdatedHeaderData(arr);
609
+ } else {
610
+ varMap[areaId] = messageData;
611
+ setUpdatedSmsEditor(arr);
693
612
  }
694
613
  }
695
614
  }
@@ -717,25 +636,10 @@ export const Whatsapp = (props) => {
717
636
  });
718
637
  };
719
638
 
720
- const onCarouselBodyTagSelect = (data, carouselData, carouselIndex) => {
721
- const { updatedBodyText, varMap: headerVarMap, textAreaId } = carouselData;
722
- onTagSelect({
723
- data,
724
- type: CAROUSEL_TEXT,
725
- mapData: headerVarMap,
726
- updatedData: updatedBodyText,
727
- areaId: textAreaId,
728
- regex: carouselBodyVarRegex,
729
- carouselIndex
730
- });
731
- }
732
-
733
639
  //setting the id of currently selected text area, is used onTagSelect
734
- const setTextAreaId = ({ target: { id } }, type, carouselIndex) => {
640
+ const setTextAreaId = ({ target: { id } }, type) => {
735
641
  if (type === HEADER_TEXT) {
736
642
  setHeaderTextAreaId(id);
737
- } else if (type === CAROUSEL_TEXT) {
738
- handleCarouselValueChange(carouselIndex, [{fieldName: "textAreaId", value: id}])
739
643
  } else {
740
644
  updateTextAreaId(id);
741
645
  }
@@ -774,6 +678,55 @@ export const Whatsapp = (props) => {
774
678
  label: renderTemplateCategoryLabel(option.tooltipLabel, option.label),
775
679
  }));
776
680
 
681
+ const mediaRadioOptions = [
682
+ {
683
+ value: WHATSAPP_MEDIA_TYPES.TEXT,
684
+ label: formatMessage(messages.mediaText),
685
+ },
686
+ {
687
+ value: WHATSAPP_MEDIA_TYPES.IMAGE,
688
+ label: (
689
+ <CapTooltip
690
+ title={
691
+ host === HOST_TWILIO
692
+ ? formatMessage(messages.disabledFeatureTooltip)
693
+ : ''
694
+ }
695
+ >
696
+ {formatMessage(messages.mediaImage)}
697
+ </CapTooltip>
698
+ ),
699
+ disabled: host === HOST_TWILIO,
700
+ },
701
+ {
702
+ value: WHATSAPP_MEDIA_TYPES.VIDEO,
703
+ label: (
704
+ <CapTooltip
705
+ title={
706
+ host === HOST_TWILIO
707
+ ? formatMessage(messages.disabledFeatureTooltip)
708
+ : ''
709
+ }>
710
+ {formatMessage(messages.mediaVideo)}
711
+ </CapTooltip>
712
+ ),
713
+ disabled: host === HOST_TWILIO,
714
+ },
715
+ {
716
+ value: WHATSAPP_MEDIA_TYPES.DOCUMENT,
717
+ label: (
718
+ <CapTooltip
719
+ title={
720
+ host === HOST_TWILIO
721
+ ? formatMessage(messages.disabledFeatureTooltip)
722
+ : ''
723
+ }>
724
+ {formatMessage(messages.mediaDocument)}
725
+ </CapTooltip>
726
+ ),
727
+ disabled: host === HOST_TWILIO,
728
+ },
729
+ ];
777
730
  const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.authentication);
778
731
  const onChangeButtonType = ({ target: { value } }) => {
779
732
  setButtonType(value);
@@ -804,7 +757,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
804
757
  });
805
758
  };
806
759
 
807
- const computeTextLength = (type, carousel) => {
760
+ const computeTextLength = (type) => {
808
761
  switch (type) {
809
762
  case MESSAGE_TEXT:
810
763
  let whatsappContentLen = 0;
@@ -821,12 +774,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
821
774
  return headerContentLen || 0;
822
775
  case FOOTER_TEXT:
823
776
  return templateFooter?.length || 0;
824
- case CAROUSEL_TEXT:
825
- let carouselContentLen = 0;
826
- carouselContentLen = isEditFlow
827
- ? carousel?.updatedBodyText?.join("")?.length
828
- : carousel?.bodyText?.length;
829
- return carouselContentLen;
830
777
  default:
831
778
  let overallLength =
832
779
  computeTextLength(MESSAGE_TEXT) +
@@ -837,10 +784,10 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
837
784
  };
838
785
 
839
786
  //used by create and edit
840
- const renderMessageLength = (type, currentLength, carousel) => (
787
+ const renderMessageLength = (type, currentLength) => (
841
788
  <CapHeading type="label1" className="whatsapp-render-message-length">
842
789
  {formatMessage(messages.templateMessageLength, {
843
- currentLength: currentLength ? currentLength : computeTextLength(type, carousel),
790
+ currentLength: currentLength ? currentLength : computeTextLength(type),
844
791
  maxLength: maxLengthByType(type),
845
792
  })}
846
793
  </CapHeading>
@@ -987,7 +934,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
987
934
  const maxLengthByType = (type) => {
988
935
  switch (type) {
989
936
  case MESSAGE_TEXT:
990
- case CAROUSEL_TEXT:
991
937
  return TEMPLATE_MESSAGE_MAX_LENGTH;
992
938
  case HEADER_TEXT:
993
939
  case FOOTER_TEXT:
@@ -1036,57 +982,37 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1036
982
  hostName: host,
1037
983
  };
1038
984
  if (isFullMode && !isEditFlow && host === HOST_GUPSHUP) {
1039
- if (isMediaTypeCarousel) {
1040
- setGupshupMediaFile((prevState) => {
1041
- const newArray = [...prevState];
1042
- newArray[activeIndex] = file;
1043
- return newArray;
1044
- });
1045
- } else {
1046
- setGupshupMediaFile(file);
1047
- }
985
+ setGupshupMediaFile(file);
1048
986
  }
1049
987
  actions.uploadWhatsappAsset(file, type, fileParams, 0, whatsappParams);
1050
988
  };
1051
989
 
1052
990
  const setUpdateWhatsappImageSrc = useCallback(
1053
991
  (filePath, fileHandle) => {
1054
- if (isMediaTypeCarousel) {
1055
- handleCarouselValueChange(parseInt(activeIndex), [{fieldName: "imageSrc", value: filePath}, {fieldName: "karixFileHandle", value: fileHandle}]);
1056
- } else {
1057
- setWhatsappImageSrc(filePath);
1058
- setKarixFileHandle(fileHandle);
1059
- }
992
+ setWhatsappImageSrc(filePath);
993
+ setKarixFileHandle(fileHandle);
1060
994
  actions.clearWhatsappAsset(0);
1061
995
  },
1062
- [whatsappImageSrc, isMediaTypeCarousel, activeIndex, carouselData],
996
+ [whatsappImageSrc],
1063
997
  );
1064
998
 
1065
999
  const updateOnWhatsappImageReUpload = useCallback(() => {
1066
- if (isMediaTypeCarousel) {
1067
- handleCarouselValueChange(parseInt(activeIndex), [{fieldName: "imageSrc", value: ''}, {fieldName: "karixFileHandle", value: ''}]);
1068
- } else {
1069
- setWhatsappImageSrc('');
1070
- setKarixFileHandle('');
1071
- }
1072
- }, [whatsappImageSrc, isMediaTypeCarousel, activeIndex, carouselData]);
1000
+ setWhatsappImageSrc('');
1001
+ setKarixFileHandle('');
1002
+ }, [whatsappImageSrc]);
1073
1003
 
1074
1004
  const setUpdateWhatsappVideoSrc = useCallback(
1075
1005
  (index, data) => {
1076
1006
  const { videoSrc = '', previewUrl = '', fileHandle = '' } = data;
1077
- if (isMediaTypeCarousel) {
1078
- handleCarouselValueChange(parseInt(activeIndex), [{fieldName: "videoSrc", value: videoSrc}, {fieldName: "videoPreviewImg", value: previewUrl}, {fieldName: "assetList", value: data}, {fieldName: "karixFileHandle", value: fileHandle}]);
1079
- } else {
1080
- setWhatsappVideoSrcAndPreview({
1081
- whatsappVideoSrc: videoSrc,
1082
- whatsappVideoPreviewImg: previewUrl,
1083
- });
1084
- setKarixFileHandle(fileHandle);
1085
- updateAssetList(data);
1086
- }
1007
+ setWhatsappVideoSrcAndPreview({
1008
+ whatsappVideoSrc: videoSrc,
1009
+ whatsappVideoPreviewImg: previewUrl,
1010
+ });
1011
+ setKarixFileHandle(fileHandle);
1012
+ updateAssetList(data);
1087
1013
  actions.clearWhatsappAsset(0);
1088
1014
  },
1089
- [whatsappVideoSrcAndPreview?.whatsappVideoSrc, isMediaTypeCarousel, activeIndex],
1015
+ [whatsappVideoSrcAndPreview?.whatsappVideoSrc],
1090
1016
  );
1091
1017
 
1092
1018
  const setUpdateWhatsappDocSrc = useCallback(
@@ -1103,14 +1029,14 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1103
1029
  setKarixFileHandle('');
1104
1030
  }, [whatsappDocSource]);
1105
1031
 
1106
- const renderImageComponent = (carouselIndex) => (
1032
+ const renderImageComponent = () => (
1107
1033
  <CapImageUpload
1108
1034
  style={{ paddingTop: '20px' }}
1109
1035
  allowedExtensionsRegex={ALLOWED_IMAGE_EXTENSIONS_REGEX}
1110
1036
  imgSize={WHATSAPP_IMG_SIZE}
1111
1037
  uploadAsset={uploadWhatsappAsset}
1112
1038
  isFullMode={isFullMode}
1113
- imageSrc={isMediaTypeCarousel ? (carouselData?.[carouselIndex]?.imageSrc || '') : whatsappImageSrc}
1039
+ imageSrc={whatsappImageSrc}
1114
1040
  updateImageSrc={setUpdateWhatsappImageSrc}
1115
1041
  updateOnReUpload={updateOnWhatsappImageReUpload}
1116
1042
  index={0}
@@ -1128,7 +1054,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1128
1054
  videoSize={WHATSAPP_VIDEO_SIZE}
1129
1055
  isFullMode={isFullMode}
1130
1056
  uploadAsset={uploadWhatsappAsset}
1131
- uploadedAssetList={carouselData?.[activeIndex]?.assetList || []}
1057
+ uploadedAssetList={assetList}
1132
1058
  onVideoUploadUpdateAssestList={setUpdateWhatsappVideoSrc}
1133
1059
  videoData={editData}
1134
1060
  className="cap-custom-video-upload"
@@ -1202,13 +1128,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1202
1128
  setTemplateMessage(formatMessage(messages.authenticationMsg));
1203
1129
  } else {
1204
1130
  setTemplateMessage('');
1205
- }
1206
- if (templateCategory === WHATSAPP_CATEGORIES.marketing && templateMediaType === WHATSAPP_MEDIA_TYPES.CAROUSEL) {
1207
- setTemplateMediaType(WHATSAPP_MEDIA_TYPES.TEXT);
1208
- setCarouselData(CAROUSEL_INITIAL_DATA);
1209
- }
1210
- if (value === WHATSAPP_CATEGORIES.marketing) {
1211
- setGupshupMediaFile([]);
1212
1131
  }
1213
1132
  setTemplateCategory(value);
1214
1133
  };
@@ -1221,8 +1140,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1221
1140
  setTemplateLanguage(value);
1222
1141
  };
1223
1142
 
1224
- const onTemplateMediaTypeChange = (value) => {
1225
- setCarouselData(CAROUSEL_INITIAL_DATA);
1143
+ const onTemplateMediaTypeChange = ({ target: { value } }) => {
1226
1144
  setTemplateMediaType(value);
1227
1145
  };
1228
1146
 
@@ -1297,27 +1215,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1297
1215
  return errorMessage;
1298
1216
  };
1299
1217
 
1300
- const handleCarouselValueChange = (carouselIndex, fields) => {
1301
- const updateCarouselData = cloneDeep(carouselData);
1302
- fields.forEach((field) => {
1303
- updateCarouselData[carouselIndex][field.fieldName] = field.value;
1304
- });
1305
- setCarouselData(updateCarouselData);
1306
- }
1307
-
1308
- const carouselBodyTextErrorHandler = (value, carouselIndex) => {
1309
- let errorMessage = false;
1310
- if (value === "") {
1311
- errorMessage = formatMessage(messages.emptyCardBodyeErrorMessage);
1312
- } else if(value?.length > TEMPLATE_MESSAGE_MAX_LENGTH) {
1313
- errorMessage = formatMessage(messages.templateMessageLengthError);
1314
- } else {
1315
- errorMessage = variableErrorHandling(value, BODY_TEXT, carouselIndex);
1316
- }
1317
- return errorMessage;
1318
- }
1319
-
1320
- const variableErrorHandling = (value, type, carouselIndex) => {
1218
+ const variableErrorHandling = (value, type) => {
1321
1219
  let errorMessage = false;
1322
1220
  const validVarArr = value.match(type === HEADER_TEXT ? headerValidVarRegex : validVarRegex) || [];
1323
1221
  const validVarSet = [...new Set(validVarArr)];
@@ -1360,7 +1258,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1360
1258
  errorMessage = formatMessage(messages.sequenceVars, { one: "{{1}}" });
1361
1259
  } else {
1362
1260
  if (type === MESSAGE_TEXT) setAddedVarCount(validVarSet?.length || 0);
1363
- if (type === BODY_TEXT) handleCarouselValueChange(carouselIndex, [{ fieldName: 'addedVarCount', value: validVarSet?.length || 0 }]);
1364
1261
  }
1365
1262
  }
1366
1263
  }
@@ -1420,43 +1317,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1420
1317
  };
1421
1318
  });
1422
1319
 
1423
- const getCarouselPayload = () => {
1424
- return carouselData.map((carousel) => {
1425
- const { bodyText = '', imageSrc = '', videoSrc = '', videoPreviewImg = '', karixFileHandle = '', buttons = [], varMap: carouselVarMap = {}, updatedBodyText = [], tempBodyData = [] } = carousel || {};
1426
- const carouselButtons = buttons.map((button) => {
1427
- const { text = '', buttonType: type = '', url = '', phone_number = '', urlType = '' } = button;
1428
- return {
1429
- text,
1430
- type,
1431
- ...(type === PHONE_NUMBER && {
1432
- phone_number: `+${phone_number}`,
1433
- }),
1434
- ...(type === 'URL' && {
1435
- urlType,
1436
- url
1437
- })
1438
- };
1439
- });
1440
- return {
1441
- bodyText: isEditFlow && !isFullMode ? updatedBodyText.join("") : bodyText,
1442
- ...(carouselMediaType === "image" && {
1443
- imageUrl: getCdnUrl({ url: imageSrc, channelName: WHATSAPP }),
1444
- }),
1445
- ...(carouselMediaType === "video" && {
1446
- videoUrl: videoSrc,
1447
- videoPreviewImg,
1448
- }),
1449
- karixFileHandle,
1450
- buttons: carouselButtons,
1451
- mediaType: carouselMediaType,
1452
- ...(!isFullMode && {
1453
- cardVarMapped: carouselVarMap,
1454
- cardTemplate: tempBodyData.join(""),
1455
- })
1456
- };
1457
- });
1458
- }
1459
-
1460
1320
  const createPayload = () => {
1461
1321
  let mediaParams = {};
1462
1322
  const { whatsappVideoSrc = '', whatsappVideoPreviewImg = '' } = whatsappVideoSrcAndPreview;
@@ -1527,9 +1387,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1527
1387
  }),
1528
1388
  securityRecommendation: unsubscribeRequired,
1529
1389
  codeExpiryMinutes: expiryMinutes,
1530
- ...(isMediaTypeCarousel && {
1531
- carouselData: getCarouselPayload()
1532
- })
1533
1390
  },
1534
1391
  },
1535
1392
  },
@@ -1629,22 +1486,23 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1629
1486
  if (isBtnTypeQuickReply) {
1630
1487
  return !quickReplyData.every((quickReply) => quickReply?.isSaved === true);
1631
1488
  }
1632
- if (isMediaTypeCarousel) {
1633
- const carouselDisableCheck = carouselData.some((data) => {
1634
- return (
1635
- data.bodyError ||
1636
- data.bodyText === "" ||
1637
- (carouselMediaType === "image" && !data.imageSrc) ||
1638
- (carouselMediaType === "video" && !data.videoSrc) ||
1639
- !data?.buttons.every((button) => button?.isSaved === true)
1640
- );
1641
- });
1642
- return carouselDisableCheck;
1643
- }
1644
-
1645
1489
  return false;
1646
1490
  };
1647
1491
 
1492
+ const renderMediaSection = () => (
1493
+ <>
1494
+ {!isAuthenticationTemplate && <>{renderLabel('mediaLabel')}
1495
+ <CapRadioGroup
1496
+ id="whatsapp-media-radio"
1497
+ options={mediaRadioOptions}
1498
+ value={templateMediaType}
1499
+ onChange={onTemplateMediaTypeChange}
1500
+ className="whatsapp-media-radio"
1501
+ />
1502
+ </>}
1503
+ </>
1504
+ );
1505
+
1648
1506
  const renderMediaComponent = () => (
1649
1507
  <>
1650
1508
  {isMediaTypeImage && renderImageComponent()}
@@ -1653,245 +1511,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1653
1511
  </>
1654
1512
  );
1655
1513
 
1656
- const handleCarouselMediaOptions = ({ target: { value = ''} = {} }) => {
1657
- setCarouselData(CAROUSEL_INITIAL_DATA);
1658
- setCarouselMediaType(value);
1659
- }
1660
-
1661
- const onTabChange = (index) => {
1662
- setActiveIndex(index);
1663
- }
1664
-
1665
- const handleCarouselBodyText = ({ target: { value } }, carouselIndex) => {
1666
- const error = carouselBodyTextErrorHandler(value, carouselIndex);
1667
- handleCarouselValueChange(carouselIndex, [{ fieldName: 'bodyText', value }, {fieldName: 'bodyError', value: error}]);
1668
- };
1669
-
1670
- const onCarouselBodyAddVar = (carouselIndex) => {
1671
- const updateCarouselData = cloneDeep(carouselData);
1672
- const { bodyText } = updateCarouselData[carouselIndex];
1673
- const validVarArr = bodyText.match(validVarRegex) || [];
1674
- const tempMsg = `${bodyText}{{${validVarArr.length + 1}}}`;
1675
- const error = carouselBodyTextErrorHandler(tempMsg, carouselIndex);
1676
- handleCarouselValueChange(carouselIndex, [{ fieldName: 'bodyText', value: tempMsg }, {fieldName: 'bodyError', value: error}]);
1677
- }
1678
-
1679
- const deleteCarouselCard = (index) => {
1680
- const updateCarouselData = cloneDeep(carouselData);
1681
- updateCarouselData.splice(index, 1);
1682
- setCarouselData(updateCarouselData);
1683
- }
1684
-
1685
- const getTabPanes = (isEditMode) => {
1686
- return carouselData.map((data, index) => {
1687
- return {
1688
- key: index,
1689
- tab: index + 1,
1690
- content: (
1691
- <CapCard
1692
- title={`${formatMessage(messages.card)} ${index + 1}`}
1693
- extra={
1694
- !isEditMode && (
1695
- <CapButton
1696
- type="flat"
1697
- onClick={() => {
1698
- deleteCarouselCard(index);
1699
- }}
1700
- disabled={carouselData.length === 1}
1701
- >
1702
- <CapIcon type="delete"></CapIcon>
1703
- </CapButton>
1704
- )
1705
- }
1706
- className="whatsapp-carousel-card"
1707
- >
1708
- <CapRow>
1709
- {carouselMediaType === "image" ? (
1710
- <CapRow>
1711
- <CapHeading type="h4">
1712
- {formatMessage(messages.mediaImage)}
1713
- </CapHeading>
1714
- {renderImageComponent(index)}
1715
- </CapRow>
1716
- ) : (
1717
- <CapRow>
1718
- <CapHeading type="h4">
1719
- {formatMessage(messages.mediaVideo)}
1720
- </CapHeading>
1721
- {renderVideoComonent()}
1722
- </CapRow>
1723
- )}
1724
- </CapRow>
1725
- <CapRow>
1726
- <CapHeader
1727
- className={`${
1728
- isMediaTypeImage ? "whatsapp-heading-spacing" : ""
1729
- }`}
1730
- title={
1731
- <CapHeading
1732
- type="h4"
1733
- className="whatsapp-carousel-message-heading"
1734
- >
1735
- {formatMessage(messages.carouselCardBodyMessageLabel)}
1736
- <CapTooltipWithInfo
1737
- placement="right"
1738
- className="whatsapp-text-field_spacing"
1739
- autoAdjustOverflow
1740
- title={
1741
- <FormattedMessage
1742
- {...messages.templateMessageTooltip}
1743
- values={{
1744
- br: <br />,
1745
- var: "{{1}}"
1746
- }}
1747
- />
1748
- }
1749
- />
1750
- </CapHeading>
1751
- }
1752
- suffix={
1753
- <>
1754
- {isEditMode
1755
- ? templateStatus === WHATSAPP_STATUSES.approved &&
1756
- !isAuthenticationTemplate && (
1757
- <TagList
1758
- label={formatMessage(globalMessages.addLabels)}
1759
- onTagSelect={(tag) => onCarouselBodyTagSelect(tag, data, index)}
1760
- location={location}
1761
- tags={tags || []}
1762
- onContextChange={handleOnTagsContextChange}
1763
- injectedTags={injectedTags || {}}
1764
- selectedOfferDetails={selectedOfferDetails}
1765
- eventContextTags={eventContextTags}
1766
- />
1767
- )
1768
- : !isAuthenticationTemplate && (
1769
- <CapButton
1770
- data-testid="suffix-button"
1771
- type="flat"
1772
- isAddBtn
1773
- onClick={() => onCarouselBodyAddVar(index)}
1774
- disabled={
1775
- (data?.addedVarCount >= 5 || data?.bodyError) &&
1776
- data?.bodyText
1777
- }
1778
- >
1779
- {formatMessage(messages.addVar)}
1780
- </CapButton>
1781
- )}
1782
- </>
1783
- }
1784
- />
1785
- {isEditMode ?
1786
- <>
1787
- <CapTooltip placement="bottom" title={disabledEditTooltipRender()}>
1788
- <CapRow
1789
- className={`whatsapp-edit-template-message-input ${
1790
- templateStatus !== WHATSAPP_STATUSES.approved &&
1791
- "whatsapp-edit-disabled"
1792
- }`}
1793
- >
1794
- {renderedEditMessage(data?.tempBodyData, CAROUSEL_TEXT, {carouselIndex: index, data: data})}
1795
- </CapRow>
1796
- </CapTooltip>
1797
- {renderMessageLength(CAROUSEL_TEXT, 0, data)}
1798
- {data?.carouselTagValidationErr && tagValidationErrorMessage(CAROUSEL_TEXT, data)}
1799
- {computeTextLength(CAROUSEL_TEXT, data) > TEMPLATE_MESSAGE_MAX_LENGTH && (
1800
- <CapError>
1801
- {formatMessage(messages.templateMessageLengthError)}
1802
- </CapError>
1803
- )}
1804
- </>
1805
- :
1806
- <CapRow>
1807
- <div className="whatsapp-create-template-message-input-wrapper">
1808
- <TextArea
1809
- autosize={{ minRows: 3, maxRows: 5 }}
1810
- placeholder={formatMessage(
1811
- messages.carouselCardBodyMessagePlaceholder
1812
- )}
1813
- onChange={e => handleCarouselBodyText(e, index)}
1814
- errorMessage={
1815
- data?.bodyError && <CapError>{data?.bodyError}</CapError>
1816
- }
1817
- value={data?.bodyText || ""}
1818
- disabled={isAuthenticationTemplate}
1819
- />
1820
- </div>
1821
- {renderMessageLength(CAROUSEL_TEXT, 0, data)}
1822
- </CapRow>
1823
- }
1824
- </CapRow>
1825
- <CapRow>
1826
- <CapHeading
1827
- className="whatsapp-carousel-message-heading"
1828
- type="h4"
1829
- >
1830
- {formatMessage(messages.btnLabel)}
1831
- </CapHeading>
1832
- {index === 0 && (
1833
- <CapRow>
1834
- <CapInfoNote
1835
- message={formatMessage(messages.carouselButtonInfo)}
1836
- />
1837
- </CapRow>
1838
- )}
1839
- <CapRow>
1840
- <CapWhatsappCarouselButton
1841
- carouselData={carouselData}
1842
- setCarouselData={setCarouselData}
1843
- carouselIndex={index}
1844
- isEditFlow={isEditMode}
1845
- tags={tags || []}
1846
- injectedTags={injectedTags || {}}
1847
- selectedOfferDetails={selectedOfferDetails}
1848
- />
1849
- </CapRow>
1850
- </CapRow>
1851
- </CapCard>
1852
- )
1853
- };
1854
- })
1855
- }
1856
-
1857
- const addContent = () => {
1858
- const updatedCarouselData = cloneDeep(carouselData); // Shallow copy, assuming carouselData isn't deeply nested
1859
- const firstCarouselButtonData = updatedCarouselData[0]?.buttons;
1860
-
1861
- const buttonArray = firstCarouselButtonData.map((button) => {
1862
- switch (button?.buttonType) {
1863
- case PHONE_NUMBER:
1864
- return INITIAL_CAROUSEL_PHONE_NUMBER_DATA;
1865
- case QUICK_REPLY:
1866
- return INITIAL_CAROUSEL_QUICK_REPLY_DATA;
1867
- default:
1868
- return INITIAL_CAROUSEL_URL_DATA;
1869
- }
1870
- });
1871
-
1872
- CAROUSEL_INITIAL_DATA[0].buttons = buttonArray;
1873
- setCarouselData([...updatedCarouselData, CAROUSEL_INITIAL_DATA[0]]);
1874
- };
1875
-
1876
- const checkDisableAddCarouselButton = () => {
1877
- return carouselData?.[0]?.buttons.some((button) => button?.isSaved === true);
1878
- }
1879
-
1880
- const operations = (
1881
- <>
1882
- <CapDivider type="vertical" />
1883
- <CapButton
1884
- onClick={addContent}
1885
- type="flat"
1886
- className="add-carousel-content-button"
1887
- disabled={MAX_CAROUSEL_ALLOWED === carouselData.length || !checkDisableAddCarouselButton()}
1888
- >
1889
- <CapIcon type="plus" />
1890
- </CapButton>
1891
- </>
1892
- )
1893
-
1894
- const createModeContent = () => (
1514
+ const createModeContent = (
1895
1515
  <>
1896
1516
  {/* template name */}
1897
1517
  <CapHeader
@@ -1936,32 +1556,8 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1936
1556
  onChange={onTemplateLanguageChange}
1937
1557
  value={templateLanguage}
1938
1558
  />
1939
- <CapRow>
1940
- {/* template category */}
1941
- <CapColumn span={12}>
1942
- {renderLabel("templateCategoryLabel")}
1943
- <CapSelect
1944
- id="select-whatsapp-category"
1945
- options={
1946
- host === HOST_TWILIO
1947
- ? twilioCategoryOptions
1948
- : karixGupshupCategoryOptions
1949
- }
1950
- onChange={onTemplateCategoryChange}
1951
- value={templateCategory}
1952
- />
1953
- </CapColumn>
1954
- {/* template media type */}
1955
- <CapColumn span={12}>
1956
- {renderLabel("mediaLabel")}
1957
- <CapSelect
1958
- id="select-whatsapp-media"
1959
- options={mediaTypeOptions({host, templateCategory})}
1960
- onChange={onTemplateMediaTypeChange}
1961
- value={templateMediaType}
1962
- />
1963
- </CapColumn>
1964
- </CapRow>
1559
+ {/* template media type */}
1560
+ {renderMediaSection()}
1965
1561
  {renderMediaComponent()}
1966
1562
  {/* this section is for header section in create mode */}
1967
1563
  {isMediaTypeText && isHostIsNotTwilio && !isAuthenticationTemplate && (
@@ -2093,39 +1689,8 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2093
1689
  {renderUnsubscribeText()}
2094
1690
  </CapRow>
2095
1691
  {renderMessageLength(MESSAGE_TEXT)}
2096
- {
2097
- isMediaTypeCarousel && (
2098
- <CapRow>
2099
- <CapRow className="carousel-media-selection">
2100
- <CapColumn className="carousel-media-selection-heading">
2101
- <CapHeading type="h4">
2102
- {formatMessage(messages.carouselMediaType)}
2103
- </CapHeading>
2104
- </CapColumn>
2105
- <CapColumn>
2106
- <CapRadioGroup
2107
- id="carousel-media-radio"
2108
- options={carouselMediaOptions}
2109
- value={carouselMediaType}
2110
- onChange={handleCarouselMediaOptions}
2111
- className="whatsapp-media-radio"
2112
- />
2113
- </CapColumn>
2114
- </CapRow>
2115
- <CapRow className="whatsapp-carousel-tab">
2116
- <CapTab
2117
- defaultActiveKey={`${defaultActiveIndex}`}
2118
- activeKey={activeIndex}
2119
- tabBarExtraContent={operations}
2120
- onChange={onTabChange}
2121
- panes={getTabPanes(false)}
2122
- />
2123
- </CapRow>
2124
- </CapRow>
2125
- )
2126
- }
2127
1692
  {/* this section if for footer in create mode */}
2128
- {isHostIsNotTwilio && !isMediaTypeCarousel && (
1693
+ {isHostIsNotTwilio && (
2129
1694
  <>
2130
1695
  <CapHeader
2131
1696
  className={`${isMediaTypeImage ? "whatsapp-heading-spacing" : ""}`}
@@ -2231,7 +1796,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2231
1796
  {renderMessageLength(FOOTER_TEXT)}
2232
1797
  </>
2233
1798
  )}
2234
- {!isMediaTypeCarousel && renderButtonsSection()}
1799
+ {renderButtonsSection()}
2235
1800
  </>
2236
1801
  );
2237
1802
  //create methods end
@@ -2345,7 +1910,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2345
1910
  };
2346
1911
 
2347
1912
  // on change event of Text Area
2348
- const textAreaValueChange = ({ target: { value, id } }, type, carousel) => {
1913
+ const textAreaValueChange = ({ target: { value, id } }, type) => {
2349
1914
  const numId = Number(id.slice(id.indexOf("_") + 1));
2350
1915
  //assign entered value to varMap
2351
1916
  if (type === HEADER_TEXT) {
@@ -2360,21 +1925,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2360
1925
  arr[numId] = value;
2361
1926
  }
2362
1927
  setUpdatedHeaderData(arr);
2363
- } else if (type === CAROUSEL_TEXT) {
2364
- const carouselUpdatedBodyTextData = carousel?.data?.updatedBodyText || [];
2365
- const arr = [...carouselUpdatedBodyTextData];
2366
- if (value === "") {
2367
- arr[numId] = id.slice(0, id.indexOf("_"));
2368
- } else {
2369
- arr[numId] = value;
2370
- }
2371
- const clonedCarouselBodyvarMap = carousel?.data?.varMap || {};
2372
- const bodyVarMapData = {...clonedCarouselBodyvarMap, [id]: value};
2373
- let tagFields = [];
2374
- if (!isFullMode) {
2375
- tagFields = tagValidation(arr, carouselBodyVarRegex, CAROUSEL_TEXT) || [];
2376
- }
2377
- handleCarouselValueChange(carousel?.carouselIndex, [...tagFields, {fieldName: "varMap", value: bodyVarMapData}, {fieldName: 'updatedBodyText', value: arr}])
2378
1928
  } else {
2379
1929
  const arr = [...updatedSmsEditor];
2380
1930
  varMap[id] = value;
@@ -2388,51 +1938,27 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2388
1938
  }
2389
1939
  };
2390
1940
 
2391
- const textAreaValue = (idValue, type, carousel) => {
1941
+ const textAreaValue = (idValue, type) => {
2392
1942
  if (idValue >= 0) {
2393
- let value = [];
2394
- let regex = '';
2395
- switch (type) {
2396
- case HEADER_TEXT:
2397
- value = updatedHeaderData[idValue];
2398
- regex = headerValidVarRegex;
2399
- break;
2400
- case CAROUSEL_TEXT:
2401
- value = carousel?.data?.updatedBodyText?.[idValue];
2402
- regex = carouselBodyVarRegex;
2403
- break;
2404
- default:
2405
- value = updatedSmsEditor[idValue];
2406
- regex = validVarRegex;
2407
- break;
2408
- }
1943
+ const value =
1944
+ type === HEADER_TEXT
1945
+ ? updatedHeaderData[idValue]
1946
+ : updatedSmsEditor[idValue];
2409
1947
  //if value is there and it is not a variable return it
2410
- if (value && (value.match(regex) || []).length === 0) {
1948
+ if (value && (value.match(type === HEADER_TEXT ? headerValidVarRegex : validVarRegex) || []).length === 0) {
2411
1949
  return value;
2412
1950
  }
2413
1951
  }
2414
1952
  return "";
2415
1953
  };
2416
1954
 
2417
- const renderedEditMessage = (messageData, type, carousel) => {
1955
+ const renderedEditMessage = (messageData, type) => {
2418
1956
  const renderArray = [];
2419
- if (messageData && messageData?.length !== 0) {
1957
+ if (messageData?.length !== 0) {
2420
1958
  let varCount = 0;
2421
1959
  messageData.forEach((elem, index) => {
2422
1960
  // if var return textarea else return text
2423
- let validRegex = '';
2424
- switch (type) {
2425
- case HEADER_TEXT:
2426
- validRegex = headerValidVarRegex;
2427
- break;
2428
- case CAROUSEL_TEXT:
2429
- validRegex = carouselBodyVarRegex;
2430
- break;
2431
- default:
2432
- validRegex = validVarRegex;
2433
- break;
2434
- }
2435
- if (elem.match(validRegex)?.length > 0) {
1961
+ if (elem.match(type === HEADER_TEXT ? headerValidVarRegex : validVarRegex)?.length > 0) {
2436
1962
  varCount += 1;
2437
1963
  renderArray.push(
2438
1964
  <TextArea
@@ -2442,9 +1968,9 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2442
1968
  value: `{{${varCount}}}`,
2443
1969
  })}
2444
1970
  autosize={{ minRows: 1, maxRows: 3 }}
2445
- onChange={(e) => textAreaValueChange(e, type, carousel)}
2446
- value={textAreaValue(index, type, carousel)}
2447
- onFocus={(e) => setTextAreaId(e, type, carousel?.carouselIndex)}
1971
+ onChange={(e) => textAreaValueChange(e, type)}
1972
+ value={textAreaValue(index, type)}
1973
+ onFocus={(e) => setTextAreaId(e, type)}
2448
1974
  disabled={templateStatus !== WHATSAPP_STATUSES.approved}
2449
1975
  />
2450
1976
  );
@@ -2461,7 +1987,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2461
1987
  }
2462
1988
  });
2463
1989
  }
2464
- if (type !== HEADER_TEXT && type !== CAROUSEL_TEXT) {
1990
+ if (type !== HEADER_TEXT) {
2465
1991
  renderArray.push(renderUnsubscribeText());
2466
1992
  }
2467
1993
  return renderArray;
@@ -2482,17 +2008,9 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2482
2008
  }
2483
2009
  };
2484
2010
 
2485
- const tagValidationErrorMessage = (type, carousel) => {
2486
- let validationResponse = {};
2487
- if (type === HEADER_TEXT) {
2488
- validationResponse = headerTagValidationResponse;
2489
- } else if (type === CAROUSEL_TEXT) {
2490
- validationResponse = carousel?.carouselTagValidationErrMessage;
2491
- } else {
2492
- validationResponse = tagValidationResponse;
2493
- }
2494
- const { unsupportedTags = [], isBraceError } = validationResponse;
2495
-
2011
+ const tagValidationErrorMessage = (type) => {
2012
+ const { unsupportedTags = [], isBraceError } =
2013
+ type === HEADER_TEXT ? headerTagValidationResponse : tagValidationResponse;
2496
2014
  let tagError = "";
2497
2015
  if (unsupportedTags.length > 0) {
2498
2016
  tagError = formatMessage(globalMessages.unsupportedTagsValidationError, {
@@ -2505,7 +2023,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2505
2023
  return <CapError>{tagError}</CapError>;
2506
2024
  };
2507
2025
 
2508
- const editModeContent = () => (
2026
+ const editModeContent = (
2509
2027
  <>
2510
2028
  {templateStatus && (
2511
2029
  <CapAlert
@@ -2637,77 +2155,51 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2637
2155
  </>
2638
2156
  )}
2639
2157
  {/* button section view in edit mode*/}
2640
- {isMediaTypeCarousel &&
2641
- (
2642
- <CapRow>
2643
- <CapRow className="carousel-media-selection">
2644
- <CapColumn className="carousel-media-selection-heading">
2645
- <CapHeading type="h4">
2646
- {formatMessage(messages.carouselMediaType)}
2647
- </CapHeading>
2648
- </CapColumn>
2649
- <CapColumn>
2650
- <CapLabel type="label15">{carouselData?.[0]?.mediaType}</CapLabel>
2651
- </CapColumn>
2652
- </CapRow>
2653
- <CapRow className="whatsapp-carousel-tab">
2654
- <CapTab
2655
- defaultActiveKey={`${defaultActiveIndex}`}
2656
- activeKey={activeIndex}
2657
- onChange={onTabChange}
2658
- panes={getTabPanes(true)}
2659
- />
2660
- </CapRow>
2661
- </CapRow>
2662
- )
2663
- }
2664
- {!isMediaTypeCarousel &&
2665
- <CapRow>
2666
- {isBtnTypeQuickReply ? (
2158
+ <CapRow>
2159
+ {isBtnTypeQuickReply ? (
2160
+ <CapHeading type="h4" className="whatsapp-render-heading">
2161
+ {formatMessage(messages.quickReplyButtons)}
2162
+ </CapHeading>
2163
+ ) : (
2164
+ <>
2667
2165
  <CapHeading type="h4" className="whatsapp-render-heading">
2668
- {formatMessage(messages.quickReplyButtons)}
2166
+ {formatMessage(messages.btnLabel)}
2669
2167
  </CapHeading>
2670
- ) : (
2671
- <>
2672
- <CapHeading type="h4" className="whatsapp-render-heading">
2673
- {formatMessage(messages.btnLabel)}
2674
- </CapHeading>
2675
- <CapLabel type="label15">
2676
- {isBtnTypeCta
2677
- ? formatMessage(messages.btnTypeCTA)
2678
- : !isAuthenticationTemplate && formatMessage(messages.btnTypeNone)}
2679
- </CapLabel>
2680
- </>
2681
- )}
2682
- {isAuthenticationTemplate && (
2683
2168
  <CapLabel type="label15">
2684
- <CapWhatsappQuickReply
2685
- authenticationFlow={true}
2686
- />
2169
+ {isBtnTypeCta
2170
+ ? formatMessage(messages.btnTypeCTA)
2171
+ : !isAuthenticationTemplate && formatMessage(messages.btnTypeNone)}
2687
2172
  </CapLabel>
2688
- )}
2689
- {isBtnTypeCta && (
2690
- <CapWhatsappCTA
2691
- ctaData={ctaData}
2692
- updateHandler={updateHandler}
2693
- deleteHandler={deleteHandler}
2694
- isEditFlow={isEditFlow}
2695
- hostName={host}
2696
- tags={tags || []}
2697
- injectedTags={injectedTags || {}}
2698
- selectedOfferDetails={selectedOfferDetails}
2699
- />
2700
- )}
2701
- {isBtnTypeQuickReply && (
2173
+ </>
2174
+ )}
2175
+ {isAuthenticationTemplate && (
2176
+ <CapLabel type="label15">
2702
2177
  <CapWhatsappQuickReply
2703
- quickReplyData={quickReplyData}
2704
- isEditFlow={isEditFlow}
2705
- renderMessageLength={renderMessageLength}
2706
- setQuickReplyData={setQuickReplyData}
2178
+ authenticationFlow={true}
2707
2179
  />
2708
- )}
2709
- </CapRow>
2710
- }
2180
+ </CapLabel>
2181
+ )}
2182
+ {isBtnTypeCta && (
2183
+ <CapWhatsappCTA
2184
+ ctaData={ctaData}
2185
+ updateHandler={updateHandler}
2186
+ deleteHandler={deleteHandler}
2187
+ isEditFlow={isEditFlow}
2188
+ hostName={host}
2189
+ tags={tags || []}
2190
+ injectedTags={injectedTags || {}}
2191
+ selectedOfferDetails={selectedOfferDetails}
2192
+ />
2193
+ )}
2194
+ {isBtnTypeQuickReply && (
2195
+ <CapWhatsappQuickReply
2196
+ quickReplyData={quickReplyData}
2197
+ isEditFlow={isEditFlow}
2198
+ renderMessageLength={renderMessageLength}
2199
+ setQuickReplyData={setQuickReplyData}
2200
+ />
2201
+ )}
2202
+ </CapRow>
2711
2203
  </>
2712
2204
  );
2713
2205
  //edit methods end
@@ -2773,11 +2265,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2773
2265
  showUrlPreview,
2774
2266
  metaTagsDetails,
2775
2267
  }),
2776
- ...(isMediaTypeCarousel && {
2777
- carouselData,
2778
- carouselMediaType,
2779
- isEditFlow,
2780
- }),
2781
2268
  }}
2782
2269
  whatsappContentLen={computeTextLength()}
2783
2270
  whatsappAccountName={accountName}
@@ -2785,34 +2272,20 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2785
2272
  );
2786
2273
  };
2787
2274
 
2788
- const isEditDoneDisabled = () => {
2789
- let carouselDisableCheck = false;
2790
- if (isMediaTypeCarousel) {
2791
- carouselDisableCheck = carouselData.some((data) => {
2792
- return (
2793
- data.carouselTagValidationErr ||
2794
- Object.values(data.varMap).some((inputValue) => inputValue === "") ||
2795
- computeTextLength(CAROUSEL_TEXT, data) > TEMPLATE_MESSAGE_MAX_LENGTH ||
2796
- (carouselMediaType === "image" && !data.imageSrc) ||
2797
- (carouselMediaType === "video" && !data.videoSrc) ||
2798
- data?.buttons.some((btn) => btn?.url?.includes("{{1}}"))
2799
- );
2800
- });
2801
- }
2802
- return (isTagValidationError ||
2275
+ const isEditDoneDisabled = () =>
2276
+ isTagValidationError ||
2803
2277
  isHeaderTagValidationError ||
2804
2278
  Object.values(varMap).some((inputValue) => inputValue === "") ||
2805
2279
  Object.values(headerVarMappedData).some((inputValue) => inputValue === "") ||
2806
2280
  computeTextLength(MESSAGE_TEXT) > TEMPLATE_MESSAGE_MAX_LENGTH ||
2807
2281
  computeTextLength(HEADER_TEXT) > TEMPLATE_HEADER_MAX_LENGTH ||
2808
- (isBtnTypeCta && ctaData.some((btn) => btn?.url?.includes("{{1}}"))) || isMediatypeValid()) || carouselDisableCheck;
2809
- }
2282
+ (isBtnTypeCta && ctaData.some((btn) => btn?.url?.includes("{{1}}"))) || isMediatypeValid();
2810
2283
 
2811
2284
  return (
2812
2285
  <CapSpin spinning={spin}>
2813
2286
  <CapRow className="cap-whatsapp-creatives">
2814
2287
  <CapColumn span={14}>
2815
- {isEditFlow ? editModeContent() : createModeContent()}
2288
+ {isEditFlow ? editModeContent : createModeContent}
2816
2289
  <div className="whatsapp-scroll-div" />
2817
2290
  </CapColumn>
2818
2291
  <CapColumn span={10} className="whatsapp-preview-container">
@@ -2849,7 +2322,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2849
2322
  </CapButton>
2850
2323
  </>
2851
2324
  )}
2852
- {isEditFlow && (
2325
+ {!isFullMode && isEditFlow && (
2853
2326
  <CapTooltip
2854
2327
  title={
2855
2328
  isEditDoneDisabled()