@capillarytech/creatives-library 7.12.0 → 7.12.3

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 (55) hide show
  1. package/index.js +6 -0
  2. package/package.json +1 -1
  3. package/routes.js +7 -2
  4. package/services/api.js +8 -2
  5. package/v2Components/CallTaskPreview/tests/__snapshots__/index.test.js.snap +30 -0
  6. package/v2Components/CapImageUpload/index.js +24 -11
  7. package/v2Components/CapImageUpload/index.scss +12 -27
  8. package/v2Components/CapImageUpload/messages.js +10 -5
  9. package/v2Components/TemplatePreview/_templatePreview.scss +13 -1
  10. package/v2Components/TemplatePreview/index.js +43 -2
  11. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +33 -1
  12. package/v2Components/TemplatePreview/tests/index.test.js +7 -7
  13. package/v2Containers/App/constants.js +2 -1
  14. package/v2Containers/Assets/images/addCreativesIllustration.svg +30 -0
  15. package/v2Containers/Assets/images/rcsIllustration.png +0 -0
  16. package/v2Containers/Cap/messages.js +20 -1
  17. package/v2Containers/CreativesContainer/SlideBoxContent.js +57 -11
  18. package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -0
  19. package/v2Containers/CreativesContainer/constants.js +1 -0
  20. package/v2Containers/CreativesContainer/messages.js +4 -0
  21. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +24 -4
  22. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +23 -4
  23. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +147 -2
  24. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -0
  25. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +71 -0
  26. package/v2Containers/CreativesContainer/tests/index.test.js +21 -9
  27. package/v2Containers/Facebook/Advertisement/index.js +4 -2
  28. package/v2Containers/MobilePush/Edit/index.js +21 -34
  29. package/v2Containers/Rcs/actions.js +57 -0
  30. package/v2Containers/Rcs/constants.js +50 -0
  31. package/v2Containers/Rcs/index.js +1064 -0
  32. package/v2Containers/Rcs/index.scss +72 -0
  33. package/v2Containers/Rcs/messages.js +122 -0
  34. package/v2Containers/Rcs/reducer.js +107 -0
  35. package/v2Containers/Rcs/sagas.js +141 -0
  36. package/v2Containers/Rcs/selectors.js +8 -0
  37. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +145080 -0
  38. package/v2Containers/Rcs/tests/index.test.js +226 -0
  39. package/v2Containers/Rcs/tests/mockData.js +169 -0
  40. package/v2Containers/Rcs/utils.js +40 -0
  41. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -4
  42. package/v2Containers/Templates/_templates.scss +9 -1
  43. package/v2Containers/Templates/actions.js +2 -1
  44. package/v2Containers/Templates/constants.js +1 -0
  45. package/v2Containers/Templates/index.js +234 -174
  46. package/v2Containers/Templates/messages.js +20 -0
  47. package/v2Containers/Templates/reducer.js +2 -0
  48. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +520 -80
  49. package/v2Containers/TemplatesV2/index.js +2 -1
  50. package/v2Containers/TemplatesV2/messages.js +4 -0
  51. package/v2Containers/Whatsapp/index.js +4 -2
  52. package/v2Containers/Whatsapp/messages.js +0 -13
  53. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +13 -13
  54. package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +32 -26
  55. package/v2Containers/mockdata.js +567 -1588
