@capillarytech/creatives-library 7.12.58 → 7.12.60

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.58",
4
+ "version": "7.12.60",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -255,6 +255,17 @@
255
255
  }
256
256
  }
257
257
 
258
+ .whatsapp-brand-name {
259
+ position: absolute;
260
+ top: 11%;
261
+ left: 38%;
262
+ color: white;
263
+ font-size: small;
264
+ max-width: 100px;
265
+ text-overflow: ellipsis;
266
+ overflow: hidden;
267
+ white-space: nowrap;
268
+ }
258
269
  .whatsapp-divider{
259
270
  margin: 8px 0;
260
271
  }
@@ -154,7 +154,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
154
154
  showTestAndPreviewIcon,
155
155
  module,
156
156
  viberBrandName,
157
- viberAccountName,
157
+ whatsappAccountName,
158
158
  whatsappContentLen,
159
159
  intl,
160
160
  templateData,
@@ -321,6 +321,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
321
321
  return renderArray;
322
322
  };
323
323
 
324
+ const whatsappUpdatedAccountName = whatsappAccountName || templateData?.versions?.base?.content?.whatsapp?.accountName || '';
324
325
  const whatsappUpdatedLen = whatsappContentLen !== undefined ? whatsappContentLen : content?.charCount;
325
326
 
326
327
  return (
@@ -723,6 +724,9 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
723
724
  src={whatsappMobileAndroid}
724
725
  alt={formatMessage(messages.previewGenerated)}
725
726
  />
727
+ <CapLabel className="whatsapp-brand-name">
728
+ {whatsappUpdatedAccountName || ''}
729
+ </CapLabel>
726
730
  <div className="msg-container whatsapp-message-container">
727
731
  <div className="message-pop align-left" style={whatsappSectionStyle}>
728
732
  <div className="whatsapp-content">
@@ -59,6 +59,12 @@ exports[`Test Templates container Should render correct preview component for wh
59
59
  className="preview-image"
60
60
  src="test-file-stub"
61
61
  />
62
+ <CapLabel
63
+ className="whatsapp-brand-name"
64
+ type="label1"
65
+ >
66
+ 30
67
+ </CapLabel>
62
68
  <div
63
69
  className="msg-container whatsapp-message-container"
64
70
  >
@@ -74,49 +80,48 @@ exports[`Test Templates container Should render correct preview component for wh
74
80
  }
75
81
  }
76
82
  >
77
- <CapLabel
83
+ <div
78
84
  className="whatsapp-content"
79
- type="label1"
80
85
  >
81
86
  You have received {{1}} points
82
- </CapLabel>
83
- <CapDivider
84
- className="whatsapp-divider"
85
- />
86
- <CapLabel
87
- className="whatsapp-cta-preview"
88
- type="label21"
89
- >
90
- <CapIcon
91
- size="xs"
92
- svgProps={
93
- Object {
94
- "style": Object {
95
- "marginRight": "4px",
96
- },
97
- }
98
- }
99
- type="call"
87
+ <CapDivider
88
+ className="whatsapp-divider"
100
89
  />
