@capillarytech/creatives-library 8.0.92 → 8.0.94

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