@capillarytech/creatives-library 8.0.69 → 8.0.71
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
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import Bugsnag from "@bugsnag/js";
|
|
3
4
|
import {
|
|
4
5
|
CapSlideBox,
|
|
5
6
|
CapHeader,
|
|
@@ -139,21 +140,27 @@ export class Creatives extends React.Component {
|
|
|
139
140
|
templateData.updatedByName = commonUtil.getUserNameById(userId, usersList);
|
|
140
141
|
this.setState({ slidBoxContent: constants.PREVIEW, templateData });
|
|
141
142
|
} else {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
143
|
+
if (get(template, 'versions.base.content.zalo.previewUrl')) {
|
|
144
|
+
commonUtil.handlePreviewInNewTab(
|
|
145
|
+
template.versions.base.content.zalo.previewUrl
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
const {
|
|
149
|
+
name = "",
|
|
150
|
+
sourceAccountIdentifier = "",
|
|
151
|
+
configs: { token = "" } = {},
|
|
152
|
+
hostName = ""
|
|
153
|
+
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
154
|
+
this.props.zaloActions.getTemplateInfoById({
|
|
155
|
+
username: name,
|
|
156
|
+
oa_id: sourceAccountIdentifier,
|
|
157
|
+
token,
|
|
158
|
+
host: hostName || this.props?.hostName || this.props.Templates?.senderDetails?.hostName,
|
|
159
|
+
id: template?._id,
|
|
160
|
+
preview: true,
|
|
161
|
+
actionCallback: this.actionCallback,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
157
164
|
}
|
|
158
165
|
};
|
|
159
166
|
|
|
@@ -12,6 +12,7 @@ import styled from 'styled-components';
|
|
|
12
12
|
import {injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
13
13
|
import { createStructuredSelector } from 'reselect';
|
|
14
14
|
import moment from "moment";
|
|
15
|
+
import Bugsnag from "@bugsnag/js";
|
|
15
16
|
import get from 'lodash/get';
|
|
16
17
|
import isEmpty from 'lodash/isEmpty';
|
|
17
18
|
import isEqual from 'lodash/isEqual';
|
|
@@ -50,7 +51,8 @@ import {
|
|
|
50
51
|
CapImage,
|
|
51
52
|
CapStatus,
|
|
52
53
|
CapColoredTag,
|
|
53
|
-
|
|
54
|
+
CapSpin
|
|
55
|
+
} from "@capillarytech/cap-ui-library";
|
|
54
56
|
import { makeSelectTemplates, makeSelectTemplatesResponse } from './selectors';
|
|
55
57
|
import { makeSelectCreate as makeSelectCreateSms} from '../Sms/Create/selectors';
|
|
56
58
|
import { makeSelectCreate as makeSelectCreateMobilePush } from '../MobilePush/Create/selectors';
|
|
@@ -227,6 +229,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
227
229
|
hostName: '',
|
|
228
230
|
searchedZaloTemplates: [],
|
|
229
231
|
searchingZaloTemplate: false,
|
|
232
|
+
zaloPreviewItemId: {},
|
|
230
233
|
};
|
|
231
234
|
|
|
232
235
|
this.handleOnHoverItem = this.handleOnHoverItem.bind(this);
|
|
@@ -533,8 +536,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
533
536
|
params.accountId = Number(query.account_id);
|
|
534
537
|
this.getAllTemplates({params});
|
|
535
538
|
}
|
|
536
|
-
}
|
|
537
|
-
|
|
539
|
+
}
|
|
540
|
+
|
|
538
541
|
|
|
539
542
|
if (selectedChannel === "ebill" && nextProps.CreateEbill && nextProps.CreateEbill.createResponse && nextProps.CreateEbill.createResponse.templateId && nextProps.CreateEbill.createResponse.templateId !== '') {
|
|
540
543
|
const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
|
|
@@ -693,6 +696,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
693
696
|
}
|
|
694
697
|
const zaloPreviewUrl = get(nextProps, 'Zalo.zaloTemplatePreviewData.versions.base.content.zalo.previewUrl', '');
|
|
695
698
|
if (zaloPreviewUrl && this.state.channel.toLowerCase() === ZALO_LOWERCASE) {
|
|
699
|
+
this.setState({ zaloPreviewItemId: {} });
|
|
696
700
|
handlePreviewInNewTab(zaloPreviewUrl);
|
|
697
701
|
this.props.zaloActions.resetTemplatePreviewData();
|
|
698
702
|
}
|
|
@@ -920,7 +924,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
920
924
|
}
|
|
921
925
|
if (
|
|
922
926
|
this.state.channel.toLowerCase() === ZALO_LOWERCASE &&
|
|
923
|
-
!isEmpty(this.props.Templates?.selectedZaloAccount) &&
|
|
927
|
+
!isEmpty(this.props.Templates?.selectedZaloAccount) &&
|
|
924
928
|
!params?.isAccountSelection && !isEmpty(this.props.Templates?.selectedZaloAccount?.hostName)
|
|
925
929
|
) {
|
|
926
930
|
const {
|
|
@@ -982,7 +986,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
982
986
|
default:
|
|
983
987
|
return selectedWhatsappCategory === category;
|
|
984
988
|
}
|
|
985
|
-
}
|
|
989
|
+
}
|
|
986
990
|
return true;
|
|
987
991
|
}
|
|
988
992
|
filterWhatsappTemplates = (templates) => {
|
|
@@ -1072,7 +1076,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1072
1076
|
) : <>{children}</>
|
|
1073
1077
|
};
|
|
1074
1078
|
|
|
1075
|
-
getTemplateDataForGrid = ({templates = [], handlers, filterContent, channel, isLoading, loadingTip}) => {
|
|
1079
|
+
getTemplateDataForGrid = ({templates = [], handlers, filterContent, channel, isLoading, loadingTip, previewTemplateId }) => {
|
|
1076
1080
|
const currentChannel = channel.toUpperCase();
|
|
1077
1081
|
const {channel: stateChannel} = this.state;
|
|
1078
1082
|
const channelLowerCase = stateChannel.toLowerCase();
|
|
@@ -1104,11 +1108,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1104
1108
|
? this.getCreativesEditText(channelLowerCase)
|
|
1105
1109
|
: messages.selectButton
|
|
1106
1110
|
);
|
|
1107
|
-
|
|
1111
|
+
|
|
1108
1112
|
const cardDataList = filteredTemplates && filteredTemplates.length ? map(filteredTemplates, (template) => {
|
|
1109
1113
|
const androidBodyType = get(template, 'versions.base.content.ANDROID.bodyType');
|
|
1110
1114
|
const iosBodyType = get(template, 'versions.base.content.IOS.bodyType');
|
|
1111
1115
|
const inappBodyType = androidBodyType || iosBodyType;
|
|
1116
|
+
const isZaloPreviewLoading = previewTemplateId === template?._id;
|
|
1112
1117
|
const templateData = {
|
|
1113
1118
|
key: `${currentChannel}-card-${template?.name}`,
|
|
1114
1119
|
title: (
|
|
@@ -1131,20 +1136,27 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1131
1136
|
</span>
|
|
1132
1137
|
),
|
|
1133
1138
|
extra: [
|
|
1134
|
-
|
|
1135
|
-
<
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1139
|
+
currentChannel === ZALO && isZaloPreviewLoading ? (
|
|
1140
|
+
<CapSpin style={{ marginRight: "16px", position: "static", display: "inline" }} spinning />
|
|
1141
|
+
) : (
|
|
1142
|
+
this.getHoverComponent(
|
|
1143
|
+
<CapIcon
|
|
1144
|
+
className={`view-${channelLowerCase}`}
|
|
1145
|
+
style={{ marginRight: "16px" }}
|
|
1146
|
+
type="eye"
|
|
1147
|
+
onClick={() => {
|
|
1148
|
+
if (!this.props.isFullMode || this.props.isDltFromRcs) {
|
|
1149
|
+
if (!get(template, "versions.base.content.zalo.previewUrl", "")) {
|
|
1150
|
+
this.setState({ zaloPreviewItemId: template?._id });
|
|
1151
|
+
}
|
|
1152
|
+
this.props.handlePeviewTemplate(template);
|
|
1153
|
+
} else {
|
|
1154
|
+
handlers.handlePreviewClick(template);
|
|
1155
|
+
}
|
|
1156
|
+
}}
|
|
1157
|
+
/>
|
|
1158
|
+
)
|
|
1159
|
+
)
|
|
1148
1160
|
],
|
|
1149
1161
|
hoverOption: (
|
|
1150
1162
|
<CapButton
|
|
@@ -1153,15 +1165,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1153
1165
|
? `edit-${channelLowerCase}`
|
|
1154
1166
|
: `select-${channelLowerCase}`
|
|
1155
1167
|
}
|
|
1156
|
-
onClick={
|
|
1168
|
+
onClick={e =>
|
|
1157
1169
|
handlers.handleEditClick(e, template, undefined, undefined, {
|
|
1158
|
-
account: this.state.selectedAccount
|
|
1170
|
+
account: this.state.selectedAccount
|
|
1159
1171
|
})
|
|
1160
1172
|
}
|
|
1161
1173
|
>
|
|
1162
1174
|
{hoverButtonText}
|
|
1163
1175
|
</CapButton>
|
|
1164
|
-
)
|
|
1176
|
+
)
|
|
1165
1177
|
};
|
|
1166
1178
|
const {
|
|
1167
1179
|
versions: {
|
|
@@ -1220,7 +1232,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1220
1232
|
break;
|
|
1221
1233
|
}
|
|
1222
1234
|
case MOBILE_PUSH:
|
|
1223
|
-
case INAPP:
|
|
1235
|
+
case INAPP:
|
|
1224
1236
|
templateData.content = template;
|
|
1225
1237
|
break;
|
|
1226
1238
|
case WECHAT:
|
|
@@ -2188,21 +2200,26 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2188
2200
|
this.setState({ previewTemplate: templateInfo });
|
|
2189
2201
|
}
|
|
2190
2202
|
} else {
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2203
|
+
if (get(template, "versions.base.content.zalo.previewUrl", "")) {
|
|
2204
|
+
handlePreviewInNewTab(template.versions.base.content.zalo.previewUrl);
|
|
2205
|
+
} else {
|
|
2206
|
+
this.setState({ zaloPreviewItemId: template._id });
|
|
2207
|
+
const {
|
|
2208
|
+
name = "",
|
|
2209
|
+
sourceAccountIdentifier = "",
|
|
2210
|
+
configs: { token = "" } = {},
|
|
2211
|
+
hostName = ""
|
|
2212
|
+
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
2213
|
+
this.props.zaloActions.getTemplateInfoById({
|
|
2214
|
+
username: name,
|
|
2215
|
+
oa_id: sourceAccountIdentifier,
|
|
2216
|
+
token,
|
|
2217
|
+
host: hostName || this.state.hostName || this.props.Templates?.senderDetails?.hostName,
|
|
2218
|
+
id: template?._id,
|
|
2219
|
+
preview: true,
|
|
2220
|
+
actionCallback: this.actionCallback
|
|
2221
|
+
});
|
|
2222
|
+
}
|
|
2206
2223
|
}
|
|
2207
2224
|
}
|
|
2208
2225
|
|
|
@@ -3182,70 +3199,130 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3182
3199
|
return (
|
|
3183
3200
|
<>
|
|
3184
3201
|
{activeMode === ACCOUNT_CHANGE_MODE && this.renderAccountSelection()}
|
|
3185
|
-
<div
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3202
|
+
<div
|
|
3203
|
+
className={`creatives-templates-list ${
|
|
3204
|
+
this.props.isFullMode ? "full-mode" : "library-mode"
|
|
3205
|
+
}`}
|
|
3206
|
+
>
|
|
3207
|
+
<input
|
|
3208
|
+
type="file"
|
|
3209
|
+
id="filename"
|
|
3210
|
+
style={{ display: "none" }}
|
|
3211
|
+
accept=".zip, .html, .htm"
|
|
3212
|
+
onChange={event =>
|
|
3213
|
+
this.handleFileUpload(event, { files: event.target.files })
|
|
3214
|
+
}
|
|
3215
|
+
/>
|
|
3193
3216
|
|
|
3194
|
-
{
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
}
|
|
3217
|
+
{channel.toLowerCase() === WHATSAPP_LOWERCASE &&
|
|
3218
|
+
showWhatsappCountWarning ? (
|
|
3219
|
+
<CapAlert message={whatsappCountExceedText} type="info" />
|
|
3220
|
+
) : null}
|
|
3199
3221
|
|
|
3200
|
-
{
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
}
|
|
3222
|
+
{channel.toLowerCase() === WHATSAPP_LOWERCASE && !isFullMode ? (
|
|
3223
|
+
<CapInfoNote
|
|
3224
|
+
message={formatMessage(messages.whatsappOnlyApprovedTemplates)}
|
|
3225
|
+
/>
|
|
3226
|
+
) : null}
|
|
3205
3227
|
|
|
3228
|
+
{channel.toLowerCase() === ZALO_LOWERCASE && !isFullMode ? (
|
|
3229
|
+
<CapInfoNote
|
|
3230
|
+
message={formatMessage(messages.zaloOnlyApprovedTemplates)}
|
|
3231
|
+
/>
|
|
3232
|
+
) : null}
|
|
3206
3233
|
<CapRow>
|
|
3207
|
-
<Pagination
|
|
3208
|
-
{
|
|
3234
|
+
<Pagination
|
|
3235
|
+
templateInProgress={
|
|
3236
|
+
this.props.Templates.getAllTemplatesInProgress
|
|
3237
|
+
}
|
|
3238
|
+
onPageChange={
|
|
3239
|
+
templates.length ? this.onPaginationChange : () => {}
|
|
3240
|
+
}
|
|
3241
|
+
paginationSelector="pagination-container"
|
|
3242
|
+
>
|
|
3243
|
+
{this.getTemplateDataForGrid({
|
|
3244
|
+
previewTemplateId: this.state.zaloPreviewItemId,
|
|
3245
|
+
isLoading,
|
|
3246
|
+
loadingTip,
|
|
3247
|
+
channel: this.state.channel,
|
|
3248
|
+
templates: this.state.searchingZaloTemplate
|
|
3249
|
+
? this.state.searchedZaloTemplates
|
|
3250
|
+
: this.props.TemplatesList,
|
|
3251
|
+
filterContent,
|
|
3252
|
+
handlers: {
|
|
3253
|
+
handlePreviewClick: this.handlePreviewClick,
|
|
3254
|
+
handleEditClick: this.handleEditClick
|
|
3255
|
+
}
|
|
3256
|
+
})}
|
|
3209
3257
|
</Pagination>
|
|
3210
|
-
{showNoTemplatesFound &&
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3258
|
+
{showNoTemplatesFound && (
|
|
3259
|
+
<div
|
|
3260
|
+
style={{
|
|
3261
|
+
height: "65vh",
|
|
3262
|
+
textAlign: "center",
|
|
3263
|
+
lineHeight: "65vh"
|
|
3264
|
+
}}
|
|
3265
|
+
>
|
|
3266
|
+
<CapHeading type="h6">
|
|
3267
|
+
{this.props.intl.formatMessage(messages.noTemplatesFound)}
|
|
3268
|
+
</CapHeading>
|
|
3269
|
+
</div>
|
|
3270
|
+
)}
|
|
3214
3271
|
</CapRow>
|
|
3215
3272
|
|
|
3216
|
-
|
|
3217
3273
|
<CapRow>
|
|
3218
|
-
{!isEmpty(creativesParams.mode) &&
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3274
|
+
{!isEmpty(creativesParams.mode) &&
|
|
3275
|
+
isFullMode && ( //creatives container for fullmode
|
|
3276
|
+
<CreativesContainer
|
|
3277
|
+
key={creativesParams.mode}
|
|
3278
|
+
messageDetails={{ type: "default" }}
|
|
3279
|
+
creativesMode={creativesParams.mode}
|
|
3280
|
+
messages={messages}
|
|
3281
|
+
isFullMode={isFullMode}
|
|
3282
|
+
templateData={creativesParams}
|
|
3283
|
+
getCreativesData={() => {
|
|
3284
|
+
this.onCreateComplete(true);
|
|
3285
|
+
}}
|
|
3286
|
+
channel={route.name.toUpperCase()}
|
|
3287
|
+
handleCloseCreatives={this.onCreateComplete}
|
|
3288
|
+
selectedWeChatAccount={get(
|
|
3289
|
+
this.props,
|
|
3290
|
+
"Templates.selectedWeChatAccount",
|
|
3291
|
+
{}
|
|
3292
|
+
)}
|
|
3293
|
+
selectedAccount={this.state.selectedAccount}
|
|
3294
|
+
/>
|
|
3295
|
+
)}
|
|
3233
3296
|
</CapRow>
|
|
3234
3297
|
<CapRow>
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3298
|
+
{(this.state.channel.toLowerCase() === "ebill" ||
|
|
3299
|
+
this.state.channel.toLowerCase() === "email") &&
|
|
3300
|
+
htmlPreviewContent && (
|
|
3301
|
+
<EmailPreview
|
|
3302
|
+
header={previewHeader}
|
|
3303
|
+
content={htmlPreviewContent}
|
|
3304
|
+
show={this.state.showHtmlPreview}
|
|
3305
|
+
device={this.state.device}
|
|
3306
|
+
handleClose={this.toggleEmailPreview}
|
|
3307
|
+
changePreviewDevice={this.changePreviewDevice}
|
|
3308
|
+
versions={get(this.state, "previewTemplate.versions", {})}
|
|
3309
|
+
lastModified={
|
|
3310
|
+
this.state.previewTemplate
|
|
3311
|
+
? this.state.previewTemplate.updatedAt
|
|
3312
|
+
: ""
|
|
3313
|
+
}
|
|
3314
|
+
updatedByName={commonUtil.getUserNameById(
|
|
3315
|
+
parseInt(this.state.previewTemplate.updatedBy, 10),
|
|
3316
|
+
commonUtil.getMergedUserList(this.props.Templates.userList)
|
|
3317
|
+
)}
|
|
3318
|
+
/>
|
|
3319
|
+
)}
|
|
3247
3320
|
<CapSlideBox
|
|
3248
|
-
header={
|
|
3321
|
+
header={
|
|
3322
|
+
<h3>
|
|
3323
|
+
{this.props.intl.formatMessage(messages.layoutSelection)}
|
|
3324
|
+
</h3>
|
|
3325
|
+
}
|
|
3249
3326
|
width={60}
|
|
3250
3327
|
content={cmsTemplateSelectionContent}
|
|
3251
3328
|
show={this.state.showEdmEmailTemplates}
|
|
@@ -3255,7 +3332,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3255
3332
|
/>
|
|
3256
3333
|
{this.renderDeleteConfirmationModal()}
|
|
3257
3334
|
</CapRow>
|
|
3258
|
-
|
|
3259
3335
|
</div>
|
|
3260
3336
|
</>
|
|
3261
3337
|
);
|
|
@@ -7,6 +7,8 @@ import * as Api from '../../services/api';
|
|
|
7
7
|
import * as types from './constants';
|
|
8
8
|
import { saveCdnConfigs, removeAllCdnLocalStorageItems } from '../../utils/cdnTransformation';
|
|
9
9
|
import { COPY_OF } from '../../containers/App/constants';
|
|
10
|
+
import { ZALO_TEMPLATE_INFO_REQUEST } from '../Zalo/constants';
|
|
11
|
+
import { getTemplateInfoById } from '../Zalo/saga';
|
|
10
12
|
// Individual exports for testing
|
|
11
13
|
export function* getAllTemplates(channel, queryParams) {
|
|
12
14
|
try {
|
|
@@ -221,6 +223,10 @@ export function* watchGetCdnTransformationConfig() {
|
|
|
221
223
|
);
|
|
222
224
|
}
|
|
223
225
|
|
|
226
|
+
export function* watchForGetTemplateInfoById() {
|
|
227
|
+
yield takeLatest(ZALO_TEMPLATE_INFO_REQUEST, getTemplateInfoById);
|
|
228
|
+
}
|
|
229
|
+
|
|
224
230
|
// All sagas to be loaded
|
|
225
231
|
export default [
|
|
226
232
|
watchGetAllTemplates,
|
|
@@ -245,6 +251,7 @@ export function* v2TemplateSaga() {
|
|
|
245
251
|
watchGetCdnTransformationConfig(),
|
|
246
252
|
watchFetchWeCrmAccounts(),
|
|
247
253
|
watchGetSenderDetails(),
|
|
254
|
+
watchForGetTemplateInfoById(),
|
|
248
255
|
]);
|
|
249
256
|
}
|
|
250
257
|
|