@capillarytech/creatives-library 7.0.8 → 7.1.0

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 (33) hide show
  1. package/config/app.js +2 -0
  2. package/index.js +7 -0
  3. package/package.json +1 -1
  4. package/reducers.js +2 -1
  5. package/services/api.js +7 -0
  6. package/utils/common.js +177 -0
  7. package/v2Components/TemplatePreview/assets/images/mobile.svg +24 -0
  8. package/v2Components/TemplatePreview/index.js +8 -12
  9. package/v2Containers/App/constants.js +1 -1
  10. package/v2Containers/CreativesContainer/SlideBoxContent.js +17 -3
  11. package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -0
  12. package/v2Containers/CreativesContainer/constants.js +2 -0
  13. package/v2Containers/CreativesContainer/index.js +14 -14
  14. package/v2Containers/FTP/_FTP.scss +103 -0
  15. package/v2Containers/FTP/actions.js +7 -0
  16. package/v2Containers/FTP/constants.js +3 -0
  17. package/v2Containers/FTP/index.js +509 -0
  18. package/v2Containers/FTP/messages.js +60 -0
  19. package/v2Containers/FTP/reducer.js +32 -0
  20. package/v2Containers/FTP/sagas.js +26 -0
  21. package/v2Containers/FTP/selectors.js +20 -0
  22. package/v2Containers/FTP/temp.js +11838 -0
  23. package/v2Containers/Templates/_templates.scss +2 -2
  24. package/v2Containers/Templates/actions.js +110 -117
  25. package/v2Containers/Templates/constants.js +0 -2
  26. package/v2Containers/Templates/index.js +1 -29
  27. package/v2Containers/Templates/messages.js +0 -4
  28. package/v2Containers/Templates/reducer.js +0 -2
  29. package/v2Containers/TemplatesV2/index.js +13 -0
  30. package/v2Containers/TemplatesV2/messages.js +4 -0
  31. package/v2Containers/Viber/index.js +12 -32
  32. package/v2Containers/Viber/messages.js +4 -12
  33. package/v2Components/TemplatePreview/assets/images/viberMobile.svg +0 -135
package/config/app.js CHANGED
@@ -11,6 +11,7 @@ const config = {
11
11
  dashboard_url: '/sms',
12
12
  dashboard_url_v2: '/v2',
13
13
  subscription_api_endpoint: '/arya/api/v1/org-settings/subscription',
14
+ exports_api_endpoint: '/arya/api/v1/export/data',
14
15
  accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
15
16
  },