101
- Call
102
- </CapLabel>
103
- <CapLabel
104
- className="whatsapp-cta-preview"
105
- type="label21"
106
- >
107
- <CapIcon
108
- size="xs"
109
- svgProps={
110
- Object {
111
- "style": Object {
112
- "marginRight": "4px",
113
- },
90
+ <CapLabel
91
+ className="whatsapp-cta-preview"
92
+ type="label21"
93
+ >
94
+ <CapIcon
95
+ size="xs"
96
+ svgProps={
97
+ Object {
98
+ "style": Object {
99
+ "marginRight": "4px",
100
+ },
101
+ }
114
102
  }
115
- }
116
- type="launch"
117
- />
118
- Visit
119
- </CapLabel>
103
+ type="call"
104
+ />
105
+ Call
106
+ </CapLabel>
107
+ <CapLabel
108
+ className="whatsapp-cta-preview"
109
+ type="label21"
110
+ >
111
+ <CapIcon
112
+ size="xs"
113
+ svgProps={
114
+ Object {
115
+ "style": Object {
116
+ "marginRight": "4px",
117
+ },
118
+ }
119
+ }
120
+ type="launch"
121
+ />
122
+ Visit
123
+ </CapLabel>
124
+ </div>
120
125
  </div>
121
126
  </div>
122
127
  </div>
@@ -134,7 +139,7 @@ exports[`Test Templates container Should render correct preview component for wh
134
139
  id="app.components.TemplatePreview.whatsappMessageLength"
135
140
  values={
136
141
  Object {
137
- "length": 30,
142
+ "length": "test",
138
143
  }
139
144
  }
140
145
  />
@@ -160,6 +165,12 @@ exports[`Test Templates container Should render correct preview component for wh
160
165
  className="preview-image"
161
166
  src="test-file-stub"
162
167
  />
168
+ <CapLabel
169
+ className="whatsapp-brand-name"
170
+ type="label1"
171
+ >
172
+ 30
173
+ </CapLabel>
163
174
  <div
164
175
  className="msg-container whatsapp-message-container"
165
176
  >
@@ -175,15 +186,14 @@ exports[`Test Templates container Should render correct preview component for wh
175
186
  }
176
187
  }
177
188
  >
178
- <CapLabel
189
+ <div
179
190
  className="whatsapp-content"
180
- type="label1"
181
191
  >
182
192
  You have received {{1}} points
183
- </CapLabel>
184
- <CapDivider
185
- className="whatsapp-divider"
186
- />
193
+ <CapDivider
194
+ className="whatsapp-divider"
195
+ />
196
+ </div>
187
197
  </div>
188
198
  </div>
189
199
  </div>
@@ -201,7 +211,7 @@ exports[`Test Templates container Should render correct preview component for wh
201
211
  id="app.components.TemplatePreview.whatsappMessageLength"
202
212
  values={
203
213
  Object {
204
- "length": 30,
214
+ "length": "test",
205
215
  }
206
216
  }
207
217
  />
@@ -227,6 +237,10 @@ exports[`Test Templates container Should render correct preview component for wh
227
237
  className="preview-image"
228
238
  src="test-file-stub"
229
239
  />
240
+ <CapLabel
241
+ className="whatsapp-brand-name"
242
+ type="label1"
243
+ />
230
244
  <div
231
245
  className="msg-container whatsapp-message-container"
232
246
  >
@@ -242,9 +256,8 @@ exports[`Test Templates container Should render correct preview component for wh
242
256
  }
243
257
  }
244
258
  >
245
- <CapLabel
259
+ <div
246
260
  className="whatsapp-content"
247
- type="label1"
248
261
  />
249
262
  </div>
250
263
  </div>
@@ -263,7 +276,7 @@ exports[`Test Templates container Should render correct preview component for wh
263
276
  id="app.components.TemplatePreview.whatsappMessageLength"
264
277
  values={
265
278
  Object {
266
- "length": 0,
279
+ "length": "test",
267
280
  }
268
281
  }
269
282
  />
@@ -9,12 +9,14 @@ describe('Test Templates container', () => {
9
9
  const renderFunction = (
10
10
  channel,
11
11
  content,
12
+ whatsappAccountName,
12
13
  whatsappContentLen,
13
14
  ) => {
14
15
  renderedComponent = shallowWithIntl(
15
16
  <TemplatePreview
16
17
  channel={channel}
17
18
  content={content}
19
+ whatsappAccountName={whatsappAccountName}
18
20
  whatsappContentLen={whatsappContentLen}
19
21
  />,
20
22
  );
@@ -414,6 +414,7 @@ export function SlideBoxContent(props) {
414
414
  content={getChannelPreviewContent(templateData)}
415
415
  viberBrandName={selectedAccount || ""}
416
416
  viberAccountName={(selectedAccount || "")[0]}
417
+ whatsappAccountName={selectedAccount}
417
418
  unicodeEnabled={get(templateData, `versions.base['unicode-validity']`)}
418
419
  channel={(templateData.type || '').toLowerCase()}
419
420
  charCounterEnabled={channel === constants.SMS}
@@ -369,7 +369,6 @@ export class Creatives extends React.Component {
369
369
  const {
370
370
  messageBody = '',
371
371
  templateConfigs: {
372
- id,
373
372
  name,
374
373
  template,
375
374
  varMapped,
@@ -391,7 +390,6 @@ export class Creatives extends React.Component {
391
390
  });
392
391
  const unsubscribeRegex = /Click {{unsubscribe}} to unsubscribe/g;
393
392
  creativesTemplateData = {
394
- _id: id,
395
393
  type: constants.WHATSAPP,
396
394
  edit: true,
397
395
  name,
@@ -583,6 +581,11 @@ export class Creatives extends React.Component {
583
581
  break;
584
582
  case constants.WHATSAPP:
585
583
  if (template.value) {
584
+ const { Templates, templateData: templateDataProps } = this.props;
585
+ const selectedWhatsappAccount = Templates?.selectedWhatsappAccount;
586
+ const { accountDetails: selectedAccountDetails, accountId: selectedAccountId } = templateDataProps || {};
587
+ const accountDetails = (selectedWhatsappAccount ? selectedWhatsappAccount : selectedAccountDetails);
588
+ const accountId = selectedAccountId || (selectedWhatsappAccount?.id || '');
586
589
  const { versions } = template.value;
587
590
  const {
588
591
  languages = [{}],
@@ -606,10 +609,11 @@ export class Creatives extends React.Component {
606
609
  });
607
610
  templateData = {
608
611
  channel,
609
- accountName: '',
612
+ accountId,
613
+ accountName: accountDetails?.name || '',
610
614
  messageBody: languages[0].content,
611
615
  templateConfigs: {
612
- id: template._id,
616
+ id: template?.value?.name,
613
617
  name: template?.value?.name,
614
618
  template: templateEditor,
615
619
  varMapped,
@@ -67,4 +67,4 @@ export const GET_SENDER_DETAILS_REQUEST =
67
67
  export const GET_SENDER_DETAILS_SUCCESS =
68
68
  'app/v2Containers/Templates/GET_SENDER_DETAILS_SUCCESS';
69
69
  export const GET_SENDER_DETAILS_FAILURE =
70
- 'app/v2Containers/Templates/GET_SENDER_DETAILS_FAILURE';
70
+ 'app/v2Containers/Templates/GET_SENDER_DETAILS_FAILURE';
@@ -263,6 +263,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
263
263
  case WHATSAPP:
264
264
  channel = 'Whatsapp';
265
265
  activeMode = ACCOUNT_SELECTION_MODE;
266
+ this.props.actions.getWeCrmAccounts(channel);
266
267
  this.props.actions.getSenderDetails({
267
268
  channel: WHATSAPP,
268
269
  orgUnitId: -1,
@@ -301,7 +302,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
301
302
  if (this.props.location.query.type === 'embedded') {
302
303
  this.props.actions.resetAccount();
303
304
  }
304
- if (['line', VIBER_CHANNEL, FACEBOOK_CHANNEL, 'sms', 'email', 'ebill', RCS_LOWERCASE, WHATSAPP_LOWERCASE].includes((this.state.channel || '').toLowerCase())) {
305
+ if (['line', VIBER_CHANNEL, FACEBOOK_CHANNEL, 'sms', 'email', 'ebill', RCS_LOWERCASE].includes((this.state.channel || '').toLowerCase())) {
305
306
  const queryParams = {
306
307
  // name: this.state.searchText,
307
308
  // sortBy: this.state.sortBy,
@@ -428,21 +429,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
428
429
  }
429
430
  }
430
431
 
431
- if (
432
- selectedChannel === WHATSAPP_LOWERCASE &&
433
- isEmpty(nextProps.Templates.selectedWhatsappAccount)
434
- ) {
435
- const { connectionProperties = {}, hostName = '' } = get(nextProps.Templates, 'senderDetails.data[0].domainProperties', {});
436
- if (isEmpty(connectionProperties) || hostName === '') {
437
- return;
438
- }
439
- this.setState({activeMode: TEMPLATES_MODE, hostName}, () => {
440
- this.props.actions.setChannelAccount(WHATSAPP, { connectionProperties, hostName });
441
- this.getAllTemplates({ params });
442
- }
443
- );
444
- }
445
-
446
432
  if ((selectedChannel === 'wechat' || selectedChannel === 'mobilepush') && isEmpty(nextProps.Templates.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && !this.isEnabledInLibraryModule("showAccountSelection")) {
447
433
  let selectedAccount = '';
448
434
  if (isEmpty(nextProps.Templates.weCrmAccounts)) {
@@ -572,8 +558,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
572
558
  if (!isEmpty(nextProps.Templates.templateDetails) && !isEqual(nextProps.Templates.templateDetails, this.props.Templates.templateDetails)) {
573
559
  this.setState({previewTemplate: nextProps.Templates.templateDetails});
574
560
  }
575
- const weCrmAccountsList = get(nextProps, `Templates.weCrmAccounts`, []);
576
- const weCrmChannels = ['wechat'];
561
+ const { weCrmAccounts: weCrmAccountsList = [], senderDetails: { hostName = '' } = {} } = get(nextProps, 'Templates', {});
562
+ const weCrmChannels = ['wechat', WHATSAPP_LOWERCASE];
577
563
 
578
564
  if (weCrmAccountsList.length === 1 && this.state.defaultAccount && (weCrmChannels.indexOf(selectedChannel) > -1)) {
579
565
  const paramsDefault = {
@@ -581,14 +567,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
581
567
  sortBy: this.state.sortBy,
582
568
  };
583
569
  if (weCrmChannels.includes(selectedChannel)) {
584
- paramsDefault.wecrmId = weCrmAccountsList[0].configs.wecrm_app_id;
585
- paramsDefault.wecrmToken = weCrmAccountsList[0].configs.wecrm_token;
586
- paramsDefault.originalId = weCrmAccountsList[0].sourceAccountIdentifier;
570
+ if ([WHATSAPP_LOWERCASE].includes(selectedChannel)) {
571
+ if (hostName === '') {
572
+ return;
573
+ }
574
+ weCrmAccountsList[0].hostName = hostName;
575
+ nextProps.actions.setChannelAccount(selectedChannel.toUpperCase(), weCrmAccountsList[0]);
576
+ } else {
577
+ paramsDefault.wecrmId = weCrmAccountsList[0].configs.wecrm_app_id;
578
+ paramsDefault.wecrmToken = weCrmAccountsList[0].configs.wecrm_token;
579
+ paramsDefault.originalId = weCrmAccountsList[0].sourceAccountIdentifier;
587
580
  nextProps.actions.setWeChatAccount(
588
581
  weCrmAccountsList[0],
589
582
  );
583
+ }
590
584
  }
591
- this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name });
585
+ this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName });
592
586
  this.getAllTemplates({params: paramsDefault}, true);
593
587
  }
594
588
  }
@@ -2051,7 +2045,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2051
2045
  const rcsLoader = this.checkLoader(RCS_LOWERCASE);
2052
2046
 
2053
2047
  const wechatLoader = (((this.state.selectedAccount !== '' && getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'wechat');
2054
- const whatsappLoader = this.checkLoader(WHATSAPP_LOWERCASE) || this.props.Templates?.senderDetails?.status === 'REQUEST';
2048
+ const whatsappLoader =
2049
+ (
2050
+ (this.state.selectedAccount !== "" && getAllTemplatesInProgress) ||
2051
+ fetchingWeCrmAccounts ||
2052
+ this.props.Templates?.senderDetails?.status === "REQUEST"
2053
+ ) &&
2054
+ this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE;
2055
2055
  const mobilePushLoader = (((getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'mobilepush');
2056
2056
  const emailLoader = (
2057
2057
  (getAllTemplatesInProgress ||
@@ -2167,19 +2167,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2167
2167
  const { selectedAccount } = this.state;
2168
2168
  let { channel = '' } = this.state;
2169
2169
  channel = channel.toUpperCase();
2170
- const { Templates: templates = {}, location = {}, intl: {formatMessage}} = this.props;
2170
+ const { Templates: templates = {}, location = {} } = this.props;
2171
2171
  const { query = {} } = location;
2172
- const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {}, selectedWhatsappAccount = {} } = templates;
2172
+ const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {} } = templates;
2173
2173
  const isWechatChannel = channel === WECHAT;
2174
2174
  const isMobilePushChannel = channel === MOBILE_PUSH;
2175
2175
  const isFacebookChannel = channel === FACEBOOK;
2176
2176
 
2177
- if (channel === WHATSAPP && isEmpty(selectedWhatsappAccount)) {
2178
- return <CapHeading>{formatMessage(messages.noAccountsPresentWhatsapp)}</CapHeading>;
2179
- } else if (channel === WHATSAPP && !isEmpty(selectedWhatsappAccount)) {
2180
- this.setTemplatesMode();
2181
- }
2182
-
2183
2177
  if ([WECHAT, MOBILE_PUSH, LINE].includes(channel) && !isEmpty(weCrmAccounts) && !isFacebookChannel) {
2184
2178
  forEach(weCrmAccounts, (account) => {
2185
2179
  if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || [MOBILE_PUSH, LINE].includes(channel)) {
@@ -2215,6 +2209,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2215
2209
  }
2216
2210
  });
2217
2211
  }
2212
+ const {
2213
+ intl: {
2214
+ formatMessage,
2215
+ },
2216
+ } = this.props;
2218
2217
  let accountHeader = formatMessage(messages.mobilepushAccount);
2219
2218
  let noAccountHeader = messages.noAccountsPresent;
2220
2219
  switch (channel) {
@@ -2241,10 +2240,18 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
2241
2240
  noAccountHeader = messages.noAccountsPresentFacebook;
2242
2241
  break;
2243
2242
  }
2243
+ case WHATSAPP: {
2244
+ accountHeader = formatMessage(messages.whatsappAccount);
2245
+ noAccountHeader = messages.noAccountsPresentWhatsapp;
2246
+ break;
2247
+ }
2244
2248
  default:
2245
2249
  break;
2246
2250
  }
2247
2251
  let showNoAccountHeader = isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts;
2252
+ if (channel === WHATSAPP && this.state.hostName === '') {
2253
+ showNoAccountHeader = true;
2254
+ }
2248
2255
  if (channel === FACEBOOK && !isEmpty(campaignSettings) ) {
2249
2256
  const fbSetting = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
2250
2257
  const { orgUnitFacebookPageSettingsMap } = fbSetting[0] || {};
@@ -124,7 +124,7 @@ export default defineMessages({
124
124
  },
125
125
  "noAccountsPresent": {
126
126
  id: `${scope}.noAccountsPresent`,
127
- defaultMessage: "Account not setup for your brand",
127
+ defaultMessage: "Push notifications are not setup for your brand",
128
128
  },
129
129
  "noAccountsPresentWeChat": {
130
130
  id: `${scope}.noAccountsPresentWeChat`,
@@ -181,13 +181,13 @@ function templatesReducer(state = initialState, action) {
181
181
  case types.GET_SENDER_DETAILS_SUCCESS:
182
182
  return state.set('senderDetails', {
183
183
  status: 'SUCCESS',
184
- data: action.payload,
184
+ hostName: action.payload,
185
185
  errors: [],
186
186
  });
187
187
  case types.GET_SENDER_DETAILS_FAILURE:
188
188
  return state.set('senderDetails', {
189
189
  status: 'FAILURE',
190
- data: [],
190
+ hostName: '',
191
191
  errors: action.payload,
192
192
  });
193
193
  default:
@@ -157,7 +157,7 @@ export function* getSenderDetails({
157
157
  if (!apiResponse?.errors?.length) {
158
158
  yield put({
159
159
  type: types.GET_SENDER_DETAILS_SUCCESS,
160
- payload: apiResponse.entity.WHATSAPP,
160
+ payload: apiResponse.entity.WHATSAPP[0].domainProperties.hostName,
161
161
  });
162
162
  } else {
163
163
  yield put({