@capillarytech/creatives-library 7.12.24 → 7.12.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.12.24",
4
+ "version": "7.12.26",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -45,13 +45,14 @@ export const CapActionButton = (props) => {
45
45
  let errorMessage = false;
46
46
  if (!isUrl(val)) {
47
47
  errorMessage = formatMessage(messages.inValidUrlErrorMessage);
48
- } else {
49
- updateButtonChange([{
50
- type,
51
- text: buttonText,
52
- url: val,
53
- }]);
54
48
  }
49
+ updateButtonChange({
50
+ type,
51
+ text: buttonText,
52
+ url: val,
53
+ error: errorMessage,
54
+ });
55
+
55
56
  updateButtonURLErrorMessage(errorMessage);
56
57
  };
57
58
 
@@ -76,81 +76,6 @@ exports[`CapActionButton test Test if CapActionButton component renders 1`] = `
76
76
  `;
77
77
 
78
78
  exports[`CapActionButton test Test if CapActionButton component renders 2`] = `
79
- <CapRow
80
- className="cap-action-button"
81
- >
82
- <CapHeading
83
- type="h4"
84
- >
85
- <FormattedMessage
86
- defaultMessage="Button text"
87
- id="creatives.componentsV2.CapActionButton.templateButtonText"
88
- values={Object {}}
89
- />
90
- </CapHeading>
91
- <_class
92
- id="rcs-template-Button-Text"
93
- labelPosition="top"
94
- maxLength={200}
95
- onChange={[Function]}
96
- placeholder="Enter button text"
97
- size="default"
98
- suffix={
99
- <CapLabel
100
- type="label1"
101
- >
102
- 9 / 200
103
- </CapLabel>
104
- }
105
- value="testValue"
106
- />
107
- <CapHeading
108
- style={
109
- Object {
110
- "paddingTop": "20px",
111
- }
112
- }
113
- type="h4"
114
- >
115
- <FormattedMessage
116
- defaultMessage="Button link"
117
- id="creatives.componentsV2.CapActionButton.templateButtonLink"
118
- values={Object {}}
119
- />
120
- </CapHeading>
121
- <_class
122
- errorMessage="Button URL is not valid"
123
- id="rcs-template-Button-link"
124
- labelPosition="top"
125
- onChange={[Function]}
126
- placeholder="Enter button link"
127
- size="default"
128
- value="testValue"
129
- />
130
- <CapDivider
131
- style={
132
- Object {
133
- "marginBottom": 16,
134
- "marginTop": 23,
135
- }
136
- }
137
- />
138
- <CapTooltip
139
- placement="topLeft"
140
- title="Not enabled yet. Coming soon!"
141
- >
142
- <CapButton
143
- className="disabled-button"
144
- isAddBtn={true}
145
- type="flat"
146
- >
147
- Add button
148
- </CapButton>
149
- </CapTooltip>
150
- </CapRow>
151
- `;
152
-
153
- exports[`CapActionButton test Test if CapActionButton component renders 3`] = `
154
79
  <CapRow
155
80
  className="cap-action-button"
156
81
  >
@@ -19,7 +19,7 @@ export const TEMPLATE_DESC_MAX_LENGTH = 1000;
19
19
  export const FALLBACK_MESSAGE_MAX_LENGTH = 160;
20
20
  export const TEMPLATE_TITLE_MAX_LENGTH = 200;
21
21
  export const TEMPLATE_BUTTON_TEXT_MAX_LENGTH = 20;
22
-
22
+ export const CTA = 'CTA';
23
23
  export const TAG = 'TAG';
24
24
  export const EMBEDDED = 'embedded';
25
25
  export const DEFAULT = 'default';
@@ -70,6 +70,7 @@ import {
70
70
  VERTICAL,
71
71
  STANDALONE,
72
72
  RICHCARD,
73
+ CTA,
73
74
  } from './constants';
74
75
  import globalMessages from '../Cap/messages';
75
76
  import messages from './messages';
@@ -132,6 +133,7 @@ export const Rcs = (props) => {
132
133
  const [dltPreviewData, setDltPreviewData] = useState('');
133
134
  const [suggestions, setSuggestions] = useState([]);
134
135
  const [buttonType, setButtonType] = useState('');
136
+ const [suggestionError, setSuggestionError] = useState(true);
135
137
  const mediaRadioOptions = [
136
138
  {
137
139
  value: RCS_MEDIA_TYPES.NONE,
@@ -166,8 +168,15 @@ export const Rcs = (props) => {
166
168
  }
167
169
  }
168
170
  `;
