@capillarytech/creatives-library 7.17.168 → 7.17.169-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/package.json +1 -1
- package/v2Components/FormBuilder/_formBuilder.scss +1 -0
- package/v2Containers/Templates/index.js +12 -3
- package/v2Containers/Templates/sagas.js +1 -1
- package/v2Containers/Templates/tests/index.test.js +1 -0
- package/v2Containers/Whatsapp/index.js +14 -7
- package/v2Containers/Zalo/constants.js +1 -0
- package/v2Containers/Zalo/index.js +52 -23
- package/v2Containers/Zalo/selectors.js +8 -1
package/package.json
CHANGED
|
@@ -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 { ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
|
|
113
|
+
import { VIET_GUYS, 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,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;
|
|
703
710
|
}
|
|
704
711
|
}
|
|
705
712
|
|
|
@@ -853,10 +860,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
853
860
|
name = "",
|
|
854
861
|
sourceAccountIdentifier = "",
|
|
855
862
|
configs: { token = "" } = {},
|
|
863
|
+
hostName = "",
|
|
856
864
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
857
865
|
queryParams.username = name;
|
|
858
866
|
queryParams.oa_id = sourceAccountIdentifier;
|
|
859
867
|
queryParams.token = token;
|
|
868
|
+
queryParams.host = hostName;
|
|
860
869
|
}
|
|
861
870
|
this.setState({ page, templatesCount }, () => {
|
|
862
871
|
queryParams.page = page;
|
|
@@ -2103,14 +2112,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2103
2112
|
sourceAccountIdentifier = "",
|
|
2104
2113
|
configs: { token = "" } = {},
|
|
2105
2114
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
2106
|
-
this.props.zaloActions.getTemplateInfoById({
|
|
2115
|
+
this.state.hostName === VIET_GUYS ? this.props.zaloActions.getTemplateInfoById({
|
|
2107
2116
|
username: name,
|
|
2108
2117
|
oa_id: sourceAccountIdentifier,
|
|
2109
2118
|
token: token,
|
|
2110
2119
|
id: template?._id,
|
|
2111
2120
|
preview: true,
|
|
2112
2121
|
actionCallback: this.actionCallback,
|
|
2113
|
-
});
|
|
2122
|
+
}) : window.open(template?.versions?.base?.content?.zalo?.previewUrl, '_blank');
|
|
2114
2123
|
}
|
|
2115
2124
|
}
|
|
2116
2125
|
|
|
@@ -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?.[channel][0]?.domainProperties?.hostName || '',
|
|
180
180
|
});
|
|
181
181
|
} else {
|
|
182
182
|
yield put({
|
|
@@ -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('');
|
|
@@ -18,6 +18,7 @@ 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';
|
|
21
22
|
|
|
22
23
|
const prefix = 'app/v2Containers/Zalo';
|
|
23
24
|
export const ZALO_TEMPLATE_INFO_REQUEST = `${prefix}/ZALO_TEMPLATE_INFO_REQUEST`;
|
|
@@ -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 } from './selectors';
|
|
26
|
+
import { makeSelectZalo, makeSelectAccount, makeSelectGapitTemplates } from './selectors';
|
|
27
27
|
import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
|
|
28
28
|
import * as zaloActions from './actions';
|
|
29
29
|
import './index.scss';
|
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
ERROR_ALERT,
|
|
41
41
|
WARNING_ALERT,
|
|
42
42
|
ZALO_STATUSES,
|
|
43
|
+
VIET_GUYS,
|
|
43
44
|
} from './constants';
|
|
44
45
|
import { SMS, ZALO } from '../CreativesContainer/constants';
|
|
45
46
|
import messages from './messages';
|
|
@@ -56,7 +57,7 @@ export const Zalo = (props) => {
|
|
|
56
57
|
isFullMode,
|
|
57
58
|
templateData = {},
|
|
58
59
|
editData = {},
|
|
59
|
-
accountData: { selectedZaloAccount = {} } = {},
|
|
60
|
+
accountData: { selectedZaloAccount = {}, senderDetails = {} } = {},
|
|
60
61
|
globalActions,
|
|
61
62
|
location,
|
|
62
63
|
getDefaultTags,
|
|
@@ -79,6 +80,7 @@ export const Zalo = (props) => {
|
|
|
79
80
|
);
|
|
80
81
|
const [tags, updateTags] = useState([]);
|
|
81
82
|
const [textAreaId, updateTextAreaId] = useState('');
|
|
83
|
+
const [host, setHost] = useState('');
|
|
82
84
|
const { zaloTemplateInfoValue = {}, zaloTemplateInfoStatus = REQUEST } =
|
|
83
85
|
editData;
|
|
84
86
|
const {
|
|
@@ -112,16 +114,18 @@ export const Zalo = (props) => {
|
|
|
112
114
|
configs: { token: accessToken = '' } = {},
|
|
113
115
|
name = '',
|
|
114
116
|
} = selectedZaloAccount;
|
|
117
|
+
const {hostName = ''} = senderDetails;
|
|
115
118
|
const oaId = getDefaultTags === OUTBOUND ? zaloAccountId : accountId;
|
|
116
119
|
setOaId(sourceAccountIdentifier || oaId);
|
|
117
120
|
setToken(accessToken || zaloToken);
|
|
118
121
|
setUsername(name || accountName);
|
|
122
|
+
setHost(hostName);
|
|
119
123
|
}
|
|
120
124
|
}, [selectedZaloAccount, templateData]);
|
|
121
125
|
|
|
122
126
|
//gets template details
|
|
123
127
|
useEffect(() => {
|
|
124
|
-
if (zaloTempId && oa_id && token && username) {
|
|
128
|
+
if (zaloTempId && oa_id && token && username && host === VIET_GUYS) {
|
|
125
129
|
actions.getTemplateInfoById({
|
|
126
130
|
username,
|
|
127
131
|
oa_id,
|
|
@@ -129,12 +133,23 @@ export const Zalo = (props) => {
|
|
|
129
133
|
id: zaloTempId,
|
|
130
134
|
actionCallback,
|
|
131
135
|
});
|
|
136
|
+
} else {
|
|
137
|
+
makeSelectGapitTemplates();
|
|
138
|
+
const {_id : gapitTemplateId = ''} = templateData;
|
|
139
|
+
const data = props.gapItTemplateData.find(template => template._id == gapitTemplateId);
|
|
140
|
+
const { templateName = "", listParams = [], previewUrl = "", status = ""} = data?.versions?.base?.content?.zalo || {};
|
|
141
|
+
setTemplateName(templateName);
|
|
142
|
+
setTemplateId(gapitTemplateId);
|
|
143
|
+
setTemplateListParams(listParams);
|
|
144
|
+
setTemplatePreviewUrl(previewUrl);
|
|
145
|
+
setZaloTemplateStatus(status);
|
|
146
|
+
updateTextAreaId(listParams[0]?.name);
|
|
132
147
|
}
|
|
133
148
|
//cleanup code
|
|
134
149
|
return () => {
|
|
135
150
|
actions.resetTemplateInfoData();
|
|
136
151
|
};
|
|
137
|
-
}, [zaloTempId, oa_id, token, username]);
|
|
152
|
+
}, [zaloTempId, oa_id, token, username, host]);
|
|
138
153
|
|
|
139
154
|
const handleSetValues = (paramsData = []) =>
|
|
140
155
|
paramsData.map((paramData) => {
|
|
@@ -147,27 +162,39 @@ export const Zalo = (props) => {
|
|
|
147
162
|
});
|
|
148
163
|
|
|
149
164
|
const setDataForEdit = (setValues) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
if(host === VIET_GUYS) {
|
|
166
|
+
const {
|
|
167
|
+
name = '',
|
|
168
|
+
_id: zaloId = '',
|
|
169
|
+
versions: {
|
|
170
|
+
base: {
|
|
171
|
+
content: {
|
|
172
|
+
zalo: {
|
|
173
|
+
listParams: paramsData = [],
|
|
174
|
+
previewUrl = '',
|
|
175
|
+
status = '',
|
|
176
|
+
} = {},
|
|
160
177
|
} = {},
|
|
161
178
|
} = {},
|
|
162
179
|
} = {},
|
|
163
|
-
} =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
180
|
+
} = zaloTemplateInfoValue;
|
|
181
|
+
setTemplateName(name);
|
|
182
|
+
setTemplateId(zaloId);
|
|
183
|
+
setTemplateListParams(setValues ? handleSetValues(paramsData) : paramsData);
|
|
184
|
+
setTemplatePreviewUrl(previewUrl);
|
|
185
|
+
setZaloTemplateStatus(status);
|
|
186
|
+
updateTextAreaId(paramsData[0]?.name);
|
|
187
|
+
} else {
|
|
188
|
+
const {_id : gapitTemplateId = ''} = templateData;
|
|
189
|
+
const data = props.gapItTemplateData.find(template => template._id == gapitTemplateId);
|
|
190
|
+
const { templateName = "", listParams = [], previewUrl = "", status = ""} = data?.versions?.base?.content?.zalo || {};
|
|
191
|
+
setTemplateName(templateName);
|
|
192
|
+
setTemplateId(gapitTemplateId);
|
|
193
|
+
setTemplateListParams(listParams);
|
|
194
|
+
setTemplatePreviewUrl(previewUrl);
|
|
195
|
+
setZaloTemplateStatus(status);
|
|
196
|
+
updateTextAreaId(listParams[0]?.name);
|
|
197
|
+
}
|
|
171
198
|
};
|
|
172
199
|
|
|
173
200
|
useEffect(() => {
|
|
@@ -370,6 +397,7 @@ export const Zalo = (props) => {
|
|
|
370
397
|
varMapped: varMap,
|
|
371
398
|
},
|
|
372
399
|
token,
|
|
400
|
+
host,
|
|
373
401
|
};
|
|
374
402
|
return payload;
|
|
375
403
|
};
|
|
@@ -407,7 +435,7 @@ export const Zalo = (props) => {
|
|
|
407
435
|
});
|
|
408
436
|
|
|
409
437
|
return (
|
|
410
|
-
<CapSpin spinning={zaloTemplateInfoStatus === REQUEST}>
|
|
438
|
+
<CapSpin spinning={zaloTemplateInfoStatus === REQUEST && host === VIET_GUYS}>
|
|
411
439
|
<CapRow type="flex" className="cap-zalo-creatives">
|
|
412
440
|
<CapColumn span={14}>
|
|
413
441
|
{templateStatus && (
|
|
@@ -485,6 +513,7 @@ const mapStateToProps = createStructuredSelector({
|
|
|
485
513
|
accountData: makeSelectAccount(),
|
|
486
514
|
metaEntities: makeSelectMetaEntities(),
|
|
487
515
|
injectedTags: setInjectedTags(),
|
|
516
|
+
gapItTemplateData: makeSelectGapitTemplates(),
|
|
488
517
|
});
|
|
489
518
|
|
|
490
519
|
const mapDispatchToProps = (dispatch) => ({
|
|
@@ -9,4 +9,11 @@ const makeSelectZalo = () =>
|
|
|
9
9
|
const makeSelectAccount = () =>
|
|
10
10
|
createSelector(selectAccountDomain(), (substate) => substate && substate.toJS());
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const makeSelectGapitTemplates = () =>
|
|
13
|
+
createSelector(selectAccountDomain(), (substate) => {
|
|
14
|
+
const getAllTemplates = substate && substate.toJS();
|
|
15
|
+
const { templates = []} = getAllTemplates;
|
|
16
|
+
return templates;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { makeSelectZalo, makeSelectAccount, makeSelectGapitTemplates };
|