16
17
  development: {
@@ -19,6 +20,7 @@ const config = {
19
20
  auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
20
21
  arya_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1',
21
22
  subscription_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/org-settings/subscription',
23
+ exports_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/export/data',
22
24
  login_url: '/auth/login',
23
25
  dashboard_url: '/sms',
24
26
  dashboard_url_v2: '/v2',
package/index.js CHANGED
@@ -56,6 +56,10 @@ import MobilepushCreate from './v2Containers/MobilePush/Create';
56
56
  import mobilepushCreateReducer from './v2Containers/MobilePush/Create/reducer';
57
57
  import mobilepushCreateSaga from './v2Containers/MobilePush/Create/sagas';
58
58
 
59
+ import FTP from './v2Containers/FTP';
60
+ import FTPReducer from './v2Containers/FTP/reducer';
61
+ import FTPSagas from './v2Containers/FTP/sagas';
62
+
59
63
  import MobilepushEdit from './v2Containers/MobilePush/Edit';
60
64
  import mobilepushEditReducer from './v2Containers/MobilePush/Edit/reducer';
61
65
  import mobilepushEditSaga from './v2Containers/MobilePush/Edit/sagas';
@@ -99,6 +103,7 @@ const FacebookContainer = {Facebook, facebookReducer, facebookSaga};
99
103
  const ViberContainer = {Viber, viberReducer, viberSaga};
100
104
 
101
105
  const GalleryContainer = {Gallery, galleryReducer, gallerySagas};
106
+ const FTPContainer = {FTP, FTPReducer, FTPSagas};
102
107
 
103
108
  export {default as TagList} from './v2Containers/TagList/index';
104
109
  export {default as TagListSaga} from './v2Containers/TagList/sagas';
@@ -110,6 +115,7 @@ export {default as CallTaskPreview} from './v2Components/CallTaskPreview';
110
115
  export {default as EmailMobilePreview} from './v2Components/EmailMobilePreview';
111
116
  export {default as MobilePushPreview} from './v2Components/MobilePushPreviewV2';
112
117
  export {default as WechatRichmediaTemplatePreview} from './v2Components/TemplatePreview/WechatRichmediaTemplatePreview';
118
+ export {default as FTP} from './v2Containers/FTP';
113
119
 
114
120
  CreativesContainer.CreativesContainerReducer = CreativesContainerReducer;
115
121
 
@@ -137,5 +143,6 @@ export { CapContainer,
137
143
  updateCharCount,
138
144
  FacebookContainer,
139
145
  GalleryContainer,
146
+ FTPContainer,
140
147
  ViberContainer,
141
148
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.0.8",
4
+ "version": "7.1.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/reducers.js CHANGED
@@ -19,7 +19,7 @@ import templateReducer from 'containers/Templates/reducer';
19
19
  import tagsReducer from 'containers/TagList/reducer';
20
20
  import emailReducer from 'containers/Email/reducer';
21
21
  import ebillReducer from 'containers/Ebill/reducer';
22
-
22
+ import ftpReducer from 'v2Containers/FTP/reducer';
23
23
  /*
24
24
  * routeReducer
25
25
  *
@@ -64,6 +64,7 @@ export default function createReducer(asyncReducers) {
64
64
  email: emailReducer,
65
65
  ebill: ebillReducer,
66
66
  beeEditor: beeEditorReducer,
67
+ FTP: ftpReducer,
67
68
  ...asyncReducers,
68
69
  });
69
70
  }
package/services/api.js CHANGED
@@ -9,6 +9,7 @@ import getSchema from './getSchema';
9
9
  import * as API from '../utils/ApiCaller';
10
10
  import { GA } from '@capillarytech/cap-ui-utils';
11
11
  let API_ENDPOINT = config.development.api_endpoint;
12
+ let EXPORT_API_ENDPOINT = config.development.exports_api_endpoint;
12
13
  let CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_endpoint;
13
14
  let API_AUTH_ENDPOINT = config.development.auth_endpoint;
14
15
  let ARYA_ENDPOINT = config.development.arya_endpoint;
@@ -213,6 +214,12 @@ export const duplicateTemplate = ({id, channel}) => {
213
214
  return request(url, getAPICallObject('GET'));
214
215
  };
215
216
 
217
+ export const getFTPServers = () => {
218
+ console.log('in api.js getFTPServers');
219
+ const url = `${EXPORT_API_ENDPOINT}/ftplist`;
220
+ return request(url, getAPICallObject('GET'));
221
+ };
222
+
216
223
  export const editWeChatTemplate = ({template}) => {
217
224
  console.log('in api.js', template);
218
225
  const url = `${API_ENDPOINT}/templates/WECHAT`;
package/utils/common.js CHANGED
@@ -37,3 +37,180 @@ export const hasStore2DoorFeature = Auth.hasFeatureAccess.bind(
37
37
  null,
38
38
  STORE2DOOR_PLUS_ENABLED,
39
39
  );
40
+
41
+ export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails = []}) {
42
+ console.log('populating tags', (tagsList || []).length);
43
+ const mainTags = {};
44
+
45
+ //Form tags object with tag headers
46
+ _.forEach(tagsList, (temp) => {
47
+ const tag = temp.definition;
48
+ if (!tag['tag-header']) {
49
+ mainTags[tag.value] = {
50
+ name: tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
51
+ value: tag.value,
52
+ };
53
+ } else if (tag['tag-header'] && mainTags[tag.value]) {
54
+ mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
55
+ } else if (!mainTags[tag.value]) {
56
+ // console.log('Inside ', tag.label);
57
+ mainTags[tag.value] = {
58
+ 'tag-header': true,
59
+ "name": tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
60
+ "subtags": tag.subtags,
61
+ "value": tag.value,
62
+ };
63
+ }
64
+ });
65
+
66
+ const mainTagsCloned = _.cloneDeep(mainTags);
67
+ //Insert subtags in tag headers and reomve them from top level
68
+ const result = {};
69
+ _.forEach(mainTagsCloned, (tag, key) => {
70
+ if (tag['tag-header']) {
71
+ const tagWithChildren = populateTagForChildren(tag, mainTagsCloned, key);
72
+ tagWithChildren.resolved = true;
73
+ result[key] = tagWithChildren;
74
+ } else {
75
+ result[key] = tag;
76
+ }
77
+ });
78
+
79
+ //Delete extra tag headers
80
+ _.forEach(result, (tag) => {
81
+ if (tag['tag-header']) {
82
+ _.forEach(tag.subtags, (subtag, key) => {
83
+ if (result[key]) {
84
+ result[key].deleted = true;
85
+ }
86
+ });
87
+ }
88
+ });
89
+ //Actually delete them
90
+ _.forEach(result, (tag, key) => {
91
+ if (tag.deleted) {
92
+ delete result[key];
93
+ }
94
+ });
95
+ let combinedTags = result;
96
+ if (offerDetails.length) {
97
+ combinedTags = transformCouponTags(offerDetails, result);
98
+ }
99
+ return getTreeStructureData(combinedTags);
100
+ }
101
+
102
+ function transformCouponTags(offerDetails, allTags) {
103
+ const couponTags = {};
104
+ const couponTagsKeys = Object.keys(_.get(allTags, 'coupon.subtags', []));
105
+ const withCouponId = (obj, id) => {
106
+ const tempObj = {};
107
+ if (obj.subtags) {
108
+ tempObj.subtags = _.mapValues(obj.subtags, (tag) => {
109
+ let val = tag.value;
110
+ val = `${val}(${id})`;
111
+ const newObj = {
112
+ ...tag,
113
+ value: val,
114
+ };
115
+ return {
116
+ ...withCouponId(newObj, id),
117
+ };
118
+ });
119
+ }
120
+ return {
121
+ ...obj,
122
+ ...tempObj,
123
+ couponSeriesId: id,
124
+ };
125
+ };
126
+ offerDetails.forEach((offer) => {
127
+ const { id, couponName, description, couponSeriesId } = offer;
128
+ const couponId = id || couponSeriesId;
129
+ const couponSubTags = {};
130
+ couponTagsKeys.forEach((couponTagKey) => {
131
+ let val = allTags.coupon.subtags[couponTagKey].value;
132
+ val = `${val}(${couponId})`;
133
+ const newObj = {
134
+ ...allTags.coupon.subtags[couponTagKey],
135
+ value: val,
136
+ };
137
+ const couponSubTagsObj = withCouponId(newObj, couponId);
138
+ couponSubTags[couponTagKey] = couponSubTagsObj;
139
+ });
140
+ const couponNameFinal = couponName || description;
141
+ const key = couponNameFinal || couponId;
142
+ couponTags[key] = {
143
+ 'tag-header': true,
144
+ 'name': couponNameFinal || couponId,
145
+ 'desc': couponNameFinal || couponId,
146
+ 'couponSeriesId': couponId,
147
+ 'subtags': couponSubTags,
148
+ 'resolved': true,
149
+ 'couponTags': true,
150
+ };
151
+ });
152
+ // eslint-disable-next-line no-param-reassign
153
+ allTags.coupon.subtags = couponTags;
154
+ return allTags;
155
+ }
156
+
157
+ function populateTagForChildren(targetTag, tagsObject, tagValue) {
158
+ const tag = targetTag;
159
+ if (tag && tag['tag-header'] && !tag.resolved) {
160
+ const tempSubTags = {};
161
+ _.forEach(tag.subtags, (subtag) => {
162
+ if (tagsObject[subtag]) {
163
+ const children = populateTagForChildren(tagsObject[subtag], tagsObject, subtag);
164
+ children.resolved = true;
165
+ tempSubTags[subtag] = children;
166
+ }
167
+ });
168
+ tag.subtags = tempSubTags;
169
+ return tag;
170
+ }
171
+ return tagsObject[tagValue];
172
+ }
173
+
174
+ function getTreeStructureData(data) {
175
+ const result = [];
176
+ _.forOwn(data, (mainTag) => {
177
+ const { name, value, subtags = [] } = mainTag;
178
+ if (!mainTag['tag-header']) {
179
+ result.push({
180
+ title: name,
181
+ value: `{{${value}}}`,
182
+ });
183
+ } else {
184
+ const obj = {
185
+ title: name,
186
+ value: `{{${value}}}`,
187
+ selectable: false,
188
+ };
189
+ obj.children = getSubTags(subtags);
190
+ result.push(obj);
191
+ }
192
+ });
193
+ return result;
194
+ }
195
+
196
+ function getSubTags(subtagsParam) {
197
+ const result = [];
198
+ _.forOwn(subtagsParam, (subTag) => {
199
+ const { name, value, subtags = [] } = subTag;
200
+ if (_.isEmpty(subtags)) {
201
+ result.push({
202
+ title: name,
203
+ value: `{{${value}}}`,
204
+ });
205
+ } else {
206
+ const obj = {
207
+ title: name,
208
+ value: `{{${value}}}`,
209
+ selectable: false,
210
+ };
211
+ obj.children = getSubTags(subtags);
212
+ result.push(obj);
213
+ }
214
+ });
215
+ return result;
216
+ }