@@ -0,0 +1,226 @@
1
+ import React from 'react';
2
+ import { browserHistory } from 'react-router';
3
+ import { Provider } from 'react-redux';
4
+ import configureStore from '../../../store';
5
+ import { mountWithIntl } from '../../../../app/helpers/intl-enzym-test-helpers';
6
+ import { Rcs } from '../index';
7
+ import { mockData } from './mockData';
8
+
9
+ let store;
10
+ beforeAll(() => {
11
+ store = configureStore({}, browserHistory);
12
+ });
13
+
14
+ jest.mock('../../CreativesContainer', () => ({
15
+ __esModule: true,
16
+ default: (props) => (
17
+ <div className="creatives-container-mock" {...props}>
18
+ CreativesContainer
19
+ </div>
20
+ ),
21
+ }));
22
+
23
+ describe('Creatives rcs test/>', () => {
24
+ let renderedComponent;
25
+ const uploadRcsAsset = jest.fn();
26
+ const clearRcsAsset = jest.fn();
27
+ const createTemplate = jest.fn();
28
+ const clearCreateResponse = jest.fn();
29
+ const getTemplateDetails = jest.fn();
30
+ const editTemplate = jest.fn();
31
+ const clearEditResponse = jest.fn();
32
+ const fetchSchemaForEntity = jest.fn();
33
+ const onCreateComplete = jest.fn();
34
+ const handleClose = jest.fn();
35
+ const formatMessage = jest.fn();
36
+ const params = {
37
+ id: mockData.rcsData1.templateDetails._id,
38
+ };
39
+ const rcsData1 = mockData.rcsData1;
40
+ const rcsData2 = mockData.rcsData2;
41
+ const rcsData3 = mockData.rcsData3;
42
+
43
+ const renderHelper = (args) => {
44
+ renderedComponent = mountWithIntl(
45
+ <Provider store={store}>
46
+ <Rcs
47
+ actions={{
48
+ uploadRcsAsset,
49
+ clearRcsAsset,
50
+ createTemplate,
51
+ clearCreateResponse,
52
+ getTemplateDetails,
53
+ editTemplate,
54
+ clearEditResponse,
55
+ }}
56
+ globalActions={{ fetchSchemaForEntity }}
57
+ onCreateComplete={onCreateComplete}
58
+ handleClose={handleClose}
59
+ intl={{ formatMessage }}
60
+ location={args.isEditFlow ? mockData.location2 : mockData.location1}
61
+ params={args.params}
62
+ rcsData={args.rcsData}
63
+ isFullMode={args.isFullMode || true}
64
+ isEditFlow={args.isEditFlow || false}
65
+ loadingTags={false}
66
+ metaEntities={[]}
67
+ getDefaultTags={true}
68
+ isDltEnabled={args.isDltEnabled || false}
69
+ smsRegister={'DLT'}
70
+ />
71
+ </Provider>,
72
+ );
73
+ };
74
+
75
+ it('should render create mode', () => {
76
+ renderHelper({});
77
+ expect(renderedComponent).toMatchSnapshot();
78
+ });
79
+
80
+ it('template name change', () => {
81
+ renderHelper({});
82
+ const templateNameRenderHelper = (val) => {
83
+ let event = { target: { value: val } };
84
+ renderedComponent
85
+ .find('#rcs_template_name_input')
86
+ .last()
87
+ .simulate('change', event);
88
+ };
89
+ templateNameRenderHelper('test_name');
90
+ expect(renderedComponent).toMatchSnapshot();
91
+ templateNameRenderHelper('');
92
+ expect(renderedComponent).toMatchSnapshot();
93
+ });
94
+
95
+ it('template media change', () => {
96
+ renderHelper({});
97
+ const event = { target: { value: 'IMAGE' } };
98
+ expect(renderedComponent.find('CapRadioGroup').props().value).toBe('NONE');
99
+ expect(renderedComponent).toMatchSnapshot();
100
+ renderedComponent.find('CapRadioGroup').props().onChange(event);
101
+ renderedComponent.update();
102
+ expect(renderedComponent.find('CapRadioGroup').props().value).toBe('IMAGE');
103
+ expect(renderedComponent).toMatchSnapshot();
104
+ });
105
+
106
+ it('template title change', () => {
107
+ renderHelper({});
108
+ const templateTitleRenderHelper = (val) => {
109
+ let event = { target: { value: val } };
110
+ renderedComponent
111
+ .find('#rcs-template-title-input')
112
+ .last()
113
+ .simulate('change', event);
114
+ };
115
+ templateTitleRenderHelper('test_title');
116
+ expect(renderedComponent).toMatchSnapshot();
117
+ templateTitleRenderHelper('');
118
+ expect(renderedComponent).toMatchSnapshot();
119
+ });
120
+
121
+ it('template desc change', () => {
122
+ renderHelper({});
123
+ const templateDescRenderHelper = (val) => {
124
+ let event = { target: { value: val } };
125
+ renderedComponent
126
+ .find('#rcs_template_message_textarea')
127
+ .last()
128
+ .simulate('change', event);
129
+ };
130
+ templateDescRenderHelper('test_desc');
131
+ expect(renderedComponent).toMatchSnapshot();
132
+ templateDescRenderHelper('');
133
+ expect(renderedComponent).toMatchSnapshot();
134
+ });
135
+
136
+ it('non dlt fallback msg', () => {
137
+ renderHelper({});
138
+ const templateDescRenderHelper = (val) => {
139
+ let event = { target: { value: val } };
140
+ renderedComponent
141
+ .find('#rcs_fallback_message_textarea')
142
+ .last()
143
+ .simulate('change', event);
144
+ };
145
+ templateDescRenderHelper('test_nondlt_fallback');
146
+ expect(renderedComponent).toMatchSnapshot();
147
+ templateDescRenderHelper('');
148
+ expect(renderedComponent).toMatchSnapshot();
149
+ });
150
+
151
+ it('create with all data, non dlt org', () => {
152
+ renderHelper({});
153
+ createTemplate.mockImplementation((obj, callback) => {
154
+ callback();
155
+ });
156
+ expect(
157
+ renderedComponent.find('CapButton.rcs-done-btn').first().props().disabled,
158
+ ).toBe(true);
159
+ renderedComponent
160
+ .find('#rcs_template_name_input')
161
+ .last()
162
+ .simulate('change', { target: { value: 'final_name' } });
163
+ renderedComponent
164
+ .find('#rcs-template-title-input')
165
+ .last()
166
+ .simulate('change', { target: { value: 'final_title' } });
167
+ renderedComponent
168
+ .find('#rcs_template_message_textarea')
169
+ .last()
170
+ .simulate('change', { target: { value: 'final_desc' } });
171
+ expect(
172
+ renderedComponent.find('CapButton.fallback-preview-btn').first().props()
173
+ .disabled,
174
+ ).toBe(true);
175
+ renderedComponent
176
+ .find('#rcs_fallback_message_textarea')
177
+ .last()
178
+ .simulate('change', { target: { value: 'final_fallback' } });
179
+ expect(
180
+ renderedComponent.find('CapButton.fallback-preview-btn').first().props()
181
+ .disabled,
182
+ ).toBe(false);
183
+ renderedComponent.find('CapButton.fallback-preview-btn').simulate('click');
184
+ expect(renderedComponent).toMatchSnapshot();
185
+ expect(
186
+ renderedComponent.find('CapButton.rcs-done-btn').first().props().disabled,
187
+ ).toBe(false);
188
+ renderedComponent.find('CapButton.rcs-done-btn').simulate('click');
189
+ expect(renderedComponent).toMatchSnapshot();
190
+ });
191
+
192
+ it('should render edit mode in various cases', () => {
193
+ //non dlt fallback
194
+ renderHelper({
195
+ params,
196
+ rcsData: rcsData1,
197
+ isEditFlow: true,
198
+ });
199
+ expect(renderedComponent).toMatchSnapshot();
200
+ //dlt enabled but no fallback
201
+ renderHelper({
202
+ params,
203
+ rcsData: rcsData2,
204
+ isEditFlow: true,
205
+ isDltEnabled: true,
206
+ });
207
+ renderedComponent.find('CapButton.add-dlt-btn').simulate('click');
208
+ expect(renderedComponent).toMatchSnapshot();
209
+ });
210
+
211
+ it('rcs edit with dlt fallback and save', () => {
212
+ editTemplate.mockImplementation((obj, callback) => {
213
+ callback();
214
+ });
215
+ //dlt fallback
216
+ renderHelper({
217
+ params,
218
+ rcsData: rcsData3,
219
+ isEditFlow: true,
220
+ isDltEnabled: true,
221
+ });
222
+ expect(renderedComponent).toMatchSnapshot();
223
+ renderedComponent.find('CapButton.rcs-done-btn').simulate('click');
224
+ expect(renderedComponent).toMatchSnapshot();
225
+ });
226
+ });
@@ -0,0 +1,169 @@
1
+ export const mockData = {
2
+ rcsData1: {
3
+ templateDetails: {
4
+ _id: '623acf4df971231e66c85882',
5
+ name: 'RCS_TEST1',
6
+ type: 'RCS',
7
+ versions: {
8
+ history: [],
9
+ base: {
10
+ content: {
11
+ RCS: {
12
+ cardContent: [
13
+ {
14
+ title: 'This is RCS title',
15
+ description: 'This is RCS description ',
16
+ mediaType: 'IMAGE',
17
+ media: {
18
+ mediaUrl:
19
+ 'https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/62f8c77c-f132-44d8-a822-0e90f57c.jpg',
20
+ height: 'MEDIUM',
21
+ },
22
+ },
23
+ ],
24
+ cardSettings: {
25
+ cardOrientation: 'VERTICAL',
26
+ mediaAlignment: 'RIGHT',
27
+ },
28
+ cardType: 'STANDALONE',
29
+ contentType: 'RICHCARD',
30
+ smsFallBackContent: {
31
+ message: 'This is fallback msg ',
32
+ },
33
+ },
34
+ },
35
+ },
36
+ },
37
+ isActive: true,
38
+ orgId: 50146,
39
+ createdBy: '15000449',
40
+ updatedBy: '15000449',
41
+ createdAt: '2022-03-23T07:42:05.226Z',
42
+ updatedAt: '2022-03-30T03:25:24.084Z',
43
+ },
44
+ },
45
+ rcsData2: {
46
+ templateDetails: {
47
+ _id: '62419c0a70387f3eb2f8fdcd',
48
+ name: 'RCS_TEST2',
49
+ type: 'RCS',
50
+ versions: {
51
+ history: [],
52
+ base: {
53
+ content: {
54
+ RCS: {
55
+ cardContent: [
56
+ {
57
+ title: 'Rcs title',
58
+ description: 'Rcs desc',
59
+ mediaType: 'NONE',
60
+ media: {
61
+ mediaUrl: '',
62
+ height: 'MEDIUM',
63
+ },
64
+ },
65
+ ],
66
+ cardSettings: {
67
+ cardOrientation: 'VERTICAL',
68
+ mediaAlignment: 'RIGHT',
69
+ },
70
+ cardType: 'STANDALONE',
71
+ contentType: 'RICHCARD',
72
+ smsFallBackContent: {
73
+ message: '',
74
+ templateConfigs: {},
75
+ },
76
+ },
77
+ },
78
+ },
79
+ },
80
+ isActive: true,
81
+ orgId: 1604,
82
+ createdBy: '15000449',
83
+ updatedBy: '15000449',
84
+ createdAt: '2022-03-28T11:29:15.072Z',
85
+ updatedAt: '2022-03-30T03:30:21.273Z',
86
+ },
87
+ },
88
+ rcsData3: {
89
+ templateDetails: {
90
+ _id: '62419c0a70387f3eb2f8fdcd',
91
+ name: 'RCS_TEST3',
92
+ type: 'RCS',
93
+ versions: {
94
+ history: [],
95
+ base: {
96
+ content: {
97
+ RCS: {
98
+ cardContent: [
99
+ {
100
+ title: 'Rcs title',
101
+ description: 'Rcs desc',
102
+ mediaType: 'IMAGE',
103
+ media: {
104
+ mediaUrl:
105
+ 'https://s3.amazonaws.com/test_files_cache_bkp/intouch_creative_assets/8fcb2fdce8f92e4a48d4.png',
106
+ height: 'MEDIUM',
107
+ },
108
+ },
109
+ ],
110
+ cardSettings: {
111
+ cardOrientation: 'VERTICAL',
112
+ mediaAlignment: 'RIGHT',
113
+ },
114
+ cardType: 'STANDALONE',
115
+ contentType: 'RICHCARD',
116
+ smsFallBackContent: {
117
+ message:
118
+ 'Dear Linen Club Rewards member, your Coupon code for Rs test is test. Kindly show it to the cashier before billing. Conditions Apply. test',
119
+ templateConfigs: {
120
+ templateId: '1007983204882734091',
121
+ templateName: 'Coupon Resend',
122
+ template:
123
+ 'Dear Linen Club Rewards member, your Coupon code for Rs {#var#} is {#var#}. Kindly show it to the cashier before billing. Conditions Apply. {#var#}',
124
+ registeredSenderIds: ['LINNCL', 'LINNCB'],
125
+ templateVariableMapping: {
126
+ '{#var#}_5': {
127
+ count: 1,
128
+ data: 'test',
129
+ },
130
+ '{#var#}_3': {
131
+ count: 1,
132
+ data: 'test',
133
+ },
134
+ '{#var#}_1': {
135
+ count: 1,
136
+ data: 'test',
137
+ },
138
+ },
139
+ },
140
+ },
141
+ },
142
+ },
143
+ },
144
+ },
145
+ isActive: true,
146
+ orgId: 1604,
147
+ createdBy: '15000449',
148
+ updatedBy: '15000449',
149
+ createdAt: '2022-03-28T11:29:15.072Z',
150
+ updatedAt: '2022-03-30T03:29:30.271Z',
151
+ },
152
+ },
153
+ location1: {
154
+ pathname: '/rcs/create',
155
+ query: {
156
+ type: false,
157
+ module: 'default',
158
+ },
159
+ search: '',
160
+ },
161
+ location2: {
162
+ pathname: '/rcs/edit',
163
+ query: {
164
+ type: false,
165
+ module: 'default',
166
+ },
167
+ search: '',
168
+ },
169
+ };
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
3
+ import CapImage from '@capillarytech/cap-ui-library/CapImage';
4
+ import { RCS } from '../CreativesContainer/constants';
5
+ import './index.scss';
6
+ export const getRCSContent = (template) => {
7
+ const {
8
+ versions: {
9
+ base: {
10
+ content: {
11
+ [RCS]: {
12
+ cardContent = [{}],
13
+ } = {},
14
+ } = {},
15
+ } = {},
16
+ } = {},
17
+ } = template;
18
+ const { media = {}, description, title } = cardContent[0];
19
+ const { mediaUrl } = media;
20
+ return (
21
+ <div className="cap-rcs-creatives">
22
+ {mediaUrl && (
23
+ <CapImage
24
+ src={mediaUrl}
25
+ className="rcs-listing-image"
26
+ />
27
+ )}
28
+ <CapLabel
29
+ type="label19"
30
+ className="rcs-listing-content title"
31
+ fontWeight="bold"
32
+ >
33
+ {title}
34
+ </CapLabel>
35
+ <CapLabel type="label19" className="rcs-listing-content desc">
36
+ {description}
37
+ </CapLabel>
38
+ </div>
39
+ );
40
+ };
@@ -6071,7 +6071,7 @@ FREE GIFTS-
6071
6071
  />
