@capillarytech/creatives-library 6.13.6 → 6.13.8

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.
Files changed (51) hide show
  1. package/app.js +3 -3
  2. package/assets/viber.png +0 -0
  3. package/containers/Templates/index.js +0 -3
  4. package/index.js +8 -1
  5. package/package.json +2 -2
  6. package/reducers.js +2 -0
  7. package/routes.js +7 -1
  8. package/services/api.js +5 -0
  9. package/v2Components/TemplatePreview/_templatePreview.scss +8 -2
  10. package/v2Components/TemplatePreview/index.js +104 -18
  11. package/v2Containers/App/constants.js +1 -1
  12. package/v2Containers/CreativesContainer/SlideBoxContent.js +65 -2
  13. package/v2Containers/CreativesContainer/constants.js +2 -0
  14. package/v2Containers/CreativesContainer/index.js +29 -2
  15. package/v2Containers/Templates/_templates.scss +57 -0
  16. package/v2Containers/Templates/index.js +59 -6
  17. package/v2Containers/TemplatesV2/index.js +9 -1
  18. package/v2Containers/TemplatesV2/messages.js +4 -0
  19. package/v2Containers/Viber/_viber.scss +3 -0
  20. package/v2Containers/Viber/actions.js +74 -0
  21. package/v2Containers/Viber/constants.js +30 -0
  22. package/v2Containers/Viber/index.js +707 -0
  23. package/v2Containers/Viber/messages.js +137 -0
  24. package/v2Containers/Viber/reducer.js +84 -0
  25. package/v2Containers/Viber/sagas.js +107 -0
  26. package/v2Containers/Viber/selectors.js +21 -0
  27. package/v2Containers/Line/Create/_lineCreate.scss +0 -64
  28. package/v2Containers/Line/Create/actions.js +0 -94
  29. package/v2Containers/Line/Create/constants.js +0 -43
  30. package/v2Containers/Line/Create/index.js +0 -1112
  31. package/v2Containers/Line/Create/initialSchema.js +0 -378
  32. package/v2Containers/Line/Create/messages.js +0 -229
  33. package/v2Containers/Line/Create/reducer.js +0 -99
  34. package/v2Containers/Line/Create/sagas.js +0 -113
  35. package/v2Containers/Line/Create/selectors.js +0 -30
  36. package/v2Containers/Line/CreateWrapper/constants.js +0 -2
  37. package/v2Containers/Line/CreateWrapper/index.js +0 -117
  38. package/v2Containers/Line/CreateWrapper/messages.js +0 -55
  39. package/v2Containers/Line/Edit/_lineEdit.scss +0 -23
  40. package/v2Containers/Line/Edit/actions.js +0 -79
  41. package/v2Containers/Line/Edit/constants.js +0 -27
  42. package/v2Containers/Line/Edit/index.js +0 -1051
  43. package/v2Containers/Line/Edit/messages.js +0 -173
  44. package/v2Containers/Line/Edit/reducer.js +0 -83
  45. package/v2Containers/Line/Edit/sagas.js +0 -81
  46. package/v2Containers/Line/Edit/selectors.js +0 -29
  47. package/v2Containers/Line/Edit/tests/actions.test.js +0 -18
  48. package/v2Containers/Line/Edit/tests/index.test.js +0 -10
  49. package/v2Containers/Line/Edit/tests/reducer.test.js +0 -9
  50. package/v2Containers/Line/Edit/tests/sagas.test.js +0 -15
  51. package/v2Containers/Line/Edit/tests/selectors.test.js +0 -10
@@ -30,6 +30,7 @@ import { makeSelectEbill as makeSelectCreateEbill } from '../Ebill/selectors';
30
30
  import { makeSelectEmail as makeSelectCreateEmail } from '../Email/selectors';
31
31
  import { makeSelectEdit } from '../Sms/Edit/selectors';
32
32
  import { makeSelectLine } from '../Line/Container/selectors';
33
+ import { makeSelectViber } from '../Viber/selectors';
33
34
  import { UserIsAuthenticated } from '../../utils/authWrapper';
