@capillarytech/creatives-library 7.17.169-alpha.3 → 7.17.169
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 +6 -0
- package/package.json +1 -1
- package/v2Components/FormBuilder/_formBuilder.scss +0 -1
- package/v2Containers/CreativesContainer/index.js +8 -14
- package/v2Containers/Templates/index.js +3 -12
- package/v2Containers/Templates/sagas.js +1 -1
- package/v2Containers/Templates/tests/index.test.js +0 -1
- package/v2Containers/Templates/tests/sagas.test.js +1 -54
- package/v2Containers/Whatsapp/index.js +7 -14
- package/v2Containers/Zalo/constants.js +0 -1
- package/v2Containers/Zalo/index.js +32 -73
- package/v2Containers/Zalo/selectors.js +1 -8
- package/v2Containers/Zalo/tests/mockData.js +0 -46
- package/v2Containers/Zalo/tests/selector.test.js +2 -25
package/index.js
CHANGED
|
@@ -3,6 +3,9 @@ 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
|
+
|
|
6
9
|
import LanguageProvider from './v2Containers/LanguageProvider';
|
|
7
10
|
import LanguageProviderReducer from './v2Containers/LanguageProvider/reducer';
|
|
8
11
|
import LanguageProviderSaga from './v2Containers/LanguageProvider/sagas';
|
|
@@ -16,6 +19,9 @@ import smsCreateReducer from './v2Containers/Sms/Create/reducer';
|
|
|
16
19
|
import smsCreateSaga from './v2Containers/Sms/Create/sagas';
|
|
17
20
|
|
|
18
21
|
import SmsEdit from './v2Containers/Sms/Edit/index';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
19
25
|
import smsEditReducer from './v2Containers/Sms/Edit/reducer';
|
|
20
26
|
import smsEditSaga from './v2Containers/Sms/Edit/sagas';
|
|
21
27
|
|
package/package.json
CHANGED
|
@@ -41,7 +41,6 @@ import { WHATSAPP_STATUSES, WHATSAPP_MEDIA_TYPES } from '../Whatsapp/constants';
|
|
|
41
41
|
|
|
42
42
|
import { updateImagesInHtml } from '../../utils/cdnTransformation';
|
|
43
43
|
import { IOS } from '../InApp/constants';
|
|
44
|
-
import { VIET_GUYS } from '../Zalo/constants';
|
|
45
44
|
|
|
46
45
|
const classPrefix = 'add-creatives-section';
|
|
47
46
|
const CREATIVES_CONTAINER = 'creativesContainer';
|
|
@@ -125,19 +124,14 @@ export class Creatives extends React.Component {
|
|
|
125
124
|
sourceAccountIdentifier = "",
|
|
126
125
|
configs: { token = "" } = {},
|
|
127
126
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
actionCallback: this.actionCallback,
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
window.open(template?.versions?.base?.content?.zalo?.previewUrl, '_blank');
|
|
140
|
-
}
|
|
127
|
+
this.props.zaloActions.getTemplateInfoById({
|
|
128
|
+
username: name,
|
|
129
|
+
oa_id: sourceAccountIdentifier,
|
|
130
|
+
token,
|
|
131
|
+
id: template?._id,
|
|
132
|
+
preview: true,
|
|
133
|
+
actionCallback: this.actionCallback,
|
|
134
|
+
});
|
|
141
135
|
}
|
|
142
136
|
};
|
|
143
137
|
onEditTemplate = () => {
|
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
HOST_GUPSHUP,
|
|
111
111
|
} from '../Whatsapp/constants';
|
|
112
112
|
import { INAPP_LAYOUT_DETAILS } from '../InApp/constants';
|
|
113
|
-
import {
|
|
113
|
+
import { ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
|
|
114
114
|
import { getWhatsappContent, getWhatsappStatus, getWhatsappCategory, getWhatsappCta, getWhatsappQuickReply, getWhatsappAutoFill } from '../Whatsapp/utils';
|
|
115
115
|
import { getRCSContent } from '../Rcs/utils';
|
|
116
116
|
import zaloMessages from '../Zalo/messages';
|
|
@@ -305,10 +305,6 @@ 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
|
-
});
|
|
312
308
|
break;
|
|
313
309
|
default:
|
|
314
310
|
channel = '';
|
|
@@ -635,7 +631,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
635
631
|
paramsDefault.username = name;
|
|
636
632
|
paramsDefault.oa_id = sourceAccountIdentifier;
|
|
637
633
|
paramsDefault.token = token;
|
|
638
|
-
paramsDefault.host = hostName;
|
|
639
634
|
} else {
|
|
640
635
|
paramsDefault.wecrmId = wecrm_app_id;
|
|
641
636
|
paramsDefault.wecrmToken = wecrm_token;
|
|
@@ -700,13 +695,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
700
695
|
name = "",
|
|
701
696
|
sourceAccountIdentifier = "",
|
|
702
697
|
configs: { token = "" } = {},
|
|
703
|
-
hostName = "",
|
|
704
698
|
} = setAcc || {};
|
|
705
699
|
params.username = name;
|
|
706
700
|
params.oa_id = sourceAccountIdentifier;
|
|
707
701
|
params.token = token;
|
|
708
702
|
params.isAccountSelection = true;
|
|
709
|
-
params.host = hostName;
|
|
710
703
|
}
|
|
711
704
|
}
|
|
712
705
|
|
|
@@ -860,12 +853,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
860
853
|
name = "",
|
|
861
854
|
sourceAccountIdentifier = "",
|
|
862
855
|
configs: { token = "" } = {},
|
|
863
|
-
hostName = "",
|
|
864
856
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
865
857
|
queryParams.username = name;
|
|
866
858
|
queryParams.oa_id = sourceAccountIdentifier;
|
|
867
859
|
queryParams.token = token;
|
|
868
|
-
queryParams.host = hostName;
|
|
869
860
|
}
|
|
870
861
|
this.setState({ page, templatesCount }, () => {
|
|
871
862
|
queryParams.page = page;
|
|
@@ -2112,14 +2103,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2112
2103
|
sourceAccountIdentifier = "",
|
|
2113
2104
|
configs: { token = "" } = {},
|
|
2114
2105
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
2115
|
-
this.
|
|
2106
|
+
this.props.zaloActions.getTemplateInfoById({
|
|
2116
2107
|
username: name,
|
|
2117
2108
|
oa_id: sourceAccountIdentifier,
|
|
2118
2109
|
token: token,
|
|
2119
2110
|
id: template?._id,
|
|
2120
2111
|
preview: true,
|
|
2121
2112
|
actionCallback: this.actionCallback,
|
|
2122
|
-
})
|
|
2113
|
+
});
|
|
2123
2114
|
}
|
|
2124
2115
|
}
|
|
2125
2116
|
|
|
@@ -176,7 +176,7 @@ export function* getSenderDetails({
|
|
|
176
176
|
if (!apiResponse?.errors?.length) {
|
|
177
177
|
yield put({
|
|
178
178
|
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
179
|
-
payload: apiResponse?.entity?.[
|
|
179
|
+
payload: apiResponse?.entity?.WHATSAPP[0]?.domainProperties?.hostName || '',
|
|
180
180
|
});
|
|
181
181
|
} else {
|
|
182
182
|
yield put({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
|
-
import { take, call, takeLatest, takeEvery
|
|
2
|
+
import { take, call, takeLatest, takeEvery } 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,12 +10,9 @@ import {
|
|
|
10
10
|
getAllTemplates,
|
|
11
11
|
watchGetCdnTransformationConfig,
|
|
12
12
|
watchGetAllTemplates,
|
|
13
|
-
getSenderDetails,
|
|
14
13
|
} from '../sagas';
|
|
15
14
|
|
|
16
15
|
import * as mockData from './mockData';
|
|
17
|
-
import { ZALO } from '../../CreativesContainer/constants';
|
|
18
|
-
import { VIET_GUYS } from '../../Zalo/constants';
|
|
19
16
|
|
|
20
17
|
describe('getCdnTransformationConfig saga', () => {
|
|
21
18
|
it("handle valid response from api", () => {
|
|
@@ -137,53 +134,3 @@ describe('watchForTemplates saga', () => {
|
|
|
137
134
|
);
|
|
138
135
|
});
|
|
139
136
|
});
|
|
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}
|
|
842
|
+
setTemplateMessage(`${templateMessage}${formatMessage(messages.securitySuffix)}`);
|
|
843
843
|
} else {
|
|
844
844
|
setTemplateMessage(formatMessage(messages.authenticationMsg));
|
|
845
845
|
}
|
|
@@ -1088,21 +1088,14 @@ 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
|
-
|
|
1103
1091
|
const onTemplateCategoryChange = (value) => {
|
|
1104
1092
|
if (value === WHATSAPP_CATEGORIES.authentication) {
|
|
1105
|
-
|
|
1093
|
+
setTemplateHeader('');
|
|
1094
|
+
setTemplateFooter('');
|
|
1095
|
+
setExpiryMinutes(0);
|
|
1096
|
+
setUnsubscribeRequired(false);
|
|
1097
|
+
setCtadata({});
|
|
1098
|
+
setQuickReplyData({});
|
|
1106
1099
|
setTemplateMessage(formatMessage(messages.authenticationMsg));
|
|
1107
1100
|
} else {
|
|
1108
1101
|
setTemplateMessage('');
|
|
@@ -18,7 +18,6 @@ export const LIBRARY = 'library';
|
|
|
18
18
|
export const FULL = 'full';
|
|
19
19
|
export const ALL = 'all';
|
|
20
20
|
export const OUTBOUND = 'outbound';
|
|
21
|
-
export const VIET_GUYS = 'vietguyszalotrans';
|
|
22
21
|
|
|
23
22
|
const prefix = 'app/v2Containers/Zalo';
|
|
24
23
|
export const ZALO_TEMPLATE_INFO_REQUEST = `${prefix}/ZALO_TEMPLATE_INFO_REQUEST`;
|
|
@@ -4,7 +4,7 @@ import React, { useState, useEffect } from 'react';
|
|
|
4
4
|
import { bindActionCreators } from 'redux';
|
|
5
5
|
import { createStructuredSelector } from 'reselect';
|
|
6
6
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
7
|
-
import { get, isEmpty
|
|
7
|
+
import { get, isEmpty } from 'lodash';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
10
10
|
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
CAP_SPACE_32,
|
|
24
24
|
CAP_WHITE,
|
|
25
25
|
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
26
|
-
import { makeSelectZalo, makeSelectAccount
|
|
26
|
+
import { makeSelectZalo, makeSelectAccount } from './selectors';
|
|
27
27
|
import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
|
|
28
28
|
import * as zaloActions from './actions';
|
|
29
29
|
import './index.scss';
|
|
@@ -40,7 +40,6 @@ import {
|
|
|
40
40
|
ERROR_ALERT,
|
|
41
41
|
WARNING_ALERT,
|
|
42
42
|
ZALO_STATUSES,
|
|
43
|
-
VIET_GUYS,
|
|
44
43
|
} from './constants';
|
|
45
44
|
import { SMS, ZALO } from '../CreativesContainer/constants';
|
|
46
45
|
import messages from './messages';
|
|
@@ -57,7 +56,7 @@ export const Zalo = (props) => {
|
|
|
57
56
|
isFullMode,
|
|
58
57
|
templateData = {},
|
|
59
58
|
editData = {},
|
|
60
|
-
accountData: { selectedZaloAccount = {}
|
|
59
|
+
accountData: { selectedZaloAccount = {} } = {},
|
|
61
60
|
globalActions,
|
|
62
61
|
location,
|
|
63
62
|
getDefaultTags,
|
|
@@ -66,21 +65,18 @@ export const Zalo = (props) => {
|
|
|
66
65
|
injectedTags,
|
|
67
66
|
getFormData,
|
|
68
67
|
selectedOfferDetails,
|
|
69
|
-
gapItTemplateData,
|
|
70
68
|
} = props || {};
|
|
71
|
-
const {hostName = ''} = senderDetails;
|
|
72
69
|
const { formatMessage } = intl;
|
|
73
70
|
const [oa_id, setOaId] = useState('');
|
|
74
71
|
const [token, setToken] = useState('');
|
|
75
72
|
const [username, setUsername] = useState('');
|
|
76
73
|
const [templateName, setTemplateName] = useState('');
|
|
77
74
|
const [templateId, setTemplateId] = useState('');
|
|
78
|
-
const [templateListParams, setTemplateListParams] = useState(
|
|
75
|
+
const [templateListParams, setTemplateListParams] = useState([]);
|
|
79
76
|
const [templatePreviewUrl, setTemplatePreviewUrl] = useState('');
|
|
80
77
|
const [templateStatus, setZaloTemplateStatus] = useState(
|
|
81
78
|
ZALO_STATUSES.ENABLE,
|
|
82
79
|
);
|
|
83
|
-
const [gapitAllTemplateData, setGapitAllTemplateData] = useState([]);
|
|
84
80
|
const [tags, updateTags] = useState([]);
|
|
85
81
|
const [textAreaId, updateTextAreaId] = useState('');
|
|
86
82
|
const { zaloTemplateInfoValue = {}, zaloTemplateInfoStatus = REQUEST } =
|
|
@@ -121,21 +117,11 @@ export const Zalo = (props) => {
|
|
|
121
117
|
setToken(accessToken || zaloToken);
|
|
122
118
|
setUsername(name || accountName);
|
|
123
119
|
}
|
|
124
|
-
|
|
125
|
-
}, [selectedZaloAccount, templateData, gapItTemplateData]);
|
|
126
|
-
|
|
127
|
-
const updateTemplateData = (gapitTemplateId, templateName, listParams, previewUrl, status) => {
|
|
128
|
-
setTemplateName(templateName);
|
|
129
|
-
setTemplateId(gapitTemplateId);
|
|
130
|
-
setTemplateListParams(listParams);
|
|
131
|
-
setTemplatePreviewUrl(previewUrl);
|
|
132
|
-
setZaloTemplateStatus(status);
|
|
133
|
-
updateTextAreaId(listParams[0]?.name);
|
|
134
|
-
};
|
|
120
|
+
}, [selectedZaloAccount, templateData]);
|
|
135
121
|
|
|
136
122
|
//gets template details
|
|
137
123
|
useEffect(() => {
|
|
138
|
-
if (zaloTempId && oa_id && token && username
|
|
124
|
+
if (zaloTempId && oa_id && token && username) {
|
|
139
125
|
actions.getTemplateInfoById({
|
|
140
126
|
username,
|
|
141
127
|
oa_id,
|
|
@@ -143,17 +129,6 @@ export const Zalo = (props) => {
|
|
|
143
129
|
id: zaloTempId,
|
|
144
130
|
actionCallback,
|
|
145
131
|
});
|
|
146
|
-
} else if (hostName !== VIET_GUYS) {
|
|
147
|
-
const { _id: gapitTemplateId = '' } = templateData;
|
|
148
|
-
if (gapitTemplateId) {
|
|
149
|
-
const data = gapitAllTemplateData.find(template => template._id == gapitTemplateId);
|
|
150
|
-
const { templateName = "", listParams = [], previewUrl = "", status = "" } = data?.versions?.base?.content?.zalo || {};
|
|
151
|
-
updateTemplateData(gapitTemplateId, templateName, listParams, previewUrl, status);
|
|
152
|
-
} else {
|
|
153
|
-
const { id: gapitTemplateId = '', name: templateName = '', template: previewUrl = '', varMapped: listParams = {} } = templateData?.templateConfigs || {};
|
|
154
|
-
const handledListParams = handleSetValues(Object.entries(listParams));
|
|
155
|
-
updateTemplateData(gapitTemplateId, templateName, handledListParams, previewUrl, ZALO_STATUSES.ENABLE);
|
|
156
|
-
}
|
|
157
132
|
}
|
|
158
133
|
//cleanup code
|
|
159
134
|
return () => {
|
|
@@ -162,7 +137,7 @@ export const Zalo = (props) => {
|
|
|
162
137
|
}, [zaloTempId, oa_id, token, username]);
|
|
163
138
|
|
|
164
139
|
const handleSetValues = (paramsData = []) =>
|
|
165
|
-
paramsData
|
|
140
|
+
paramsData.map((paramData) => {
|
|
166
141
|
for (const key in varMapped) {
|
|
167
142
|
if (paramData?.name === key) {
|
|
168
143
|
paramData.value = varMapped[key];
|
|
@@ -172,36 +147,27 @@ export const Zalo = (props) => {
|
|
|
172
147
|
});
|
|
173
148
|
|
|
174
149
|
const setDataForEdit = (setValues) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
status = '',
|
|
186
|
-
} = {},
|
|
150
|
+
const {
|
|
151
|
+
name = '',
|
|
152
|
+
_id: zaloId = '',
|
|
153
|
+
versions: {
|
|
154
|
+
base: {
|
|
155
|
+
content: {
|
|
156
|
+
zalo: {
|
|
157
|
+
listParams: paramsData = [],
|
|
158
|
+
previewUrl = '',
|
|
159
|
+
status = '',
|
|
187
160
|
} = {},
|
|
188
161
|
} = {},
|
|
189
162
|
} = {},
|
|
190
|
-
} =
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
} else {
|
|
199
|
-
const { _id: gapitTemplateId = '' } = templateData;
|
|
200
|
-
let data = gapitAllTemplateData.find(template => template._id == gapitTemplateId);
|
|
201
|
-
const { templateName = "", listParams = [], previewUrl = "", status = "" } = data?.versions?.base?.content?.zalo || {};
|
|
202
|
-
updateTemplateData(gapitTemplateId, templateName, listParams, previewUrl, status);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
163
|
+
} = {},
|
|
164
|
+
} = zaloTemplateInfoValue;
|
|
165
|
+
setTemplateName(name);
|
|
166
|
+
setTemplateId(zaloId);
|
|
167
|
+
setTemplateListParams(setValues ? handleSetValues(paramsData) : paramsData);
|
|
168
|
+
setTemplatePreviewUrl(previewUrl);
|
|
169
|
+
setZaloTemplateStatus(status);
|
|
170
|
+
updateTextAreaId(paramsData[0]?.name);
|
|
205
171
|
};
|
|
206
172
|
|
|
207
173
|
useEffect(() => {
|
|
@@ -373,7 +339,7 @@ export const Zalo = (props) => {
|
|
|
373
339
|
|
|
374
340
|
const isEditDoneDisabled = () => {
|
|
375
341
|
let disableCheck = false;
|
|
376
|
-
templateListParams
|
|
342
|
+
templateListParams.forEach((listParams) => {
|
|
377
343
|
const { error, value } = listParams;
|
|
378
344
|
const errorMessage = !error
|
|
379
345
|
? handleErrorValidation(value, listParams)
|
|
@@ -385,16 +351,11 @@ export const Zalo = (props) => {
|
|
|
385
351
|
return disableCheck;
|
|
386
352
|
};
|
|
387
353
|
const createPayload = () => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const { name, value } = listParam;
|
|
394
|
-
varMap[name] = value;
|
|
395
|
-
}
|
|
396
|
-
);
|
|
397
|
-
}
|
|
354
|
+
const varMap = {};
|
|
355
|
+
templateListParams.forEach((listParam) => {
|
|
356
|
+
const { name, value } = listParam;
|
|
357
|
+
varMap[name] = value;
|
|
358
|
+
});
|
|
398
359
|
const payload = {
|
|
399
360
|
channel: ZALO,
|
|
400
361
|
accountId: oa_id,
|
|
@@ -409,7 +370,6 @@ export const Zalo = (props) => {
|
|
|
409
370
|
varMapped: varMap,
|
|
410
371
|
},
|
|
411
372
|
token,
|
|
412
|
-
host: hostName,
|
|
413
373
|
};
|
|
414
374
|
return payload;
|
|
415
375
|
};
|
|
@@ -447,7 +407,7 @@ export const Zalo = (props) => {
|
|
|
447
407
|
});
|
|
448
408
|
|
|
449
409
|
return (
|
|
450
|
-
<CapSpin spinning={zaloTemplateInfoStatus === REQUEST
|
|
410
|
+
<CapSpin spinning={zaloTemplateInfoStatus === REQUEST}>
|
|
451
411
|
<CapRow type="flex" className="cap-zalo-creatives">
|
|
452
412
|
<CapColumn span={14}>
|
|
453
413
|
{templateStatus && (
|
|
@@ -525,7 +485,6 @@ const mapStateToProps = createStructuredSelector({
|
|
|
525
485
|
accountData: makeSelectAccount(),
|
|
526
486
|
metaEntities: makeSelectMetaEntities(),
|
|
527
487
|
injectedTags: setInjectedTags(),
|
|
528
|
-
gapItTemplateData: makeSelectGapitTemplates(),
|
|
529
488
|
});
|
|
530
489
|
|
|
531
490
|
const mapDispatchToProps = (dispatch) => ({
|
|
@@ -9,11 +9,4 @@ const makeSelectZalo = () =>
|
|
|
9
9
|
const makeSelectAccount = () =>
|
|
10
10
|
createSelector(selectAccountDomain(), (substate) => substate && substate.toJS());
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
createSelector(selectAccountDomain(), (substate) => {
|
|
14
|
-
const getAllTemplates = substate && substate.toJS();
|
|
15
|
-
const { templates = []} = getAllTemplates;
|
|
16
|
-
return templates;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export { makeSelectZalo, makeSelectAccount, makeSelectGapitTemplates };
|
|
12
|
+
export { makeSelectZalo, makeSelectAccount };
|
|
@@ -11462,9 +11462,6 @@ export const accountData = {
|
|
|
11462
11462
|
modifiedDate: '2023-10-16T00:00:00+05:30',
|
|
11463
11463
|
},
|
|
11464
11464
|
},
|
|
11465
|
-
senderDetails: {
|
|
11466
|
-
hostName: 'vietguyszalotrans',
|
|
11467
|
-
},
|
|
11468
11465
|
};
|
|
11469
11466
|
|
|
11470
11467
|
export const templateData = {
|
|
@@ -11482,46 +11479,3 @@ export const templateConfigs = {
|
|
|
11482
11479
|
ma_so1: '4',
|
|
11483
11480
|
},
|
|
11484
11481
|
};
|
|
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
|
-
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fromJS } from "immutable";
|
|
2
|
-
import { makeSelectZalo, makeSelectAccount
|
|
2
|
+
import { makeSelectZalo, makeSelectAccount } from "../selectors";
|
|
3
3
|
|
|
4
4
|
describe("makeSelectZalo", () => {
|
|
5
5
|
it("returns the expected object with default values when substate is empty", () => {
|
|
@@ -25,27 +25,4 @@ describe("makeSelectZalo", () => {
|
|
|
25
25
|
// Assert
|
|
26
26
|
expect(result).toEqual(expected);
|
|
27
27
|
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('makeSelectGapitTemplates', () => {
|
|
31
|
-
it('should return an empty array if templates are not present', () => {
|
|
32
|
-
const state = fromJS({ templates: {} });
|
|
33
|
-
const selector = makeSelectGapitTemplates();
|
|
34
|
-
const result = selector(state);
|
|
35
|
-
expect(result).toEqual([]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should return an array of templates if present', () => {
|
|
39
|
-
const state = fromJS({ templates: { templates: ['template1', 'template2'] } });
|
|
40
|
-
const selector = makeSelectGapitTemplates();
|
|
41
|
-
const result = selector(state);
|
|
42
|
-
expect(result).toEqual(['template1', 'template2']);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should return an empty array if templates is null', () => {
|
|
46
|
-
const state = fromJS({ templates: {} });
|
|
47
|
-
const selector = makeSelectGapitTemplates();
|
|
48
|
-
const result = selector(state);
|
|
49
|
-
expect(result).toEqual([]);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
28
|
+
});
|