@capillarytech/creatives-library 9.1.7 → 9.1.8-alpha.sprint-cap-214249.39

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/constants/unified.js +0 -1
  2. package/package.json +1 -1
  3. package/utils/common.js +0 -6
  4. package/utils/createMobilePushPayload.js +50 -33
  5. package/utils/tests/createMobilePushPayload.test.js +113 -8
  6. package/v2Components/CapMpushCTA/index.js +10 -9
  7. package/v2Components/CapMpushCTA/index.scss +29 -3
  8. package/v2Components/CapMpushCTA/tests/index.test.js +89 -0
  9. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +20 -12
  10. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
  11. package/v2Components/CommonTestAndPreview/constants.js +2 -0
  12. package/v2Components/CommonTestAndPreview/index.js +48 -10
  13. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +81 -5
  14. package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
  15. package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
  16. package/v2Components/TemplatePreview/index.js +24 -16
  17. package/v2Components/TemplatePreview/tests/index.test.js +68 -0
  18. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
  19. package/v2Containers/CreativesContainer/index.js +2 -1
  20. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
  21. package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
  22. package/v2Containers/MobilePushNew/components/MediaUploaders.js +297 -216
  23. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +158 -125
  24. package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
  25. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
  26. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +464 -108
  27. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +106 -35
  28. package/v2Containers/MobilePushNew/constants.js +5 -0
  29. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
  30. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +52 -0
  31. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
  32. package/v2Containers/MobilePushNew/hooks/useUpload.js +29 -39
  33. package/v2Containers/MobilePushNew/index.js +487 -235
  34. package/v2Containers/MobilePushNew/index.scss +205 -4
  35. package/v2Containers/MobilePushNew/messages.js +106 -6
  36. package/v2Containers/MobilePushNew/tests/index.test.js +469 -1
  37. package/v2Containers/MobilePushNew/tests/utils.test.js +70 -0
  38. package/v2Containers/MobilePushNew/utils.js +56 -0
  39. package/v2Containers/Templates/_templates.scss +10 -2
  40. package/v2Containers/Templates/index.js +83 -81
  41. package/v2Containers/Templates/tests/index.test.js +68 -0
@@ -5,16 +5,20 @@ import CapRow from "@capillarytech/cap-ui-library/CapRow";
5
5
  import CapButton from "@capillarytech/cap-ui-library/CapButton";
6
6
  import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
7
7
  import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
8
- import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
8
+ import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
9
+ // import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
9
10
  import CapMpushCTA from "../../../v2Components/CapMpushCTA";
10
- import { PRIMARY, SECONDARY, DEEP_LINK } from "../constants";
11
+ import { PRIMARY, DEEP_LINK } from "../constants";
12
+ // import { SECONDARY } from "../constants";
11
13
  import messages from "../messages";
12
14
 
