@capillarytech/creatives-library 3.0.30 → 3.0.31

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/app.js CHANGED
@@ -10,7 +10,7 @@ import CapV2 from 'v2Containers/Cap';
10
10
  import Cap from 'containers/Cap';
11
11
  import { LocaleProvider } from 'antd';
12
12
  import { makeSelectLocationState } from 'containers/Cap/selectors';
13
- import LanguageProvider from 'v2Containers/LanguageProvider';
13
+ import LanguageProvider from 'containers/LanguageProvider';
14
14
  import FontFaceObserver from 'fontfaceobserver';
15
15
  /* eslint-disable import/no-unresolved, import/extensions */
16
16
  import '!file-loader?name=[name].[ext]!./favicon.ico';
@@ -152,11 +152,6 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
152
152
  }
153
153
  <div style={{marginTop: '8px', fontSize: '16px'}} >{`${this.props.intl.formatMessage(messages.sms)}: ${smsDetails.parts}`}</div>
154
154
  <div style={{fontSize: '16px'}}>{`${this.props.intl.formatMessage(messages.charactersPerSms)}: ${smsDetails.chars_used}`}</div>
155
- { smsDetails.optoutUrlPresent && <div>
156
- <span style={{fontWeight: '100', fontSize: '12px'}}>{this.props.intl.formatMessage(messages.includes)}</span>
157
- <span style={{fontSize: '12px'}}>{this.props.intl.formatMessage(messages.optout)}</span>
158
- <span style={{fontWeight: '100', fontSize: '12px'}}>{this.props.intl.formatMessage(messages.tag)}</span>: {smsDetails.optouturlLength}
159
- </div>}
160
155
  </p>
161
156
  </div>
162
157
  : ''
@@ -26,16 +26,4 @@ export default defineMessages({
26
26
  id: 'app.components.TemplatePreview.smsFormatType',
27
27
  defaultMessage: 'Message has unicode characters',
28
28
  },
29
- includes: {
30
- id: 'app.components.TemplatePreview.includes',
31
- defaultMessage: 'Includes ',
32
- },
33
- optout: {
34
- id: 'app.components.TemplatePreview.optout',
35
- defaultMessage: 'Optout ',
36
- },
37
- tag: {
38
- id: 'app.components.TemplatePreview.tag',
39
- defaultMessage: 'tag ',
40
- },
41
29
  });
package/config/app.js CHANGED
@@ -5,18 +5,14 @@ const config = {
5
5
  production: {
6
6
  api_endpoint: '/arya/api/v1/creatives',
7
7
  auth_endpoint: '/arya/api/v1/auth',
8
- arya_endpoint: '/arya/api/v1',
9
8
  login_url: 'auth/login',
10
9
  dashboard_url: '/sms',
11
10
  dashboard_url_v2: '/v2',
12
- subscription_api_endpoint: '/arya/api/v1/subscription',
13
11
  accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
14
12
  },
15
13
  development: {
16
14
  api_endpoint: 'https://nightly.capillary.in/arya/api/v1/creatives',
17
15
  auth_endpoint: 'https://nightly.capillary.in/arya/api/v1/auth',
18
- arya_endpoint: 'https://nightly.capillary.in/arya/api/v1',
19
- subscription_api_endpoint: 'https://nightly.capillary.in/arya/api/v1/subscription',
20
16
  login_url: 'auth/login',
21
17
  dashboard_url: '/sms',
22
18
  dashboard_url_v2: '/v2',
@@ -166,7 +166,6 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
166
166
  const map = {
167
167
  'en': 'en',
168
168
  'zh-cn': 'zh',
169
- 'zh': 'zh',
170
169
  };
171
170
  return map[locale];
172
171
  }
@@ -20,7 +20,8 @@ import './_smsCreate.scss';
20
20
  import FormBuilder from '../../../components/FormBuilder';
21
21
  import * as actions from './actions';
22
22
  import messages from './messages';
23
- import {checkUnicode, updateCharCount} from '../../../utils/smsCharCountV2';
23
+ import * as charCount from '../../../utils/smsCharCount';
24
+ import {checkUnicode} from '../../../utils/smsCharCountV2';
24
25
  import * as globalActions from '../../../containers/Cap/actions';
25
26
  import {getMessageObject} from '../../../utils/messageUtils';
26
27
 
@@ -222,7 +223,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
222
223
  }
