@capillarytech/creatives-library 7.17.94 → 7.17.95

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.17.94",
4
+ "version": "7.17.95",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -8,6 +8,7 @@ import CapHeader from "@capillarytech/cap-ui-library/CapHeader";
8
8
  import CapInput from "@capillarytech/cap-ui-library/CapInput";
9
9
  import CapRadioGroup from "@capillarytech/cap-ui-library/CapRadioGroup";
10
10
  import CapRow from "@capillarytech/cap-ui-library/CapRow";
11
+ import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
11
12
  import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
12
13
  import CapLink from "@capillarytech/cap-ui-library/CapLink";
13
14
  import CapError from "@capillarytech/cap-ui-library/CapError";
@@ -150,7 +151,7 @@ const CapDeviceContent = (props) => {
150
151
 
151
152
  return (
152
153
  <>
153
- <div className="creatives-device-content">
154
+ <CapRow className="creatives-device-content">
154
155
  <CapLink
155
156
  title={isAndroid
156
157
  ? formatMessage(messages.copyContentFromIOS)
@@ -158,15 +159,15 @@ const CapDeviceContent = (props) => {
158
159
  className="inapp-copy-content"
159
160
  onClick={onCopyTitleAndContent}
160
161
  />
161
- <div className="creatives-inapp-title">
162
- <div
162
+ <CapRow className="creatives-inapp-title">
163
+ <CapColumn
163
164
  className="inapp-content-main"
164
165
  >
165
166
  <CapHeading type="h5" className="inapp-title">
166
167
  {formatMessage(messages.title)}
167
168
  </CapHeading>
168
169
  {getTagList(0)} {/* here 0 signifies the tags for template title */}
169
- </div>
170
+ </CapColumn>
170
171
  <CapInput
171
172
  id="inapp-title-name-input"
172
173
  onChange={onTitleChange}
@@ -175,9 +176,9 @@ const CapDeviceContent = (props) => {
175
176
  size="default"
176
177
  isRequired
177
178
  />
178
- </div>
179
- <div className="creatives-inapp-media">
180
- <div className="inapp-content-media">
179
+ </CapRow>
180
+ <CapRow className="creatives-inapp-media">
181
+ <CapRow className="inapp-content-media">
181
182
  <CapHeading type="h5" className="inapp-media-header">
182
183
  {formatMessage(messages.mediaLabel)}
183
184
  </CapHeading>
@@ -188,17 +189,17 @@ const CapDeviceContent = (props) => {
188
189
  onChange={onTemplateMediaTypeChange}
189
190
  className="inapp-media-radio"
190
191
  />
191
- </div>
192
- </div>
193
- <div className={`creatives-inapp-message ${!isMediaTypeImage && "message-bottom-margin"}`}>
194
- <div
192
+ </CapRow>
193
+ </CapRow>
194
+ <CapRow className={`creatives-inapp-message ${!isMediaTypeImage && "message-bottom-margin"}`}>
195
+ <CapColumn
195
196
  className="inapp-message-header"
196
197
  >
197
198
  <CapHeading type="h5" className="inapp-message-header-style">
198
199
  {formatMessage(messages.message)}
199
200
  </CapHeading>
200
201
  {getTagList(1)} {/* here 1 signifies the tags for template message */}
201
- </div>
202
+ </CapColumn>
202
203
  <TextArea
203
204
  id="inapp-create-template-message-input"
204
205
  className="inapp-create-template-message-input"
@@ -234,11 +235,11 @@ const CapDeviceContent = (props) => {
234
235
  />
235
236
  </>
236
237
  )}
237
- </div>
238
- </div>
239
- <div className="inapp-action-link">
238
+ </CapRow>
239
+ </CapRow>
240
+ <CapRow className="inapp-action-link">
240
241
  <CapCheckbox onChange={() => setAddActionLink(!addActionLink)} checked={addActionLink} />
241
- <div className="inapp-render-heading">
242
+ <CapRow className="inapp-render-heading">
242
243
  <CapHeader
243
244
  title={<CapRow type="flex">
244
245
  <CapHeading type="h4">
@@ -248,7 +249,7 @@ const CapDeviceContent = (props) => {
248
249
  description={<CapLabel type="label3">{formatMessage(messages.addActionLinkDesc)}</CapLabel>}
249
250
  />
250
251
  {addActionLink && (
251
- <div className="inapp-action-deep-link">
252
+ <CapRow className="inapp-action-deep-link">
252
253
  <CapHeading type="h4">
253
254
  {formatMessage(messages.actionDeepLink)}
254
255
  </CapHeading>
@@ -259,11 +260,11 @@ const CapDeviceContent = (props) => {
259
260
  value={deepLinkValue}
260
261
  onChange={(value) => { setDeepLinkValue(value); }}
261
262
  />
262
- </div>
263
+ </CapRow>
263
264
  )}
264
- </div>
265
- </div>
266
- <div className="inapp-cta-button">
265
+ </CapRow>
266
+ </CapRow>
267
+ <CapRow className="inapp-cta-button">
267
268
  <CapHeader
268
269
  className="inapp-render-heading-cta-button"
269
270
  title={<CapRow type="flex">
@@ -294,7 +295,7 @@ const CapDeviceContent = (props) => {
294
295
  deepLink={deepLink || []}
295
296
  />
296
297
  )}
297
- </div>
298
+ </CapRow>
298
299
  </>
299
300
  );
300
301
  };
@@ -48,7 +48,7 @@
48
48
  }
49
49
  .cap-custom-image-upload {
50
50
  .dragger-button.re-upload {
51
- top: 28rem;
51
+ top: 12rem;
52
52
  position: absolute;
53
53
  right: $CAP_SPACE_20;
54
54
  color: $FONT_COLOR_05;
@@ -33,37 +33,47 @@ describe('Test CapDeviceContent', () => {
33
33
  fireEvent.click(copyLink);
34
34
  expect(copyLink).toBeInTheDocument();
35
35
  });
36
- it('test case for CapDeviceContent component Ios pane', () => {
37
- renderComponent(
38
- {...deviceContentProps,
39
- panes: "iOS",
40
- buttonType: 'CTA',
41
- setTemplateMediaType: jest.fn(),
42
- setButtonType: jest.fn(),
43
- setCtaData: jest.fn(),
44
- setTemplateMessage: jest.fn(),
45
- setTemplateMessageError: jest.fn(),
46
- setTitle: jest.fn(),
47
- templateMediType: 'IMAGE',
48
- addActionLink: true,
49
- ctaData: [
50
- {
51
- index: 0,
52
- ctaType: "WEBSITE",
53
- text: "test",
54
- urlType: "DEEP_LINK",
55
- url: "",
56
- isSaved: true,
57
- label: "Test_1",
58
- },
59
- ] });
60
- const msgBox = screen.getAllByPlaceholderText(/Please input in-app notification message content/i);
36
+ it("test case for CapDeviceContent component Ios pane", () => {
37
+ renderComponent({
38
+ ...deviceContentProps,
39
+ panes: "iOS",
40
+ buttonType: "CTA",
41
+ setTemplateMediaType: jest.fn(),
42
+ setButtonType: jest.fn(),
43
+ setCtaData: jest.fn(),
44
+ setTemplateMessage: jest.fn(),
45
+ setTemplateMessageError: jest.fn(),
46
+ setTitle: jest.fn(),
47
+ templateMediType: "IMAGE",
48
+ addActionLink: true,
49
+ ctaData: [
50
+ {
51
+ index: 0,
52
+ ctaType: "WEBSITE",
53
+ text: "test",
54
+ urlType: "DEEP_LINK",
55
+ url: "link",
56
+ isSaved: true,
57
+ },
58
+ ],
59
+ deepLink: [
60
+ {
61
+ label: "Test_1",
62
+ value: "link",
63
+ },
64
+ ],
65
+ });
66
+ const msgBox = screen.getAllByPlaceholderText(
67
+ /Please input in-app notification message content/i
68
+ );
61
69
  msgBox[0].focus();
62
- fireEvent.change(msgBox[0], { target: {value: 'val'}});
63
- fireEvent.change(msgBox[0], { target: {value: ''}});
64
- const titleBox = screen.getAllByPlaceholderText(/Please input message title name/i);
70
+ fireEvent.change(msgBox[0], { target: { value: "val" } });
71
+ fireEvent.change(msgBox[0], { target: { value: "" } });
72
+ const titleBox = screen.getAllByPlaceholderText(
73
+ /Please input message title name/i
74
+ );
65
75
  titleBox[0].focus();
66
- fireEvent.change(titleBox[0], { target: {value: 'val'}});
76
+ fireEvent.change(titleBox[0], { target: { value: "val" } });
67
77
  const img = screen.getByText(/image/i);
68
78
  fireEvent.click(img);
69
79
  const none = screen.getByText(/None/i);
@@ -43,7 +43,8 @@ export const CapInAppCTA = (props) => {
43
43
 
44
44
  const [urlError, setUrlError] = useState(false);
45
45
  const [buttonError, setButtonError] = useState(false);
46
- const [ctaDeepLinkValue, setCtaDeepLinkValue] = useState("");
46
+ const [ctaDeepLinkValue, setCtaDeepLinkValue] = useState(ctaData[0]?.url || "");
47
+ const selectedDeepLink = deepLink?.find(link => link?.value === ctaData[0]?.url);
47
48
 
48
49
  const updateHelper = (type, value, index) => {
49
50
  let clonedCta = cloneDeep(ctaData[index]);
@@ -94,12 +95,11 @@ export const CapInAppCTA = (props) => {
94
95
  const onDeepLinkSelect = (value) => {
95
96
  setCtaDeepLinkValue(value);
96
97
  let errorMessage = false;
97
- if (!isUrl(value.key)) {
98
+ if (!isUrl(value)) {
98
99
  errorMessage = formatMessage(messages.ctaWebsiteUrlErrorMessage);
99
100
  }
100
101
  setUrlError(errorMessage);
101
- updateHelper('url', value.key, 0); // 0 is an index
102
- updateHelper('label', value.label, 0); // 0 is an index
102
+ updateHelper('url', value, 0); // 0 is an index
103
103
  };
104
104
 
105
105
  const ctaSaveDisabled = (index) => {
@@ -120,7 +120,7 @@ export const CapInAppCTA = (props) => {
120
120
  const renderedContent = () => {
121
121
  const renderArray = [];
122
122
  ctaData?.forEach((cta) => {
123
- const { index, text, url, urlType, isSaved, label } = cta || {};
123
+ const { index, text, url, urlType, isSaved } = cta || {};
124
124
  //this is to display buttons after they are saved, in both create and edit mode.
125
125
  if (isSaved) {
126
126
  renderArray.push(
@@ -145,7 +145,7 @@ export const CapInAppCTA = (props) => {
145
145
  : <CapTag className="cta-type-label">{formatMessage(messages.urlExternalLink)}</CapTag>}
146
146
  </CapColumn>
147
147
  <CapColumn>
148
- {urlType === DEEP_LINK ? label : ''}
148
+ {urlType === DEEP_LINK ? selectedDeepLink?.label : ''}
149
149
  </CapColumn>
150
150
  {(
151
151
  <CapRow className="cta-action-grp">
@@ -219,7 +219,6 @@ export const CapInAppCTA = (props) => {
219
219
  options={deepLink || []}
220
220
  onChange={onDeepLinkSelect}
221
221
  value={ctaDeepLinkValue}
222
- labelInValue
223
222
  />
224
223
  </>
225
224
 
@@ -589,59 +589,16 @@ export class Creatives extends React.Component {
589
589
  }
590
590
  break;
591
591
  case constants.MOBILE_PUSH:
592
- if (get(template, "value.versions.base")) {
593
- const mobilpushTemplate = template.value;
594
- templateData.accountId = get(mobilpushTemplate, 'definition.accountId');
595
- const type = (get(this.props, "messageDetails.type") || '').toLowerCase();
596
- if (type === LOYALTY) {
597
- templateData.licenseCode = get(mobilpushTemplate, 'definition.licenseCode');
598
- templateData.templateId = get(mobilpushTemplate, '_id');
599
- }
600
- const androidContent = get(mobilpushTemplate, 'versions.base.ANDROID');
601
- if (!isEmpty(androidContent)) {
602
- if (type !== LOYALTY) {
603
- delete androidContent.cuid;
604
- delete androidContent.luid;
605
- delete androidContent.communicationId;
606
- }
607
- const custom = {};
608
- forEach(androidContent.custom, (customKeyValue) => {
609
- custom[customKeyValue.key] = customKeyValue.value;
610
- } );
611
- androidContent.custom = custom;
612
- templateData.androidContent = androidContent;
613
- templateData.androidContent.type = get(mobilpushTemplate, 'definition.mode', '').toUpperCase();
614
- templateData.androidContent.deviceType = 'ANDROID';
615
- }
616
- const iosContent = get(mobilpushTemplate, 'versions.base.IOS');
617
- if (!isEmpty(iosContent)) {
618
- if (type !== LOYALTY) {
619
- delete iosContent.cuid;
620
- delete iosContent.luid;
621
- delete iosContent.communicationId;
622
- }
623
- const custom = {};
624
- forEach(iosContent.custom, (customKeyValue) => {
625
- custom[customKeyValue.key] = customKeyValue.value;
626
- } );
627
- iosContent.custom = custom;
628
- templateData.iosContent = iosContent;
629
- templateData.iosContent.type = get(mobilpushTemplate, 'definition.mode').toUpperCase();
630
- templateData.iosContent.deviceType = 'IOS';
631
- }
632
- templateData.messageSubject = mobilpushTemplate.name ? mobilpushTemplate.name : "messageSubject";
633
- }
634
- break;
635
592
  case constants.INAPP:
636
- if (get(template, "value.versions.base.content")) {
637
- const inAppTemplate = template.value;
638
- templateData.accountId = get(inAppTemplate, 'definition.accountId');
593
+ if (get(template, "value.versions.base")) {
594
+ const channelTemplate = template.value;
595
+ templateData.accountId = get(channelTemplate, 'definition.accountId');
639
596
  const type = (get(this.props, "messageDetails.type") || '').toLowerCase();
640
597
  if (type === LOYALTY) {
641
- templateData.licenseCode = get(inAppTemplate, 'definition.licenseCode');
642
- templateData.templateId = get(inAppTemplate, '_id');
598
+ templateData.licenseCode = get(channelTemplate, 'definition.licenseCode');
599
+ templateData.templateId = get(channelTemplate, '_id');
643
600
  }
644
- const androidContent = get(inAppTemplate, 'versions.base.content.ANDROID');
601
+ const androidContent = channel === constants.INAPP ? get(channelTemplate, 'versions.base.content.ANDROID') : get(channelTemplate, 'versions.base.ANDROID');
645
602
  if (!isEmpty(androidContent)) {
646
603
  if (type !== LOYALTY) {
647
604
  delete androidContent.cuid;
@@ -654,10 +611,10 @@ export class Creatives extends React.Component {
654
611
  });
655
612
  androidContent.custom = custom;
656
613
  templateData.androidContent = androidContent;
657
- templateData.androidContent.type = get(inAppTemplate, 'definition.mode', '').toUpperCase();
614
+ templateData.androidContent.type = get(channelTemplate, 'definition.mode', '').toUpperCase();
658
615
  templateData.androidContent.deviceType = 'ANDROID';
659
616
  }
660
- const iosContent = get(inAppTemplate, 'versions.base.content.IOS');
617
+ const iosContent = channel === constants.INAPP ? get(channelTemplate, 'versions.base.content.IOS') : get(channelTemplate, 'versions.base.IOS');
661
618
  if (!isEmpty(iosContent)) {
662
619
  if (type !== LOYALTY) {
663
620
  delete iosContent.cuid;
@@ -670,10 +627,10 @@ export class Creatives extends React.Component {
670
627
  });
671
628
  iosContent.custom = custom;
672
629
  templateData.iosContent = iosContent;
673
- templateData.iosContent.type = get(inAppTemplate, 'definition.mode').toUpperCase();
630
+ templateData.iosContent.type = get(channelTemplate, 'definition.mode').toUpperCase();
674
631
  templateData.iosContent.deviceType = IOS.toUpperCase();
675
632
  }
676
- templateData.messageSubject = inAppTemplate?.name ? inAppTemplate?.name : "messageSubject";
633
+ templateData.messageSubject = channelTemplate?.name ? channelTemplate?.name : "messageSubject";
677
634
  }
678
635
  break;
679
636
  case constants.WECHAT:
@@ -960,6 +917,7 @@ export class Creatives extends React.Component {
960
917
  };
961
918
  break;
962
919
  case constants.MOBILE_PUSH:
920
+ case constants.INAPP:
963
921
  gtmDetails = {
964
922
  ...gtmDetails,
965
923
 
@@ -967,13 +925,6 @@ export class Creatives extends React.Component {
967
925
  imageAdded: androidType === 'IMAGE' || iosType === 'IMAGE',
968
926
  };
969
927
  break;
970
- case constants.INAPP:
971
- gtmDetails = {
972
- ...gtmDetails,
973
- content: `${androidTitle} ${androidMessage} ${iosTitle} ${iosMessage}`,
974
- imageAdded: androidType === IMAGE || iosType === IMAGE,
975
- };
976
- break;
977
928
  case constants.LINE:
978
929
  gtmDetails = Object.assign({
979
930
  ...gtmDetails,
@@ -48,7 +48,6 @@ export const INITIAL_CTA_DATA = [
48
48
  urlType: DEEP_LINK,
49
49
  url: "",
50
50
  isSaved: false,
51
- label: "",
52
51
  },
53
52
  ];
54
53
 
@@ -118,7 +117,7 @@ export const BUTTON_RADIO_OPTIONS = [
118
117
  <CapHeading type="h4">
119
118
  <FormattedMessage {...messages.btnTypeCTA} />
120
119
  </CapHeading>
121
- <CapLabel><FormattedMessage {...messages.ctaDesc} /></CapLabel>
120
+ <CapLabel><FormattedMessage {...messages.ctaDescription} /></CapLabel>
122
121
  </div>
123
122
  </>
124
123
  ),
@@ -171,22 +171,21 @@ export const InApp = (props) => {
171
171
  : INAPP_MEDIA_TYPES.IMAGE
172
172
  );
173
173
  setInAppImageSrcAndroid(androidExpandableDetails?.image);
174
- setDeepLinkValueAndroid(androidCta.actionLink);
174
+ setDeepLinkValueAndroid(androidCta?.actionLink);
175
175
  setAddActionLinkAndroid(!isEmpty(androidCta) && true);
176
176
  setButtonTypeAndroid(
177
- androidExpandableDetails?.buttonType || INAPP_BUTTON_TYPES.NONE
177
+ androidExpandableDetails?.ctas?.length ? INAPP_BUTTON_TYPES.CTA : INAPP_BUTTON_TYPES.NONE
178
178
  );
179
- if (androidExpandableDetails?.buttonType === INAPP_BUTTON_TYPES.CTA && androidExpandableDetails?.buttons.length > 0) {
179
+ if (androidExpandableDetails?.ctas?.length > 0) {
180
180
  setCtaDataAndroid(
181
- androidExpandableDetails?.buttons?.map((cta) => {
182
- const { index, type, text, url = "", label } = cta;
181
+ androidExpandableDetails?.ctas?.map((cta, index) => {
182
+ const { type, actionText, actionLink = "" } = cta;
183
183
  const obj = {
184
184
  index,
185
- text,
186
- url,
185
+ text: actionText,
186
+ url: actionLink,
187
187
  urlType: type,
188
188
  isSaved: true,
189
- label,
190
189
  };
191
190
  return obj;
192
191
  })
@@ -203,20 +202,19 @@ export const InApp = (props) => {
203
202
  setTemplateMessageIos(iosMessage);
204
203
  setTemplateMediaTypeIos(iosExpandableDetails?.style === BIG_TEXT ? INAPP_MEDIA_TYPES.TEXT : INAPP_MEDIA_TYPES.IMAGE);
205
204
  setInAppImageSrcIos(iosExpandableDetails?.image);
206
- setButtonTypeIos(iosExpandableDetails?.buttonType || INAPP_BUTTON_TYPES.NONE);
205
+ setButtonTypeIos(iosExpandableDetails?.ctas?.length ? INAPP_BUTTON_TYPES.CTA : INAPP_BUTTON_TYPES.NONE);
207
206
  setAddActionLinkIos(!isEmpty(iosCta) && true);
208
207
  setDeepLinkValueIos(iosCta?.actionLink);
209
- if (iosExpandableDetails?.buttonType === INAPP_BUTTON_TYPES.CTA && iosExpandableDetails?.buttons.length > 0) {
208
+ if (iosExpandableDetails?.ctas?.length > 0) {
210
209
  setCtaDataIos(
211
- iosExpandableDetails?.buttons?.map((cta) => {
212
- const { index, type, text, url = "", label } = cta;
210
+ iosExpandableDetails?.ctas?.map((cta, index) => {
211
+ const { type, actionText, actionLink = "" } = cta;
213
212
  const obj = {
214
213
  index,
215
- text,
216
- url,
214
+ text: actionText,
215
+ url: actionLink,
217
216
  urlType: type,
218
217
  isSaved: true,
219
- label,
220
218
  };
221
219
  return obj;
222
220
  })
@@ -543,20 +541,17 @@ export const InApp = (props) => {
543
541
 
544
542
  const getCtaPayload = (type) =>
545
543
  (type === ANDROID ? ctaDataAndroid : ctaDataIos).map((cta) => {
546
- const { index, text, urlType, url, label } = cta;
544
+ const { text, urlType, url } = cta;
547
545
  return {
548
- index,
549
546
  type: urlType,
550
- text,
551
- url,
552
- label,
547
+ actionText: text,
548
+ actionLink: url,
553
549
  };
554
550
  });
555
551
 
556
552
  const createPayload = () => {
557
553
  let androidMediaParams = {};
558
554
  let iosMediaParams = {};
559
- const buttonType = panes === ANDROID ? buttonTypeAndroid : buttonTypeIos;
560
555
  const commonDevicePayload = {
561
556
  luid: "{{luid}}",
562
557
  cuid: "{{cuid}}",
@@ -602,8 +597,7 @@ export const InApp = (props) => {
602
597
  message: templateMessageAndroid,
603
598
  ...androidMediaParams,
604
599
  ...(isBtnTypeCta && {
605
- buttonType,
606
- buttons: getCtaPayload(ANDROID),
600
+ ctas: getCtaPayload(ANDROID),
607
601
  }),
608
602
  },
609
603
  custom: [],
@@ -619,8 +613,7 @@ export const InApp = (props) => {
619
613
  message: templateMessageIos,
620
614
  ...iosMediaParams,
621
615
  ...(isBtnTypeCta && {
622
- buttonType,
623
- buttons: getCtaPayload(IOS),
616
+ ctas: getCtaPayload(IOS),
624
617
  }),
625
618
  },
626
619
  custom: [],
@@ -37,7 +37,7 @@
37
37
  .inapp-footer {
38
38
  background-color: $CAP_WHITE;
39
39
  bottom: 0;
40
- position: fixed;
40
+ // position: fixed;
41
41
  width: 100%;
42
42
  padding: $CAP_SPACE_20 0;
43
43
  z-index: 1;
@@ -91,8 +91,8 @@ export default defineMessages({
91
91
  id: `${prefix}.btnTypeCTA`,
92
92
  defaultMessage: "Call to action",
93
93
  },
94
- ctaDesc: {
95
- id: `${prefix}.ctaDesc`,
94
+ ctaDescription: {
95
+ id: `${prefix}.ctaDescription`,
96
96
  defaultMessage:
97
97
  "Create a button that lets customers take an action",
98
98
  },