169
- const updateButtonChange = (val) => {
170
- setSuggestions(val);
171
+ const updateButtonChange = (data) => {
172
+ const {
173
+ type,
174
+ text,
175
+ url,
176
+ error,
177
+ } = data;
178
+ setSuggestions([{type, text, url}]);
179
+ setSuggestionError(error);
171
180
  };
172
181
  const RcsLabel = styled.div`
173
182
  display: flex;
@@ -182,14 +191,14 @@ export const Rcs = (props) => {
182
191
  <FormattedMessage {...messages.templateCTAButtonDesc} />
183
192
  </CapLabel>
184
193
  </div>
185
- {buttonType && <CapActionButton
186
- type="CTA"
194
+ {buttonType.includes(CTA) && <CapActionButton
195
+ type={CTA}
187
196
  buttonTextlen={TEMPLATE_BUTTON_TEXT_MAX_LENGTH}
188
197
  updateButtonChange={updateButtonChange}
189
198
  suggestions={suggestions}
190
199
  />}
191
200
  </>,
192
- value: "CTA",
201
+ value: CTA,
193
202
  },
194
203
  {
195
204
  label: <CapTooltip
@@ -248,7 +257,7 @@ export const Rcs = (props) => {
248
257
  setEditFlow(true);
249
258
  if (rcsSuggestions.length > 0) {
250
259
  setSuggestions(rcsSuggestions);
251
- setButtonType(["CTA"]);
260
+ setButtonType(CTA);
252
261
  }
253
262
 
254
263
  // for DLT Fallback message
@@ -453,10 +462,11 @@ export const Rcs = (props) => {
453
462
  }
454
463
  return errorMessage;
455
464
  };
456
- const onChangeButtonTypes = (val) => {
457
- setButtonType(val[0]);
465
+
466
+ const onChangeButtonTypes = useCallback((checkedValues) => {
467
+ setButtonType(checkedValues);
458
468
  setSuggestions([]);
459
- };
469
+ });
460
470
  const renderTextComponent = (
461
471
  <>
462
472
  {/* template title */}
@@ -1002,7 +1012,7 @@ export const Rcs = (props) => {
1002
1012
 
1003
1013
  // if call to action (Button text & link) is not added
1004
1014
  const {text, url} = suggestions[0] || {};
1005
- if (buttonType && !(text && url) ) {
1015
+ if (buttonType.includes(CTA) && !(text && url && !suggestionError ) ) {
1006
1016
  return true;
1007
1017
  }
1008
1018
  if (templateDescError || fallbackMessageError) {
@@ -1029,7 +1039,7 @@ export const Rcs = (props) => {
1029
1039
  let mediaTypeMsg = isMediaTypeNone ? 'textMessage' : 'image';
1030
1040
  mediaTypeMsg = formatMessage(messages[mediaTypeMsg]);
1031
1041
  const {text, url} = suggestions[0] || {};
1032
- if (buttonType && !(text && url) ) {
1042
+ if (buttonType.includes(CTA) && !(text && url) ) {
1033
1043
  mediaTypeMsg = `${formatMessage(messages.buttonTextAndUrl)} ${mediaTypeMsg} `;
1034
1044
  }
1035
1045
  return (