@capillarytech/creatives-library 8.0.109 → 8.0.110

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": "8.0.109",
4
+ "version": "8.0.110",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -42,3 +42,4 @@ export const KARIX_GUPSHUP_URL_OPTIONS = [
42
42
  export const BTN_MAX_LENGTH = 20;
43
43
  export const PHONE_NUMBER_MAX_LENGTH = 15;
44
44
  export const URL_MAX_LENGTH = 2000;
45
+ export const DYNAMIC_URL_SUFFIX = '{{1}}';
@@ -33,6 +33,7 @@ import {
33
33
  WEBSITE,
34
34
  DYNAMIC_URL,
35
35
  STATIC_URL,
36
+ DYNAMIC_URL_SUFFIX,
36
37
  } from './constants';
37
38
  import {
38
39
  INITIAL_CTA_DATA,
@@ -120,8 +121,8 @@ export const CapWhatsappCTA = (props) => {
120
121
 
121
122
  const ctaOptions = CTA_OPTIONS.map((option) => {
122
123
  const { value, label, tooltipLabel } = option;
123
- //if button 1 is of type-> PHONE_NUMBER, it is disabled in second button
124
- const isDisabled = ctaData.length === 2 && ctaData[0].ctaType === value;
124
+ //only disable PHONE_NUMBER if first button is also PHONE_NUMBER
125
+ const isDisabled = ctaData.length === 2 && ctaData[0].ctaType === PHONE_NUMBER && value === PHONE_NUMBER;
125
126
  return {
126
127
  value,
127
128
  label: renderCtaOptions(label, tooltipLabel, isDisabled),
@@ -162,7 +163,6 @@ export const CapWhatsappCTA = (props) => {
162
163
  let { value, id } = target;
163
164
  if (urlType === DYNAMIC_URL) {
164
165
  value = value.replace(invalidVarRegex, '');
165
- value = `${value}{{1}}`;
166
166
  }
167
167
  let errorMessage = false;
168
168
  if (!isUrl(value)) {
@@ -190,6 +190,14 @@ export const CapWhatsappCTA = (props) => {
190
190
  };
191
191
 
192
192
  const saveCta = (index) => {
193
+ const clonedIndexCta = cloneDeep(ctaData[index]);
194
+ // If this is a website CTA with dynamic URL type, ensure {{1}} is added at the end
195
+ if (clonedIndexCta?.ctaType === WEBSITE && clonedIndexCta?.urlType === DYNAMIC_URL) {
196
+ if (!clonedIndexCta?.url?.includes(DYNAMIC_URL_SUFFIX)) {
197
+ clonedIndexCta.url += DYNAMIC_URL_SUFFIX;
198
+ ctaData[index] = clonedIndexCta;
199
+ }
200
+ }
193
201
  updateHelper('isSaved', true, index);
194
202
  };
195
203
  const editCta = (index) => {
@@ -391,6 +399,7 @@ export const CapWhatsappCTA = (props) => {
391
399
  </CapHeading>
392
400
  <CapInput
393
401
  id={index}
402
+ addonAfter={urlType === DYNAMIC_URL && !url.includes(DYNAMIC_URL_SUFFIX) && DYNAMIC_URL_SUFFIX}
394
403
  className="whatsapp-cta-url"
395
404
  onChange={(event) => onUrlChange(event, urlType)}
396
405
  placeholder={