15
+ // Secondary button is commented out below: it needs backend support, so it is being revamped.
16
+ // Restore the commented secondaryButton / setSecondaryButton props, state, handler and JSX together.
13
17
  const CtaButtons = ({
14
18
  primaryButton,
15
- secondaryButton,
19
+ // secondaryButton,
16
20
  setPrimaryButton,
17
- setSecondaryButton,
21
+ // setSecondaryButton,
18
22
  ctaData,
19
23
  updateHandler,
20
24
  deleteHandler,
@@ -27,7 +31,7 @@ const CtaButtons = ({
27
31
  }) => {
28
32
  // Local state to control CTA form visibility
29
33
  const [showPrimaryCTA, setShowPrimaryCTA] = useState(false);
30
- const [showSecondaryCTA, setShowSecondaryCTA] = useState(false);
34
+ // const [showSecondaryCTA, setShowSecondaryCTA] = useState(false);
31
35
 
32
36
  const handleAddPrimary = () => {
33
37
  // Prevent multiple clicks if primary button is already being added or form is already showing
@@ -53,68 +57,67 @@ const CtaButtons = ({
53
57
  setShowPrimaryCTA(true);
54
58
  };
55
59
 
56
- const handleAddSecondary = () => {
57
- // Prevent multiple clicks if secondary button is already being added or form is already showing
58
- //cooment until supported from BE & Hydra
59
- // if (secondaryButton && showSecondaryCTA) {
60
- // return;
61
- // }
62
-
63
- // if (shouldShowSecondaryCTA) {
64
- // return;
65
- // }
66
-
67
- // If ctaData doesn't have a secondary button, initialize it
68
- if (ctaData?.length < 2 || !ctaData?.find((cta) => cta?.index === 1)) {
69
- const newSecondaryButton = {
70
- index: 1,
71
- ctaType: SECONDARY,
72
- text: "",
73
- urlType: DEEP_LINK,
74
- url: "",
75
- deepLinkKeys: "",
76
- isSaved: false,
77
- };
78
- updateHandler(newSecondaryButton, 1);
79
- }
80
-
81
- // setSecondaryButton(true);
82
- // setShowSecondaryCTA(true);
83
- };
60
+ // Secondary button: needs backend support, revamped
61
+ // const handleAddSecondary = () => {
62
+ // if (secondaryButton && showSecondaryCTA) {
63
+ // return;
64
+ // }
65
+ // if (ctaData?.length < 2 || !ctaData?.find((cta) => cta?.index === 1)) {
66
+ // const newSecondaryButton = {
67
+ // index: 1,
68
+ // ctaType: SECONDARY,
69
+ // text: "",
70
+ // urlType: DEEP_LINK,
71
+ // url: "",
72
+ // deepLinkKeys: "",
73
+ // isSaved: false,
74
+ // };
75
+ // updateHandler(newSecondaryButton, 1);
76
+ // }
77
+ // setSecondaryButton(true);
78
+ // setShowSecondaryCTA(true);
79
+ // };
84
80
 
85
81
  // Check if primary button exists (saved or being edited)
86
82
  const primaryButtonExists = ctaData?.length > 0 && ctaData[0]?.text;
87
83
  const isPrimaryButtonSaved = primaryButtonExists && ctaData[0]?.isSaved;
88
84
 
89
- // Check if secondary button exists (saved or being edited)
90
- const secondaryButtonExists = ctaData?.length > 1 && ctaData[1]?.text;
91
- const isSecondaryButtonSaved = secondaryButtonExists && ctaData[1]?.isSaved;
85
+ // Secondary button: needs backend support, revamped
86
+ // const secondaryButtonExists = ctaData?.length > 1 && ctaData[1]?.text;
87
+ // const isSecondaryButtonSaved = secondaryButtonExists && ctaData[1]?.isSaved;
92
88
 
93
89
  // Show primary CTA if button is active and (form is showing OR button exists)
94
90
  const shouldShowPrimaryCTA = primaryButton && (showPrimaryCTA || primaryButtonExists);
95
91
 
96
- // Show secondary CTA if button is active and (form is showing OR button exists)
97
- const shouldShowSecondaryCTA = secondaryButton && (showSecondaryCTA || secondaryButtonExists);
92
+ // Secondary button: needs backend support, revamped
93
+ // const shouldShowSecondaryCTA = secondaryButton && (showSecondaryCTA || secondaryButtonExists);
98
94
 
99
95
  // Enhanced delete handler to hide forms when buttons are deleted
100
96
  const handleDelete = (index) => {
101
97
  if (index === 0) {
102
98
  setShowPrimaryCTA(false);
103
99
  setPrimaryButton(false);
104
- } else if (index === 1) {
105
- //cooment until supported from BE & Hydra
106
- // setShowSecondaryCTA(false);
107
- // setSecondaryButton(false);
108
100
  }
101
+ // Secondary button: needs backend support, revamped
102
+ // else if (index === 1) {
103
+ // setShowSecondaryCTA(false);
104
+ // setSecondaryButton(false);
105
+ // }
109
106
  deleteHandler(index);
110
107
  };
111
108
 
112
109
  return (
113
110
  <>
114
111
  <CapRow className="mpush-cta-buttons">
115
- <CapHeading type="h3">
116
- <FormattedMessage {...messages.buttons} />
117
- </CapHeading>
112
+ {/* Heading with "(Optional)" on the same line */}
113
+ <CapRow type="flex" align="middle" noWrap className="mpush-section-heading">
114
+ <CapHeading type="h3">
115
+ <FormattedMessage {...messages.buttons} />
116
+ </CapHeading>
117
+ <CapLabel className="optional-text">
118
+ <FormattedMessage {...messages.optionalText} />
119
+ </CapLabel>
120
+ </CapRow>
118
121
  {!isPrimaryButtonSaved && !shouldShowPrimaryCTA && (
119
122
  <CapButton
120
123
  type="link"
@@ -142,6 +145,7 @@ const CtaButtons = ({
142
145
  handleOnTagsContextChange={handleOnTagsContextChange}
143
146
  />
144
147
  )}
148
+ {/* Secondary button: needs backend support, so it is being revamped. Hidden until then.
145
149
  {isPrimaryButtonSaved && !isSecondaryButtonSaved && !shouldShowSecondaryCTA && (
146
150
  <CapTooltip
147
151
  overlay={<FormattedMessage {...messages.secondaryButtonTooltip} />}
@@ -171,15 +175,16 @@ const CtaButtons = ({
171
175
  buttonType={SECONDARY}
172
176
  />
173
177
  )}
178
+ */}
174
179
  </>
175
180
  );
176
181
  };
177
182
 
178
183
  CtaButtons.propTypes = {
179
184
  primaryButton: PropTypes.bool.isRequired,
180
- secondaryButton: PropTypes.bool.isRequired,
185
+ // secondaryButton: PropTypes.bool.isRequired,
181
186
  setPrimaryButton: PropTypes.func.isRequired,
182
- setSecondaryButton: PropTypes.func.isRequired,
187
+ // setSecondaryButton: PropTypes.func.isRequired,
183
188
  ctaData: PropTypes.array.isRequired,
184
189
  updateHandler: PropTypes.func.isRequired,
185
190
  deleteHandler: PropTypes.func.isRequired,