@capillarytech/creatives-library 8.0.82 → 8.0.85

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.
@@ -636,4 +636,7 @@
636
636
  span {
637
637
  font-size: $FONT_SIZE_VS;
638
638
  }
639
+ }
640
+ .line-image-preview{
641
+ max-width: 8.57rem;;
639
642
  }
@@ -464,6 +464,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
464
464
  >
465
465
  <CapImage
466
466
  src={previewImageUrl}
467
+ className="line-image-preview"
467
468
  alt="brand-name"
468
469
  rest={{
469
470
  style: {
@@ -495,6 +496,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
495
496
  >
496
497
  <CapImage
497
498
  src={baseUrl ? `${baseUrl}/1040` : lineImgPlaceholder}
499
+ className="line-image-preview"
498
500
  alt="brand-name"
499
501
  rest={{
500
502
  style: {
@@ -2,9 +2,9 @@ import { call, put, takeLatest, all } from 'redux-saga/effects';
2
2
  import * as Api from '../../../services/api';
3
3
  import * as types from './constants';
4
4
 
5
- export function* getAllAssets(assetType, queryParams) {
5
+ export function* getAllAssets({assetType , queryParams}) {
6
6
  try {
7
- const result = yield call(Api.getAllAssets, assetType, queryParams);
7
+ const result = yield call(Api.getAllAssets, {assetType, queryParams});
8
8
  yield put({ type: types.GET_ALL_ASSETS_SUCCESS, data: result?.response, isReset: queryParams.page === 1 });
9
9
  } catch (error) {
10
10
  yield put({ type: types.GET_ALL_ASSETS_FAILURE, error });
@@ -1,46 +1,44 @@
1
1
  import { expectSaga } from 'redux-saga-test-plan';
2
- import { call, put } from 'redux-saga/effects';
2
+ import { call } from 'redux-saga/effects';
3
3
  import { throwError } from 'redux-saga-test-plan/providers';
4
- import * as Api from '../../../../services/api';
5
- import * as types from '../constants';
6
- import * as sagas from '../sagas';
7
- import {gallerySaga} from '../sagas';
4
+ import * as Api from '../../../../services/api';
5
+ import * as types from '../constants';
6
+ import * as sagas from '../sagas';
8
7
 
9
8
  describe('Asset and User Management Sagas', () => {
9
+ jest.setTimeout(1000);
10
+
10
11
  describe('getAllAssets Saga', () => {
12
+ const mockAssets = [{ id: 1, url: 'http://example.com/asset.jpg' }];
13
+ const mockError = new Error('Fetch failed');
11
14
  const assetType = 'image';
12
15
  const queryParams = { page: 1 };
13
16
 
14
17
  it('handles fetching all assets successfully', () => {
15
- const fakeResponse = {
16
- response: [{ id: 1, url: 'http://example.com/asset.jpg' }],
18
+ const result = {
19
+ response: { data: { data: mockAssets } },
17
20
  };
18
-
19
- return expectSaga(sagas.getAllAssets, assetType, queryParams)
21
+ return expectSaga(sagas.getAllAssets, { assetType, queryParams })
20
22
  .provide([
21
- [call(Api.getAllAssets, assetType, queryParams), fakeResponse]
23
+ [call(Api.getAllAssets, { assetType, queryParams }), result],
22
24
  ])
23
25
  .put({
24
- type: types.GET_ALL_ASSETS_SUCCESS,
25
- data: fakeResponse.response,
26
- isReset: true
26
+ type: 'app/Gallery/GET_ALL_ASSETS_SUCCESS',
27
+ data: { data: { data: mockAssets } },
28
+ isReset: true,
27
29
  })
28
- .run();
30
+ .run(500);
29
31
  });
30
32
 
31
- it('handles failure in fetching all assets', () => {
32
- const error = new Error('Fetch failed');
33
-
34
- return expectSaga(sagas.getAllAssets, assetType, queryParams)
35
- .provide([
36
- [call(Api.getAllAssets, assetType, queryParams), throwError(error)]
37
- ])
38
- .put({
39
- type: types.GET_ALL_ASSETS_FAILURE,
40
- error
41
- })
42
- .run();
43
- });
33
+ it('handles failure in fetching all assets', () => expectSaga(sagas.getAllAssets, { assetType, queryParams })
34
+ .provide([
35
+ [call(Api.getAllAssets, { assetType, queryParams }), throwError(mockError)],
36
+ ])
37
+ .put({
38
+ type: 'app/Gallery/GET_ALL_ASSETS_FAILURE',
39
+ error: mockError,
40
+ })
41
+ .run(500));
44
42
  });
45
43
 
46
44
  describe('uploadAsset Saga', () => {
@@ -51,17 +49,17 @@ describe('Asset and User Management Sagas', () => {
51
49
  it('handles successful asset upload', () => {
52
50
  const fakeResponse = {
53
51
  response: { asset: { id: 1, url: 'http://example.com/asset.jpg' } },
54
- status: { code: 200 }
52
+ status: { code: 200 },
55
53
  };
56
54
 
57
55
  return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
58
56
  .provide([
59
- [call(Api.uploadFile, file, assetType, fileParams), fakeResponse]
57
+ [call(Api.uploadFile, file, assetType, fileParams), fakeResponse],
60
58
  ])
61
59
  .put({
62
60
  type: types.UPLOAD_ASSET_SUCCESS,
63
61
  data: fakeResponse.response.asset,
64
- statusCode: 200
62
+ statusCode: 200,
65
63
  })
66
64
  .run();
67
65
  });
@@ -71,11 +69,11 @@ describe('Asset and User Management Sagas', () => {
71
69
 
72
70
  return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
73
71
  .provide([
74
- [call(Api.uploadFile, file, assetType, fileParams), throwError(error)]
72
+ [call(Api.uploadFile, file, assetType, fileParams), throwError(error)],
75
73
  ])
76
74
  .put({
77
75
  type: types.UPLOAD_ASSET_FAILURE,
78
- error
76
+ error,
79
77
  })
80
78
  .run();
81
79
  });
@@ -87,16 +85,16 @@ describe('Asset and User Management Sagas', () => {
87
85
 
88
86
  it('handles deleting an asset successfully', () => {
89
87
  const fakeResponse = {
90
- response: 'Asset deleted successfully'
88
+ response: 'Asset deleted successfully',
91
89
  };
92
90
 
93
91
  return expectSaga(sagas.deleteAssetById, assetId, assetType)
94
92
  .provide([
95
- [call(Api.deleteAssetById, assetId, assetType), fakeResponse]
93
+ [call(Api.deleteAssetById, assetId, assetType), fakeResponse],
96
94
  ])
97
95
  .put({
98
96
  type: types.DELETE_ASSET_SUCCESS,
99
- data: fakeResponse.response
97
+ data: fakeResponse.response,
100
98
  })
101
99
  .run();
102
100
  });
@@ -110,7 +108,7 @@ describe('Asset and User Management Sagas', () => {
110
108
  ])
111
109
  .put({
112
110
  type: types.DELETE_ASSET_FAILURE,
113
- error
111
+ error,
114
112
  })
115
113
  .run();
116
114
  });
@@ -120,17 +118,17 @@ describe('Asset and User Management Sagas', () => {
120
118
  it('handles fetching user list successfully', () => {
121
119
  const fakeResponse = {
122
120
  data: {
123
- result: [{ id: 1, name: 'User One' }]
124
- }
121
+ result: [{ id: 1, name: 'User One' }],
122
+ },
125
123
  };
126
124
 
127
125
  return expectSaga(sagas.fetchUserList)
128
126
  .provide([
129
- [call(Api.getUserList), fakeResponse]
127
+ [call(Api.getUserList), fakeResponse],
130
128
  ])
131
129
  .put({
132
130
  type: types.GET_USER_LIST_SUCCESS,
133
- data: fakeResponse.data.result
131
+ data: fakeResponse.data.result,
134
132
  })
135
133
  .run();
136
134
  });
@@ -140,11 +138,11 @@ describe('Asset and User Management Sagas', () => {
140
138
 
141
139
  return expectSaga(sagas.fetchUserList)
142
140
  .provide([
143
- [call(Api.getUserList), throwError(error)]
141
+ [call(Api.getUserList), throwError(error)],
144
142
  ])
145
143
  .put({
146
144
  type: types.GET_USER_LIST_FAILURE,
147
- data: error
145
+ data: error,
148
146
  })
149
147
  .run();
150
148
  });
@@ -153,9 +151,7 @@ describe('Asset and User Management Sagas', () => {
153
151
 
154
152
  // Test combined saga
155
153
  describe('Combined gallerySaga', () => {
156
- it('should initialize all gallery-related watcher sagas without error', () => {
157
- return expectSaga(gallerySaga)
158
- .run();
159
- });
154
+ it('should initialize all gallery-related watcher sagas without error', () => expectSaga(sagas.gallerySaga)
155
+ .run());
160
156
  });
161
- });
157
+ });
@@ -12,7 +12,9 @@ export function* createTemplate(template) {
12
12
  if (result.message || result.status.code === 500) {
13
13
  errorMsg = result.message;
14
14
  }
15
- yield put({ type: types.CREATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
15
+ yield put({
16
+ type: types.CREATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg,
17
+ });
16
18
  } catch (error) {
17
19
  yield put({ type: types.CREATE_TEMPLATE_FAILURE, error, errorMsg });
18
20
  }
@@ -21,12 +23,13 @@ export function* createTemplate(template) {
21
23
  export function* duplicateTemplate(id, channel) {
22
24
  let errorMsg;
23
25
  try {
24
-
25
- const result = yield call(Api.duplicateTemplate, id, channel );
26
+ const result = yield call(Api.duplicateTemplate, id, channel);
26
27
  if (result.message || result.status.code === 500) {
27
28
  errorMsg = result.message;
28
29
  }
29
- yield put({ type: types.DUPLICATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
30
+ yield put({
31
+ type: types.DUPLICATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg,
32
+ });
30
33
  } catch (error) {
31
34
  yield put({ type: types.DUPLICATE_TEMPLATE_FAILURE, error, errorMsg });
32
35
  }
@@ -34,7 +37,6 @@ export function* duplicateTemplate(id, channel) {
34
37
 
35
38
  export function* getTemplateDetails(id) {
36
39
  try {
37
-
38
40
  const result = yield call(Api.getTemplateDetails, id);
39
41
  // const sidebar = result.response.sidebar;
40
42
  yield put({ type: types.GET_TEMPLATE_DETAILS_SUCCESS, data: result.response });
@@ -43,16 +45,18 @@ export function* getTemplateDetails(id) {
43
45
  }
44
46
  }
45
47
 
46
- export function* getAllAssets(assetType, queryParams) {
48
+ export function* getAllAssets({ assetType, queryParams }) {
47
49
  try {
48
- const result = yield call(Api.getAllAssets, assetType, queryParams);
50
+ const result = yield call(Api.getAllAssets, { assetType, queryParams });
49
51
  yield put({ type: types.GET_ALL_ASSETS_SUCCESS, data: result?.response, isReset: queryParams.page === 1 });
50
52
  } catch (error) {
51
53
  yield put({ type: types.GET_ALL_ASSETS_FAILURE, error });
52
54
  }
53
55
  }
54
56
 
55
- export function* getCmsSetting({cmsType, projectId, cmsMode, langId, isEdmSupport}) {
57
+ export function* getCmsSetting({
58
+ cmsType, projectId, cmsMode, langId, isEdmSupport,
59
+ }) {
56
60
  try {
57
61
  const result = yield call(Api.getCmsTemplateSettings, cmsType, projectId, cmsMode, langId, isEdmSupport);
58
62
  yield put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: result.data.response.cmsDetails });
@@ -61,7 +65,7 @@ export function* getCmsSetting({cmsType, projectId, cmsMode, langId, isEdmSuppor
61
65
  }
62
66
  }
63
67
 
64
- export function* getCmsData({cmsType, projectId, langId}) {
68
+ export function* getCmsData({ cmsType, projectId, langId }) {
65
69
  try {
66
70
  const result = yield call(Api.getCmsTemplateData, cmsType, projectId, langId);
67
71
  yield put({ type: types.GET_CMS_EDITOR_DATA_SUCCESS, data: result.data.response.data, langId: result.data.response.langId });
@@ -1,29 +1,32 @@
1
1
  import { expectSaga } from 'redux-saga-test-plan';
2
- import { call, put } from 'redux-saga/effects';
2
+ import { call } from 'redux-saga/effects';
3
3
  import { throwError } from 'redux-saga-test-plan/providers';
4
- import * as Api from '../../../services/api';
5
- import * as types from '../constants';
6
- import * as sagas from '../sagas';
4
+ import * as Api from '../../../services/api';
5
+ import * as types from '../constants';
6
+ import * as sagas from '../sagas';
7
7
 
8
8
  describe('Email Template Sagas', () => {
9
+ // Increase timeout to prevent timeout warnings
10
+ jest.setTimeout(1000);
11
+
9
12
  describe('createTemplate Saga', () => {
10
13
  const template = { name: 'New Template' };
11
14
 
12
15
  it('handles creating a template successfully', () => {
13
16
  const fakeResponse = {
14
17
  response: { id: 1, name: 'New Template' },
15
- status: { code: 200 }
18
+ status: { code: 200 },
16
19
  };
17
20
 
18
21
  return expectSaga(sagas.createTemplate, template)
19
22
  .provide([
20
- [call(Api.createEmailTemplate, template), fakeResponse]
23
+ [call(Api.createEmailTemplate, template), fakeResponse],
21
24
  ])
22
25
  .put({
23
26
  type: types.CREATE_TEMPLATE_SUCCESS,
24
27
  data: fakeResponse.response,
25
28
  statusCode: 200,
26
- errorMsg: undefined
29
+ errorMsg: undefined,
27
30
  })
28
31
  .run();
29
32
  });
@@ -33,12 +36,12 @@ describe('Email Template Sagas', () => {
33
36
 
34
37
  return expectSaga(sagas.createTemplate, template)
35
38
  .provide([
36
- [call(Api.createEmailTemplate, template), throwError(error)]
39
+ [call(Api.createEmailTemplate, template), throwError(error)],
37
40
  ])
38
41
  .put({
39
42
  type: types.CREATE_TEMPLATE_FAILURE,
40
43
  error,
41
- errorMsg: undefined
44
+ errorMsg: undefined,
42
45
  })
43
46
  .run();
44
47
  });
@@ -51,18 +54,18 @@ describe('Email Template Sagas', () => {
51
54
  it('handles duplicating a template successfully', () => {
52
55
  const fakeResponse = {
53
56
  response: { id: 2, name: 'Duplicated Template' },
54
- status: { code: 200 }
57
+ status: { code: 200 },
55
58
  };
56
59
 
57
60
  return expectSaga(sagas.duplicateTemplate, id, channel)
58
61
  .provide([
59
- [call(Api.duplicateTemplate, id, channel), fakeResponse]
62
+ [call(Api.duplicateTemplate, id, channel), fakeResponse],
60
63
  ])
61
64
  .put({
62
65
  type: types.DUPLICATE_TEMPLATE_SUCCESS,
63
66
  data: fakeResponse.response,
64
67
  statusCode: 200,
65
- errorMsg: undefined
68
+ errorMsg: undefined,
66
69
  })
67
70
  .run();
68
71
  });
@@ -72,12 +75,12 @@ describe('Email Template Sagas', () => {
72
75
 
73
76
  return expectSaga(sagas.duplicateTemplate, id, channel)
74
77
  .provide([
75
- [call(Api.duplicateTemplate, id, channel), throwError(error)]
78
+ [call(Api.duplicateTemplate, id, channel), throwError(error)],
76
79
  ])
77
80
  .put({
78
81
  type: types.DUPLICATE_TEMPLATE_FAILURE,
79
82
  error,
80
- errorMsg: undefined
83
+ errorMsg: undefined,
81
84
  })
82
85
  .run();
83
86
  });
@@ -88,16 +91,16 @@ describe('Email Template Sagas', () => {
88
91
 
89
92
  it('handles fetching template details successfully', () => {
90
93
  const fakeResponse = {
91
- response: { id: 123, name: 'Detailed Template' }
94
+ response: { id: 123, name: 'Detailed Template' },
92
95
  };
93
96
 
94
97
  return expectSaga(sagas.getTemplateDetails, id)
95
98
  .provide([
96
- [call(Api.getTemplateDetails, id), fakeResponse]
99
+ [call(Api.getTemplateDetails, id), fakeResponse],
97
100
  ])
98
101
  .put({
99
102
  type: types.GET_TEMPLATE_DETAILS_SUCCESS,
100
- data: fakeResponse.response
103
+ data: fakeResponse.response,
101
104
  })
102
105
  .run();
103
106
  });
@@ -107,71 +110,70 @@ describe('Email Template Sagas', () => {
107
110
 
108
111
  return expectSaga(sagas.getTemplateDetails, id)
109
112
  .provide([
110
- [call(Api.getTemplateDetails, id), throwError(error)]
113
+ [call(Api.getTemplateDetails, id), throwError(error)],
111
114
  ])
112
115
  .put({
113
116
  type: types.GET_TEMPLATE_DETAILS_FAILURE,
114
- error
117
+ error,
115
118
  })
116
119
  .run();
117
120
  });
118
121
  });
119
122
 
120
123
  describe('getAllAssets Saga', () => {
124
+ const mockAssets = [{ id: 1, url: 'http://example.com/asset.jpg' }];
125
+ const mockError = new Error('Fetch failed');
121
126
  const assetType = 'image';
122
127
  const queryParams = { page: 1 };
123
128
 
124
129
  it('handles fetching all assets successfully', () => {
125
- const fakeResponse = {
126
- response: [{ id: 1, url: 'http://example.com/asset.jpg' }],
130
+ const result = {
131
+ response: { data: { data: mockAssets } },
127
132
  };
128
-
129
- return expectSaga(sagas.getAllAssets, assetType, queryParams)
133
+ return expectSaga(sagas.getAllAssets, { assetType, queryParams })
130
134
  .provide([
131
- [call(Api.getAllAssets, assetType, queryParams), fakeResponse]
135
+ [call(Api.getAllAssets, { assetType, queryParams }), result],
132
136
  ])
133
137
  .put({
134
138
  type: types.GET_ALL_ASSETS_SUCCESS,
135
- data: fakeResponse.response,
136
- isReset: true
139
+ data: { data: { data: mockAssets } }, // Match the exact nested structure
140
+ isReset: true,
137
141
  })
138
- .run();
142
+ .run(500);
139
143
  });
140
144
 
141
- it('handles failure in fetching all assets', () => {
142
- const error = new Error('Fetch failed');
143
-
144
- return expectSaga(sagas.getAllAssets, assetType, queryParams)
145
- .provide([
146
- [call(Api.getAllAssets, assetType, queryParams), throwError(error)]
147
- ])
148
- .put({
149
- type: types.GET_ALL_ASSETS_FAILURE,
150
- error
151
- })
152
- .run();
153
- });
145
+ it('handles failure in fetching all assets', () => expectSaga(sagas.getAllAssets, { assetType, queryParams })
146
+ .provide([
147
+ [call(Api.getAllAssets, { assetType, queryParams }), throwError(mockError)],
148
+ ])
149
+ .put({
150
+ type: types.GET_ALL_ASSETS_FAILURE,
151
+ error: mockError,
152
+ })
153
+ .run(500));
154
154
  });
155
155
 
156
156
  describe('getCmsSetting Saga', () => {
157
- const params = { cmsType: 'email', projectId: '123', cmsMode: 'edit', langId: 'en', isEdmSupport: true };
157
+ const params = {
158
+ cmsType: 'email', projectId: '123', cmsMode: 'edit', langId: 'en', isEdmSupport: true,
159
+ };
158
160
 
159
161
  it('handles fetching CMS settings successfully', () => {
160
162
  const fakeResponse = {
161
163
  data: {
162
164
  response: {
163
- cmsDetails: { id: 1, name: 'CMS Config' }
164
- }
165
- }
165
+ cmsDetails: { id: 1, name: 'CMS Config' },
166
+ },
167
+ },
166
168
  };
167
169
 
168
170
  return expectSaga(sagas.getCmsSetting, params)
169
171
  .provide([
170
- [call(Api.getCmsTemplateSettings, params.cmsType, params.projectId, params.cmsMode, params.langId, params.isEdmSupport), fakeResponse]
172
+ [call(Api.getCmsTemplateSettings, params.cmsType, params.projectId, params.cmsMode, params.langId, params.isEdmSupport), fakeResponse],
171
173
  ])
172
174
  .put({
173
175
  type: types.GET_CMS_EDITOR_DETAILS_SUCCESS,
174
- settings: fakeResponse.data.response.cmsDetails
176
+ settings: fakeResponse.data.response.cmsDetails,
175
177
  })
176
178
  .run();
177
179
  });
@@ -181,11 +183,11 @@ describe('Email Template Sagas', () => {
181
183
 
182
184
  return expectSaga(sagas.getCmsSetting, params)
183
185
  .provide([
184
- [call(Api.getCmsTemplateSettings, params.cmsType, params.projectId, params.cmsMode, params.langId, params.isEdmSupport), throwError(error)]
186
+ [call(Api.getCmsTemplateSettings, params.cmsType, params.projectId, params.cmsMode, params.langId, params.isEdmSupport), throwError(error)],
185
187
  ])
186
188
  .put({
187
189
  type: types.GET_CMS_EDITOR_DETAILS_FAILURE,
188
- error
190
+ error,
189
191
  })
190
192
  .run();
191
193
  });
@@ -199,19 +201,19 @@ describe('Email Template Sagas', () => {
199
201
  data: {
200
202
  response: {
201
203
  data: { id: 1, content: 'Content here' },
202
- langId: 'en'
203
- }
204
- }
204
+ langId: 'en',
205
+ },
206
+ },
205
207
  };
206
208
 
207
209
  return expectSaga(sagas.getCmsData, params)
208
210
  .provide([
209
- [call(Api.getCmsTemplateData, params.cmsType, params.projectId, params.langId), fakeResponse]
211
+ [call(Api.getCmsTemplateData, params.cmsType, params.projectId, params.langId), fakeResponse],
210
212
  ])
211
213
  .put({
212
214
  type: types.GET_CMS_EDITOR_DATA_SUCCESS,
213
215
  data: fakeResponse.data.response.data,
214
- langId: fakeResponse.data.response.langId
216
+ langId: fakeResponse.data.response.langId,
215
217
  })
216
218
  .run();
217
219
  });
@@ -221,11 +223,11 @@ describe('Email Template Sagas', () => {
221
223
 
222
224
  return expectSaga(sagas.getCmsData, params)
223
225
  .provide([
224
- [call(Api.getCmsTemplateData, params.cmsType, params.projectId, params.langId), throwError(error)]
226
+ [call(Api.getCmsTemplateData, params.cmsType, params.projectId, params.langId), throwError(error)],
225
227
  ])
226
228
  .put({
227
229
  type: types.GET_CMS_EDITOR_DATA_FAILURE,
228
- error
230
+ error,
229
231
  })
230
232
  .run();
231
233
  });
@@ -239,17 +241,17 @@ describe('Email Template Sagas', () => {
239
241
  it('handles successful asset upload', () => {
240
242
  const fakeResponse = {
241
243
  response: { asset: { id: 1, url: 'http://example.com/asset.jpg' } },
242
- status: { code: '200' }
244
+ status: { code: '200' },
243
245
  };
244
246
 
245
247
  return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
246
248
  .provide([
247
- [call(Api.uploadFile, file, assetType, fileParams), fakeResponse]
249
+ [call(Api.uploadFile, file, assetType, fileParams), fakeResponse],
248
250
  ])
249
251
  .put({
250
252
  type: types.UPLOAD_ASSET_SUCCESS,
251
253
  data: fakeResponse.response.asset,
252
- statusCode: '200'
254
+ statusCode: '200',
253
255
  })
254
256
  .run();
255
257
  });
@@ -259,20 +261,18 @@ describe('Email Template Sagas', () => {
259
261
 
260
262
  return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
261
263
  .provide([
262
- [call(Api.uploadFile, file, assetType, fileParams), throwError(error)]
264
+ [call(Api.uploadFile, file, assetType, fileParams), throwError(error)],
263
265
  ])
264
266
  .put({
265
267
  type: types.UPLOAD_ASSET_FAILURE,
266
- error
268
+ error,
267
269
  })
268
270
  .run();
269
271
  });
270
272
  });
271
273
 
272
274
  describe('Combined emailSaga', () => {
273
- it('should initialize all email-related watcher sagas without error', () => {
274
- return expectSaga(sagas.emailSaga)
275
- .run();
276
- });
275
+ it('should initialize all email-related watcher sagas without error', () => expectSaga(sagas.emailSaga)
276
+ .run());
277
277
  });
278
- });
278
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.82",
4
+ "version": "8.0.85",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -1013,4 +1013,7 @@
1013
1013
  }
1014
1014
  .viber-image-preview {
1015
1015
  width: 9.75rem;
1016
+ }
1017
+ .line-image-preview{
1018
+ max-width: 8.57rem;;
1016
1019
  }
@@ -758,6 +758,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
758
758
  <CapImage
759
759
  src={previewImageUrl}
760
760
  alt="brand-name"
761
+ className="line-image-preview"
761
762
  rest={{
762
763
  style: {
763
764
  maxWidth: "100%",
@@ -799,6 +800,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
799
800
  baseUrl ? `${baseUrl}/1040` : lineImgPlaceholder
800
801
  }
801
802
  alt="brand-name"
803
+ className="line-image-preview"
802
804
  rest={{
803
805
  style: {
804
806
  maxWidth: "100%",
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
 
8
- import * as types from "../../MobilePush/Edit/constants";
8
+ import * as types from "./constants";
9
9
 
10
10
  export function defaultAction() {
11
11
  return {
@@ -14,23 +14,23 @@ export function defaultAction() {
14
14
  }
15
15
 
16
16
  export function editTemplate(template, callback) {
17
-
18
17
  return {
19
18
  type: types.EDIT_TEMPLATE_REQUEST, template, callback,
20
19
  };
21
20
  }
22
21
 
23
22
  export function getTemplateDetails(id) {
24
-
25
23
  return {
26
24
  type: types.GET_TEMPLATE_DETAILS_REQUEST, id,
27
25
  };
28
26
  }
27
+
29
28
  export function getIosCtas(licenseCode) {
30
29
  return {
31
30
  type: types.GET_IOS_CTAS, licenseCode,
32
31
  };
33
32
  }
33
+
34
34
  export function uploadAsset(file, assetType, fileParams, mode) {
35
35
  return {
36
36
  type: types.UPLOAD_ASSET_REQUEST,
@@ -41,16 +41,17 @@ export function uploadAsset(file, assetType, fileParams, mode) {
41
41
  };
42
42
  }
43
43
  export function clearEditResponse() {
44
-
45
44
  return {
46
45
  type: types.CLEAR_EDIT_RESPONSE_REQUEST,
47
46
  };
48
47
  }
48
+
49
49
  export function clearData() {
50
50
  return {
51
51
  type: types.CLEAR_DATA,
52
52
  };
53
53
  }
54
+
54
55
  export function clearAsset() {
55
56
  return {
56
57
  type: types.CLEAR_ASSET,
@@ -69,6 +70,7 @@ export function setWeChatAccount(weChatAccount) {
69
70
  weChatAccount,
70
71
  };
71
72
  }
73
+
72
74
  export function getMobilepushTemplatesList(channel, queryParams) {
73
75
  return {
74
76
  type: types.GET_MOBILEPUSH_TEMPLATES_LIST_REQUEST,
@@ -76,6 +78,7 @@ export function getMobilepushTemplatesList(channel, queryParams) {
76
78
  queryParams,
77
79
  };
78
80
  }
81
+
79
82
  export function setSelectedTemplate(templateData) {
80
83
  return {
81
84
  type: types.SET_SELECTED_TEMPLATE,
@@ -1,4 +1,3 @@
1
-
2
1
  /*
3
2
  *
4
3
  * Create
@@ -525,8 +524,16 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
525
524
  }
526
525
  return actionLink;
527
526
  }).filter((actionLink) => actionLink);
527
+ // Check if base URL already has query parameters
528
+ const baseUrl = obj.versions.base.ANDROID.cta.actionLink;
528
529
  if (params.length) {
529
- obj.versions.base.ANDROID.cta.actionLink = `${obj.versions.base.ANDROID.cta.actionLink}?${params.join('&')}`;
530
+ // Only append parameters if the URL doesn't already have them
531
+ if (baseUrl.indexOf('?') === -1) {
532
+ obj.versions.base.ANDROID.cta.actionLink = `${baseUrl}?${params.join('&')}`;
533
+ } else {
534
+ // URL already has parameters, don't append them again
535
+ obj.versions.base.ANDROID.cta.actionLink = baseUrl;
536
+ }
530
537
  }
531
538
  }
532
539
  }
@@ -596,8 +603,16 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
596
603
  }
597
604
  return actionLink;
598
605
  }).filter((actionLink) => actionLink);
606
+ // Check if base URL already has query parameters
607
+ const baseUrl = obj.versions.base.IOS.cta.actionLink;
599
608
  if (params.length) {
600
- obj.versions.base.IOS.cta.actionLink = `${obj.versions.base.IOS.cta.actionLink}?${params.join('&')}`;
609
+ // Only append parameters if the URL doesn't already have them
610
+ if (baseUrl.indexOf('?') === -1) {
611
+ obj.versions.base.IOS.cta.actionLink = `${baseUrl}?${params.join('&')}`;
612
+ } else {
613
+ // URL already has parameters, don't append them again
614
+ obj.versions.base.IOS.cta.actionLink = baseUrl;
615
+ }
601
616
  }
602
617
  }
603
618
  }
@@ -743,14 +758,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
743
758
  } else {
744
759
  android['cta-deeplink-text'] = androidData ? androidData.cta.actionLink : '';
745
760
  }
746
- if (androidData.cta.type === "DEEP_LINK" ) {
747
- const link = android['cta-deeplink-select'].split('?')[0];
748
- const params = android['cta-deeplink-select'].split('?')[1] && android['cta-deeplink-select'].split('?')[1].split('&');
749
- android['cta-deeplink-select'] = link;
750
- _.forEach(params, (param) => {
751
- android[`custom-value-${param.split('=')[0]}-cta-deeplink-select`] = param.split('=')[1];
752
- });
753
- }
754
761
  }
755
762
  if (androidData.expandableDetails && androidData.expandableDetails.image) {
756
763
  android.image = androidData.expandableDetails.image;
@@ -765,30 +772,59 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
765
772
  }
766
773
  android['secondary-cta-0-label'] = androidData.expandableDetails.ctas[0].actionText;
767
774
  if (androidData.expandableDetails.ctas[0].type === "DEEP_LINK") {
768
- const link = android['cta-deeplink-secondary-cta-0-select'].split('?')[0];
769
- const params = android['cta-deeplink-secondary-cta-0-select'].split('?')[1] && android['cta-deeplink-secondary-cta-0-select'].split('?')[1].split('&');
770
- android['cta-deeplink-secondary-cta-0-select'] = link;
771
- _.forEach(params, (param) => {
772
- android[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-0-select`] = param.split('=')[1];
773
- });
774
- }
775
- }
776
- if (androidData.expandableDetails && androidData.expandableDetails.ctas && androidData.expandableDetails.ctas.length > 1) {
777
- android['add-sec-cta-2'] = true;
778
- android['cta-deeplink-secondary-cta-1'] = androidData.expandableDetails.ctas[1].type === "DEEP_LINK" ? "Deeplink" : "External Link";
779
- if (androidData.expandableDetails.ctas[1].type === "DEEP_LINK") {
780
- android['cta-deeplink-secondary-cta-1-select'] = androidData.expandableDetails.ctas[1].actionLink;
781
- } else {
782
- android['cta-deeplink-secondary-cta-1-text'] = androidData.expandableDetails.ctas[1].actionLink;
775
+ const originalUrl = android['cta-deeplink-secondary-cta-0-select'];
776
+
777
+ // Check if URL contains custom parameters that need extraction
778
+ if (originalUrl.includes('custom_param=')) {
779
+ const link = originalUrl.split('?')[0];
780
+ const params = originalUrl.split('?')[1] && originalUrl.split('?')[1].split('&');
781
+
782
+ // Only process and extract custom parameters
783
+ const customParams = params?.filter(param => param.startsWith('custom_param='));
784
+
785
+ if (customParams?.length) {
786
+ android['cta-deeplink-secondary-cta-0-select'] = link;
787
+ _.forEach(customParams, (param) => {
788
+ android[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-0-select`] = param.split('=')[1];
789
+ });
790
+ }
791
+ }
792
+ // If no custom parameters, keep original URL intact
793
+ // android['cta-deeplink-secondary-cta-0-select'] remains unchanged
783
794
  }
784
- android['secondary-cta-1-label'] = androidData.expandableDetails.ctas[1].actionText;
785
- if (androidData.expandableDetails.ctas[1].type === "DEEP_LINK" && android['cta-deeplink-secondary-cta-1-select']) {
786
- const link = android['cta-deeplink-secondary-cta-1-select'].split('?')[0];
787
- const params = android['cta-deeplink-secondary-cta-1-select'].split('?')[1] && android['cta-deeplink-secondary-cta-1-select'].split('?')[1].split('&');
788
- android['cta-deeplink-secondary-cta-1-select'] = link;
789
- _.forEach(params, (param) => {
790
- android[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select`] = param.split('=')[1];
791
- });
795
+ if (androidData.expandableDetails && androidData.expandableDetails.ctas && androidData.expandableDetails.ctas.length > 1) {
796
+ android['add-sec-cta-2'] = true;
797
+ android['cta-deeplink-secondary-cta-1'] = androidData.expandableDetails.ctas[1].type === "DEEP_LINK" ? "Deeplink" : "External Link";
798
+ if (androidData.expandableDetails.ctas[1].type === "DEEP_LINK") {
799
+ android['cta-deeplink-secondary-cta-1-select'] = androidData.expandableDetails.ctas[1].actionLink;
800
+ } else {
801
+ android['cta-deeplink-secondary-cta-1-text'] = androidData.expandableDetails.ctas[1].actionLink;
802
+ }
803
+ android['secondary-cta-1-label'] = androidData.expandableDetails.ctas[1].actionText;
804
+ if (androidData.expandableDetails.ctas[1].type === "DEEP_LINK" && android['cta-deeplink-secondary-cta-1-select']) {
805
+ const originalUrl = android['cta-deeplink-secondary-cta-1-select'];
806
+
807
+ // Check if URL contains custom parameters that need extraction
808
+ if (originalUrl.includes('custom_param=')) {
809
+ const link = originalUrl.split('?')[0];
810
+ const params = originalUrl.split('?')[1] && originalUrl.split('?')[1].split('&');
811
+
812
+ // Only process and extract custom parameters
813
+ const customParams = params?.filter(param => param.startsWith('custom_param='));
814
+
815
+ if (customParams?.length) {
816
+ android['cta-deeplink-secondary-cta-1-select'] = link;
817
+ _.forEach(customParams, (param) => {
818
+ android[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select`] = param.split('=')[1];
819
+ });
820
+ }
821
+ }
822
+ // If no custom parameters, keep original URL intact
823
+ // android['cta-deeplink-secondary-cta-1-select'] remains unchanged
824
+ }
825
+ if (androidData.expandableDetails && androidData.expandableDetails.ctas?.[1]?.type === "DEEP_LINK") {
826
+ android['cta-deeplink-secondary-cta-1-select'] = androidData.expandableDetails.ctas[1].actionLink;
827
+ }
792
828
  }
793
829
  }
794
830
  }
@@ -809,17 +845,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
809
845
  } else {
810
846
  ios['cta-deeplink2-text'] = iosData ? iosData.cta.actionLink : '';
811
847
  }
812
- if (iosData.cta.type === "DEEP_LINK") {
813
- const link = ios['cta-deeplink2-select'].split('?')[0];
814
- let params = ios['cta-deeplink2-select'].split('?');
815
- if (params[1]) {
816
- params = params[1].split('&');
817
- _.forEach(params, (param) => {
818
- ios[`custom-value-${param.split('=')[0]}-cta-deeplink2-select`] = param.split('=')[1];
819
- });
820
- }
821
- ios['cta-deeplink2-select'] = link;
822
- }
823
848
  }
824
849
  if (iosData.expandableDetails && iosData.expandableDetails.image) {
825
850
  ios.image = iosData.expandableDetails.image;
@@ -836,12 +861,25 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
836
861
  }
837
862
  ios['secondary-cta-1-label'] = iosData.expandableDetails.ctas[0].actionText;
838
863
  if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK" && ios['cta-deeplink-secondary-cta-1-select2']) {
839
- const link = ios['cta-deeplink-secondary-cta-1-select2'].split('?')[0];
840
- const paramsIos = ios['cta-deeplink-secondary-cta-1-select2'].split('?')[1] && ios['cta-deeplink-secondary-cta-1-select2'].split('?')[1].split('&');
841
- ios['cta-deeplink-secondary-cta-1-select2'] = link;
842
- _.forEach(paramsIos, (param) => {
843
- ios[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select2`] = param.split('=')[1];
844
- });
864
+ const originalUrl = ios['cta-deeplink-secondary-cta-1-select2'];
865
+
866
+ // Check if URL contains custom parameters that need extraction
867
+ if (originalUrl.includes('custom_param=')) {
868
+ const link = originalUrl.split('?')[0];
869
+ const params = originalUrl.split('?')[1] && originalUrl.split('?')[1].split('&');
870
+
871
+ // Only process and extract custom parameters
872
+ const customParams = params?.filter(param => param.startsWith('custom_param='));
873
+
874
+ if (customParams?.length) {
875
+ ios['cta-deeplink-secondary-cta-1-select2'] = link;
876
+ _.forEach(customParams, (param) => {
877
+ ios[`custom-value-${param.split('=')[0]}-cta-deeplink-secondary-cta-1-select2`] = param.split('=')[1];
878
+ });
879
+ }
880
+ }
881
+ // If no custom parameters, keep original URL intact
882
+ // ios['cta-deeplink-secondary-cta-1-select2'] remains unchanged
845
883
  }
846
884
  set(templateCta, "ctaTemplateDetails[0].buttonText", iosData.expandableDetails.ctas[0].actionLabel);
847
885
  set(templateCta, "name", iosData.expandableDetails.ctas[0].actionText);