@capillarytech/creatives-library 7.10.48 → 7.10.50
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/utils/v2common.js +13 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +2 -0
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/Templates/_templates.scss +14 -0
- package/v2Containers/Templates/index.js +33 -11
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/TemplatesV2/index.js +11 -0
- package/v2Containers/Whatsapp/index.js +46 -2
- package/v2Containers/Whatsapp/messages.js +5 -0
package/package.json
CHANGED
package/utils/v2common.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const getObjFromQueryParams = (searchString) => {
|
|
2
|
+
const params = new URLSearchParams(searchString);
|
|
3
|
+
const obj = {};
|
|
4
|
+
// iterate over all keys
|
|
5
|
+
for (const key of params.keys()) {
|
|
6
|
+
if (params.getAll(key).length > 1) {
|
|
7
|
+
obj[key] = params.getAll(key);
|
|
8
|
+
} else {
|
|
9
|
+
obj[key] = params.get(key);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
@@ -526,12 +526,11 @@ class Creatives extends React.Component {
|
|
|
526
526
|
const accountId = selectedAccountId || (selectedWhatsappAccount?.id || '');
|
|
527
527
|
const { versions } = template.value;
|
|
528
528
|
const whatsappContent = cloneDeep(versions.base.content.whatsapp);
|
|
529
|
-
console.log("accountDetailsaccountDetails", accountDetails, accountDetails.name)
|
|
530
529
|
templateData = {
|
|
531
530
|
channel,
|
|
532
531
|
accountId,
|
|
533
532
|
accountName: accountDetails.name,
|
|
534
|
-
messageBody:
|
|
533
|
+
messageBody: whatsappContent.languages[0].content,
|
|
535
534
|
category: whatsappContent.category,
|
|
536
535
|
language: whatsappContent.languages[0].language,
|
|
537
536
|
mediaType: whatsappContent.mediaType,
|
|
@@ -132,6 +132,20 @@
|
|
|
132
132
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
+
|
|
136
|
+
.create-new-link{
|
|
137
|
+
.ant-anchor-link {
|
|
138
|
+
display: flex;
|
|
139
|
+
|
|
140
|
+
.ant-anchor-link-title {
|
|
141
|
+
margin: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.cap-link-v2-suffix {
|
|
145
|
+
margin-top: -2px;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
135
149
|
}
|
|
136
150
|
|
|
137
151
|
.card-title {
|
|
@@ -32,6 +32,7 @@ import { makeSelectEdit } from '../Sms/Edit/selectors';
|
|
|
32
32
|
import { makeSelectLine } from '../Line/Container/selectors';
|
|
33
33
|
import { makeSelectViber } from '../Viber/selectors';
|
|
34
34
|
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
35
|
+
import { getObjFromQueryParams } from '../../utils/v2common';
|
|
35
36
|
import messages from './messages';
|
|
36
37
|
import {checkUnicode} from '../../utils/smsCharCountV2';
|
|
37
38
|
import * as actions from './actions';
|
|
@@ -240,6 +241,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
240
241
|
if (this.props.location.query.type === 'embedded' && this.isEnabledInLibraryModule("setLocale")) {
|
|
241
242
|
this.setLocale();
|
|
242
243
|
}
|
|
244
|
+
|
|
245
|
+
const queryItems = getObjFromQueryParams(location.search);
|
|
246
|
+
|
|
247
|
+
if(queryItems.channel === WHATSAPP_LOWERCASE && queryItems.mode === 'create') {
|
|
248
|
+
this.createTemplate();
|
|
249
|
+
}
|
|
250
|
+
|
|
243
251
|
if (this.props.location.query.type === 'embedded') {
|
|
244
252
|
this.props.actions.resetAccount();
|
|
245
253
|
}
|
|
@@ -1320,7 +1328,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1320
1328
|
} else {
|
|
1321
1329
|
this.props.createNew();
|
|
1322
1330
|
}
|
|
1323
|
-
} else if (ev
|
|
1331
|
+
} else if (ev?.key && (ev.key.toLowerCase() === "text" || ev.key.toLowerCase() === "image")) {
|
|
1324
1332
|
routeParams = {
|
|
1325
1333
|
pathname: `/${channel === 'line' ? 'line' : 'mobilepush'}/create/${ev.key.toLowerCase()}`,
|
|
1326
1334
|
query: type === 'embedded' ? {type: 'embedded', module} : {module},
|
|
@@ -2222,6 +2230,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2222
2230
|
setLineFilter = (e) => this.setState({lineFilter: e.target.value});
|
|
2223
2231
|
setSMSFilter = (e) => this.setState({smsFilter: e.target.value});
|
|
2224
2232
|
|
|
2233
|
+
openCreativesFullMode = () => {
|
|
2234
|
+
window.open("/creatives/ui/v2?channel=WHATSAPP&&mode=create", "_blank");
|
|
2235
|
+
}
|
|
2225
2236
|
|
|
2226
2237
|
render() {
|
|
2227
2238
|
const isFullMode = this.isFullMode();
|
|
@@ -2295,16 +2306,27 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2295
2306
|
const channelLowerCase = (channel || '').toLowerCase();
|
|
2296
2307
|
const isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
2297
2308
|
|
|
2298
|
-
const createButton =
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2309
|
+
const createButton =
|
|
2310
|
+
( channelLowerCase === WHATSAPP_LOWERCASE && !this.props.isFullMode )
|
|
2311
|
+
? (
|
|
2312
|
+
<CapLink
|
|
2313
|
+
onClick={this.openCreativesFullMode}
|
|
2314
|
+
title={formatMessage(messages.createNewTemplateLink)}
|
|
2315
|
+
suffix={<CapIcon type="open-in-new" size="s" />}
|
|
2316
|
+
className="create-new-link"
|
|
2317
|
+
/>
|
|
2318
|
+
)
|
|
2319
|
+
: (
|
|
2320
|
+
<CapButton
|
|
2321
|
+
className={`create-new-${channelLowerCase}`}
|
|
2322
|
+
type={"primary"}
|
|
2323
|
+
disabled={this.isCreateDisabled()}
|
|
2324
|
+
style={{marginLeft: '8px', marginBottom: '12px'}}
|
|
2325
|
+
onClick={this.createTemplate}
|
|
2326
|
+
>
|
|
2327
|
+
{ this.props.intl.formatMessage((isTraiDltFeature && channel.toUpperCase() === SMS ) ? messages.uploadTemplate : messages.createNewActionButton) }
|
|
2328
|
+
</CapButton>
|
|
2329
|
+
);
|
|
2308
2330
|
|
|
2309
2331
|
const isWhatsappCountExeeded = templatesCount >= MAX_WHATSAPP_TEMPLATES;
|
|
2310
2332
|
const whatsappCountExceedText = <FormattedMessage {...messages.whatsappMaxTemplates} values={{ maxCount: MAX_WHATSAPP_TEMPLATES }}/>;
|
|
@@ -274,6 +274,10 @@ export default defineMessages({
|
|
|
274
274
|
id: `${scope}.createNewActionButton`,
|
|
275
275
|
defaultMessage: `Create new`,
|
|
276
276
|
},
|
|
277
|
+
"createNewTemplateLink": {
|
|
278
|
+
id: `${scope}.createNewTemplateLink`,
|
|
279
|
+
defaultMessage: `Create new template`,
|
|
280
|
+
},
|
|
277
281
|
"creativeTemplates": {
|
|
278
282
|
id: `${scope}.creativeTemplates`,
|
|
279
283
|
defaultMessage: `Creative templates`,
|
|
@@ -31,6 +31,7 @@ import withStyles from '../../hoc/withStyles';
|
|
|
31
31
|
import styles, { CapTabStyle } from './TemplatesV2.style';
|
|
32
32
|
import { CREATIVES_UI_VIEW, LOYALTY} from '../App/constants';
|
|
33
33
|
import AccessForbidden from '../../v2Components/AccessForbidden';
|
|
34
|
+
import { getObjFromQueryParams } from '../../utils/v2common';
|
|
34
35
|
|
|
35
36
|
const {CapCustomCardList} = CapCustomCard;
|
|
36
37
|
|
|
@@ -120,6 +121,16 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
120
121
|
onChannelChange(defaultChannel);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
124
|
+
|
|
125
|
+
componentDidMount() {
|
|
126
|
+
const queryItems = getObjFromQueryParams(location.search);
|
|
127
|
+
|
|
128
|
+
if(queryItems.channel === 'whatsapp') {
|
|
129
|
+
console.log("reached whatsapp content");
|
|
130
|
+
this.channelChange('whatsapp');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
123
134
|
componentWillReceiveProps(nextProps) {
|
|
124
135
|
if (this.props.channel !== nextProps.channel) {
|
|
125
136
|
const panes = this.setChannelContent(nextProps.channel, this.state.panes);
|
|
@@ -51,9 +51,11 @@ import withCreatives from '../../hoc/withCreatives';
|
|
|
51
51
|
import TemplatePreview from '../../v2Components/TemplatePreview';
|
|
52
52
|
import TagList from '../TagList';
|
|
53
53
|
import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
|
|
54
|
+
import { validateTags } from '../../utils/tagValidations';
|
|
54
55
|
|
|
55
56
|
let varMap = {};
|
|
56
57
|
let editContent = {};
|
|
58
|
+
let tagValidationResponse = {};
|
|
57
59
|
|
|
58
60
|
export const Whatsapp = (props) => {
|
|
59
61
|
const {
|
|
@@ -101,6 +103,7 @@ export const Whatsapp = (props) => {
|
|
|
101
103
|
//for tag only
|
|
102
104
|
const [tags, updateTags] = useState([]);
|
|
103
105
|
const [textAreaId, updateTextAreaId] = useState();
|
|
106
|
+
const [isTagValidationError, updateIsTagValidationError] = useState(false);
|
|
104
107
|
|
|
105
108
|
const validVarRegex = /{{([1-9]|1[0-9])}}/g;
|
|
106
109
|
|
|
@@ -157,7 +160,7 @@ export const Whatsapp = (props) => {
|
|
|
157
160
|
name = '',
|
|
158
161
|
versions = {},
|
|
159
162
|
createdAt = '',
|
|
160
|
-
} = isFullMode ? editData.templateDetails : templateData;
|
|
163
|
+
} = isFullMode ? editData.templateDetails || {} : templateData || {};
|
|
161
164
|
editContent = get(versions, `base.content.whatsapp`, {});
|
|
162
165
|
if (editContent && !isEmpty(editContent)) {
|
|
163
166
|
setEditFlow(true);
|
|
@@ -264,6 +267,27 @@ export const Whatsapp = (props) => {
|
|
|
264
267
|
}
|
|
265
268
|
}, [metaEntities, isEditFlow]);
|
|
266
269
|
|
|
270
|
+
//performs tag validation
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
if (
|
|
273
|
+
!isFullMode &&
|
|
274
|
+
updatedSmsEditor?.length > 0 &&
|
|
275
|
+
!updatedSmsEditor.join('').match(validVarRegex)
|
|
276
|
+
) {
|
|
277
|
+
tagValidationResponse =
|
|
278
|
+
validateTags({
|
|
279
|
+
content: updatedSmsEditor.join(''),
|
|
280
|
+
tagsParam: tags,
|
|
281
|
+
injectedTagsParams: injectedTags,
|
|
282
|
+
location,
|
|
283
|
+
tagModule: getDefaultTags,
|
|
284
|
+
}) || {};
|
|
285
|
+
updateIsTagValidationError(
|
|
286
|
+
tagValidationResponse.unsupportedTags.length > 0,
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}, [updatedSmsEditor, tags]);
|
|
290
|
+
|
|
267
291
|
const handleOnTagsContextChange = (data) => {
|
|
268
292
|
const { type } = location.query || {};
|
|
269
293
|
const isEmbedded = type === EMBEDDED;
|
|
@@ -789,6 +813,17 @@ export const Whatsapp = (props) => {
|
|
|
789
813
|
}
|
|
790
814
|
};
|
|
791
815
|
|
|
816
|
+
const tagValidationErrorMessage = () => {
|
|
817
|
+
const { unsupportedTags = [] } = tagValidationResponse;
|
|
818
|
+
let tagError = '';
|
|
819
|
+
if (unsupportedTags.length > 0) {
|
|
820
|
+
tagError = formatMessage(messages.unsupportedTagsValidationError, {
|
|
821
|
+
unsupportedTags,
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
return <CapError>{tagError}</CapError>;
|
|
825
|
+
};
|
|
826
|
+
|
|
792
827
|
const editModeContent = (
|
|
793
828
|
<>
|
|
794
829
|
<CapAlert
|
|
@@ -828,6 +863,7 @@ export const Whatsapp = (props) => {
|
|
|
828
863
|
</CapTooltip>
|
|
829
864
|
|
|
830
865
|
{renderMessageLength()}
|
|
866
|
+
{isTagValidationError && tagValidationErrorMessage()}
|
|
831
867
|
</>
|
|
832
868
|
);
|
|
833
869
|
//edit methods end
|
|
@@ -853,6 +889,14 @@ export const Whatsapp = (props) => {
|
|
|
853
889
|
);
|
|
854
890
|
};
|
|
855
891
|
|
|
892
|
+
const isEditDoneDisabled = () => {
|
|
893
|
+
return isTagValidationError || Object.values(varMap).some( (inputValue) => {
|
|
894
|
+
if (inputValue === '') {
|
|
895
|
+
return true;
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
|
|
856
900
|
return (
|
|
857
901
|
<CapSpin spinning={spin}>
|
|
858
902
|
<CapRow>
|
|
@@ -891,7 +935,7 @@ export const Whatsapp = (props) => {
|
|
|
891
935
|
<>
|
|
892
936
|
<CapButton
|
|
893
937
|
onClick={saveToMessage}
|
|
894
|
-
|
|
938
|
+
disabled={isEditDoneDisabled()}
|
|
895
939
|
className="whatsapp-create-btn"
|
|
896
940
|
>
|
|
897
941
|
<FormattedMessage {...messages.done} />
|
|
@@ -236,4 +236,9 @@ export default defineMessages({
|
|
|
236
236
|
id: `${prefix}.done`,
|
|
237
237
|
defaultMessage: 'Done',
|
|
238
238
|
},
|
|
239
|
+
unsupportedTagsValidationError: {
|
|
240
|
+
id: `${prefix}.unsupportedTagsValidationError`,
|
|
241
|
+
defaultMessage:
|
|
242
|
+
'Unsupported tags: {unsupportedTags}. Please remove them from this message.',
|
|
243
|
+
},
|
|
239
244
|
});
|