@capillarytech/creatives-library 8.0.111 → 8.0.112

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.111",
4
+ "version": "8.0.112",
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={
@@ -4,6 +4,7 @@ import get from 'lodash/get';
4
4
  import { bindActionCreators } from "redux";
5
5
  import { createStructuredSelector } from "reselect";
6
6
  import { injectIntl, FormattedMessage } from "react-intl";
7
+ import { DAEMON } from '@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes';
7
8
  import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
8
9
  import CapSpin from "@capillarytech/cap-ui-library/CapSpin";
9
10
  import CapInput from "@capillarytech/cap-ui-library/CapInput";
@@ -30,7 +31,8 @@ import TemplatePreview from "../../v2Components/TemplatePreview";
30
31
  import { validateTags } from "../../utils/tagValidations";
31
32
  import injectReducer from '../../utils/injectReducer';
32
33
  import v2InAppReducer from './reducer';
33
-
34
+ import { v2InAppSagas } from './sagas';
35
+ import injectSaga from '../../utils/injectSaga';
34
36
  import {
35
37
  ANDROID,
36
38
  BIG_PICTURE,
@@ -799,11 +801,13 @@ const mapDispatchToProps = (dispatch) => ({
799
801
  });
800
802
 
801
803
  const withReducer = injectReducer({ key: 'inapp', reducer: v2InAppReducer });
804
+ const withInAppSaga = injectSaga({ key: 'inapp', saga: v2InAppSagas, mode: DAEMON });
802
805
 
803
806
  export default withCreatives({
804
807
  WrappedComponent: injectIntl(InApp),
805
808
  mapStateToProps,
806
809
  mapDispatchToProps,
807
810
  userAuth: true,
811
+ sagas: [withInAppSaga],
808
812
  reducers: [withReducer],
809
813
  });