6072
6072
  </CapImage>
6073
6073
  <div
6074
- className="msgContainer sms"
6074
+ className="msg-container sms"
6075
6075
  >
6076
6076
  <div
6077
6077
  className="message-pop sms"
@@ -12754,7 +12754,7 @@ FREE GIFTS-
12754
12754
  />
12755
12755
  </CapImage>
12756
12756
  <div
12757
- className="msgContainer sms"
12757
+ className="msg-container sms"
12758
12758
  >
12759
12759
  <div
12760
12760
  className="message-pop sms"
@@ -19857,7 +19857,7 @@ FREE GIFTS-
19857
19857
  />
19858
19858
  </CapImage>
19859
19859
  <div
19860
- className="msgContainer sms"
19860
+ className="msg-container sms"
19861
19861
  >
19862
19862
  <div
19863
19863
  className="message-pop sms"
@@ -27069,7 +27069,7 @@ FREE GIFTS-
27069
27069
  />
27070
27070
  </CapImage>
27071
27071
  <div
27072
- className="msgContainer sms"
27072
+ className="msg-container sms"
27073
27073
  >
27074
27074
  <div
27075
27075
  className="message-pop sms"
@@ -574,9 +574,17 @@
574
574
  }
575
575
  }
576
576
 
577
- .whatsapp-illustration-desc {
577
+ .illustration-desc {
578
578
  font-size: 14px;
579
579
  color: rgba(0, 0, 0, 0.87);
580
580
  margin: 8px 0;
581
581
  white-space: pre-wrap;
582
582
  }
583
+ .rcs-illustration{
584
+ width: 25%;
585
+ text-align: center;
586
+ }
587
+ .channel-specific-illustration-text{
588
+ text-align: center;
589
+ margin-top: $CAP_SPACE_44;
590
+ }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import * as types from './constants';
8
- import { LINE, WHATSAPP } from '../CreativesContainer/constants';
8
+ import { LINE, WHATSAPP, RCS } from '../CreativesContainer/constants';
9
9
 
10
10
  export function getAllTemplates(channel, queryParams) {
11
11
  return {
@@ -59,6 +59,7 @@ export function setChannelAccount(channel, account) {
59
59
  const channelTypeMapping = {
60
60
  [LINE]: types.SET_LINE_ACCOUNT,
61
61
  [WHATSAPP]: types.SET_WHATSAPP_ACCOUNT,
62
+ [RCS]: types.SET_RCS_ACCOUNT,
62
63
  };
63
64
  if (channelTypeMapping[channel]) {
64
65
  return {
@@ -46,6 +46,7 @@ export const SET_LINE_ACCOUNT = "app/v2Containers/Templates/SET_LINE_ACCOUNT";
46
46
  export const SET_VIBER_ACCOUNT = "app/v2Containers/Templates/SET_VIBER_ACCOUNT";
47
47
  export const SET_FACEBOOK_ACCOUNT = "app/v2Containers/Templates/SET_FACEBOOK_ACCOUNT";
48
48
  export const SET_WHATSAPP_ACCOUNT = "app/v2Containers/Templates/SET_WHATSAPP_ACCOUNT";
49
+ export const SET_RCS_ACCOUNT = "app/v2Containers/Templates/SET_RCS_ACCOUNT";
49
50
 
50
51
  export const GET_DEAFULT_BEE_TEMPLATES_REQUEST = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_REQUEST';
51
52
  export const GET_DEAFULT_BEE_TEMPLATES_SUCCESS = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_SUCCESS';