@capillarytech/creatives-library 3.1.49 → 3.2.1

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 (70) hide show
  1. package/app.js +1 -1
  2. package/components/FormBuilder/index.js +1 -1
  3. package/components/Header/index.js +3 -4
  4. package/components/Header/messages.js +0 -4
  5. package/config/app.js +2 -4
  6. package/containers/Assets/Gallery/index.js +1 -1
  7. package/containers/Cap/index.js +5 -4
  8. package/containers/Email/index.js +2 -2
  9. package/containers/Email/messages.js +0 -8
  10. package/containers/LanguageProvider/index.js +4 -28
  11. package/containers/Templates/index.js +2 -2
  12. package/containers/Templates/messages.js +4 -24
  13. package/containers/WeChat/MapTemplates/messages.js +0 -4
  14. package/containers/WeChat/RichmediaTemplates/Create/messages.js +0 -24
  15. package/i18n.js +9 -16
  16. package/index.js +0 -6
  17. package/package.json +4 -1
  18. package/reducers.js +1 -1
  19. package/routes.js +1 -2
  20. package/services/api.js +2 -11
  21. package/translations/en.json +56 -119
  22. package/translations/zh.json +53 -116
  23. package/utils/smsCharCountV2.js +1 -1
  24. package/v2Components/CapTagList/index.js +2 -2
  25. package/v2Components/FormBuilder/index.js +4 -7
  26. package/v2Components/NavigationBar/index.js +17 -11
  27. package/v2Components/NavigationBar/messages.js +0 -28
  28. package/v2Components/NewCallTask/index.js +1 -3
  29. package/v2Components/TopBar/index.js +0 -3
  30. package/v2Components/TopBar/messages.js +0 -8
  31. package/v2Containers/Assets/Gallery/index.js +6 -12
  32. package/v2Containers/Assets/Gallery/messages.js +0 -4
  33. package/v2Containers/CallTask/index.js +1 -3
  34. package/v2Containers/Cap/index.js +2 -3
  35. package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -14
  36. package/v2Containers/CreativesContainer/index.js +1 -6
  37. package/v2Containers/Email/index.js +7 -10
  38. package/v2Containers/Email/messages.js +0 -16
  39. package/v2Containers/EmailWrapper/index.js +9 -12
  40. package/v2Containers/LanguageProvider/actions.js +4 -9
  41. package/v2Containers/LanguageProvider/constants.js +1 -7
  42. package/v2Containers/LanguageProvider/index.js +12 -49
  43. package/v2Containers/LanguageProvider/reducer.js +9 -11
  44. package/v2Containers/LanguageProvider/selectors.js +1 -1
  45. package/v2Containers/MobilePush/Create/index.js +1 -2
  46. package/v2Containers/MobilePush/Create/messages.js +0 -4
  47. package/v2Containers/MobilePush/Edit/index.js +1 -2
  48. package/v2Containers/MobilePush/Edit/messages.js +0 -4
  49. package/v2Containers/Sms/Create/index.js +1 -3
  50. package/v2Containers/Sms/Create/messages.js +0 -16
  51. package/v2Containers/Sms/Edit/index.js +1 -3
  52. package/v2Containers/Sms/Edit/messages.js +0 -16
  53. package/v2Containers/TagList/index.js +0 -43
  54. package/v2Containers/Templates/_templates.scss +1 -9
  55. package/v2Containers/Templates/index.js +53 -66
  56. package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
  57. package/v2Containers/TemplatesV2/index.js +54 -54
  58. package/v2Containers/WeChat/MapTemplates/index.js +2 -1
  59. package/v2Containers/WeChat/MapTemplates/messages.js +5 -9
  60. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +0 -10
  61. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +0 -9
  62. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +0 -3
  63. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +4 -146
  64. package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +57 -86
  65. package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +1 -24
  66. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +0 -45
  67. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +0 -4
  68. package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +1 -8
  69. package/v2Containers/WeChat/Wrapper/_wrapper.scss +1 -9
  70. package/v2Containers/WeChat/Wrapper/messages.js +5 -5