34
35
  import messages from './messages';
35
36
  import {checkUnicode} from '../../utils/smsCharCountV2';
@@ -40,6 +41,8 @@ import * as smsEditActions from '../Sms/Edit/actions';
40
41
  import * as ebillActions from '../Ebill/actions';
41
42
  import * as emailActions from '../Email/actions';
42
43
  import * as lineActions from '../Line/Container/actions';
44
+ import * as viberActions from '../Viber/actions';
45
+
43
46
  import CardGrid from '../../v2Components/CardGrid';
44
47
  import config from '../../config/app';
45
48
  import './_templates.scss';
@@ -50,8 +53,13 @@ import Pagination from '../../v2Components/Pagination';
50
53
  import EmailPreview from '../../v2Components/EmailPreview';
51
54
  import CreativesContainer from '../CreativesContainer';
52
55
  import WechatRichmediaTemplatePreview from '../../v2Components/TemplatePreview/WechatRichmediaTemplatePreview';
53
- import { CHANNEL_CREATE_TRACK_MAPPING, CHANNEL_EDIT_TRACK_MAPPING } from '../App/constants';
54
- import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE } from '../CreativesContainer/constants';
56
+ import {
57
+ CHANNEL_CREATE_TRACK_MAPPING,
58
+ CHANNEL_EDIT_TRACK_MAPPING,
59
+ VIBER as VIBER_CHANNEL,
60
+ } from '../App/constants';
61
+ import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE, VIBER } from '../CreativesContainer/constants';
62
+
55
63
  import emailIllustration from '../Assets/images/emailIllustration.svg';
56
64
  import smsIllustration from '../Assets/images/smsIllustration.svg';
57
65
  import pushIllustration from '../Assets/images/pushIllustration.svg';
@@ -161,6 +169,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
161
169
  case EBILL:
162
170
  channel = 'Ebill';
163
171
  break;
172
+ case VIBER:
173
+ channel = 'Viber';
174
+ break;
164
175
  case LINE:
165
176
  channel = "Line";
166
177
  if (!this.props.isFullMode) {
@@ -185,7 +196,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
185
196
  if (this.props.location.query.type === 'embedded') {
186
197
  this.props.actions.resetAccount();
187
198
  }
188
- if ((this.state.channel && (this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill')) || ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && !isEmpty(this.props.Templates.selectedWeChatAccount))) {
199
+ if ((['line', VIBER_CHANNEL, 'sms', 'email', 'ebill'].includes((this.state.channel || '').toLowerCase())) || ((['wechat', 'mobilepush'].includes(this.state.channel.toLowerCase()) && !isEmpty(this.props.Templates.selectedWeChatAccount)))) {
189
200
  const queryParams = {
190
201
  // name: this.state.searchText,
191
202
  // sortBy: this.state.sortBy,
@@ -245,9 +256,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
245
256
  this.setState({defaultAccount: true});
246
257
  nextProps.actions.getWeCrmAccounts(channel);
247
258
  }
259
+ } else if (nextProps.route.name.toLowerCase() === VIBER_CHANNEL) {
260
+ channel = 'Viber';
248
261
  }
262
+
249
263
  this.setState({ channel }, () => {
250
- if ((this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill') || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
264
+ if (['line', VIBER_CHANNEL, 'sms', 'email', 'ebill'].includes(this.state.channel.toLowerCase()) || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
251
265
  if (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount)) {
252
266
  params.wecrmId = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_app_id;
253
267
  params.wecrmToken = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_token;
@@ -336,6 +350,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
336
350
  this.props.ebillActions.clearCreateResponse();
337
351
  } else if (this.state.channel.toLowerCase() === "line") {
338
352
  this.props.lineActions.clearCreateResponse();
353
+ } else if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
354
+ this.props.viberActions.clearCreateResponse();
339
355
  }
340
356
  }
341
357
  }
@@ -651,7 +667,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
651
667
  <video height="279">
652
668
  <source src={originalVideoContentUrl} type="video/mp4" />
653
669
  </video>
654
- )
670
+ );
655
671
  }
656
672
  if (carouselTemplate) {
657
673
  const carouselContent = get(carouselTemplate, 'columns', [{}]).map(({ imageUrl, action: { label: actionLabel } = {} }) => ({ imageUrl, actionLabel }) );
@@ -677,6 +693,26 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
677
693
  }
678
694
  break;
679
695
  }
696
+ case VIBER: {
697
+ const {
698
+ content: {
699
+ viber: {
700
+ text = '',
701
+ imageURL = '',
702
+ buttonURL = '',
703
+ buttonText = '',
704
+ } = {},
705
+ } = {},
706
+ } = template.versions.base;
707
+ templateData.content = text;
708
+ if (imageURL) {
709
+ templateData.url = imageURL;
710
+ }
711
+ if (buttonURL && buttonText) {
712
+ templateData.buttonText = buttonText;
713
+ }
714
+ break;
715
+ }
680
716
  default:
681
717
  templateData.content = "";
682
718
  }
