@capillarytech/creatives-library 7.17.169 → 7.17.171-alpha.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.
- package/index.js +0 -6
- package/package.json +1 -1
- package/services/api.js +2 -2
- package/v2Components/FormBuilder/_formBuilder.scss +1 -0
- package/v2Containers/CreativesContainer/index.js +2 -0
- package/v2Containers/Templates/index.js +13 -0
- package/v2Containers/Templates/sagas.js +2 -1
- package/v2Containers/Templates/tests/index.test.js +1 -0
- package/v2Containers/Templates/tests/sagas.test.js +54 -1
- package/v2Containers/Whatsapp/index.js +14 -7
- package/v2Containers/Zalo/index.js +11 -8
- package/v2Containers/Zalo/selectors.js +1 -1
- package/v2Containers/Zalo/tests/mockData.js +46 -0
- package/v2Containers/Zalo/tests/selector.test.js +3 -3
package/index.js
CHANGED
|
@@ -3,9 +3,6 @@ import capReducer from './v2Containers/Cap/reducer';
|
|
|
3
3
|
import capSaga from './v2Containers/Cap/sagas';
|
|
4
4
|
import Cap from './v2Containers/Cap/index';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
6
|
import LanguageProvider from './v2Containers/LanguageProvider';
|
|
10
7
|
import LanguageProviderReducer from './v2Containers/LanguageProvider/reducer';
|
|
11
8
|
import LanguageProviderSaga from './v2Containers/LanguageProvider/sagas';
|
|
@@ -19,9 +16,6 @@ import smsCreateReducer from './v2Containers/Sms/Create/reducer';
|
|
|
19
16
|
import smsCreateSaga from './v2Containers/Sms/Create/sagas';
|
|
20
17
|
|
|
21
18
|
import SmsEdit from './v2Containers/Sms/Edit/index';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
19
|
import smsEditReducer from './v2Containers/Sms/Edit/reducer';
|
|
26
20
|
import smsEditSaga from './v2Containers/Sms/Edit/sagas';
|
|
27
21
|
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -525,8 +525,8 @@ export const getS3UrlFileSizes = (data) => {
|
|
|
525
525
|
return request(url, getAPICallObject('POST', data));
|
|
526
526
|
};
|
|
527
527
|
|
|
528
|
-
export const getTemplateInfoById = ({id, username, oa_id, token}) => {
|
|
529
|
-
const url = `${API_ENDPOINT}/templates/v1/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}`;
|
|
528
|
+
export const getTemplateInfoById = ({id, username, oa_id, token, host}) => {
|
|
529
|
+
const url = `${API_ENDPOINT}/templates/v1/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}&host=${host}`;
|
|
530
530
|
const compressedTemplatesData = request(url, getAPICallObject('GET'));
|
|
531
531
|
return compressedTemplatesData.then((data) => {
|
|
532
532
|
const { response = '' } = data || {};
|
|
@@ -124,10 +124,12 @@ export class Creatives extends React.Component {
|
|
|
124
124
|
sourceAccountIdentifier = "",
|
|
125
125
|
configs: { token = "" } = {},
|
|
126
126
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
127
|
+
const { hostName = ''} = get(this.props, "Templates.senderDetails", {});
|
|
127
128
|
this.props.zaloActions.getTemplateInfoById({
|
|
128
129
|
username: name,
|
|
129
130
|
oa_id: sourceAccountIdentifier,
|
|
130
131
|
token,
|
|
132
|
+
host: hostName,
|
|
131
133
|
id: template?._id,
|
|
132
134
|
preview: true,
|
|
133
135
|
actionCallback: this.actionCallback,
|
|
@@ -305,6 +305,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
305
305
|
channel = 'Zalo';
|
|
306
306
|
activeMode = ACCOUNT_SELECTION_MODE;
|
|
307
307
|
this.props.actions.getWeCrmAccounts(channel);
|
|
308
|
+
this.props.actions.getSenderDetails({
|
|
309
|
+
channel: ZALO,
|
|
310
|
+
orgUnitId: -1,
|
|
311
|
+
});
|
|
308
312
|
break;
|
|
309
313
|
default:
|
|
310
314
|
channel = '';
|
|
@@ -631,6 +635,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
631
635
|
paramsDefault.username = name;
|
|
632
636
|
paramsDefault.oa_id = sourceAccountIdentifier;
|
|
633
637
|
paramsDefault.token = token;
|
|
638
|
+
paramsDefault.host = hostName;
|
|
634
639
|
} else {
|
|
635
640
|
paramsDefault.wecrmId = wecrm_app_id;
|
|
636
641
|
paramsDefault.wecrmToken = wecrm_token;
|
|
@@ -695,11 +700,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
695
700
|
name = "",
|
|
696
701
|
sourceAccountIdentifier = "",
|
|
697
702
|
configs: { token = "" } = {},
|
|
703
|
+
hostName = "",
|
|
698
704
|
} = setAcc || {};
|
|
699
705
|
params.username = name;
|
|
700
706
|
params.oa_id = sourceAccountIdentifier;
|
|
701
707
|
params.token = token;
|
|
702
708
|
params.isAccountSelection = true;
|
|
709
|
+
params.host = hostName || this.state.hostName;
|
|
703
710
|
}
|
|
704
711
|
}
|
|
705
712
|
|
|
@@ -799,6 +806,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
799
806
|
if(this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
|
|
800
807
|
queryParams.name = this.state.searchText;
|
|
801
808
|
queryParams.sortBy = this.state.sortBy;
|
|
809
|
+
} else {
|
|
810
|
+
queryParams.host = this.props.Templates?.senderDetails?.hostName;
|
|
802
811
|
}
|
|
803
812
|
queryParams.page = this.state.page;
|
|
804
813
|
queryParams.perPage = this.state.perPageLimit;
|
|
@@ -853,14 +862,17 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
853
862
|
name = "",
|
|
854
863
|
sourceAccountIdentifier = "",
|
|
855
864
|
configs: { token = "" } = {},
|
|
865
|
+
hostName = "",
|
|
856
866
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
857
867
|
queryParams.username = name;
|
|
858
868
|
queryParams.oa_id = sourceAccountIdentifier;
|
|
859
869
|
queryParams.token = token;
|
|
870
|
+
queryParams.host = hostName || this.state.hostName;
|
|
860
871
|
}
|
|
861
872
|
this.setState({ page, templatesCount }, () => {
|
|
862
873
|
queryParams.page = page;
|
|
863
874
|
queryParams.perPage = this.state.perPageLimit;
|
|
875
|
+
queryParams.host = this.state.hostName;
|
|
864
876
|
const channel = this.state.channel;
|
|
865
877
|
this.props.actions.getAllTemplates(channel, queryParams, `${copyOf}`);
|
|
866
878
|
});
|
|
@@ -2107,6 +2119,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2107
2119
|
username: name,
|
|
2108
2120
|
oa_id: sourceAccountIdentifier,
|
|
2109
2121
|
token: token,
|
|
2122
|
+
host: this.state.hostName,
|
|
2110
2123
|
id: template?._id,
|
|
2111
2124
|
preview: true,
|
|
2112
2125
|
actionCallback: this.actionCallback,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
1
2
|
import { call, put, takeLatest, take, cancel, select } from 'redux-saga/effects';
|
|
2
3
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
4
|
// import { schema, normalize } from 'normalizr';
|
|
@@ -176,7 +177,7 @@ export function* getSenderDetails({
|
|
|
176
177
|
if (!apiResponse?.errors?.length) {
|
|
177
178
|
yield put({
|
|
178
179
|
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
179
|
-
payload: apiResponse
|
|
180
|
+
payload: get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
|
|
180
181
|
});
|
|
181
182
|
} else {
|
|
182
183
|
yield put({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
|
-
import { take, call, takeLatest, takeEvery } from 'redux-saga/effects';
|
|
2
|
+
import { take, call, takeLatest, takeEvery, put } from 'redux-saga/effects';
|
|
3
3
|
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
4
4
|
import * as api from '../../../services/api';
|
|
5
5
|
import * as types from '../constants';
|
|
@@ -10,9 +10,12 @@ import {
|
|
|
10
10
|
getAllTemplates,
|
|
11
11
|
watchGetCdnTransformationConfig,
|
|
12
12
|
watchGetAllTemplates,
|
|
13
|
+
getSenderDetails,
|
|
13
14
|
} from '../sagas';
|
|
14
15
|
|
|
15
16
|
import * as mockData from './mockData';
|
|
17
|
+
import { ZALO } from '../../CreativesContainer/constants';
|
|
18
|
+
import { VIET_GUYS } from '../../Zalo/constants';
|
|
16
19
|
|
|
17
20
|
describe('getCdnTransformationConfig saga', () => {
|
|
18
21
|
it("handle valid response from api", () => {
|
|
@@ -134,3 +137,53 @@ describe('watchForTemplates saga', () => {
|
|
|
134
137
|
);
|
|
135
138
|
});
|
|
136
139
|
});
|
|
140
|
+
|
|
141
|
+
describe('getSenderDetails Saga', () => {
|
|
142
|
+
const channel = 'someChannel';
|
|
143
|
+
const orgUnitId = 'someOrgUnitId';
|
|
144
|
+
const action = { channel, orgUnitId };
|
|
145
|
+
|
|
146
|
+
it('should handle apiResponse with hostName', () => {
|
|
147
|
+
const apiResponse = {
|
|
148
|
+
entity: {
|
|
149
|
+
[channel]: [
|
|
150
|
+
{
|
|
151
|
+
domainProperties: {
|
|
152
|
+
hostName: 'example.com',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const generator = getSenderDetails(action);
|
|
160
|
+
expect(generator.next().value).toEqual(call(api.getSenderDetails, channel, orgUnitId));
|
|
161
|
+
expect(generator.next(apiResponse).value).toEqual(
|
|
162
|
+
put({
|
|
163
|
+
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
164
|
+
payload: 'example.com',
|
|
165
|
+
})
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('should handle apiResponse without hostName', () => {
|
|
170
|
+
const apiResponse = {
|
|
171
|
+
entity: {
|
|
172
|
+
[channel]: [
|
|
173
|
+
{
|
|
174
|
+
domainProperties: {},
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const generator = getSenderDetails(action);
|
|
181
|
+
expect(generator.next().value).toEqual(call(api.getSenderDetails, channel, orgUnitId));
|
|
182
|
+
expect(generator.next(apiResponse).value).toEqual(
|
|
183
|
+
put({
|
|
184
|
+
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
185
|
+
payload: '',
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
@@ -839,7 +839,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
839
839
|
setUnsubscribeRequired(checked);
|
|
840
840
|
if (isAuthenticationTemplate) {
|
|
841
841
|
if (checked && !templateMessage?.includes(formatMessage(messages.securitySuffix))) {
|
|
842
|
-
setTemplateMessage(`${templateMessage}${formatMessage(messages.securitySuffix)}`);
|
|
842
|
+
setTemplateMessage(`${templateMessage} ${formatMessage(messages.securitySuffix)}`);
|
|
843
843
|
} else {
|
|
844
844
|
setTemplateMessage(formatMessage(messages.authenticationMsg));
|
|
845
845
|
}
|
|
@@ -1088,14 +1088,21 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1088
1088
|
setTemplateNameError(errorMessage);
|
|
1089
1089
|
};
|
|
1090
1090
|
|
|
1091
|
+
const resetCategoryRelatedStates = () => {
|
|
1092
|
+
setTemplateHeader('');
|
|
1093
|
+
setTemplateFooter('');
|
|
1094
|
+
setExpiryMinutes(0);
|
|
1095
|
+
setUnsubscribeRequired(false);
|
|
1096
|
+
setCtadata({});
|
|
1097
|
+
setQuickReplyData({});
|
|
1098
|
+
setTemplateMediaType(WHATSAPP_MEDIA_TYPES.TEXT)
|
|
1099
|
+
setGupshupMediaFile();
|
|
1100
|
+
setKarixFileHandle('');
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1091
1103
|
const onTemplateCategoryChange = (value) => {
|
|
1092
1104
|
if (value === WHATSAPP_CATEGORIES.authentication) {
|
|
1093
|
-
|
|
1094
|
-
setTemplateFooter('');
|
|
1095
|
-
setExpiryMinutes(0);
|
|
1096
|
-
setUnsubscribeRequired(false);
|
|
1097
|
-
setCtadata({});
|
|
1098
|
-
setQuickReplyData({});
|
|
1105
|
+
resetCategoryRelatedStates();
|
|
1099
1106
|
setTemplateMessage(formatMessage(messages.authenticationMsg));
|
|
1100
1107
|
} else {
|
|
1101
1108
|
setTemplateMessage('');
|
|
@@ -56,7 +56,7 @@ export const Zalo = (props) => {
|
|
|
56
56
|
isFullMode,
|
|
57
57
|
templateData = {},
|
|
58
58
|
editData = {},
|
|
59
|
-
accountData: { selectedZaloAccount = {} } = {},
|
|
59
|
+
accountData: { selectedZaloAccount = {}, senderDetails = {} } = {},
|
|
60
60
|
globalActions,
|
|
61
61
|
location,
|
|
62
62
|
getDefaultTags,
|
|
@@ -66,6 +66,7 @@ export const Zalo = (props) => {
|
|
|
66
66
|
getFormData,
|
|
67
67
|
selectedOfferDetails,
|
|
68
68
|
} = props || {};
|
|
69
|
+
const {hostName = ''} = senderDetails;
|
|
69
70
|
const { formatMessage } = intl;
|
|
70
71
|
const [oa_id, setOaId] = useState('');
|
|
71
72
|
const [token, setToken] = useState('');
|
|
@@ -121,11 +122,12 @@ export const Zalo = (props) => {
|
|
|
121
122
|
|
|
122
123
|
//gets template details
|
|
123
124
|
useEffect(() => {
|
|
124
|
-
if (zaloTempId && oa_id && token && username) {
|
|
125
|
+
if (zaloTempId && oa_id && token && username && hostName) {
|
|
125
126
|
actions.getTemplateInfoById({
|
|
126
127
|
username,
|
|
127
128
|
oa_id,
|
|
128
129
|
token,
|
|
130
|
+
host: hostName,
|
|
129
131
|
id: zaloTempId,
|
|
130
132
|
actionCallback,
|
|
131
133
|
});
|
|
@@ -134,10 +136,10 @@ export const Zalo = (props) => {
|
|
|
134
136
|
return () => {
|
|
135
137
|
actions.resetTemplateInfoData();
|
|
136
138
|
};
|
|
137
|
-
}, [zaloTempId, oa_id, token, username]);
|
|
139
|
+
}, [zaloTempId, oa_id, token, username, hostName]);
|
|
138
140
|
|
|
139
141
|
const handleSetValues = (paramsData = []) =>
|
|
140
|
-
paramsData
|
|
142
|
+
paramsData?.map((paramData) => {
|
|
141
143
|
for (const key in varMapped) {
|
|
142
144
|
if (paramData?.name === key) {
|
|
143
145
|
paramData.value = varMapped[key];
|
|
@@ -339,7 +341,7 @@ export const Zalo = (props) => {
|
|
|
339
341
|
|
|
340
342
|
const isEditDoneDisabled = () => {
|
|
341
343
|
let disableCheck = false;
|
|
342
|
-
templateListParams
|
|
344
|
+
templateListParams?.forEach((listParams) => {
|
|
343
345
|
const { error, value } = listParams;
|
|
344
346
|
const errorMessage = !error
|
|
345
347
|
? handleErrorValidation(value, listParams)
|
|
@@ -352,10 +354,11 @@ export const Zalo = (props) => {
|
|
|
352
354
|
};
|
|
353
355
|
const createPayload = () => {
|
|
354
356
|
const varMap = {};
|
|
355
|
-
templateListParams
|
|
356
|
-
const { name, value } = listParam;
|
|
357
|
+
templateListParams?.forEach((listParam) => {
|
|
358
|
+
const { name = '', value = '' } = listParam;
|
|
357
359
|
varMap[name] = value;
|
|
358
|
-
}
|
|
360
|
+
}
|
|
361
|
+
);
|
|
359
362
|
const payload = {
|
|
360
363
|
channel: ZALO,
|
|
361
364
|
accountId: oa_id,
|
|
@@ -11462,6 +11462,9 @@ export const accountData = {
|
|
|
11462
11462
|
modifiedDate: '2023-10-16T00:00:00+05:30',
|
|
11463
11463
|
},
|
|
11464
11464
|
},
|
|
11465
|
+
senderDetails: {
|
|
11466
|
+
hostName: 'vietguyszalotrans',
|
|
11467
|
+
},
|
|
11465
11468
|
};
|
|
11466
11469
|
|
|
11467
11470
|
export const templateData = {
|
|
@@ -11479,3 +11482,46 @@ export const templateConfigs = {
|
|
|
11479
11482
|
ma_so1: '4',
|
|
11480
11483
|
},
|
|
11481
11484
|
};
|
|
11485
|
+
|
|
11486
|
+
export const mockGapItTemplateData = [
|
|
11487
|
+
{
|
|
11488
|
+
_id: '354701',
|
|
11489
|
+
versions: {
|
|
11490
|
+
base: {
|
|
11491
|
+
content: {
|
|
11492
|
+
zalo: {
|
|
11493
|
+
templateName: 'Test',
|
|
11494
|
+
listParams: [
|
|
11495
|
+
{
|
|
11496
|
+
name: "Name",
|
|
11497
|
+
type: "STRING",
|
|
11498
|
+
require: true,
|
|
11499
|
+
maxLength: 80,
|
|
11500
|
+
minLength: 0,
|
|
11501
|
+
acceptNull: false,
|
|
11502
|
+
},
|
|
11503
|
+
{
|
|
11504
|
+
name: "So_dien_thoai",
|
|
11505
|
+
type: "STRING",
|
|
11506
|
+
require: true,
|
|
11507
|
+
maxLength: 30,
|
|
11508
|
+
minLength: 0,
|
|
11509
|
+
acceptNull: false,
|
|
11510
|
+
},
|
|
11511
|
+
{
|
|
11512
|
+
name: "so_du",
|
|
11513
|
+
type: "STRING",
|
|
11514
|
+
require: true,
|
|
11515
|
+
maxLength: 30,
|
|
11516
|
+
minLength: 0,
|
|
11517
|
+
acceptNull: false,
|
|
11518
|
+
},
|
|
11519
|
+
],
|
|
11520
|
+
previewUrl: 'https://account.zalo.cloud/znspreview/h84m64E6ST_owPQVFzTilg==',
|
|
11521
|
+
status: 'ENABLE',
|
|
11522
|
+
},
|
|
11523
|
+
},
|
|
11524
|
+
},
|
|
11525
|
+
},
|
|
11526
|
+
},
|
|
11527
|
+
];
|
|
@@ -5,7 +5,7 @@ describe("makeSelectZalo", () => {
|
|
|
5
5
|
it("returns the expected object with default values when substate is empty", () => {
|
|
6
6
|
// Arrange
|
|
7
7
|
const state = fromJS({ zalo: {} });
|
|
8
|
-
const expected = {}
|
|
8
|
+
const expected = {};
|
|
9
9
|
const selector = makeSelectZalo();
|
|
10
10
|
|
|
11
11
|
// Act
|
|
@@ -17,7 +17,7 @@ describe("makeSelectZalo", () => {
|
|
|
17
17
|
it("returns the expected object with default values when substate is empty for makeSelectAccount", () => {
|
|
18
18
|
// Arrange
|
|
19
19
|
const state = fromJS({ templates: {} });
|
|
20
|
-
const expected = {}
|
|
20
|
+
const expected = {};
|
|
21
21
|
const selector = makeSelectAccount();
|
|
22
22
|
|
|
23
23
|
// Act
|
|
@@ -25,4 +25,4 @@ describe("makeSelectZalo", () => {
|
|
|
25
25
|
// Assert
|
|
26
26
|
expect(result).toEqual(expected);
|
|
27
27
|
});
|
|
28
|
-
});
|
|
28
|
+
});
|