@@ -120,18 +120,15 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
120
120
  getAllAssets = ({params, getNextPage, resetPage}, isReRender = false) => {
121
121
  let queryParams = params;
122
122
  let page = this.state.page;
123
- let shouldFetchGalleryAssets = false;
124
123
  if (!this.props.Gallery.fetchingAllAssets && ((resetPage || (page === 1 && this.state.totalCount === 0) || page <= (this.state.totalCount / this.state.perPageLimit)) || isReRender )) {
125
124
  if (getNextPage) {
126
125
  page += 1;
127
- shouldFetchGalleryAssets = true;
128
126
  }
129
127
 
130
128
  let totalCount = this.state.totalCount;
131
129
  if (resetPage) {
132
130
  page = 1;
133
131
  totalCount = 0;
134
- shouldFetchGalleryAssets = true;
135
132
  }
136
133
  if ((!params || _.isEmpty(params))) {
137
134
  queryParams = {
@@ -140,15 +137,12 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
140
137
  }
141
138
  if (this.state.searchText !== "") {
142
139
  queryParams = {...queryParams, name: this.state.searchText};
143
- shouldFetchGalleryAssets = true;
144
- }
145
- if (!this.props.Gallery.fetchingAllAssets && (_.isEmpty(this.props.Gallery.assetList) || shouldFetchGalleryAssets)) {
146
- this.setState({page, totalCount}, () => {
147
- queryParams.page = page;
148
- queryParams.perPage = this.state.perPageLimit;
149
- this.props.actions.getAllAssets('image', queryParams);
150
- });
151
140
  }
141
+ this.setState({page, totalCount}, () => {
142
+ queryParams.page = page;
143
+ queryParams.perPage = this.state.perPageLimit;
144
+ this.props.actions.getAllAssets('image', queryParams);
145
+ });
152
146
  }
153
147
  };
154
148
  handleGallery = (e) => {
@@ -437,7 +431,7 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
437
431
  </div>
438
432
  ) : <input style={{ display: 'none'}} id="fileName" type="file" onChange={(e) => this.uploadImages(e, {files: e.target.files})} accept="image/*" multiple/>;
439
433
  const isLoading = this.props.Gallery.assetUploading || this.props.Gallery.fetchingAllAssets;
440
- const loadingTip = <FormattedMessage {...messages.loadingGallery} />;
434
+ const loadingTip = "Loading gallery... ";
441
435
 
442
436
  return (
443
437
  <div>
@@ -102,8 +102,4 @@ export default defineMessages({
102
102
  id: `creatives.containersV2.Assets.Gallery.noTemplatesFound`,
103
103
  defaultMessage: 'No templates found',
104
104
  },
105
- loadingGallery: {
106
- id: `creatives.containersV2.Assets.Gallery.loadingGallery`,
107
- defaultMessage: 'Loading gallery...',
108
- },
109
105
  });
@@ -70,7 +70,7 @@ export class CallTask extends React.Component { // eslint-disable-line react/pre
70
70
  };
71
71
  }