@@ -1174,6 +1210,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1174
1210
  this.props.lineActions.clearCreateResponse();
1175
1211
  }
1176
1212
  });
1213
+ } else if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
1214
+ this.props.viberActions.createTemplate(duplicateObj, (response) => {
1215
+ if (response && response.templateId) {
1216
+ const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
1217
+ CapNotification.success({key: 'duplicateSucess', message});
1218
+ this.getAllTemplates({params, resetPage: true});
1219
+ this.props.viberActions.clearCreateResponse();
1220
+ }
1221
+ });
1177
1222
  }
1178
1223
  }
1179
1224
 
@@ -1255,6 +1300,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1255
1300
  pathName += `/${options.account}`;
1256
1301
  }
1257
1302
  }
1303
+ if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
1304
+ pathName = `/viber/edit/${id}/`;
1305
+ }
1258
1306
  if (this.state.channel.toUpperCase() === WECHAT) {
1259
1307
  if (get(template, 'definition.msgcontent', '') === "RICH_MEDIA_WECHAT") {
1260
1308
  pathName = `/wechat/richmedia/edit/${id}`;
@@ -1553,6 +1601,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1553
1601
  } = Templates;
1554
1602
  const lineLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'line');
1555
1603
  const smsLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'sms');
1604
+ const viberLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === VIBER_CHANNEL);
1556
1605
  const wechatLoader = (((this.state.selectedAccount !== '' && getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'wechat');
1557
1606
  const mobilePushLoader = (((getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'mobilepush');
1558
1607
  const emailLoader = (
@@ -1566,7 +1615,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1566
1615
  (emailLoader !== undefined ? emailLoader : false) ||
1567
1616
  (ebillLoader !== undefined ? ebillLoader : false) ||
1568
1617
  (mobilePushLoader !== undefined ? mobilePushLoader : false) ||
1569
- (lineLoader !== undefined ? lineLoader : false);
1618
+ (lineLoader !== undefined ? lineLoader : false) ||
1619
+ (viberLoader !== undefined ? viberLoader : false);
1570
1620
  return isLoading;
1571
1621
  }
1572
1622
  getChannelTypeIllustrationInfo = (type) => {
@@ -1977,6 +2027,7 @@ Templates.propTypes = {
1977
2027
  isFullMode: PropTypes.bool,
1978
2028
  handlePeviewTemplate: PropTypes.func,
1979
2029
  router: PropTypes.object,
2030
+ viberActions: PropTypes.object,
1980
2031
  };
1981
2032
 
1982
2033
  const mapStateToProps = createStructuredSelector({
@@ -1989,6 +2040,7 @@ const mapStateToProps = createStructuredSelector({
1989
2040
  EmailCreate: makeSelectCreateEmail(),
1990
2041
  Global: makeSelectAuthenticated(),
1991
2042
  Line: makeSelectLine(),
2043
+ Viber: makeSelectViber(),
1992
2044
  });
1993
2045
 
1994
2046
  function mapDispatchToProps(dispatch) {
@@ -2001,6 +2053,7 @@ function mapDispatchToProps(dispatch) {
2001
2053
  emailActions: bindActionCreators(emailActions, dispatch),
2002
2054
  globalActions: bindActionCreators(globalActions, dispatch),
2003
2055
  lineActions: bindActionCreators(lineActions, dispatch),
2056
+ viberActions: bindActionCreators(viberActions, dispatch),
2004
2057
  };
2005
2058
  }
2006
2059
 
@@ -22,6 +22,7 @@ import * as actions from './actions';
22
22
  import Templates from '../Templates';
23
23
  import CallTask from '../CallTask';
24
24
  import Facebook from '../Facebook';
25
+ import Viber from '../Viber';
25
26
  import Line from '../Line/Container';
26
27
  import Gallery from '../Assets/Gallery';
27
28
  import withStyles from '../../hoc/withStyles';
@@ -52,6 +53,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
52
53
  //'wechat': {content: this.getTemplatesComponent('wechat'), tab: 'Wechat', key: 'wechat'},
53
54
  mPush: {content: <></>, tab: intl.formatMessage(messages.pushNotification), key: 'mobilepush'},
54
55
  line: {content: <></>, tab: intl.formatMessage(messages.line), key: 'line'},
56
+ viber: {content: <></>, tab: intl.formatMessage(messages.viber), key: 'viber'},
57
+
55
58
 
56
59
  };
57
60
  let filteredPanes = Object.keys(defaultPanes)
@@ -152,7 +155,12 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
152
155
  />
153
156
  );
154
157
  }
155
-
158
+ getViberComponent =() => (
159
+ <Viber
160
+ {...this.props}
161
+ isCreateFlow
162
+ ></Viber>
163
+ )
156
164
  getLineComponent = () => (
157
165
  <Line
158
166
  {...this.props}
@@ -46,6 +46,10 @@ export default defineMessages({
46
46
  id: 'creatives.containersV2.TemplatesV2.facebook',
47
47
  defaultMessage: 'Facebook',
48
48
  },
49
+ viber: {
50
+ id: 'creatives.containersV2.TemplatesV2.viber',
51
+ defaultMessage: 'Viber',
52
+ },
49
53
  gallery: {
50
54
  id: 'creatives.containersV2.TemplatesV2.gallery',
51
55
  defaultMessage: 'Gallery',
@@ -0,0 +1,3 @@
1
+ .cap-divider-margin{
2
+ margin: 14px 0;
3
+ }
@@ -0,0 +1,74 @@
1
+
2
+ import * as types from './constants';
3
+
4
+ export function defaultAction() {
5
+ return {
6
+ type: types.DEFAULT_ACTION,
7
+ };
8
+ }
9
+
10
+ export const uploadViberAsset = (file, assetType, fileParams, templateType) => ({
11
+ type: types.UPLOAD_VIBER_ASSET_REQUEST,
12
+ file,
13
+ assetType,
14
+ fileParams,
15
+ templateType,
16
+ });
17
+
18
+
19
+ export function createTemplate(template, callback) {
20
+ return {
21
+ type: types.CREATE_VIBER_TEMPLATE_REQUEST,
22
+ template,
23
+ callback,
24
+ };
25
+ }
26
+
27
+
28
+ // FOR EDIT
29
+
30
+ export function editTemplate(template, callback) {
31
+ console.log('action trigereed editTemplate viber @@@');
32
+ return {
33
+ type: types.EDIT_VIBER_TEMPLATE_REQUEST,
34
+ template,
35
+ callback,
36
+ };
37
+ }
38
+
39
+ export function getTemplateDetails(id, callback) {
40
+ console.log('getting template viber @@@', id);
41
+ return {
42
+ type: types.GET_VIBER_TEMPLATE_DETAILS_REQUEST,
43
+ id,
44
+ channel: 'VIBER',
45
+ callback,
46
+ };
47
+ }
48
+
49
+ export function clearData() {
50
+ return {
51
+ type: types.CLEAR_VIBER_DATA,
52
+ };
53
+ }
54
+
55
+ export function clearEditResponse() {
56
+ return {
57
+ type: types.CLEAR_VIBER_EDIT_RESPONSE_REQUEST,
58
+ };
59
+ }
60
+
61
+
62
+ export function clearCreateResponse() {
63
+ return {
64
+ type: types.CLEAR_VIBER_CREATE_RESPONSE_REQUEST,
65
+ };
66
+ }
67
+
68
+ export function clearViberAsset(templateType) {
69
+ return {
70
+ type: types.CLEAR_VIBER_ASSET,
71
+ templateType,
72
+ };
73
+ }
74
+
@@ -0,0 +1,30 @@
1
+ export const DEFAULT_ACTION = 'app/v2Containers/Viber/DEFAULT_ACTION';
2
+ export const ALLOWED_EXTENSIONS_REGEX = (/\.(jpe?g|png)$/i);
3
+ export const VIBER_IMG_HEIGHT = 400;
4
+ export const VIBER_IMG_WIDTH = 300;
5
+ export const VIBER_IMG_SIZE = 10000000;
6
+ export const charLimit = 1000;
7
+
8
+ export const UPLOAD_VIBER_ASSET_REQUEST = 'app/v2Containers/Viber/UPLOAD_ASSET_REQUEST';
9
+ export const UPLOAD_VIBER_ASSET_SUCCESS = 'app/v2Containers/Viber/UPLOAD_ASSET_SUCCESS';
10
+ export const UPLOAD_VIBER_ASSET_FAILURE = 'app/v2Containers/Viber/UPLOAD_ASSET_FAILURE';
11
+
12
+
13
+ export const CREATE_VIBER_TEMPLATE_REQUEST = 'app/v2Containers/Viber/CREATE_VIBER_TEMPLATE_REQUEST';
14
+ export const CREATE_VIBER_TEMPLATE_SUCCESS = 'app/v2Containers/Viber/CREATE_VIBER_TEMPLATE_SUCCESS';
15
+ export const CREATE_VIBER_TEMPLATE_FAILURE = 'app/v2Containers/Viber/CREATE_VIBER_TEMPLATE_FAILURE';
16
+
17
+
18
+ export const GET_VIBER_TEMPLATE_DETAILS_REQUEST = 'app/v2Containers/Viber/EDIT/CREATE_VIBER_TEMPLATE_DETAILS_REQUEST';
19
+ export const GET_VIBER_TEMPLATE_DETAILS_SUCCESS = 'app/v2Containers/Viber/EDIT/CREATE_VIBER_TEMPLATE_DETAILS_SUCCESS';
20
+ export const GET_VIBER_TEMPLATE_DETAILS_FAILURE = 'app/v2Containers/Viber/EDIT/CREATE_VIBER_TEMPLATE_DETAILS_FAILURE';
21
+
22
+ export const EDIT_VIBER_TEMPLATE_REQUEST = 'app/v2Containers/VIBER/Edit/EDIT_VIBER_TEMPLATE_REQUEST';
23
+ export const EDIT_VIBER_TEMPLATE_SUCCESS = 'app/v2Containers/VIBER/Edit/EDIT_VIBER_TEMPLATE_SUCCESS';
24
+ export const EDIT_VIBER_TEMPLATE_FAILURE = 'app/v2Containers/VIBER/Edit/EDIT_VIBER_TEMPLATE_FAILURE';
25
+
26
+ export const CLEAR_VIBER_EDIT_RESPONSE_REQUEST = 'app/v2Containers/VIBER/Edit/CLEAR_EDIT_RESPONSE_REQUEST';
27
+ export const CLEAR_VIBER_DATA = 'app/v2Containers/VIBER/Edit/CLEAR_DATA';
28
+ export const CLEAR_VIBER_CREATE_RESPONSE_REQUEST = 'app/v2Containers/VIBER/Create/CLEAR_EDIT_RESPONSE_REQUEST';
29
+ export const CLEAR_VIBER_ASSET = 'app/v2Containers/Viber/CLEAR_ASSET';
30
+