@capillarytech/creatives-library 2.0.45 → 2.0.46
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.
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* EmailPreviewV2
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
// import styled from 'styled-components';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { FormattedMessage } from 'react-intl';
|
|
11
|
+
import {isEmpty} from 'lodash';
|
|
12
|
+
import { connect } from 'react-redux';
|
|
13
|
+
import { bindActionCreators } from 'redux';
|
|
14
|
+
import { createStructuredSelector } from 'reselect';
|
|
15
|
+
import { CapSpin } from '@capillarytech/cap-ui-library';
|
|
16
|
+
import moment from 'moment';
|
|
17
|
+
import messages from '../EmailPreviewV2/messages';
|
|
18
|
+
import './index.scss';
|
|
19
|
+
import mobileBody from '../../assets/mobile.png';
|
|
20
|
+
|
|
21
|
+
import {selectTemplateContent} from '../../containers/Templates/selectors';
|
|
22
|
+
import * as templateActions from '../../containers/Templates/actions';
|
|
23
|
+
|
|
24
|
+
const deviceAspectRatio = {
|
|
25
|
+
mobile: {
|
|
26
|
+
height: "500",
|
|
27
|
+
width: "300",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
class EmailMobilePreview extends React.Component {
|
|
32
|
+
componentWillMount() {
|
|
33
|
+
const {templateData, templateContent} = this.props;
|
|
34
|
+
if (isEmpty(templateContent) && !isEmpty(templateData) && templateData._id) { // templateData: comes from templates list email preview
|
|
35
|
+
this.props.templateActions.getTemplateDetails(templateData._id); // templateContent: html data to be shown in iframe
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getPreview = ({device, messageContainerName, templateContent}) => (
|
|
40
|
+
<div className={"shell align-center"}>
|
|
41
|
+
<img src={mobileBody} alt="capillary" width="85%" height="400px" />
|
|
42
|
+
<div className={messageContainerName}>
|
|
43
|
+
<iframe srcDoc={templateContent} {...deviceAspectRatio[device]} >
|
|
44
|
+
<p><FormattedMessage {...messages.noIframeSupport}/></p>
|
|
45
|
+
</iframe>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
render() {
|
|
51
|
+
const messageContainerName = 'mobile-message-container';
|
|
52
|
+
const {currentDevice} = this.state;
|
|
53
|
+
const { templateContent } = this.props;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className="email-preview-v2">
|
|
57
|
+
|
|
58
|
+
<CapSpin spinning={!templateContent}>
|
|
59
|
+
<div id="emailPreivew-container">
|
|
60
|
+
<div id="emailPreivew-content-wrapper">
|
|
61
|
+
<div id="emailPreivew-content">
|
|
62
|
+
<div className="email-preview-container">
|
|
63
|
+
<div className={"shell align-center"}>
|
|
64
|
+
<img src={mobileBody} alt="capillary" width="85%" />
|
|
65
|
+
<div className={messageContainerName}>
|
|
66
|
+
<iframe srcDoc={templateContent} {...deviceAspectRatio[currentDevice]} >
|
|
67
|
+
<p><FormattedMessage {...messages.noIframeSupport}/></p>
|
|
68
|
+
</iframe>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
{this.props.templateData &&
|
|
76
|
+
[
|
|
77
|
+
<p className="preview-info"><FormattedMessage {...messages.lastModified} />: {moment(this.props.templateData.updatedAt).format('MM-DD-YYYY')}</p>,
|
|
78
|
+
<p style={{marginBottom: '8px'}} className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.templateData.updatedByName}</p>,
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
</CapSpin>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
EmailMobilePreview.propTypes = {
|
|
90
|
+
templateContent: PropTypes.string,
|
|
91
|
+
templateData: PropTypes.object,
|
|
92
|
+
templateActions: PropTypes.object,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
EmailMobilePreview.defaultProps = {
|
|
96
|
+
showDeviceSelection: true,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const mapStateToProps = (state, props) => createStructuredSelector({
|
|
100
|
+
templateContent: props.templateData ? selectTemplateContent() : () => props.templateContent, // when props has templateContent that means preview with content
|
|
101
|
+
});
|
|
102
|
+
function mapDispatchToProps(dispatch) {
|
|
103
|
+
return {
|
|
104
|
+
templateActions: bindActionCreators(templateActions, dispatch),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default connect(mapStateToProps, mapDispatchToProps)(EmailMobilePreview);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
$classPrefix: email-preview-v2;
|
|
2
|
+
.#{$classPrefix}{
|
|
3
|
+
#emailPreivew-container {
|
|
4
|
+
position: relative;
|
|
5
|
+
// padding: 0 24px 0 24px;
|
|
6
|
+
overflow-y: auto;
|
|
7
|
+
// font-family: 'proxima-nova';
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
#emailPreivew-content-wrapper{
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 90%;
|
|
12
|
+
overflow: auto;
|
|
13
|
+
// display: table;
|
|
14
|
+
|
|
15
|
+
#emailPreivew-content {
|
|
16
|
+
.device-wrapper {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
margin-bottom: 8px;
|
|
19
|
+
margin-top: 16px;
|
|
20
|
+
.device-name {
|
|
21
|
+
padding: 6px 24px;
|
|
22
|
+
background: #E6F0FB;
|
|
23
|
+
border: 2px solid #E6F0FB;
|
|
24
|
+
font-family: "open-sans";
|
|
25
|
+
line-height: 20px;
|
|
26
|
+
font-size: 14px;
|
|
27
|
+
color: #4E92E5;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
.active {
|
|
31
|
+
background: #FFFFFF !important;
|
|
32
|
+
border: 2px solid #E6F0FB;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
.email-preview-container{
|
|
37
|
+
.tablet-message-container {
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: 9%;
|
|
40
|
+
left: 10%;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100%;
|
|
43
|
+
overflow: auto;
|
|
44
|
+
display: -webkit-box;
|
|
45
|
+
display: -ms-flexbox;
|
|
46
|
+
display: flex;
|
|
47
|
+
}
|
|
48
|
+
.mobile-message-container {
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: 10.3%;
|
|
51
|
+
left: 14%;
|
|
52
|
+
overflow: auto;
|
|
53
|
+
display: -webkit-box;
|
|
54
|
+
display: -ms-flexbox;
|
|
55
|
+
display: flex;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
padding: 0 0px 0 24px;
|
|
59
|
+
// display: table-cell;
|
|
60
|
+
// vertical-align: middle;
|
|
61
|
+
text-align: center;
|
|
62
|
+
margin-bottom: 36px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -164,10 +164,11 @@ class Creatives extends React.Component {
|
|
|
164
164
|
return newState;
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
handleClodeSlideBox = () => {
|
|
168
168
|
this.setState((prevState) => ({
|
|
169
169
|
...prevState,
|
|
170
170
|
templateData: undefined,
|
|
171
|
+
showSlideBox: false,
|
|
171
172
|
}), this.props.handleCloseCreatives);
|
|
172
173
|
};
|
|
173
174
|
saveMessage = () => {
|
|
@@ -235,8 +236,6 @@ class Creatives extends React.Component {
|
|
|
235
236
|
getFormData={this.getFormData}
|
|
236
237
|
onCreateNew={this.onCreateNew}
|
|
237
238
|
isGetFormData={isGetFormData}
|
|
238
|
-
toggleShowSlideBox={this.toggleShowSlideBox}
|
|
239
|
-
showSlideBox={showSlideBox}
|
|
240
239
|
isFullMode={isFullMode}
|
|
241
240
|
currentChannel={currentChannel.toUpperCase()}
|
|
242
241
|
onChannelChange={this.onChannelChange}
|
|
@@ -262,7 +261,7 @@ class Creatives extends React.Component {
|
|
|
262
261
|
shouldShowDoneFooter={this.shouldShowDoneFooter}
|
|
263
262
|
/>
|
|
264
263
|
}
|
|
265
|
-
handleClose={this.
|
|
264
|
+
handleClose={this.handleClodeSlideBox}
|
|
266
265
|
show={showSlideBox}
|
|
267
266
|
size="size-l"
|
|
268
267
|
/>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* TemplatesV2 reducer
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { fromJS } from 'immutable';
|
|
8
|
+
import * as types from './constants';
|
|
9
|
+
|
|
10
|
+
const initialState = fromJS({
|
|
11
|
+
loadingTemplates: true,
|
|
12
|
+
smsTemplates: [],
|
|
13
|
+
emailTemplates: [],
|
|
14
|
+
wechatTemplates: [],
|
|
15
|
+
mobilepushTemplates: [],
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function templatesV2Reducer(state = initialState, action) {
|
|
19
|
+
const channelTemplates = `${action.channel}Templates`;
|
|
20
|
+
switch (action.type) {
|
|
21
|
+
case types.DEFAULT_ACTION:
|
|
22
|
+
return state;
|
|
23
|
+
case types.GET_TEMPLATES_REQUEST:
|
|
24
|
+
return state.set('loadingTemplates', true);
|
|
25
|
+
case types.GET_TEMPLATES_SUCESS:
|
|
26
|
+
return state.set('loadingTemplates', false).set(channelTemplates, action.templates);
|
|
27
|
+
case types.GET_TEMPLATES_FAILURE:
|
|
28
|
+
return state.set('loadingTemplates', false).set('error', action.error);
|
|
29
|
+
default:
|
|
30
|
+
return state;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default templatesV2Reducer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { take, takeLatest, call, put, cancel } from 'redux-saga/effects';
|
|
2
|
+
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
|
+
import * as Api from '../../services/api';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import * as types from './constants';
|
|
7
|
+
// Individual exports for testing
|
|
8
|
+
export function* defaultSaga() {
|
|
9
|
+
// See example in containers/HomePage/sagas.js
|
|
10
|
+
}
|
|
11
|
+
function* getTemplates(action) {
|
|
12
|
+
try {
|
|
13
|
+
const req = {
|
|
14
|
+
channel: action.channel,
|
|
15
|
+
queryParams: action.query,
|
|
16
|
+
};
|
|
17
|
+
const res = yield call(Api.getAllTemplates, req);
|
|
18
|
+
yield put({type: types.GET_TEMPLATES_SUCESS, templates: res.response.templates, channel: action.channel});
|
|
19
|
+
} catch (error) {
|
|
20
|
+
yield put({type: types.GET_TEMPLATES_FAILURE, error});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function* getTemplatesWatcher() {
|
|
24
|
+
const watcher = yield takeLatest(types.GET_TEMPLATES_REQUEST, getTemplates);
|
|
25
|
+
yield take(LOCATION_CHANGE);
|
|
26
|
+
yield cancel(watcher);
|
|
27
|
+
}
|
|
28
|
+
// All sagas to be loaded
|
|
29
|
+
export default [
|
|
30
|
+
defaultSaga,
|
|
31
|
+
getTemplatesWatcher,
|
|
32
|
+
];
|