223
224
  const result = {};
224
225
  result.base = baseData;
225
- const msgObj = updateCharCount(baseData['sms-editor']);
226
+ const msgObj = charCount.updateCharCount(baseData['sms-editor']);
226
227
  result.base.msg_count = msgObj.msgCount;
227
228
  console.log("Message Count", msgObj.msgCount);
228
229
  const response = {
package/index.js CHANGED
@@ -3,10 +3,6 @@ import capReducer from './v2Containers/Cap/reducer';
3
3
  import capSaga from './v2Containers/Cap/sagas';
4
4
  import Cap from './v2Containers/Cap/index';
5
5
 
6
- import LanguageProvider from './v2Containers/LanguageProvider';
7
- import LanguageProviderReducer from './v2Containers/LanguageProvider/reducer';
8
- import LanguageProviderSaga from './v2Containers/LanguageProvider/sagas';
9
-
10
6
  import templateReducer from './v2Containers/Templates/reducer';
11
7
  import templateSaga from './v2Containers/Templates/sagas';
12
8
  import Templates from './v2Containers/Templates/index';
@@ -51,7 +47,7 @@ import TemplatesV2 from './v2Containers/TemplatesV2/index';
51
47
 
52
48
  import CreativesContainer from './v2Containers/CreativesContainer';
53
49
  import CreativesContainerReducer from './v2Containers/CreativesContainer/reducer';
54
- import { updateCharCount } from './utils/smsCharCountV2';
50
+
55
51
 
56
52
  export {default as Ebill} from './v2Containers/Ebill';
57
53
  export {default as EbillReducer} from './v2Containers/Ebill/reducer';
@@ -59,7 +55,6 @@ export {default as EbillSaga} from './v2Containers/Ebill/sagas';
59
55
 
60
56
 
61
57
  const CapContainer = {Cap, capReducer, capSaga};
62
- const LanguageProviderContainer = {LanguageProvider, LanguageProviderReducer, LanguageProviderSaga};
63
58
  const TemplatesContainer = {Templates, templateReducer, templateSaga};
64
59
  const SmsCreateContainer = {SmsCreate, smsCreateReducer, smsCreateSaga};
65
60
  const SmsEditContainer = {SmsEdit, smsEditReducer, smsEditSaga};
@@ -84,7 +79,6 @@ export {default as MobilePushPreview} from './v2Components/MobilePushPreviewV2';
84
79
  CreativesContainer.CreativesContainerReducer = CreativesContainerReducer;
85
80
 
86
81
  export { CapContainer,
87
- LanguageProviderContainer,
88
82
  TemplatesContainer,
89
83
  SmsCreateContainer,
90
84
  SmsEditContainer,
@@ -103,5 +97,4 @@ export { CapContainer,
103
97
  TemplatesV2Container,
104
98
  CreativesContainer,
105
99
  WeChat,
106
- updateCharCount,
107
100
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "3.0.30",
4
+ "version": "3.0.31",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -16,7 +16,9 @@
16
16
  "jquery": "^3.3.1",
17
17
  "load-script": "^1.0.0",
18
18
  "normalizr": "^3.2.3",
19
+ "perfect-scrollbar": "^0.7.0",
19
20
  "react-datepicker": "^0.46.0",
21
+ "react-grid-layout": "^0.14.6",
20
22
  "react-router": "^3.2.0",
21
23
  "react-router-dom": "^4.2.2",
22
24
  "redux": "3.6.0",
@@ -25,6 +27,7 @@
25
27
  "redux-immutable": "3.0.8",
26
28
  "reselect": "2.5.4",
27
29
  "styled-components": "^3.2.1",
30
+ "warning": "3.0.0",
28
31
  "whatwg-fetch": "2.0.1"
29
32
  }
30
33
  }
package/reducers.js CHANGED
@@ -7,7 +7,7 @@ import { combineReducers } from 'redux-immutable';
7
7
  import { fromJS } from 'immutable';
8
8
  import { LOCATION_CHANGE } from 'react-router-redux';
9
9
 
10
- import languageProviderReducer from 'v2Containers/LanguageProvider/reducer';
10
+ import languageProviderReducer from 'containers/LanguageProvider/reducer';
11
11
  import capReducer from 'containers/Cap/reducer';
12
12
  import appReducer from 'containers/App/reducer';
13
13
  import createSmsReducer from 'containers/Sms/Create/reducer';
package/routes.js CHANGED
@@ -11,8 +11,7 @@ import * as ebillSagas from 'containers/Ebill/sagas';
11
11
  import * as emailSagas from 'containers/Email/sagas';
12
12
  import * as templateSagas from 'containers/Templates/sagas';
13
13
  import * as lineSagas from 'containers/Line/Create/sagas';
14
- import * as languageSaga from './v2Containers/LanguageProvider/sagas';
15
- import {updateCharCount} from './utils/smsCharCountV2';
14
+
16
15
  const errorLoading = (err) => {
17
16
  console.error('Dynamic page loading failed', err); // eslint-disable-line no-console
18
17
  };
@@ -23,10 +22,8 @@ const loadModule = (cb) => (componentModule) => {
23
22
 
24
23
  export default function createRoutes(store) {
25
24
  // Create reusable async injectors using getAsyncInjectors factory
26
- updateCharCount("", false); // calling here to get unsubscribeurl from api.
27
25
  const { injectReducer, injectSagas } = getAsyncInjectors(store); // eslint-disable-line no-unused-vars
28
26
  injectSagas(rootSaga.default);
29
- injectSagas(languageSaga.default);
30
27
  return [
31
28
  {
32
29
  path: '/',
package/services/api.js CHANGED
@@ -9,13 +9,9 @@ import getSchema from './getSchema';
9
9
  import * as API from '../utils/ApiCaller';
10
10
  let API_ENDPOINT = config.development.api_endpoint;
11
11
  let API_AUTH_ENDPOINT = config.development.auth_endpoint;
12
- let ARYA_ENDPOINT = config.development.arya_endpoint;
13
- let SUBSCRIPTION_API_ENDPOINT = config.development.subscription_api_endpoint;
14
12
  if (process.env.NODE_ENV === 'production') {
15
13
  API_ENDPOINT = config.production.api_endpoint;
16
14
  API_AUTH_ENDPOINT = config.production.auth_endpoint;
17
- ARYA_ENDPOINT = config.production.arya_endpoint;
18
- SUBSCRIPTION_API_ENDPOINT = config.production.subscription_api_endpoint;
19
15
  }
20
16
 
21
17
  const isProd = process.env.NODE_ENV === 'production';
@@ -60,8 +56,8 @@ function checkStatus(response) {
60
56
  if ((response.status >= 200 && response.status < 300) || response.status === 500) {
61
57
  return response;
62
58
  }
63
- const isLoginPage = window.location.pathname.indexOf('/login') !== -1;
64
- if (!isLoginPage) redirectIfUnauthenticated(response);
59
+
60
+ redirectIfUnauthenticated(response);
65
61
 
66
62
  const error = new Error(response.statusText);
67
63
  error.response = response;
@@ -320,21 +316,3 @@ export const createLineTemplate = ({template}) => {
320
316
  const url = `${API_ENDPOINT}/templates/LINE`;
321
317
  return request(url, getAPICallObject('POST', template));
322
318
  };
323
-
324
- export const getLocizMessage = (locale) => {
325
- const appName = 'creatives_v2';
326
- const url = `${ARYA_ENDPOINT}/translations/${appName}/${locale}`;
327
- return request(url, getAPICallObject('GET'));
328
- };
329
-
330
- export const getUnsubscribeUrl = () => {
331
- const body = {
332
- orgUnitId: -1,
333
- source: 'INSTORE',
334
- accountId: '',
335
- priority: 'BULK',
336
- channel: 'mobile',
337
- };
338
- const url = `${SUBSCRIPTION_API_ENDPOINT}/unsubscribeUrl`;
339
- return request(url, getAPICallObject('POST', body));
340
- };
@@ -1,9 +1,4 @@
1
1
  import React from 'react';
2
- import * as Api from './../services/api';
3
- let optoutUrl;
4
- let showOptoutCount = true;
5
- let responseState = "REQUEST";
6
-
7
2
  function getURLParameter(name) {
8
3
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null
9
4
  }
@@ -54,27 +49,13 @@ export function checkUnicode(content) {
54
49
  return false;
55
50
  }
56
51
  export function updateCharCount(content, isUnicodeEnabled) {
57
- if (showOptoutCount && optoutUrl === undefined && responseState === 'REQUEST') {
58
- Api.getUnsubscribeUrl().then((res) => {
59
- optoutUrl = res.response.response;
60
- responseState = "SUCCESS";
61
- }).catch((err) => {
62
- showOptoutCount = false;
63
- responseState = "FAIL";
64
- optoutUrl = undefined;
65
- console.log('get optouturl error: ', err);
66
- });
67
- }
68
- const optoutTag = /{{optout}}/g;
69
- const optoutTagLength = 14;
70
- const contentOriginal = content;
71
- const noOfOptout = (content.match(optoutTag) || []).length;
72
- content = showOptoutCount ? content.replace(optoutTag, "") : content;
73
- var chars_arr = contentOriginal.split("");
52
+ console.log(content);
53
+ var chars_arr = content.split("");
54
+ console.log(chars_arr);
74
55
  var coding = '7bit';
75
56
  var parts = 1;
76
57
  var part = 1;
77
- var chars_used = showOptoutCount ? ((optoutUrl && optoutUrl.length || 0) * noOfOptout) : 0;
58
+ var chars_used = 0;
78
59
  var chars_sms = 160;
79
60
  var sms_parts_container = [];
80
61
  var partc = [];
@@ -146,20 +127,17 @@ export function updateCharCount(content, isUnicodeEnabled) {
146
127
  }
147
128
  }
148
129
 
149
- chars_used = showOptoutCount ? (chars_used - (optoutTagLength * noOfOptout)) : chars_used;
150
130
  console.log('Type:', (coding == '7bit' ? '7bit' : 'Unicode'));
151
131
  console.log('Parts:', parts);
152
132
  console.log('SMS Chars:', chars_sms);
153
133
  console.log('SMS Char total:', chars_used);
154
- console.log('SMS optouturl: ', optoutUrl);
134
+
155
135
  return {
156
136
  unicode: (coding === '7bit' ? false : true),
157
137
  parts,
158
138
  chars_sms,
159
139
  chars_used,
160
140
  char_list: partc,
161
- optouturlLength: (optoutUrl && optoutUrl.length) || 0,
162
- optoutUrlPresent: noOfOptout > 0,
163
- responseState,
164
141
  };
165
142
  }
143
+
@@ -350,11 +350,3 @@
350
350
  background-color: #333333;
351
351
  margin-right: 4px;
352
352
  }
353
-
354
- .character-count-col{
355
- margin-top: 8px;
356
- margin-left: 40px;
357
- .optout-tag-heading{
358
- font-size: 12px;
359
- }
360
- }
@@ -59,42 +59,24 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
59
59
  <FormattedMessage {...messages.smsFormatType}/>
60
60
  }
61
61
  </CapHeading>}
62
- {smsDetails.optoutUrlPresent && <CapHeading type="h6">
63
- <FormattedMessage {...messages.optoutCharactersTotal} values={{optoutUrlLength: smsDetails.optouturlLength}} />
64
- </CapHeading>}
65
62
  </CapColumn>}
66
63
  <CapColumn span={this.props.showCount ? 8 : 24}>
67
64
  <div className={`preview-container ${type === 'embedded' ? 'embedded-preview' : ''}`}>
68
65
  { channel && channel.toLowerCase() === 'sms' &&
69
- <div>
70
- <div className="shell align-center" id="sms-preview">
71
- <img className="preview-image sms" src={smsBody} alt="Preview is being generated"/>
72
- <div className="msgContainer sms">
73
- <img className="sms-icon" src={smsIcon} alt="Sms icon" />
74
- <div className={"message-pop sms"}>
75
- {content && content.length && content.map((msg, index) =>
76
- <CapColumn key={`"message-pop-content-${index}`} className="message-pop-item align-left" style={{ background: '#3F51B5', color: '#ffffff'}}>
77
- {msg}
78
- </CapColumn>)
79
- }
80
- </div>
66
+ <div className="shell align-center" id="sms-preview">
67
+ <img className="preview-image sms" src={smsBody} alt="Preview is being generated"/>
68
+ <div className="msgContainer sms">
69
+ <img className="sms-icon" src={smsIcon} alt="Sms icon" />
70
+ <div className={"message-pop sms"}>
71
+ {content && content.length && content.map((msg, index) =>
72
+ <CapColumn key={`"message-pop-content-${index}`} className="message-pop-item align-left" style={{ background: '#3F51B5', color: '#ffffff'}}>
73
+ {msg}
74
+ </CapColumn>)
75
+ }
81
76
  </div>
82
77
  </div>
83
- {!this.props.showCount && <div>
84
- <CapColumn className="character-count-col" span={20}>
85
- {channel && channel.toLowerCase() === 'sms' && <CapHeading type="h3">
86
- <FormattedMessage {...messages.charactersTotal} values={{smsCount: smsDetails.parts, charCount: smsDetails.chars_used}}/>
87
- {smsDetails.unicode &&
88
- <FormattedMessage {...messages.smsFormatType}/>
89
- }
90
- </CapHeading>}
91
- {smsDetails.optoutUrlPresent && <CapHeading type="h6" className="optout-tag-heading">
92
- <FormattedMessage {...messages.optoutCharactersTotal} values={{optoutUrlLength: smsDetails.optouturlLength}} />
93
- </CapHeading>}
94
- </CapColumn>
95
- </div>}
96
78
  </div>
97
- }
79
+ }
98
80
  {channel && channel.toLowerCase() === 'wechat' ?
99
81
  ( <div className="shell align-center" id="sms-preview">
100
82
  <img className="preview-image" src={channel.toLowerCase() === 'wechat' ? wechatBody : smsBody} alt="Preview is being generated"/>
@@ -22,10 +22,6 @@ export default defineMessages({
22
22
  id: 'app.components.TemplatePreview.charactersTotal',
23
23
  defaultMessage: "{smsCount} SMS ({charCount} characters)",
24
24
  },
25
- optoutCharactersTotal: {
26
- id: 'app.components.TemplatePreview.optoutCharactersTotal',
27
- defaultMessage: "Includes Optout tag ({optoutUrlLength} characters)",
28
- },
29
25
  smsFormatType: {
30
26
  id: 'app.components.TemplatePreview.smsFormatType',
31
27
  defaultMessage: 'Message has unicode characters',
@@ -4,19 +4,14 @@
4
4
  *
5
5
  */
6
6
 
7
- import * as types from './constants';
7
+ import {
8
+ CHANGE_LOCALE,
9
+ } from './constants';
8
10
 
9
11
  export function changeLocale(languageLocale) {
10
12
  console.log('trying to change locale', languageLocale);
11
13
  return {
12
- type: types.CHANGE_LOCALE,
14
+ type: CHANGE_LOCALE,
13
15
  locale: languageLocale,
14
16
  };
15
17
  }
16
-
17
- export function getLocizMessage(locale) {
18
- return {
19
- type: types.GET_LOCIZ_MESSAGE_REQUEST,
20
- locale,
21
- };
22
- }
@@ -6,10 +6,3 @@
6
6
 
7
7
  export const CHANGE_LOCALE = 'app/LanguageToggle/CHANGE_LOCALE';
8
8
  export const DEFAULT_LOCALE = 'en';
9
-
10
- export const GET_LOCIZ_MESSAGE_REQUEST =
11
- 'app/LanguageProvider/GET_LOCIZ_MESSAGE_REQUEST';
12
- export const GET_LOCIZ_MESSAGE_SUCCESS =
13
- 'app/LanguageProvider/GET_LOCIZ_MESSAGE_SUCCESS';
14
- export const GET_LOCIZ_MESSAGE_FAILURE =
15
- 'app/LanguageProvider/GET_LOCIZ_MESSAGE_FAILURE';
@@ -10,38 +10,15 @@ import PropTypes from 'prop-types';
10
10
 
11
11
  import React from 'react';
12
12
  import { connect } from 'react-redux';
13
- import { createStructuredSelector } from 'reselect';
13
+ import { createSelector } from 'reselect';
14
14
  import { IntlProvider } from 'react-intl';
15
- import { bindActionCreators } from 'redux';
16
- import * as actions from './actions';
17
- import { makeSelectLocale } from './selectors';
18
15
 
16
+ import { makeSelectLocale } from './selectors';
19
17
 
20
18
  export class LanguageProvider extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
21
- componentDidMount() {
22
- const user = localStorage.getItem('user');
23
- let locale = localStorage.getItem('jlocale') || 'en';
24
- if (user) {
25
- locale = JSON.parse(user).lang;
26
- }
27
- locale = this.getMappedLocale(locale);
28
- this.props.actions.getLocizMessage(locale);
29
- }
30
-
31
- getMappedLocale = (locale) => {
32
- const map = {
33
- 'en': 'en-US',
34
- 'zh-cn': 'zh',
35
- 'zh': 'zh',
36
- 'en-US': 'en-US',
37
- };
38
- return map[locale];
39
- };
40
-
41
19
  render() {
42
- const { locale, messages} = this.props.language;
43
20
  return (
44
- <IntlProvider locale={locale} key={locale} messages={messages}>
21
+ <IntlProvider locale={this.props.locale} key={this.props.locale} messages={this.props.messages[this.props.locale]}>
45
22
  {React.Children.only(this.props.children)}
46
23
  </IntlProvider>
47
24
  );
@@ -49,19 +26,20 @@ export class LanguageProvider extends React.PureComponent { // eslint-disable-li
49
26
  }
50
27
 
51
28
  LanguageProvider.propTypes = {
52
- language: PropTypes.object,
53
- actions: PropTypes.object,
29
+ locale: PropTypes.string,
30
+ messages: PropTypes.object,
54
31
  children: PropTypes.element.isRequired,
55
32
  };
56
33
 
57
34
 
58
- const mapStateToProps = createStructuredSelector({
59
- language: makeSelectLocale(),
60
- });
35
+ const mapStateToProps = createSelector(
36
+ makeSelectLocale(),
37
+ (locale) => ({ locale })
38
+ );
61
39
 
62
40
  function mapDispatchToProps(dispatch) {
63
41
  return {
64
- actions: bindActionCreators(actions, dispatch),
42
+ dispatch,
65
43
  };
66
44
  }
67
45
 
@@ -6,30 +6,22 @@
6
6
 
7
7
  import { fromJS } from 'immutable';
8
8
 
9
- import * as types from './constants';
9
+ import {
10
+ CHANGE_LOCALE,
11
+ } from './constants';
10
12
  import {
11
13
  DEFAULT_LOCALE,
12
14
  } from '../Cap/constants'; // eslint-disable-line
13
15
 
14
16
  const initialState = fromJS({
15
17
  locale: DEFAULT_LOCALE,
16
- messages: {},
17
- localeLoading: false,
18
18
  });
19
19
 
20
20
  function languageProviderReducer(state = initialState, action) {
21
21
  switch (action.type) {
22
- case types.CHANGE_LOCALE:
22
+ case CHANGE_LOCALE:
23
23
  return state
24
24
  .set('locale', action.locale);
25
- case types.GET_LOCIZ_MESSAGE_REQUEST:
26
- return state.set('localeLoading', true);
27
- case types.GET_LOCIZ_MESSAGE_SUCCESS:
28
- return state
29
- .set('localeLoading', false)
30
- .set('messages', fromJS(action.data));
31
- case types.GET_LOCIZ_MESSAGE_FAILURE:
32
- return state.set('localeLoading', false);
33
25
  default:
34
26
  return state;
35
27
  }
@@ -11,7 +11,7 @@ const selectLanguage = (state) => state.get('language');
11
11
 
12
12
  const makeSelectLocale = () => createSelector(
13
13
  selectLanguage,
14
- (languageState) => languageState.toJS()
14
+ (languageState) => languageState.get('locale')
15
15
  );
16
16
 
17
17
  export {
@@ -742,7 +742,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
742
742
  }
743
743
  const formData = _.cloneDeep(this.state.formData);
744
744
  formData[currentTab - 1][field.id] = myField.value;
745
- this.setState({formData}, () => this.onTemplateContentChange());
745
+ this.setState({formData});
746
746
  }
747
747
 
748
748
  startTemplateCreation(data) {
@@ -789,7 +789,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
789
789
  const formData = _.cloneDeep(this.state.formData);
790
790
  formData[currentTab - 1][field.id] = myField.value;
791
791
  formData.base[field.id] = myField.value;
792
- this.setState({formData}, () => this.onTemplateContentChange());
792
+ this.setState({formData});
793
793
  }
794
794
 
795
795
  handleFrameTasks = (e) => {
@@ -0,0 +1,5 @@
1
+ .cap-tab-v2-wrapper{
2
+ .ant-tabs-tabpane {
3
+ border: none;
4
+ }
5
+ }
@@ -5,15 +5,18 @@
5
5
  */
6
6
 
7
7
  import PropTypes from 'prop-types';
8
+
8
9
  import React from 'react';
9
10
  import { connect } from 'react-redux';
10
11
  import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
11
12
  import { createStructuredSelector } from 'reselect';
12
13
  import { bindActionCreators } from 'redux';
14
+ import styled from 'styled-components';
13
15
  import { CapTab, CapCustomCard, CapButton, CapHeader, CapSpin, CapIcon } from '@capillarytech/cap-ui-library';
14
16
  import { find, get } from 'lodash';
15
17
  import Helmet from 'react-helmet';
16
18
 
19
+ import {CAP_SPACE_24, CAP_SPACE_16} from '@capillarytech/cap-ui-library/styled/variables';
17
20
  import { UserIsAuthenticated } from '../../utils/authWrapper';
18
21
  import { makeSelectTemplates, makeSelectTemplatesResponse } from '../Templates/selectors';
19
22
  import messages from './messages';
@@ -21,13 +24,29 @@ import * as actions from './actions';
21
24
  import Templates from '../Templates';
22
25
  import CallTask from '../CallTask';
23
26
  import Gallery from '../Assets/Gallery';
24
- import withStyles from '../../hoc/withStyles';
25
- import styles, { CapTabStyle } from './TemplatesV2.style';
27
+ import './_templatesV2.scss';
26
28
 
27
29
  const {CapCustomCardList} = CapCustomCard;
28
30
 
29
- const StyledCapTab = withStyles(CapTab, CapTabStyle);
30
-
31
+ const ComponentWrapper = styled.div`
32
+ ${(props) => props.isFullMode ? `
33
+ max-width: 1140px;
34
+ margin: 0 auto;
35
+ width: 100%;
36
+ padding: ${CAP_SPACE_24} 0;
37
+ .ant-tabs-content{
38
+ margin-top: ${CAP_SPACE_16}
39
+ }
40
+ ` : `.cap-tab-v2 {
41
+ height: calc(100vh - 118px);
42
+ } `}
43
+
44
+
45
+ `;
46
+ const MarginTop = styled.div`
47
+ ${(props) => props.isFullMode ? `margin-top: ${CAP_SPACE_24}` : ``
48
+ }
49
+ `;
31
50
  export class TemplatesV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
32
51
  constructor(props) {
33
52
  super(props);
@@ -127,20 +146,21 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
127
146
  }
128
147
  }
129
148
 
130
- setChannelContent = (selectedChannel, argsPanes) => (
131
- argsPanes.map((pane) => {
132
- let content = null;
149
+ setChannelContent = (selectedChannel, argsPanes) => {
150
+ const panes = argsPanes.map((p) => {
151
+ const pane = p;
133
152
  if (pane.key === selectedChannel) {
134
- const channel = selectedChannel === "mpush" ? "mobilepush" : selectedChannel;
135
- content = this.getTemplatesComponent(channel);
153
+ let channel = selectedChannel;
154
+ if (channel === "mpush") {
155
+ channel = "mobilepush";
156
+ }
157
+ pane.content = this.getTemplatesComponent(channel);
158
+ return pane;
136
159
  }
137
- return {
138
- ...pane,
139
- content,
140
- };
141
- })
142
- );
143
-
160
+ return {...pane, content: <div></div>};
161
+ });
162
+ return panes;
163
+ }
144
164
  channelChange = (selectedChannel) => {
145
165
  const panes = this.setChannelContent(selectedChannel, this.state.panes);
146
166
  this.setState({panes, selectedChannel}, () => { if (!this.props.isFullMode) this.props.onChannelChange(selectedChannel); });
@@ -151,25 +171,28 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
151
171
  return this.props.Templates.loadingTemplates;
152
172
  }
153
173
  render() {
154
- const { isFullMode, className } = this.props;
174
+ const {isFullMode} = this.props;
155
175
  return (
156
- <div className={`${className} creatives-templates-container ${isFullMode ? 'fullmode' : 'library-mode'}`}>
176
+ <div className={`creatives-templates-container ${isFullMode ? 'fullmode' : 'library-mode'}`}>
157
177
  {isFullMode && <Helmet
158
178
  title={this.props.intl.formatMessage(messages.creatives)}
159
179
  meta={[
160
180
  { name: 'description', content: this.props.intl.formatMessage(messages.creativesDesc) },
161
181
  ]}
162
182
  />}
163
- <div className="component-wrapper">
183
+ <ComponentWrapper isFullMode={isFullMode}>
184
+
164
185
  {isFullMode && <CapHeader title={<FormattedMessage {...messages.creatives}/>} description={<FormattedMessage {...messages.creativesDesc}/>}/>}
165
- <StyledCapTab
166
- panes={this.state.panes}
167
- onChange={this.channelChange}
168
- activeKey={this.state.selectedChannel}
169
- defaultActiveKey={this.state.selectedChannel}
170
- isFullMode={isFullMode}
171
- />
172
- </div>
186
+ <MarginTop isFullMode={isFullMode}>
187
+ <CapTab
188
+ panes={this.state.panes}
189
+ onChange={this.channelChange}
190
+ activeKey={this.state.selectedChannel}
191
+ defaultActiveKey={this.state.selectedChannel}/>
192
+ </MarginTop>
193
+
194
+
195
+ </ComponentWrapper>
173
196
  </div>
174
197
 
175
198
  );
@@ -189,7 +212,6 @@ TemplatesV2.propTypes = {
189
212
  intl: intlShape,
190
213
  onChannelChange: PropTypes.func,
191
214
  channelsToHide: PropTypes.array,
192
- className: PropTypes.string.isRequired,
193
215
  };
194
216
 
195
217
  TemplatesV2.defaultProps = {
@@ -207,4 +229,4 @@ function mapDispatchToProps(dispatch) {
207
229
  };
208
230
  }
209
231
 
210
- export default UserIsAuthenticated(connect(mapStateToProps, mapDispatchToProps)(injectIntl(withStyles(TemplatesV2, styles))));
232
+ export default UserIsAuthenticated(connect(mapStateToProps, mapDispatchToProps)(injectIntl(TemplatesV2)));
package/hoc/withStyles.js DELETED
@@ -1,12 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- /**
4
- * Higher Order Component to have consistent logic of styling components
5
- * @param {*} WrappedComponent
6
- * @returns {*} styled wrapped component
7
- */
8
- export default (WrappedComponent, styles) => {
9
- const StyledComponent = styled(WrappedComponent)`${styles};`;
10
- StyledComponent.defaultProps = WrappedComponent.defaultProps;
11
- return StyledComponent;
12
- };
@@ -1,39 +0,0 @@
1
- import { takeLatest, take, all, cancel, call, put } from 'redux-saga/effects';
2
- import { LOCATION_CHANGE } from 'react-router-redux';
3
- import * as Api from '../../services/api';
4
- import * as types from './constants';
5
-
6
- function* getLocizMessage(action) {
7
- try {
8
- const result = yield call(Api.getLocizMessage, action.locale);
9
- yield [
10
- put({
11
- type: types.GET_LOCIZ_MESSAGE_SUCCESS,
12
- data: result,
13
- }),
14
- ];
15
- } catch (error) {
16
- yield [
17
- put({
18
- type: types.GET_LOCIZ_MESSAGE_FAILURE,
19
- data: error,
20
- }),
21
- ];
22
- }
23
- }
24
- export function* watchGetLocizMessage() {
25
- const watcher = yield takeLatest(
26
- types.GET_LOCIZ_MESSAGE_REQUEST,
27
- getLocizMessage,
28
- );
29
- yield take(LOCATION_CHANGE);
30
- yield cancel(watcher);
31
- }
32
-
33
- export default [watchGetLocizMessage];
34
-
35
- export function* LanguageProviderRootSaga() {
36
- yield all([
37
- watchGetLocizMessage(),
38
- ]);
39
- }
@@ -1,29 +0,0 @@
1
- import { css } from 'styled-components';
2
- import {CAP_SPACE_24, CAP_SPACE_16} from '@capillarytech/cap-ui-library/styled/variables';
3
-
4
- export default css`
5
- .cap-tab-v2-wrapper{
6
- .ant-tabs-tabpane {
7
- border: none;
8
- }
9
- }
10
-
11
- .component-wrapper {
12
- ${(props) => props.isFullMode ? `
13
- max-width: 1140px;
14
- margin: 0 auto;
15
- width: 100%;
16
- padding: ${CAP_SPACE_24} 0;
17
- .ant-tabs-content{
18
- margin-top: ${CAP_SPACE_16}
19
- }
20
- ` : `.cap-tab-v2 {
21
- height: calc(100vh - 118px);
22
- } `}
23
- }
24
- `;
25
-
26
- export const CapTabStyle = css`
27
- ${(props) => props.isFullMode ? `margin-top: ${CAP_SPACE_24}` : ``
28
- }
29
- `;