@capillarytech/creatives-library 7.17.37-alpha.2 → 7.17.37-alpha.4

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.37-alpha.2",
4
+ "version": "7.17.37-alpha.4",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -90,7 +90,7 @@ function checkStatus(response) {
90
90
  const isLoginPage = window.location.pathname.indexOf('/login') !== -1;
91
91
  if (!isLoginPage) redirectIfUnauthenticated(response);
92
92
 
93
- const error = new Error({ statusText, status });
93
+ const error = new Error(statusText);
94
94
  error.response = response;
95
95
  error.isError = true;
96
96
  error.status = status;
@@ -493,14 +493,14 @@ export const getSenderDetails = (channel, orgUnitId) => {
493
493
  export const getCdnTransformationConfig = () => {
494
494
  const url = `${API_ENDPOINT}/common/getCdnTransformationConfig`;
495
495
  return request(url, getAPICallObject('GET'));
496
- }
496
+ };
497
497
 
498
498
  export const getS3UrlFileSizes = (data) => {
499
499
  const url = `${API_ENDPOINT}/assets/files/metadata`;
500
500
  return request(url, getAPICallObject('POST', data));
501
- }
501
+ };
502
502
 
503
503
  export const getTemplateInfoById = ({id, username, oa_id, token}) => {
504
- const url = `${API_ENDPOINT}/templates/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}`;
505
- return request(url, getAPICallObject('GET'));
506
- }
504
+ const url = `${API_ENDPOINT}/templates/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}`;
505
+ return request(url, getAPICallObject('GET'));
506
+ };
@@ -1,8 +1,12 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import {
4
- CapSlideBox, CapHeader, CapLink, CapInput,
5
- } from '@capillarytech/cap-ui-library';
4
+ CapSlideBox,
5
+ CapHeader,
6
+ CapLink,
7
+ CapInput,
8
+ CapNotification,
9
+ } from "@capillarytech/cap-ui-library";
6
10
  import { injectIntl, FormattedMessage } from 'react-intl';
7
11
  import classnames from 'classnames';
8
12
  import {isEmpty, get, forEach, cloneDeep} from 'lodash';
@@ -26,6 +30,7 @@ import * as globalActions from '../Cap/actions';
26
30
  import * as zaloActions from '../Zalo/actions';
27
31
  import {isLoading as isLoadingSelector} from './selectors';
28
32
  import messages from './messages';
33
+ import zaloMessages from '../Zalo/messages';
29
34
  import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
30
35
  import { makeSelectFetchingCmsData } from '../Email/selectors';
31
36
  import { IMAGE as LINE_IMAGE, IMAGE_MAP, IMAGE_CAROUSEL, VIDEO as LINE_VIDEO, TEMPLATE, STICKER } from '../Line/Container/constants';
@@ -98,6 +103,13 @@ export class Creatives extends React.Component {
98
103
  }
99
104
  this.setState(data);
100
105
  };
106
+
107
+ actionCallback = () => {
108
+ CapNotification.error({
109
+ message: <FormattedMessage {...zaloMessages.zaloFailureNotificationPreview}/>,
110
+ });
111
+ };
112
+
101
113
  onPreviewTemplate = (template) => {
102
114
  if (template.type !== constants.ZALO.toLowerCase()) {
103
115
  const templateData = template;
@@ -117,6 +129,7 @@ export class Creatives extends React.Component {
117
129
  token,
118
130
  id: template?._id,
119
131
  preview: true,
132
+ actionCallback: this.actionCallback,
120
133
  });
121
134
  }
122
135
  };
@@ -1910,6 +1910,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1910
1910
 
1911
1911
  selectTemplate = (id) => find(this.props.TemplatesList, {_id: id})
1912
1912
 
1913
+ actionCallback = () => {
1914
+ CapNotification.error({
1915
+ message: this.props.intl.formatMessage(zaloMessages.zaloFailureNotificationPreview),
1916
+ });
1917
+ };
1918
+
1913
1919
  handlePreviewClick(template, modeType) {
1914
1920
  if (this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
1915
1921
  this.togglePreview();
@@ -1952,6 +1958,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1952
1958
  token: token,
1953
1959
  id: template?._id,
1954
1960
  preview: true,
1961
+ actionCallback: this.actionCallback,
1955
1962
  });
1956
1963
  }
1957
1964
  }
@@ -15,6 +15,7 @@ import {
15
15
  CapHeading,
16
16
  CapHeader,
17
17
  CapIcon,
18
+ CapNotification,
18
19
  } from "@capillarytech/cap-ui-library";
19
20
  import {
20
21
  CAP_SPACE_16,
@@ -124,6 +125,7 @@ export const Zalo = ({
124
125
  oa_id: sourceAccountIdentifier,
125
126
  token,
126
127
  id,
128
+ actionCallback,
127
129
  });
128
130
  }, []);
129
131
 
@@ -282,6 +284,12 @@ export const Zalo = ({
282
284
  }
283
285
  };
284
286
 
287
+ const actionCallback = () => {
288
+ CapNotification.error({
289
+ message: formatMessage(messages.zaloFailureNotificationTemplate),
290
+ });
291
+ };
292
+
285
293
  return (
286
294
  <CapSpin spinning={zaloTemplateInfoStatus === REQUEST}>
287
295
  <CapRow type="flex" className="cap-zalo-creatives">
@@ -71,4 +71,12 @@ export default defineMessages({
71
71
  id: `${prefix}.PENDING_REVIEW`,
72
72
  defaultMessage: 'pending review',
73
73
  },
74
+ zaloFailureNotificationTemplate: {
75
+ id: `${prefix}.zaloFailureNotificationTemplate`,
76
+ defaultMessage: 'Unable to load zalo template',
77
+ },
78
+ zaloFailureNotificationPreview: {
79
+ id: `${prefix}.zaloFailureNotificationPreview`,
80
+ defaultMessage: 'Unable to load zalo preview',
81
+ },
74
82
  });
@@ -8,23 +8,29 @@ import {
8
8
  } from "./constants";
9
9
 
10
10
  export function* getTemplateInfoById({ payload }) {
11
+ const { preview = "", actionCallback } = payload;
11
12
  try {
12
13
  const res = yield call(Api.getTemplateInfoById, payload);
13
14
  if (res?.success) {
14
15
  yield put({
15
- type: payload?.preview
16
- ? ZALO_TEMPLATE_PREVIEW_INFO
17
- : ZALO_TEMPLATE_INFO_SUCCESS,
16
+ type: preview ? ZALO_TEMPLATE_PREVIEW_INFO : ZALO_TEMPLATE_INFO_SUCCESS,
18
17
  result: res?.response || {},
19
18
  });
20
19
  } else {
20
+ const errorMsg = res?.message || res?.status?.message;
21
21
  yield put({
22
22
  type: ZALO_TEMPLATE_INFO_ERROR,
23
- error: res?.error || res?.message,
23
+ error: errorMsg,
24
24
  });
25
+ if (actionCallback) {
26
+ actionCallback(errorMsg);
27
+ }
25
28
  }
26
29
  } catch (error) {
27
30
  yield put({ type: ZALO_TEMPLATE_INFO_ERROR, error });
31
+ if (actionCallback) {
32
+ actionCallback(error);
33
+ }
28
34
  }
29
35
  }
30
36