72
72
  render() {
73
- const { intl, onCallTaskSubmit, templateData, loadingMetaEntities, metaEntities, selectedOfferDetails } = this.props;
73
+ const { intl, onCallTaskSubmit, templateData, loadingMetaEntities, metaEntities } = this.props;
74
74
  const { formatMessage } = intl;
75
75
  const { mode } = this.state;
76
76
  return (
@@ -82,7 +82,6 @@ export class CallTask extends React.Component { // eslint-disable-line react/pre
82
82
  mode={mode}
83
83
  templateData={templateData}
84
84
  onCallTaskSubmit={onCallTaskSubmit}
85
- selectedOfferDetails={selectedOfferDetails}
86
85
  />
87
86
  :
88
87
  <div>
@@ -133,7 +132,6 @@ CallTask.propTypes = {
133
132
  showContentInSlidebox: PropTypes.bool,
134
133
  onCreateNew: PropTypes.func,
135
134
  isFullMode: PropTypes.bool,
136
- selectedOfferDetails: PropTypes.array,
137
135
  };
138
136
 
139
137
 
@@ -74,6 +74,7 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
74
74
  //locale = 'zh';
75
75
  console.log('Setting final locale as', locale);
76
76
  moment.locale(locale);
77
+ this.props.locationActions.changeLocale(locale);
77
78
  }
78
79
 
79
80
  componentWillReceiveProps(nextProps) {
@@ -131,10 +132,8 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
131
132
 
132
133
  getMappedLocale(locale) {
133
134
  const map = {
134
- 'en': 'en-US',
135
+ 'en': 'en',
135
136
  'zh-cn': 'zh',
136
- 'en-US': 'en-US',
137
- 'zh': 'zh',
138
137
  };
139
138
  return map[locale];
140
139
  }
@@ -60,8 +60,6 @@ function SlideBoxContent(props) {
60
60
  onValidationFail,
61
61
  channelsToHide,
62
62
  forwardedTags,
63
- selectedOfferDetails,
64
- channelsToDisable,
65
63
  weChatTemplateType,
66
64
  onWechatTemplateChange,
67
65
  selectedWeChatAccount,
@@ -115,7 +113,6 @@ function SlideBoxContent(props) {
115
113
  cap={cap}
116
114
  channelsToHide={channelsToHide}
117
115
  forwardedTags={forwardedTags}
118
- channelsToDisable={channelsToDisable}
119
116
  />
120
117
  )}
121
118
  {isPreview && (
@@ -177,7 +174,6 @@ function SlideBoxContent(props) {
177
174
  getDefaultTags={type}
178
175
  templateData={templateData}
179
176
  forwardedTags={forwardedTags}
180
- selectedOfferDetails={selectedOfferDetails}
181
177
  />
182
178
  )}
183
179
  {
@@ -187,7 +183,6 @@ function SlideBoxContent(props) {
187
183
  templateData={templateData}
188
184
  onCallTaskSubmit={onCallTaskSubmit}
189
185
  forwardedTags={forwardedTags}
190
- selectedOfferDetails={selectedOfferDetails}
191
186
  />
192
187
  }
193
188
  {
@@ -196,7 +191,6 @@ function SlideBoxContent(props) {
196
191
  mode={'create'}
197
192
  onCallTaskSubmit={onCallTaskSubmit}
198
193
  forwardedTags={forwardedTags}
199
- selectedOfferDetails={selectedOfferDetails}
200
194
  />
201
195
  }
202
196
  {isCreateSms && (
@@ -210,7 +204,6 @@ function SlideBoxContent(props) {
210
204
  getDefaultTags={type}
211
205
  isFullMode={isFullMode}
212
206
  forwardedTags={forwardedTags}
213
- selectedOfferDetails={selectedOfferDetails}
214
207
  />
215
208
  )}
216
209
  {isEmailCreate && (
@@ -232,7 +225,6 @@ function SlideBoxContent(props) {
232
225
  showTemplateName={showTemplateName}
233
226
  onValidationFail={onValidationFail}
234
227
  forwardedTags={forwardedTags}
235
- selectedOfferDetails={selectedOfferDetails}
236
228
  />
237
229
  )}
238
230
  {(isEditEmailWithId || isEmailEditWithContent) && (
@@ -255,7 +247,6 @@ function SlideBoxContent(props) {
255
247
  showTemplateName={showTemplateName}
256
248
  onValidationFail={onValidationFail}
257
249
  forwardedTags={forwardedTags}
258
- selectedOfferDetails={selectedOfferDetails}
259
250
  />
260
251
  )}
261
252
  {isEditMPush &&
@@ -275,7 +266,6 @@ function SlideBoxContent(props) {
275
266
  getDefaultTags={type}
276
267
  onValidationFail={onValidationFail}
277
268
  forwardedTags={forwardedTags}
278
- selectedOfferDetails={selectedOfferDetails}
279
269
  />
280
270
  }
281
271
  {isCreateMPush &&
@@ -299,8 +289,7 @@ function SlideBoxContent(props) {
299
289
  showTemplateName={showTemplateName}
300
290
  query={query}
301
291
  forwardedTags={forwardedTags}
302
- onValidationFail={onValidationFail}
303
- selectedOfferDetails={selectedOfferDetails}/>
292
+ onValidationFail={onValidationFail}/>
304
293
  }
305
294
  </CreativesWrapper>
306
295
  );
@@ -334,8 +323,6 @@ SlideBoxContent.propTypes = {
334
323
  onValidationFail: PropTypes.func,
335
324
  channelsToHide: PropTypes.array,
336
325
  forwardedTags: PropTypes.object,
337
- selectedOfferDetails: PropTypes.array,
338
- channelsToDisable: PropTypes.array,
339
326
  weChatTemplateType: PropTypes.string,
340
327
  onWechatTemplateChange: PropTypes.func,
341
328
  selectedWeChatAccount: PropTypes.object,
@@ -465,9 +465,8 @@ class Creatives extends React.Component {
465
465
  }
466
466
  render() {
467
467
  const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep, isLoadingContent, mobilePushCreateMode, isDiscardMessage, weChatTemplateType, weChatMaptemplateStep} = this.state;
468
- const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags, channelsToDisable, selectedOfferDetails} = this.props;
468
+ const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags} = this.props;
469
469
  const mapTemplateCreate = slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
470
- /* TODO: Instead of passing down same props separately to each component down, write common function to these props and pass it accordingly */
471
470
  return (
472
471
  <SlideBoxWrapper className={classnames(`${classPrefix} ${isFullMode ? 'creatives-full-mode' : 'creatives-library-mode'} ${mapTemplateCreate ? 'map-template-create' : ''}`)}>
473
472
  <CapSlideBox
@@ -523,8 +522,6 @@ class Creatives extends React.Component {
523
522
  onValidationFail={this.onValidationFail}
524
523
  channelsToHide={channelsToHide}
525
524
  forwardedTags={forwardedTags}
526
- selectedOfferDetails={selectedOfferDetails}
527
- channelsToDisable={channelsToDisable}
528
525
  weChatTemplateType={weChatTemplateType}
529
526
  onWechatTemplateChange={this.onWechatTemplateChange}
530
527
  weChatMaptemplateStep={weChatMaptemplateStep}
@@ -576,8 +573,6 @@ Creatives.propTypes = {
576
573
  EmailLayout: PropTypes.string,
577
574
  channelsToHide: PropTypes.array,
578
575
  forwardedTags: PropTypes.object,
579
- selectedOfferDetails: PropTypes.array,
580
- channelsToDisable: PropTypes.array,
581
576
  selectedWeChatAccount: PropTypes.object,
582
577
  };
583
578
  const mapStatesToProps = () => createStructuredSelector({
@@ -58,7 +58,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
58
58
  showImageSelectionBox: false,
59
59
  isDragDrop: false,
60
60
  showConfirmationModal: false,
61
- modalContent: {title: this.props.intl.formatMessage(messages.alert), body: this.props.intl.formatMessage(messages.deleteLanguageConfirmation), type: 'confirm', id: 'email-language-delete-modal'},
61
+ modalContent: {title: this.props.intl.formatMessage(messages.alertMessage), body: this.props.intl.formatMessage(messages.deleteLanguageConfirmation), type: 'confirm', id: 'email-language-delete-modal'},
62
62
  showModal: false,
63
63
  page: 1,
64
64
  perPageLimit: 25,
@@ -906,14 +906,14 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
906
906
  let modalContent = {};
907
907
  if (type === 'delete-version') {
908
908
  modalContent = {
909
- title: this.props.intl.formatMessage(messages.alert),
909
+ title: this.props.intl.formatMessage(messages.alertMessage),
910
910
  body: this.props.intl.formatMessage(messages.deleteVersionConfirmation),
911
911
  type: 'confirm',
912
912
  id: 'email-version-delete-modal',
913
913
  };
914
914
  } else if (type === 'delete-language') {
915
915
  modalContent = {
916
- title: this.props.intl.formatMessage(messages.alert),
916
+ title: this.props.intl.formatMessage(messages.alertMessage),
917
917
  body: this.props.intl.formatMessage(messages.deleteLanguageConfirmation),
918
918
  type: 'confirm',
919
919
  id: 'email-language-delete-modal',
@@ -1001,7 +1001,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1001
1001
  showImageSelectionBox: false,
1002
1002
  isDragDrop: false,
1003
1003
  showConfirmationModal: false,
1004
- modalContent: {title: this.props.intl.formatMessage(messages.alert), body: this.props.intl.formatMessage(messages.deleteLanguageConfirmation), type: 'confirm', id: 'email-language-delete-modal'},
1004
+ modalContent: {title: this.props.intl.formatMessage(messages.alertMessage), body: this.props.intl.formatMessage(messages.deleteLanguageConfirmation), type: 'confirm', id: 'email-language-delete-modal'},
1005
1005
  showModal: false,
1006
1006
  page: 1,
1007
1007
  perPageLimit: 25,
@@ -1823,7 +1823,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1823
1823
 
1824
1824
  moveToTemplates = () => {
1825
1825
  const modalContent = {
1826
- title: this.props.intl.formatMessage(messages.alert),
1826
+ title: this.props.intl.formatMessage(messages.alertMessage),
1827
1827
  body: this.props.intl.formatMessage(messages.goBackTemporaryChangesLost),
1828
1828
  type: 'confirm',
1829
1829
  id: 'template-back-confirm-modal',
@@ -2559,10 +2559,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2559
2559
  // const actionComponents = '';
2560
2560
  const schema = this.state.schema;
2561
2561
  const isLoading = this.isEmailLoading();
2562
- const previewHeader = (<h3>{this.props.intl.formatMessage(messages.h3emailPreview)}</h3>);
2563
- const imagePreviewHeader = (<h3>{this.props.intl.formatMessage(messages.h3imageSelection)}</h3>);
2562
+ const previewHeader = (<h3>Email Preview</h3>);
2563
+ const imagePreviewHeader = (<h3>Image Selection</h3>);
2564
2564
  const imagePreviewContent = this.getImagePreviewContent();
2565
- const { selectedOfferDetails } = this.props;
2566
2565
  if (!this.props.currentOrgDetails || !this.props.currentOrgDetails.basic_details) {
2567
2566
  return (<div>Loading...</div>);
2568
2567
  }
@@ -2618,7 +2617,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2618
2617
  getValidationData={this.saveValidationData}
2619
2618
  saveForm={this.state.saveForm}
2620
2619
  stopValidation={this.stopValidation}
2621
- selectedOfferDetails={selectedOfferDetails}
2622
2620
  /> : ''}
2623
2621
  </Col>
2624
2622
  </Row>
@@ -2671,7 +2669,6 @@ Email.propTypes = {
2671
2669
  defaultData: PropTypes.object,
2672
2670
  showTemplateName: PropTypes.func,
2673
2671
  onValidationFail: PropTypes.func,
2674
- selectedOfferDetails: PropTypes.array,
2675
2672
  };
2676
2673
 
2677
2674
  const mapStateToProps = (state, props) => createStructuredSelector({
@@ -278,20 +278,4 @@ export default defineMessages({
278
278
  id: 'creatives.containersV2.Email.alertMessage',
279
279
  defaultMessage: 'Alert',
280
280
  },
281
- "h3emailPreview": {
282
- id: 'creatives.containersV2.Email.h3emailPreview',
283
- defaultMessage: 'Email preview',
284
- },
285
- "h3imageSelection": {
286
- id: 'creatives.containersV2.Email.h3imageSelection',
287
- defaultMessage: 'Image selection',
288
- },
289
- "English": {
290
- id: 'creatives.containersV2.Email.english',
291
- defaultMessage: 'English',
292
- },
293
- "Add label": {
294
- id: 'creatives.containersV2.Email.addLabel',
295
- defaultMessage: 'Add label',
296
- },
297
281
  });
@@ -173,7 +173,6 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
173
173
  setIsLoadingContent,
174
174
  onValidationFail,
175
175
  forwardedTags,
176
- selectedOfferDetails,
177
176
  } = this.props;
178
177
  const {
179
178
  templateName,
@@ -204,15 +203,15 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
204
203
  </CardContainer>
205
204
  <div>
206
205
  {emailCreateMode === "upload" &&
207
- <div style={{ marginLeft: '8px' }}>
208
- <CapUploader onChange={this.useFileUpload} accept=".zip, .html, .htm" showUploadList={false}>
209
- <CapButton>{this.props.intl.formatMessage(messages.upload)}</CapButton>
210
- </CapUploader>
211
- {!_.isEmpty(EmailLayout) &&
212
- <div>{_.get(modeContent, "file.name")}</div>
213
- }
214
- </div>
215
- }
206
+ <div style={{ marginLeft: '8px'}}>
207
+ <CapUploader onChange={this.useFileUpload} accept=".zip, .html, .htm" showUploadList={false}>
208
+ <CapButton>{this.props.intl.formatMessage(messages.upload)}</CapButton>
209
+ </CapUploader>
210
+ {!_.isEmpty(EmailLayout) &&
211
+ <div>{_.get(modeContent, "file.name")}</div>
212
+ }
213
+ </div>
214
+ }
216
215
  </div>
217
216
  </div>
218
217
  :
@@ -233,7 +232,6 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
233
232
  showTemplateName={showTemplateName}
234
233
  onValidationFail={onValidationFail}
235
234
  forwardedTags={forwardedTags}
236
- selectedOfferDetails={selectedOfferDetails}
237
235
  />}
238
236
  {CmsTemplates && !isShowEmailCreate && <CmsTemplatesComponent cmsTemplates={CmsTemplates} handleEdmDefaultTemplateSelection={this.useEditor} />}
239
237
  </div>
@@ -265,7 +263,6 @@ EmailWrapper.propTypes = {
265
263
  showTemplateName: PropTypes.func,
266
264
  onValidationFail: PropTypes.func,
267
265
  forwardedTags: PropTypes.object,
268
- selectedOfferDetails: PropTypes.array,
269
266
  };
270
267
 
271
268
  const mapStateToProps = createStructuredSelector({
@@ -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
- }
@@ -4,11 +4,5 @@
4
4
  *
5
5
  */
6
6
 
7
+ export const CHANGE_LOCALE = 'app/LanguageToggle/CHANGE_LOCALE';
7
8
  export const DEFAULT_LOCALE = 'en';
8
-
9
- export const GET_LOCIZ_MESSAGE_REQUEST =
10
- 'app/LanguageProvider/GET_LOCIZ_MESSAGE_REQUEST';
11
- export const GET_LOCIZ_MESSAGE_SUCCESS =
12
- 'app/LanguageProvider/GET_LOCIZ_MESSAGE_SUCCESS';
13
- export const GET_LOCIZ_MESSAGE_FAILURE =
14
- 'app/LanguageProvider/GET_LOCIZ_MESSAGE_FAILURE';
@@ -9,74 +9,37 @@
9
9
  import PropTypes from 'prop-types';
10
10
 
11
11
  import React from 'react';
12
- import { ConfigProvider } from 'antd';
13
- import enUS from 'antd/es/locale-provider/en_US';
14
- import zhCN from 'antd/es/locale-provider/zh_CN';
15
12
  import { connect } from 'react-redux';
16
- import { createStructuredSelector } from 'reselect';
13
+ import { createSelector } from 'reselect';
17
14
  import { IntlProvider } from 'react-intl';
18
- import moment from 'moment';
19
- import { bindActionCreators } from 'redux';
20
- import * as actions from './actions';
21
- import { makeSelectLocale } from './selectors';
22
15
 
16
+ import { makeSelectLocale } from './selectors';
23
17
 
24
18
  export class LanguageProvider extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
25
- componentDidMount() {
26
- const user = localStorage.getItem('user');
27
- let locale = localStorage.getItem('jlocale') || 'en';
28
- moment.locale(locale);
29
- if (user) {
30
- locale = JSON.parse(user).lang;
31
- }
32
- locale = this.getMappedLocale(locale);
33
- this.props.actions.getLocizMessage(locale);
34
- }
35
- /*global getMappedLocale */
36
- getMappedLocale = (locale) => {
37
- const map = {
38
- 'en': 'en-US',
39
- 'zh-cn': 'zh',
40
- 'zh': 'zh',
41
- 'en-US': 'en-US',
42
- };
43
- return map[locale];
44
- };
45
-
46
19
  render() {
47
- const { locale, messages} = this.props.language;
48
- const mappedLocale = {
49
- 'en': enUS,
50
- 'zh-cn': zhCN,
51
- 'en-US': enUS,
52
- 'zh': zhCN,
53
- };
54
- const jLocale = localStorage.getItem('jlocale') || 'en';
55
- const file = mappedLocale[jLocale];
56
20
  return (
57
- <ConfigProvider locale={file}>
58
- <IntlProvider locale={locale} key={locale} messages={messages}>
59
- {React.Children.only(this.props.children)}
60
- </IntlProvider>
61
- </ConfigProvider>
21
+ <IntlProvider locale={this.props.locale} key={this.props.locale} messages={this.props.messages[this.props.locale]}>
22
+ {React.Children.only(this.props.children)}
23
+ </IntlProvider>
62
24
  );
63
25
  }
64
26
  }
65
27
 
66
28
  LanguageProvider.propTypes = {
67
- language: PropTypes.object,
68
- actions: PropTypes.object,
29
+ locale: PropTypes.string,
30
+ messages: PropTypes.object,
69
31
  children: PropTypes.element.isRequired,
70
32
  };
71
33
 
72
34
 
73
- const mapStateToProps = createStructuredSelector({
74
- language: makeSelectLocale(),
75
- });
35
+ const mapStateToProps = createSelector(
36
+ makeSelectLocale(),
37
+ (locale) => ({ locale })
38
+ );
76
39
 
77
40
  function mapDispatchToProps(dispatch) {
78
41
  return {
79
- actions: bindActionCreators(actions, dispatch),
42
+ dispatch,
80
43
  };
81
44
  }
82
45
 
@@ -6,24 +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';
12
+ import {
13
+ DEFAULT_LOCALE,
14
+ } from '../Cap/constants'; // eslint-disable-line
10
15
 
11
16
  const initialState = fromJS({
12
- locale: types.DEFAULT_LOCALE,
13
- messages: {},
14
- localeLoading: false,
17
+ locale: DEFAULT_LOCALE,
15
18
  });
16
19
 
17
20
  function languageProviderReducer(state = initialState, action) {
18
21
  switch (action.type) {
19
- case types.GET_LOCIZ_MESSAGE_REQUEST:
20
- return state.set('localeLoading', true);
21
- case types.GET_LOCIZ_MESSAGE_SUCCESS:
22
+ case CHANGE_LOCALE:
22
23
  return state
23
- .set('localeLoading', false)
24
- .set('messages', fromJS(action.data));
25
- case types.GET_LOCIZ_MESSAGE_FAILURE:
26
- return state.set('localeLoading', false);
24
+ .set('locale', action.locale);
27
25
  default:
28
26
  return state;
29
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 {
@@ -978,7 +978,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
978
978
  size={"label"}/>
979
979
  </CapColumn>
980
980
  <CapColumn span={6}>
981
- <CapLink title={this.props.intl.formatMessage(messages.change)} onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
981
+ <CapLink title="change" onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
982
982
  </CapColumn>
983
983
  </CapRow>,
984
984
  primitive: true,
@@ -1705,7 +1705,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1705
1705
  setModalContent={this.setModalContent}
1706
1706
  startValidation={this.state.startValidation}
1707
1707
  stopValidation={this.stopValidation}
1708
- selectedOfferDetails={this.props.selectedOfferDetails}
1709
1708
  />
1710
1709
  </CapColumn>
1711
1710
  {this.props.iosCtasData && this.state.showIosCtaTable &&
@@ -290,8 +290,4 @@ export default defineMessages({
290
290
  id: 'creatives.containersV2.MobilePush.Create.here',
291
291
  defaultMessage: 'here .',
292
292
  },
293
- "change": {
294
- id: 'creatives.containersV2.MobilePush.Create.change',
295
- defaultMessage: 'change',
296
- },
297
293
  });
@@ -967,7 +967,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
967
967
  size={"label"}/>
968
968
  </CapColumn>
969
969
  <CapColumn span={6}>
970
- <CapLink title={this.props.intl.formatMessage(messages.change)} onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
970
+ <CapLink title="change" onClick={() => this.addSecondoryCtaIos(true, this.state.formData, {id: "add-sec-cta-ios"})}/>
971
971
  </CapColumn>
972
972
  </CapRow>,
973
973
  primitive: true,
@@ -1792,7 +1792,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1792
1792
  setModalContent={this.setModalContent}
1793
1793
  startValidation={this.state.startValidation}
1794
1794
  stopValidation={this.stopValidation}
1795
- selectedOfferDetails={this.props.selectedOfferDetails}
1796
1795
  />}
1797
1796
  </CapColumn>
1798
1797
  {this.props.iosCtasData && this.state.showIosCtaTable &&
@@ -282,8 +282,4 @@ export default defineMessages({
282
282
  id: 'creatives.containersV2.MobilePush.Edit.pleaseInput',
283
283
  defaultMessage: "Please input",
284
284
  },
285
- "change": {
286
- id: 'creatives.containersV2.MobilePush.Edit.change',
287
- defaultMessage: "change",
288
- },
289
285
  });
@@ -176,7 +176,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
176
176
  const unicodeEnabled = _.get(this.state, `formData[0]['unicode-validity']`);
177
177
  const smsDetails = updateCharCount(content || "", unicodeEnabled || false);
178
178
  if (this.smsCount.current) {
179
- this.smsCount.current.innerText = `${smsDetails.parts}${this.props.intl.formatMessage(messages.sms)} (${smsDetails.chars_used} ${this.props.intl.formatMessage(messages.characters)})`;
179
+ this.smsCount.current.innerText = `${smsDetails.parts}SMS (${smsDetails.chars_used} characters)`;
180
180
  }
181
181
  }
182
182
 
@@ -970,7 +970,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
970
970
  router={this.props.router}
971
971
  startValidation={this.state.startValidation}
972
972
  stopValidation={this.stopValidation}
973
- selectedOfferDetails={this.props.selectedOfferDetails}
974
973
  />
975
974
  </CapColumn>
976
975
  </CapRow>
@@ -996,7 +995,6 @@ Create.propTypes = {
996
995
  isFullMode: PropTypes.bool,
997
996
  getFormSubscriptionData: PropTypes.func,
998
997
  isLoadingMetaEntities: PropTypes.bool,
999
- selectedOfferDetails: PropTypes.array,
1000
998
  };
1001
999
 
1002
1000
  const mapStateToProps = createStructuredSelector({
@@ -110,20 +110,4 @@ export default defineMessages({
110
110
  id: 'creatives.containersV2.Create.templateNotValid',
111
111
  defaultMessage: 'Template data is not valid',
112
112
  },
113
- "Creative name": {
114
- id: 'creatives.containersV2.Create.creativeName',
115
- defaultMessage: 'Creative name',
116
- },
117
- "Add label": {
118
- id: 'creatives.containersV2.Create.addLabel',
119
- defaultMessage: 'Add label',
120
- },
121
- "sms": {
122
- id: 'creatives.containersV2.Create.sms',
123
- defaultMessage: 'SMS',
124
- },
125
- "characters" : {
126
- id: 'creatives.containersV2.Create.characters',
127
- defaultMessage: 'characters',
128
- },
129
113
  });
@@ -194,7 +194,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
194
194
  const unicodeEnabled = _.get(this.state, `formData[0]['unicode-validity']`);
195
195
  const smsDetails = updateCharCount(content || "", unicodeEnabled || false);
196
196
  if (this.smsCount.current) {
197
- this.smsCount.current.innerText = `${smsDetails.parts}${this.props.intl.formatMessage(messages.sms)} (${smsDetails.chars_used} ${this.props.intl.formatMessage(messages.characters)})`;
197
+ this.smsCount.current.innerText = `${smsDetails.parts}SMS (${smsDetails.chars_used} characters)`;
198
198
  }
199
199
  }
200
200
 
@@ -966,7 +966,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
966
966
  router={this.props.router}
967
967
  startValidation={this.state.startValidation}
968
968
  stopValidation={this.stopValidation}
969
- selectedOfferDetails={this.props.selectedOfferDetails}
970
969
  />
971
970
  </CapColumn>
972
971
  </CapRow>
@@ -995,7 +994,6 @@ Edit.propTypes = {
995
994
  setIsLoadingContent: PropTypes.func,
996
995
  // route: PropTypes.object,
997
996
  injectedTags: PropTypes.object,
998
- selectedOfferDetails: PropTypes.array,
999
997
  };
1000
998
 
1001
999
  const mapStateToProps = createStructuredSelector({