@capillarytech/creatives-library 3.1.14 → 3.1.16
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/components/TemplatePreview/index.js +6 -1
- package/components/TemplatePreview/messages.js +12 -0
- package/config/app.js +2 -0
- package/containers/Sms/Create/index.js +2 -3
- package/index.js +2 -1
- package/package.json +1 -2
- package/routes.js +2 -1
- package/services/api.js +14 -0
- package/utils/smsCharCountV2.js +26 -10
- package/v2Components/TemplatePreview/_templatePreview.scss +8 -0
- package/v2Components/TemplatePreview/index.js +29 -11
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Containers/Sms/Create/index.js +1 -1
- package/v2Containers/Sms/Edit/index.js +1 -1
|
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import _ from 'lodash';
|
|
11
11
|
import { injectIntl, intlShape} from 'react-intl';
|
|
12
|
-
|
|
12
|
+
import styled from 'styled-components';
|
|
13
13
|
import {CapColumn} from '@capillarytech/cap-react-ui-library';
|
|
14
14
|
import './_templatePreview.scss';
|
|
15
15
|
import {updateCharCount} from '../../utils/smsCharCountV2';
|
|
@@ -51,6 +51,8 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
51
51
|
return undefined;
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
const BoldText = styled.span`
|
|
55
|
+
font-weight: 800;`;
|
|
54
56
|
return (
|
|
55
57
|
<div className={`preview-container ${type === 'embedded' ? 'embedded-preview' : ''}`}>
|
|
56
58
|
{ channel && channel.toLowerCase() === 'sms' &&
|
|
@@ -152,6 +154,9 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
152
154
|
}
|
|
153
155
|
<div style={{marginTop: '8px', fontSize: '16px'}} >{`${this.props.intl.formatMessage(messages.sms)}: ${smsDetails.parts}`}</div>
|
|
154
156
|
<div style={{fontSize: '16px'}}>{`${this.props.intl.formatMessage(messages.charactersPerSms)}: ${smsDetails.chars_used}`}</div>
|
|
157
|
+
{smsDetails.optoutUrlPresent && <div style={{fontWeight: '100', fontSize: '12px'}}>
|
|
158
|
+
{`${this.props.intl.formatMessage(messages.includes)} `}<BoldText>{`${this.props.intl.formatMessage(messages.optout)} `}</BoldText>{this.props.intl.formatMessage(messages.tag)}: {smsDetails.optouturlLength}
|
|
159
|
+
</div>}
|
|
155
160
|
</p>
|
|
156
161
|
</div>
|
|
157
162
|
: ''
|
|
@@ -26,6 +26,18 @@ export default defineMessages({
|
|
|
26
26
|
id: 'creatives.components.TemplatePreview.smsFormatType',
|
|
27
27
|
defaultMessage: 'Message has unicode characters',
|
|
28
28
|
},
|
|
29
|
+
includes: {
|
|
30
|
+
id: 'app.components.TemplatePreview.includes',
|
|
31
|
+
defaultMessage: 'Includes',
|
|
32
|
+
},
|
|
33
|
+
optout: {
|
|
34
|
+
id: 'app.components.TemplatePreview.optout',
|
|
35
|
+
defaultMessage: 'Optout',
|
|
36
|
+
},
|
|
37
|
+
tag: {
|
|
38
|
+
id: 'app.components.TemplatePreview.tag',
|
|
39
|
+
defaultMessage: 'tag',
|
|
40
|
+
},
|
|
29
41
|
previewGenerated: {
|
|
30
42
|
id: 'creatives.components.TemplatePreview.previewGenerated',
|
|
31
43
|
defaultMessage: 'Preview is being generated',
|
package/config/app.js
CHANGED
|
@@ -9,12 +9,14 @@ const config = {
|
|
|
9
9
|
login_url: 'auth/login',
|
|
10
10
|
dashboard_url: '/sms',
|
|
11
11
|
dashboard_url_v2: '/v2',
|
|
12
|
+
subscription_api_endpoint: '/arya/api/v1/subscription',
|
|
12
13
|
accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
|
|
13
14
|
},
|
|
14
15
|
development: {
|
|
15
16
|
api_endpoint: 'https://nightly.capillary.in/arya/api/v1/creatives',
|
|
16
17
|
auth_endpoint: 'https://nightly.capillary.in/arya/api/v1/auth',
|
|
17
18
|
arya_endpoint: 'https://nightly.capillary.in/arya/api/v1',
|
|
19
|
+
subscription_api_endpoint: 'https://nightly.capillary.in/arya/api/v1/subscription',
|
|
18
20
|
login_url: 'auth/login',
|
|
19
21
|
dashboard_url: '/sms',
|
|
20
22
|
dashboard_url_v2: '/v2',
|
|
@@ -20,8 +20,7 @@ import './_smsCreate.scss';
|
|
|
20
20
|
import FormBuilder from '../../../components/FormBuilder';
|
|
21
21
|
import * as actions from './actions';
|
|
22
22
|
import messages from './messages';
|
|
23
|
-
import
|
|
24
|
-
import {checkUnicode} from '../../../utils/smsCharCountV2';
|
|
23
|
+
import {checkUnicode, updateCharCount} from '../../../utils/smsCharCountV2';
|
|
25
24
|
import * as globalActions from '../../../containers/Cap/actions';
|
|
26
25
|
import {getMessageObject} from '../../../utils/messageUtils';
|
|
27
26
|
|
|
@@ -223,7 +222,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
223
222
|
}
|
|
224
223
|
const result = {};
|
|
225
224
|
result.base = baseData;
|
|
226
|
-
const msgObj =
|
|
225
|
+
const msgObj = updateCharCount(baseData['sms-editor']);
|
|
227
226
|
result.base.msg_count = msgObj.msgCount;
|
|
228
227
|
console.log("Message Count", msgObj.msgCount);
|
|
229
228
|
const response = {
|
package/index.js
CHANGED
|
@@ -59,7 +59,7 @@ import TemplatesV2 from './v2Containers/TemplatesV2/index';
|
|
|
59
59
|
|
|
60
60
|
import CreativesContainer from './v2Containers/CreativesContainer';
|
|
61
61
|
import CreativesContainerReducer from './v2Containers/CreativesContainer/reducer';
|
|
62
|
-
|
|
62
|
+
import { updateCharCount } from './utils/smsCharCountV2';
|
|
63
63
|
|
|
64
64
|
export {default as Ebill} from './v2Containers/Ebill';
|
|
65
65
|
export {default as EbillReducer} from './v2Containers/Ebill/reducer';
|
|
@@ -116,4 +116,5 @@ export { CapContainer,
|
|
|
116
116
|
MobilePushEditContainer,
|
|
117
117
|
TemplatesV2Container,
|
|
118
118
|
CreativesContainer,
|
|
119
|
+
updateCharCount,
|
|
119
120
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.16",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "LicenseRef-LICENSE",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@babel/node": "^7.8.4",
|
|
16
15
|
"@babel/polyfill": "7.4.3",
|
|
17
16
|
"babel-cli": "^6.26.0",
|
|
18
17
|
"chalk": "1.1.3",
|
package/routes.js
CHANGED
|
@@ -12,7 +12,7 @@ import * as emailSagas from 'containers/Email/sagas';
|
|
|
12
12
|
import * as templateSagas from 'containers/Templates/sagas';
|
|
13
13
|
import * as lineSagas from 'containers/Line/Create/sagas';
|
|
14
14
|
import * as languageSaga from './v2Containers/LanguageProvider/sagas';
|
|
15
|
-
|
|
15
|
+
import {updateCharCount} from './utils/smsCharCountV2';
|
|
16
16
|
const errorLoading = (err) => {
|
|
17
17
|
console.error('Dynamic page loading failed', err); // eslint-disable-line no-console
|
|
18
18
|
};
|
|
@@ -23,6 +23,7 @@ const loadModule = (cb) => (componentModule) => {
|
|
|
23
23
|
|
|
24
24
|
export default function createRoutes(store) {
|
|
25
25
|
// Create reusable async injectors using getAsyncInjectors factory
|
|
26
|
+
updateCharCount("", false); // calling here to get unsubscribeurl from api.
|
|
26
27
|
const { injectReducer, injectSagas } = getAsyncInjectors(store); // eslint-disable-line no-unused-vars
|
|
27
28
|
injectSagas(rootSaga.default);
|
|
28
29
|
injectSagas(languageSaga.default);
|
package/services/api.js
CHANGED
|
@@ -10,10 +10,12 @@ import * as API from '../utils/ApiCaller';
|
|
|
10
10
|
let API_ENDPOINT = config.development.api_endpoint;
|
|
11
11
|
let API_AUTH_ENDPOINT = config.development.auth_endpoint;
|
|
12
12
|
let ARYA_ENDPOINT = config.development.arya_endpoint;
|
|
13
|
+
let SUBSCRIPTION_API_ENDPOINT = config.development.subscription_api_endpoint;
|
|
13
14
|
if (process.env.NODE_ENV === 'production') {
|
|
14
15
|
API_ENDPOINT = config.production.api_endpoint;
|
|
15
16
|
API_AUTH_ENDPOINT = config.production.auth_endpoint;
|
|
16
17
|
ARYA_ENDPOINT = config.production.arya_endpoint;
|
|
18
|
+
SUBSCRIPTION_API_ENDPOINT = config.production.subscription_api_endpoint;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
const isProd = process.env.NODE_ENV === 'production';
|
|
@@ -325,3 +327,15 @@ export const getLocizMessage = async (locale) => {
|
|
|
325
327
|
const response = await request(url, getAPICallObject('GET'));
|
|
326
328
|
return response;
|
|
327
329
|
};
|
|
330
|
+
|
|
331
|
+
export const getUnsubscribeUrl = () => {
|
|
332
|
+
const body = {
|
|
333
|
+
orgUnitId: -1,
|
|
334
|
+
source: 'INSTORE',
|
|
335
|
+
accountId: '',
|
|
336
|
+
priority: 'BULK',
|
|
337
|
+
channel: 'mobile',
|
|
338
|
+
};
|
|
339
|
+
const url = `${SUBSCRIPTION_API_ENDPOINT}/unsubscribeUrl`;
|
|
340
|
+
return request(url, getAPICallObject('POST', body));
|
|
341
|
+
};
|
package/utils/smsCharCountV2.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import * as Api from './../services/api';
|
|
3
|
+
let optoutUrl;
|
|
4
|
+
let showOptoutCount = true;
|
|
5
|
+
let responseState = "REQUEST";
|
|
6
|
+
|
|
2
7
|
function getURLParameter(name) {
|
|
3
8
|
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null
|
|
4
9
|
}
|
|
@@ -49,13 +54,26 @@ export function checkUnicode(content) {
|
|
|
49
54
|
return false;
|
|
50
55
|
}
|
|
51
56
|
export function updateCharCount(content, isUnicodeEnabled) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
if (showOptoutCount && optoutUrl === undefined && responseState === 'REQUEST') {
|
|
58
|
+
Api.getUnsubscribeUrl().then((res) => {
|
|
59
|
+
optoutUrl = res.response.response;
|
|
60
|
+
responseState = "SUCCESS";
|
|
61
|
+
}).catch((err) => {
|
|
62
|
+
showOptoutCount = false;
|
|
63
|
+
responseState = "FAIL";
|
|
64
|
+
optoutUrl = undefined;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const optoutTag = /{{optout}}/g;
|
|
68
|
+
const optoutTagLength = 14;
|
|
69
|
+
const contentOriginal = content;
|
|
70
|
+
const noOfOptout = (content.match(optoutTag) || []).length;
|
|
71
|
+
content = showOptoutCount ? content.replace(optoutTag, "") : content;
|
|
72
|
+
var chars_arr = contentOriginal.split("");
|
|
55
73
|
var coding = '7bit';
|
|
56
74
|
var parts = 1;
|
|
57
75
|
var part = 1;
|
|
58
|
-
var chars_used = 0;
|
|
76
|
+
var chars_used = showOptoutCount ? ((optoutUrl && optoutUrl.length || 0) * noOfOptout) : 0;
|
|
59
77
|
var chars_sms = 160;
|
|
60
78
|
var sms_parts_container = [];
|
|
61
79
|
var partc = [];
|
|
@@ -127,17 +145,15 @@ export function updateCharCount(content, isUnicodeEnabled) {
|
|
|
127
145
|
}
|
|
128
146
|
}
|
|
129
147
|
|
|
130
|
-
|
|
131
|
-
console.log('Parts:', parts);
|
|
132
|
-
console.log('SMS Chars:', chars_sms);
|
|
133
|
-
console.log('SMS Char total:', chars_used);
|
|
134
|
-
|
|
148
|
+
chars_used = showOptoutCount ? (chars_used - (optoutTagLength * noOfOptout)) : chars_used;
|
|
135
149
|
return {
|
|
136
150
|
unicode: (coding === '7bit' ? false : true),
|
|
137
151
|
parts,
|
|
138
152
|
chars_sms,
|
|
139
153
|
chars_used,
|
|
140
154
|
char_list: partc,
|
|
155
|
+
optouturlLength: (optoutUrl && optoutUrl.length) || 0,
|
|
156
|
+
optoutUrlPresent: noOfOptout > 0,
|
|
157
|
+
responseState,
|
|
141
158
|
};
|
|
142
159
|
}
|
|
143
|
-
|
|
@@ -59,24 +59,42 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
59
59
|
<FormattedMessage {...messages.smsFormatType}/>
|
|
60
60
|
}
|
|
61
61
|
</CapHeading>}
|
|
62
|
+
{smsDetails.optoutUrlPresent && <CapHeading type="h6">
|
|
63
|
+
<FormattedMessage {...messages.optoutCharactersTotal} values={{optoutUrlLength: smsDetails.optouturlLength}} />
|
|
64
|
+
</CapHeading>}
|
|
62
65
|
</CapColumn>}
|
|
63
66
|
<CapColumn span={this.props.showCount ? 8 : 24}>
|
|
64
67
|
<div className={`preview-container ${type === 'embedded' ? 'embedded-preview' : ''}`}>
|
|
65
68
|
{ channel && channel.toLowerCase() === 'sms' &&
|
|
66
|
-
<div
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
<div>
|
|
70
|
+
<div className="shell align-center" id="sms-preview">
|
|
71
|
+
<img className="preview-image sms" src={smsBody} alt="Preview is being generated"/>
|
|
72
|
+
<div className="msgContainer sms">
|
|
73
|
+
<img className="sms-icon" src={smsIcon} alt="Sms icon" />
|
|
74
|
+
<div className={"message-pop sms"}>
|
|
75
|
+
{content && content.length && content.map((msg, index) =>
|
|
76
|
+
<CapColumn key={`"message-pop-content-${index}`} className="message-pop-item align-left" style={{ background: '#3F51B5', color: '#ffffff'}}>
|
|
77
|
+
{msg}
|
|
78
|
+
</CapColumn>)
|
|
79
|
+
}
|
|
80
|
+
</div>
|
|
76
81
|
</div>
|
|
77
82
|
</div>
|
|
83
|
+
{!this.props.showCount && <div>
|
|
84
|
+
<CapColumn className="character-count-col" span={20}>
|
|
85
|
+
{channel && channel.toLowerCase() === 'sms' && <CapHeading type="h3">
|
|
86
|
+
<FormattedMessage {...messages.charactersTotal} values={{smsCount: smsDetails.parts, charCount: smsDetails.chars_used}}/>
|
|
87
|
+
{smsDetails.unicode &&
|
|
88
|
+
<FormattedMessage {...messages.smsFormatType}/>
|
|
89
|
+
}
|
|
90
|
+
</CapHeading>}
|
|
91
|
+
{smsDetails.optoutUrlPresent && <CapHeading type="h6" className="optout-tag-heading">
|
|
92
|
+
<FormattedMessage {...messages.optoutCharactersTotal} values={{optoutUrlLength: smsDetails.optouturlLength}} />
|
|
93
|
+
</CapHeading>}
|
|
94
|
+
</CapColumn>
|
|
95
|
+
</div>}
|
|
78
96
|
</div>
|
|
79
|
-
|
|
97
|
+
}
|
|
80
98
|
{channel && channel.toLowerCase() === 'wechat' ?
|
|
81
99
|
( <div className="shell align-center" id="sms-preview">
|
|
82
100
|
<img className="preview-image" src={channel.toLowerCase() === 'wechat' ? wechatBody : smsBody} alt="Preview is being generated"/>
|
|
@@ -22,6 +22,10 @@ export default defineMessages({
|
|
|
22
22
|
id: 'creatives.componentsV2.TemplatePreview.charactersTotal',
|
|
23
23
|
defaultMessage: "{smsCount} SMS ({charCount} characters)",
|
|
24
24
|
},
|
|
25
|
+
optoutCharactersTotal: {
|
|
26
|
+
id: 'app.components.TemplatePreview.optoutCharactersTotal',
|
|
27
|
+
defaultMessage: "Includes Optout tag ({optoutUrlLength} characters)",
|
|
28
|
+
},
|
|
25
29
|
smsFormatType: {
|
|
26
30
|
id: 'creatives.componentsV2.TemplatePreview.smsFormatType',
|
|
27
31
|
defaultMessage: 'Message has unicode characters',
|
|
@@ -742,7 +742,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
742
742
|
}
|
|
743
743
|
const formData = _.cloneDeep(this.state.formData);
|
|
744
744
|
formData[currentTab - 1][field.id] = myField.value;
|
|
745
|
-
this.setState({formData});
|
|
745
|
+
this.setState({formData}, () => this.onTemplateContentChange());
|
|
746
746
|
}
|
|
747
747
|
|
|
748
748
|
startTemplateCreation(data) {
|
|
@@ -789,7 +789,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
789
789
|
const formData = _.cloneDeep(this.state.formData);
|
|
790
790
|
formData[currentTab - 1][field.id] = myField.value;
|
|
791
791
|
formData.base[field.id] = myField.value;
|
|
792
|
-
this.setState({formData});
|
|
792
|
+
this.setState({formData}, () => this.onTemplateContentChange());
|
|
793
793
|
}
|
|
794
794
|
|
|
795
795
|
handleFrameTasks = (e) => {
|