@capillarytech/creatives-library 7.17.169-alpha.4 → 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 -2
- 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 -82
- 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(get(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
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
1
|
import { call, put, takeLatest, take, cancel, select } from 'redux-saga/effects';
|
|
3
2
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
4
3
|
// import { schema, normalize } from 'normalizr';
|
|
@@ -177,7 +176,7 @@ export function* getSenderDetails({
|
|
|
177
176
|
if (!apiResponse?.errors?.length) {
|
|
178
177
|
yield put({
|
|
179
178
|
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
180
|
-
payload:
|
|
179
|
+
payload: apiResponse?.entity?.WHATSAPP[0]?.domainProperties?.hostName || '',
|
|
181
180
|
});
|
|
182
181
|
} else {
|
|
183
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,30 +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
|
-
|
|
79
|
-
// If templateData.versions.base.content.zalo.listParams is available, use it.
|
|
80
|
-
// Otherwise, if hostName is VIET_GUYS and templateData.templateConfigs.varMapped is available,
|
|
81
|
-
// convert it to an array of entries. If not, use templateData.templateConfigs.varMapped or an empty array.
|
|
82
|
-
const [templateListParams, setTemplateListParams] = useState(
|
|
83
|
-
(templateData?.versions?.base?.content?.zalo?.listParams ||
|
|
84
|
-
((hostName === VIET_GUYS && templateData?.templateConfigs?.varMapped)
|
|
85
|
-
? Object.entries(templateData?.templateConfigs?.varMapped)
|
|
86
|
-
: templateData?.templateConfigs?.varMapped)) ?? []
|
|
87
|
-
);
|
|
75
|
+
const [templateListParams, setTemplateListParams] = useState([]);
|
|
88
76
|
const [templatePreviewUrl, setTemplatePreviewUrl] = useState('');
|
|
89
77
|
const [templateStatus, setZaloTemplateStatus] = useState(
|
|
90
78
|
ZALO_STATUSES.ENABLE,
|
|
91
79
|
);
|
|
92
|
-
const [gapitAllTemplateData, setGapitAllTemplateData] = useState([]);
|
|
93
80
|
const [tags, updateTags] = useState([]);
|
|
94
81
|
const [textAreaId, updateTextAreaId] = useState('');
|
|
95
82
|
const { zaloTemplateInfoValue = {}, zaloTemplateInfoStatus = REQUEST } =
|
|
@@ -130,21 +117,11 @@ export const Zalo = (props) => {
|
|
|
130
117
|
setToken(accessToken || zaloToken);
|
|
131
118
|
setUsername(name || accountName);
|
|
132
119
|
}
|
|
133
|
-
|
|
134
|
-
}, [selectedZaloAccount, templateData, gapItTemplateData]);
|
|
135
|
-
|
|
136
|
-
const updateTemplateData = (gapitTemplateId, templateName, listParams, previewUrl, status) => {
|
|
137
|
-
setTemplateName(templateName);
|
|
138
|
-
setTemplateId(gapitTemplateId);
|
|
139
|
-
setTemplateListParams(listParams);
|
|
140
|
-
setTemplatePreviewUrl(previewUrl);
|
|
141
|
-
setZaloTemplateStatus(status);
|
|
142
|
-
updateTextAreaId(listParams[0]?.name);
|
|
143
|
-
};
|
|
120
|
+
}, [selectedZaloAccount, templateData]);
|
|
144
121
|
|
|
145
122
|
//gets template details
|
|
146
123
|
useEffect(() => {
|
|
147
|
-
if (zaloTempId && oa_id && token && username
|
|
124
|
+
if (zaloTempId && oa_id && token && username) {
|
|
148
125
|
actions.getTemplateInfoById({
|
|
149
126
|
username,
|
|
150
127
|
oa_id,
|
|
@@ -152,17 +129,6 @@ export const Zalo = (props) => {
|
|
|
152
129
|
id: zaloTempId,
|
|
153
130
|
actionCallback,
|
|
154
131
|
});
|
|
155
|
-
} else if (hostName !== VIET_GUYS) {
|
|
156
|
-
const { _id: gapitTemplateId = '' } = templateData;
|
|
157
|
-
if (gapitTemplateId) {
|
|
158
|
-
const data = gapitAllTemplateData.find(template => template._id == gapitTemplateId);
|
|
159
|
-
const { templateName = "", listParams = [], previewUrl = "", status = "" } = data?.versions?.base?.content?.zalo || {};
|
|
160
|
-
updateTemplateData(gapitTemplateId, templateName, listParams, previewUrl, status);
|
|
161
|
-
} else {
|
|
162
|
-
const { id: gapitTemplateId = '', name: templateName = '', template: previewUrl = '', varMapped: listParams = {} } = templateData?.templateConfigs || {};
|
|
163
|
-
const handledListParams = handleSetValues(Object.entries(listParams));
|
|
164
|
-
updateTemplateData(gapitTemplateId, templateName, handledListParams, previewUrl, ZALO_STATUSES.ENABLE);
|
|
165
|
-
}
|
|
166
132
|
}
|
|
167
133
|
//cleanup code
|
|
168
134
|
return () => {
|
|
@@ -171,7 +137,7 @@ export const Zalo = (props) => {
|
|
|
171
137
|
}, [zaloTempId, oa_id, token, username]);
|
|
172
138
|
|
|
173
139
|
const handleSetValues = (paramsData = []) =>
|
|
174
|
-
paramsData
|
|
140
|
+
paramsData.map((paramData) => {
|
|
175
141
|
for (const key in varMapped) {
|
|
176
142
|
if (paramData?.name === key) {
|
|
177
143
|
paramData.value = varMapped[key];
|
|
@@ -181,36 +147,27 @@ export const Zalo = (props) => {
|
|
|
181
147
|
});
|
|
182
148
|
|
|
183
149
|
const setDataForEdit = (setValues) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
status = '',
|
|
195
|
-
} = {},
|
|
150
|
+
const {
|
|
151
|
+
name = '',
|
|
152
|
+
_id: zaloId = '',
|
|
153
|
+
versions: {
|
|
154
|
+
base: {
|
|
155
|
+
content: {
|
|
156
|
+
zalo: {
|
|
157
|
+
listParams: paramsData = [],
|
|
158
|
+
previewUrl = '',
|
|
159
|
+
status = '',
|
|
196
160
|
} = {},
|
|
197
161
|
} = {},
|
|
198
162
|
} = {},
|
|
199
|
-
} =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
} else {
|
|
208
|
-
const { _id: gapitTemplateId = '' } = templateData;
|
|
209
|
-
let data = gapitAllTemplateData?.find(template => template?._id == gapitTemplateId);
|
|
210
|
-
const { templateName = "", listParams = [], previewUrl = "", status = "" } = data?.versions?.base?.content?.zalo || {};
|
|
211
|
-
updateTemplateData(gapitTemplateId, templateName, listParams, previewUrl, status);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
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);
|
|
214
171
|
};
|
|
215
172
|
|
|
216
173
|
useEffect(() => {
|
|
@@ -382,7 +339,7 @@ export const Zalo = (props) => {
|
|
|
382
339
|
|
|
383
340
|
const isEditDoneDisabled = () => {
|
|
384
341
|
let disableCheck = false;
|
|
385
|
-
templateListParams
|
|
342
|
+
templateListParams.forEach((listParams) => {
|
|
386
343
|
const { error, value } = listParams;
|
|
387
344
|
const errorMessage = !error
|
|
388
345
|
? handleErrorValidation(value, listParams)
|
|
@@ -394,16 +351,11 @@ export const Zalo = (props) => {
|
|
|
394
351
|
return disableCheck;
|
|
395
352
|
};
|
|
396
353
|
const createPayload = () => {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
const { name = '', value = '' } = listParam;
|
|
403
|
-
varMap[name] = value;
|
|
404
|
-
}
|
|
405
|
-
);
|
|
406
|
-
}
|
|
354
|
+
const varMap = {};
|
|
355
|
+
templateListParams.forEach((listParam) => {
|
|
356
|
+
const { name, value } = listParam;
|
|
357
|
+
varMap[name] = value;
|
|
358
|
+
});
|
|
407
359
|
const payload = {
|
|
408
360
|
channel: ZALO,
|
|
409
361
|
accountId: oa_id,
|
|
@@ -418,7 +370,6 @@ export const Zalo = (props) => {
|
|
|
418
370
|
varMapped: varMap,
|
|
419
371
|
},
|
|
420
372
|
token,
|
|
421
|
-
host: hostName,
|
|
422
373
|
};
|
|
423
374
|
return payload;
|
|
424
375
|
};
|
|
@@ -456,7 +407,7 @@ export const Zalo = (props) => {
|
|
|
456
407
|
});
|
|
457
408
|
|
|
458
409
|
return (
|
|
459
|
-
<CapSpin spinning={zaloTemplateInfoStatus === REQUEST
|
|
410
|
+
<CapSpin spinning={zaloTemplateInfoStatus === REQUEST}>
|
|
460
411
|
<CapRow type="flex" className="cap-zalo-creatives">
|
|
461
412
|
<CapColumn span={14}>
|
|
462
413
|
{templateStatus && (
|
|
@@ -534,7 +485,6 @@ const mapStateToProps = createStructuredSelector({
|
|
|
534
485
|
accountData: makeSelectAccount(),
|
|
535
486
|
metaEntities: makeSelectMetaEntities(),
|
|
536
487
|
injectedTags: setInjectedTags(),
|
|
537
|
-
gapItTemplateData: makeSelectGapitTemplates(),
|
|
538
488
|
});
|
|
539
489
|
|
|
540
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
|
+
});
|