@plusscommunities/pluss-newsletter-web-sharing 1.2.8
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/.babelrc +3 -0
- package/dist/index.cjs.js +7451 -0
- package/dist/index.esm.js +7399 -0
- package/dist/index.umd.js +7434 -0
- package/package.default.json +43 -0
- package/package.json +45 -0
- package/package.test.json +43 -0
- package/rollup.config.js +59 -0
- package/src/actions/NewsActions.js +102 -0
- package/src/actions/index.js +9 -0
- package/src/actions/types.js +10 -0
- package/src/components/ActivityText.js +73 -0
- package/src/components/MakerPopup/index.js +3 -0
- package/src/components/PreviewFull.js +32 -0
- package/src/components/PreviewGrid.js +19 -0
- package/src/components/PreviewWidget.js +28 -0
- package/src/components/Reactions/index.js +3 -0
- package/src/components/ViewFull.js +19 -0
- package/src/components/ViewWidget.js +17 -0
- package/src/components/index.js +25 -0
- package/src/components/text/index.js +4 -0
- package/src/config/index.js +9 -0
- package/src/feature.config.default.js +235 -0
- package/src/feature.config.js +235 -0
- package/src/feature.config.sharing.js +235 -0
- package/src/feature.config.test.js +235 -0
- package/src/helper/index.js +17 -0
- package/src/images/full.png +0 -0
- package/src/images/fullNoTitle.png +0 -0
- package/src/images/fullNoTitleCondensed.png +0 -0
- package/src/images/previewWidget.png +0 -0
- package/src/images/widget.png +0 -0
- package/src/index.js +33 -0
- package/src/js/Events.js +26 -0
- package/src/js/index.js +20 -0
- package/src/reducers/NewsReducer.js +82 -0
- package/src/screens/Newsletter/AddNewsletterEntry.js +1186 -0
- package/src/screens/Newsletter/AvailableNews.js +124 -0
- package/src/screens/Newsletter/GenerateNewsletter.js +891 -0
- package/src/screens/Newsletter/ListNewsletterEntries.js +234 -0
- package/src/screens/Newsletter/NewsHub.js +328 -0
- package/src/screens/Newsletter/NewsHubAnalytics.js +320 -0
- package/src/screens/Newsletter/NewsletterAnalytics.js +140 -0
- package/src/screens/Newsletter/NewsletterSubmission.js +476 -0
- package/src/screens/Newsletter/NewsletterSubmissions.js +278 -0
- package/src/screens/Newsletter/NewsletterTemplate.js +1051 -0
- package/src/screens/Newsletter/PublishAvailableNews.js +450 -0
- package/src/session/index.js +7 -0
- package/src/webapi/eventActions.js +18 -0
- package/src/webapi/helper.js +4 -0
- package/src/webapi/index.js +11 -0
- package/src/webapi/newsletterActions.js +153 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import FontAwesome from 'react-fontawesome';
|
|
5
|
+
import { connect } from 'react-redux';
|
|
6
|
+
import { newsUpdate } from '../../actions';
|
|
7
|
+
import {
|
|
8
|
+
GenericInput,
|
|
9
|
+
Button,
|
|
10
|
+
OverlayPage,
|
|
11
|
+
OverlayPageContents,
|
|
12
|
+
OverlayPageSection,
|
|
13
|
+
OverlayPageBottomButtons,
|
|
14
|
+
SuccessPopup,
|
|
15
|
+
TimePicker,
|
|
16
|
+
DatePicker,
|
|
17
|
+
AudienceSelector,
|
|
18
|
+
RadioButton,
|
|
19
|
+
CheckBox,
|
|
20
|
+
} from '../../components';
|
|
21
|
+
import { newsletterActions } from '../../webapi';
|
|
22
|
+
import { safeReadParams, getUTCFromTimeDatePickers } from '../../helper';
|
|
23
|
+
import { checkLoggedIn } from '../../session';
|
|
24
|
+
import { COLOUR_BRANDING_MAIN, COLOUR_BRANDING_OFF } from '../../js';
|
|
25
|
+
import { DEFAULT_ALLOW_COMMENTS } from '../../config';
|
|
26
|
+
import { values } from '../../feature.config';
|
|
27
|
+
|
|
28
|
+
class PublishAvailableNews extends Component {
|
|
29
|
+
initialState = {
|
|
30
|
+
updateId: safeReadParams(this.props, 'updateId'),
|
|
31
|
+
success: false,
|
|
32
|
+
submitting: false,
|
|
33
|
+
update: {},
|
|
34
|
+
isFeatured: false,
|
|
35
|
+
allowComments: DEFAULT_ALLOW_COMMENTS,
|
|
36
|
+
featuredExpiryDate: moment().format('YYYY-MM-DD'),
|
|
37
|
+
featuredExpiryDateText: moment().format('DD/MM/YYYY'),
|
|
38
|
+
publishDate: moment().format('YYYY-MM-DD'),
|
|
39
|
+
publishDateText: moment().format('DD/MM/YYYY'),
|
|
40
|
+
publishTime: '12:00pm',
|
|
41
|
+
isAudienceValid: true,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
state = { ...this.initialState };
|
|
45
|
+
|
|
46
|
+
UNSAFE_componentWillMount() {
|
|
47
|
+
checkLoggedIn(this, this.props.auth);
|
|
48
|
+
|
|
49
|
+
if (this.state.updateId) {
|
|
50
|
+
this.getData();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
handleChange(event) {
|
|
55
|
+
var stateChange = { newUpdate: { ...this.state.newUpdate } };
|
|
56
|
+
stateChange.newUpdate[event.target.getAttribute('id')] = event.target.value;
|
|
57
|
+
this.setState(stateChange);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
handleExpiryDateTextChange(value) {
|
|
61
|
+
const newState = { featuredExpiryDateText: value };
|
|
62
|
+
const m = moment(value, 'DD/MM/YYYY');
|
|
63
|
+
|
|
64
|
+
if (m.isValid() && m.year() > 1900) {
|
|
65
|
+
newState.featuredExpiryDate = m.format('YYYY-MM-DD');
|
|
66
|
+
}
|
|
67
|
+
this.setState(newState);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
handleExpiryDateChange(date) {
|
|
71
|
+
var stateChange = {
|
|
72
|
+
featuredExpiryDate: date,
|
|
73
|
+
featuredExpiryDateText: moment(date, 'YYYY-MM-DD').format('DD/MM/YYYY'),
|
|
74
|
+
showExpiryDate: false,
|
|
75
|
+
};
|
|
76
|
+
this.setState(stateChange);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
handlePublishDateTextChange(value) {
|
|
80
|
+
const newState = { publishDateText: value };
|
|
81
|
+
const m = moment(value, 'DD/MM/YYYY');
|
|
82
|
+
|
|
83
|
+
if (m.isValid() && m.year() > 1900) {
|
|
84
|
+
newState.publishDate = m.format('YYYY-MM-DD');
|
|
85
|
+
}
|
|
86
|
+
this.setState(newState);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
handlePublishDateChange(date) {
|
|
90
|
+
var stateChange = {
|
|
91
|
+
publishDate: date,
|
|
92
|
+
publishDateText: moment(date, 'YYYY-MM-DD').format('DD/MM/YYYY'),
|
|
93
|
+
showPublishDate: false,
|
|
94
|
+
};
|
|
95
|
+
this.setState(stateChange);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getData() {
|
|
99
|
+
newsletterActions.getPublishedEntries(this.state.updateId).then((res) => {
|
|
100
|
+
this.setState({
|
|
101
|
+
update: res.data[0],
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
getDate() {
|
|
107
|
+
if (!this.state.update.Timestamp) {
|
|
108
|
+
return '';
|
|
109
|
+
}
|
|
110
|
+
return moment.utc(this.state.update.Timestamp).local().format('D MMM');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
updateAudienceValidation(valid) {
|
|
114
|
+
this.setState({
|
|
115
|
+
isAudienceValid: valid,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
validatePublishTime() {
|
|
120
|
+
if (!_.isUndefined(this.state.publishTime)) {
|
|
121
|
+
return this.state.publishTime.trim() !== '';
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
validateForm() {
|
|
127
|
+
if (this.state.submitting) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
if (!this.validatePublishTime()) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (!this.state.isAudienceValid) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
handleSubmit() {
|
|
140
|
+
this.audienceSelector.getWrappedInstance().onSubmit();
|
|
141
|
+
if (!this.validateForm()) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this.setState({
|
|
146
|
+
submitting: true,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const timeToUse = getUTCFromTimeDatePickers(this.state.publishDate, this.state.publishTime);
|
|
150
|
+
const data = {
|
|
151
|
+
...this.state.update,
|
|
152
|
+
SourceId: this.state.updateId,
|
|
153
|
+
Timestamp: timeToUse.toISOString(),
|
|
154
|
+
UnixTimestamp: timeToUse.valueOf(),
|
|
155
|
+
Site: this.props.auth.site,
|
|
156
|
+
AudienceType: this.audienceSelector.getWrappedInstance().getAudienceType(),
|
|
157
|
+
AudienceTypeSelection: this.audienceSelector.getWrappedInstance().getAudienceTypeSelection(),
|
|
158
|
+
IsFeatured: this.state.isFeatured,
|
|
159
|
+
FeaturedExpiry: this.state.isFeatured ? getUTCFromTimeDatePickers(this.state.featuredExpiryDate, '23:59').valueOf() : undefined,
|
|
160
|
+
AllowComments: this.state.allowComments,
|
|
161
|
+
};
|
|
162
|
+
delete data.RowId;
|
|
163
|
+
delete data.Id;
|
|
164
|
+
delete data.SubmittedBy;
|
|
165
|
+
|
|
166
|
+
newsletterActions
|
|
167
|
+
.addOrEditNewsletterEntry(data, this.props.auth.site)
|
|
168
|
+
.then((res) => {
|
|
169
|
+
this.setState({
|
|
170
|
+
success: true,
|
|
171
|
+
submitting: false,
|
|
172
|
+
});
|
|
173
|
+
this.props.newsUpdate(this.props.auth.site);
|
|
174
|
+
})
|
|
175
|
+
.catch((res) => {
|
|
176
|
+
this.setState({ submitting: false });
|
|
177
|
+
alert('Something went wrong with the request. Please try again.');
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
renderSuccess() {
|
|
182
|
+
if (!this.state.success) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
return (
|
|
186
|
+
<SuccessPopup
|
|
187
|
+
text={`Update has been added`}
|
|
188
|
+
buttons={[
|
|
189
|
+
{
|
|
190
|
+
type: 'outlined',
|
|
191
|
+
onClick: () => {
|
|
192
|
+
window.history.back();
|
|
193
|
+
},
|
|
194
|
+
text: 'Go to home',
|
|
195
|
+
},
|
|
196
|
+
]}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
validateLoading() {
|
|
202
|
+
if (this.state.submitting) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
renderSubmit() {
|
|
209
|
+
if (_.isEmpty(this.state.update)) {
|
|
210
|
+
return (
|
|
211
|
+
<div>
|
|
212
|
+
<Button
|
|
213
|
+
inline
|
|
214
|
+
buttonType="tertiary"
|
|
215
|
+
onClick={() => {
|
|
216
|
+
window.history.back();
|
|
217
|
+
}}
|
|
218
|
+
isActive
|
|
219
|
+
style={{ marginRight: 16 }}
|
|
220
|
+
>
|
|
221
|
+
Cancel
|
|
222
|
+
</Button>
|
|
223
|
+
<Button inline buttonType="primary" isActive={false}>
|
|
224
|
+
Publish
|
|
225
|
+
</Button>
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
if (this.state.submitting) {
|
|
230
|
+
return <Button buttonType="secondary">Saving...</Button>;
|
|
231
|
+
}
|
|
232
|
+
return (
|
|
233
|
+
<div>
|
|
234
|
+
<Button
|
|
235
|
+
inline
|
|
236
|
+
buttonType="tertiary"
|
|
237
|
+
onClick={() => {
|
|
238
|
+
window.history.back();
|
|
239
|
+
}}
|
|
240
|
+
isActive
|
|
241
|
+
style={{ marginRight: 16 }}
|
|
242
|
+
>
|
|
243
|
+
Cancel
|
|
244
|
+
</Button>
|
|
245
|
+
<Button inline buttonType="primary" onClick={this.handleSubmit.bind(this)} isActive={true}>
|
|
246
|
+
Publish
|
|
247
|
+
</Button>
|
|
248
|
+
</div>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
renderFeatured() {
|
|
253
|
+
return (
|
|
254
|
+
<div style={{ marginTop: 16 }}>
|
|
255
|
+
<RadioButton
|
|
256
|
+
label={values.textIsThisAFeaturedNewsPost}
|
|
257
|
+
isActive={this.state.isFeatured}
|
|
258
|
+
options={[
|
|
259
|
+
{ Label: 'Yes', Value: true, onChange: () => this.setState({ isFeatured: true }) },
|
|
260
|
+
{ Label: 'No', Value: false, onChange: () => this.setState({ isFeatured: false }) },
|
|
261
|
+
]}
|
|
262
|
+
/>
|
|
263
|
+
<div className="genericInput-help" style={{ marginTop: 4 }}>
|
|
264
|
+
{values.textFeaturedNewsPostWillBeHighlighted}
|
|
265
|
+
</div>
|
|
266
|
+
{this.state.isFeatured && (
|
|
267
|
+
<div>
|
|
268
|
+
<GenericInput
|
|
269
|
+
className="marginTop-16"
|
|
270
|
+
id="featuredExpiryDateText"
|
|
271
|
+
label="Expiry Date"
|
|
272
|
+
alwaysShowLabel
|
|
273
|
+
value={this.state.featuredExpiryDateText}
|
|
274
|
+
onChange={(e) => this.handleExpiryDateTextChange(e.target.value)}
|
|
275
|
+
onClick={(e) => this.setState({ showExpiryDate: !this.state.showExpiryDate })}
|
|
276
|
+
/>
|
|
277
|
+
{this.state.showExpiryDate && (
|
|
278
|
+
<DatePicker selectedDate={this.state.featuredExpiryDate} selectDate={this.handleExpiryDateChange.bind(this)} />
|
|
279
|
+
)}
|
|
280
|
+
</div>
|
|
281
|
+
)}
|
|
282
|
+
</div>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
renderSideForm() {
|
|
287
|
+
if (_.isEmpty(this.state.update)) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
if (this.state.success) {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
return (
|
|
294
|
+
<OverlayPageSection className="pageSectionWrapper--newPopupSide">
|
|
295
|
+
<div>
|
|
296
|
+
<div className="padding-60 paddingVertical-40 bottomDivideBorder">
|
|
297
|
+
<AudienceSelector
|
|
298
|
+
updateValidation={this.updateAudienceValidation.bind(this)}
|
|
299
|
+
ref={(a) => {
|
|
300
|
+
this.audienceSelector = a;
|
|
301
|
+
}}
|
|
302
|
+
auth={this.props.auth}
|
|
303
|
+
disallowSingleUsers
|
|
304
|
+
disallowUserType={this.props.auth.site === 'hq'}
|
|
305
|
+
customSite={this.props.auth.site === 'hq' ? 'All sites' : false}
|
|
306
|
+
/>
|
|
307
|
+
</div>
|
|
308
|
+
<div className="padding-60 paddingVertical-40 bottomDivideBorder">
|
|
309
|
+
<p className="newTopBarTitle text-sectionTitle">FEATURED</p>
|
|
310
|
+
{this.renderFeatured()}
|
|
311
|
+
</div>
|
|
312
|
+
<div className="padding-60 paddingBottom-40 bottomDivideBorder">
|
|
313
|
+
<p className="newTopBarTitle text-sectionTitle">DETAILS</p>
|
|
314
|
+
<div>
|
|
315
|
+
<GenericInput
|
|
316
|
+
id={`publishTime`}
|
|
317
|
+
type="time"
|
|
318
|
+
label="Time"
|
|
319
|
+
className="marginTop-16"
|
|
320
|
+
value={this.state.publishTime}
|
|
321
|
+
isValid={() => {
|
|
322
|
+
return this.validatePublishTime();
|
|
323
|
+
}}
|
|
324
|
+
showError={() => {
|
|
325
|
+
return this.state.showWarnings && !this.validatePublishTime();
|
|
326
|
+
}}
|
|
327
|
+
style={{ marginBottom: 0 }}
|
|
328
|
+
inputComponent={
|
|
329
|
+
<TimePicker
|
|
330
|
+
selectedTime={this.state.publishTime}
|
|
331
|
+
selectTime={(val) => {
|
|
332
|
+
this.setState({ publishTime: val });
|
|
333
|
+
}}
|
|
334
|
+
/>
|
|
335
|
+
}
|
|
336
|
+
/>
|
|
337
|
+
{/* Test Input Date Selector */}
|
|
338
|
+
<GenericInput
|
|
339
|
+
className="marginTop-16"
|
|
340
|
+
id="publishDateText"
|
|
341
|
+
label="Publish Date"
|
|
342
|
+
alwaysShowLabel
|
|
343
|
+
value={this.state.publishDateText}
|
|
344
|
+
onChange={(e) => this.handlePublishDateTextChange(e.target.value)}
|
|
345
|
+
onClick={(e) => this.setState({ showPublishDate: !this.state.showPublishDate })}
|
|
346
|
+
/>
|
|
347
|
+
{this.state.showPublishDate && (
|
|
348
|
+
<DatePicker selectedDate={this.state.publishDate} selectDate={this.handlePublishDateChange.bind(this)} />
|
|
349
|
+
)}
|
|
350
|
+
<CheckBox
|
|
351
|
+
className="marginTop-16"
|
|
352
|
+
label="Allow comments"
|
|
353
|
+
isActive={this.state.allowComments}
|
|
354
|
+
onChange={() => {
|
|
355
|
+
this.setState({ allowComments: !this.state.allowComments });
|
|
356
|
+
}}
|
|
357
|
+
/>
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
</div>
|
|
361
|
+
</OverlayPageSection>
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
renderForm() {
|
|
366
|
+
if (this.state.success) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
if (_.isEmpty(this.state.update)) {
|
|
370
|
+
return (
|
|
371
|
+
<div className="padding-60 bottomPadding-40" style={{ textAlign: 'center' }}>
|
|
372
|
+
<FontAwesome style={{ fontSize: 32, color: COLOUR_BRANDING_OFF }} name="spinner fa-pulse fa-fw" />
|
|
373
|
+
</div>
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
return (
|
|
377
|
+
<div>
|
|
378
|
+
<div className="padding-60 bottomPadding-40">
|
|
379
|
+
<div className="newTopBar clearfix">
|
|
380
|
+
<p className="newTopBarTitle text-sectionTitle">{values.textNewsPost}</p>
|
|
381
|
+
</div>
|
|
382
|
+
{this.state.update.Publisher && (
|
|
383
|
+
<div className="newTopBar clearfix">
|
|
384
|
+
<span className="newTopBarTitle text-sectionTitle">
|
|
385
|
+
By <span className="text-brandingColour">{this.state.update.Publisher.Title}</span>
|
|
386
|
+
</span>
|
|
387
|
+
</div>
|
|
388
|
+
)}
|
|
389
|
+
<div className="marginTop-16 fontMedium text-dark" style={{ fontSize: 26 }}>
|
|
390
|
+
{this.state.update.Title}
|
|
391
|
+
</div>
|
|
392
|
+
{!_.isEmpty(this.state.update.Tags) && (
|
|
393
|
+
<div className="fontMedium marginBottom-8 text-light">
|
|
394
|
+
{_.map(this.state.update.Tags, (tag, index) => {
|
|
395
|
+
return (
|
|
396
|
+
<span key={index} style={{ color: COLOUR_BRANDING_MAIN }}>
|
|
397
|
+
{tag}
|
|
398
|
+
{index !== this.state.update.Tags.length - 1 ? ', ' : ''}
|
|
399
|
+
</span>
|
|
400
|
+
);
|
|
401
|
+
})}
|
|
402
|
+
</div>
|
|
403
|
+
)}
|
|
404
|
+
{!_.isEmpty(this.state.update.Images) &&
|
|
405
|
+
_.map(this.state.update.Images, (im, index) => {
|
|
406
|
+
return (
|
|
407
|
+
<div
|
|
408
|
+
key={index}
|
|
409
|
+
style={{
|
|
410
|
+
height: 250,
|
|
411
|
+
backgroundImage: `url(${im})`,
|
|
412
|
+
backgroundSize: 'cover',
|
|
413
|
+
backgroundPosition: 'center',
|
|
414
|
+
marginBottom: 10,
|
|
415
|
+
marginTop: 10,
|
|
416
|
+
}}
|
|
417
|
+
/>
|
|
418
|
+
);
|
|
419
|
+
})}
|
|
420
|
+
{_.isEmpty(this.state.update.Images) && <div className="fontRegular text-light">No image</div>}
|
|
421
|
+
<div className="marginTop-16 fontRegular text-dark fontSize-16" style={{ whiteSpace: 'pre-line' }}>
|
|
422
|
+
{this.state.update.Text}
|
|
423
|
+
</div>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
render() {
|
|
430
|
+
return (
|
|
431
|
+
<OverlayPage>
|
|
432
|
+
<OverlayPageContents noBottomButtons={this.state.success}>
|
|
433
|
+
<OverlayPageSection className="pageSectionWrapper--fixedPopupSize">
|
|
434
|
+
{this.renderForm()}
|
|
435
|
+
{this.renderSuccess()}
|
|
436
|
+
</OverlayPageSection>
|
|
437
|
+
{this.renderSideForm()}
|
|
438
|
+
</OverlayPageContents>
|
|
439
|
+
{!this.state.success && <OverlayPageBottomButtons>{this.renderSubmit()}</OverlayPageBottomButtons>}
|
|
440
|
+
</OverlayPage>
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const mapStateToProps = (state) => {
|
|
446
|
+
const { auth } = state;
|
|
447
|
+
return { auth };
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
export default connect(mapStateToProps, { newsUpdate })(PublishAvailableNews);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PlussCore } from '../feature.config';
|
|
2
|
+
|
|
3
|
+
const { Session } = PlussCore;
|
|
4
|
+
export const isTheBest = Session.isTheBest;
|
|
5
|
+
export const validateAccess = Session.validateAccess;
|
|
6
|
+
export const authedFunction = Session.authedFunction;
|
|
7
|
+
export const checkLoggedIn = Session.checkLoggedIn;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getUrl } from './helper';
|
|
2
|
+
import { authedFunction } from '../session';
|
|
3
|
+
|
|
4
|
+
export const eventActions = {
|
|
5
|
+
getEvents: (site, time, includePast) => {
|
|
6
|
+
let query = { site };
|
|
7
|
+
if (time) {
|
|
8
|
+
query.time = time;
|
|
9
|
+
}
|
|
10
|
+
if (includePast) {
|
|
11
|
+
query.includePast = 'true';
|
|
12
|
+
}
|
|
13
|
+
return authedFunction({
|
|
14
|
+
method: 'GET',
|
|
15
|
+
url: getUrl('events', 'get', query),
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PlussCore } from '../feature.config';
|
|
2
|
+
|
|
3
|
+
const { Apis } = PlussCore;
|
|
4
|
+
export const stringActions = Apis.stringActions;
|
|
5
|
+
export const analyticsActions = Apis.analyticsActions;
|
|
6
|
+
export const fileActions = Apis.fileActions;
|
|
7
|
+
export const userActions = Apis.userActions;
|
|
8
|
+
export const typeActions = Apis.typeActions;
|
|
9
|
+
|
|
10
|
+
export * from './eventActions';
|
|
11
|
+
export * from './newsletterActions';
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { getUrl } from './helper';
|
|
3
|
+
import { authedFunction } from '../session';
|
|
4
|
+
import { values } from '../feature.config';
|
|
5
|
+
|
|
6
|
+
export const newsletterActions = {
|
|
7
|
+
getRecent: (site, limit, maxTime, noFuture, tvMode) => {
|
|
8
|
+
const query = { site, limit, noFuture, tvMode };
|
|
9
|
+
if (maxTime) {
|
|
10
|
+
query.maxTime = maxTime;
|
|
11
|
+
}
|
|
12
|
+
return authedFunction({
|
|
13
|
+
method: 'GET',
|
|
14
|
+
url: getUrl(values.serviceKey, 'recent', query),
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
getNewsletterEntries: (site, skip, count) => {
|
|
18
|
+
const query = { site, noHQ: true, noFilter: true };
|
|
19
|
+
if (skip) {
|
|
20
|
+
query.skip = skip;
|
|
21
|
+
}
|
|
22
|
+
if (count) {
|
|
23
|
+
query.count = count;
|
|
24
|
+
}
|
|
25
|
+
return authedFunction({
|
|
26
|
+
method: 'GET',
|
|
27
|
+
url: getUrl(values.serviceKey, 'get', query),
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
recursiveGetNews: (site, results) => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const resultsToUse = results || [];
|
|
33
|
+
newsletterActions.getNewsletterEntries(site, resultsToUse.length, 500).then((res) => {
|
|
34
|
+
const finalResult = _.concat(resultsToUse, res.data.items);
|
|
35
|
+
if (finalResult.length < res.data.totalCount) {
|
|
36
|
+
return resolve(newsletterActions.recursiveGetNews(site, finalResult));
|
|
37
|
+
}
|
|
38
|
+
return resolve(finalResult);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
getNewsletterEntry: (id) => {
|
|
43
|
+
return authedFunction({
|
|
44
|
+
method: 'GET',
|
|
45
|
+
url: getUrl(values.serviceKey, `get/${id}`),
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
addOrEditNewsletterEntry: (data, site) => {
|
|
49
|
+
let url = getUrl(values.serviceKey, 'add');
|
|
50
|
+
if (data.RowId != null) {
|
|
51
|
+
url = getUrl(values.serviceKey, 'edit');
|
|
52
|
+
}
|
|
53
|
+
return authedFunction({
|
|
54
|
+
method: 'POST',
|
|
55
|
+
url,
|
|
56
|
+
data: {
|
|
57
|
+
site,
|
|
58
|
+
update: data,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
deleteNewsletterEntry: (site, id) => {
|
|
63
|
+
return authedFunction({
|
|
64
|
+
method: 'POST',
|
|
65
|
+
url: getUrl(values.serviceKey, 'remove'),
|
|
66
|
+
data: {
|
|
67
|
+
site,
|
|
68
|
+
id,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
getPublishedEntries: (ids) => {
|
|
73
|
+
const query = {};
|
|
74
|
+
if (Array.isArray(ids)) {
|
|
75
|
+
query.ids = ids.join(',');
|
|
76
|
+
} else {
|
|
77
|
+
query.ids = ids;
|
|
78
|
+
}
|
|
79
|
+
return authedFunction({
|
|
80
|
+
method: 'GET',
|
|
81
|
+
url: getUrl(values.serviceKey, 'content/specific', query),
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
getNewsletterSubmissions: (site) => {
|
|
85
|
+
return authedFunction({
|
|
86
|
+
method: 'GET',
|
|
87
|
+
url: getUrl(values.serviceKey, 'submissions/get', { site }),
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
getNewsletterSubmission: (id) => {
|
|
91
|
+
return authedFunction({
|
|
92
|
+
method: 'GET',
|
|
93
|
+
url: getUrl(values.serviceKey, `submissions/get/${id}`),
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
handleNewsletterSubmission: (site, id, action) => {
|
|
97
|
+
return authedFunction({
|
|
98
|
+
method: 'POST',
|
|
99
|
+
url: getUrl(values.serviceKey, 'submissions/handle'),
|
|
100
|
+
data: {
|
|
101
|
+
site,
|
|
102
|
+
id,
|
|
103
|
+
action,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
editNewsletterSubmission: (site, id, update) => {
|
|
108
|
+
return authedFunction({
|
|
109
|
+
method: 'POST',
|
|
110
|
+
url: getUrl(values.serviceKey, 'editSubmission'),
|
|
111
|
+
data: {
|
|
112
|
+
site,
|
|
113
|
+
id,
|
|
114
|
+
update,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
getSubmissionCount: (site) => {
|
|
119
|
+
return authedFunction({
|
|
120
|
+
method: 'GET',
|
|
121
|
+
url: getUrl(values.serviceKey, `submissions/count`, { site }),
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
getAvailableNews: (minTime, maxTime, count) => {
|
|
125
|
+
const query = {};
|
|
126
|
+
if (minTime) {
|
|
127
|
+
query.minTime = minTime;
|
|
128
|
+
}
|
|
129
|
+
if (maxTime) {
|
|
130
|
+
query.maxTime = maxTime;
|
|
131
|
+
}
|
|
132
|
+
if (count) {
|
|
133
|
+
query.count = count;
|
|
134
|
+
}
|
|
135
|
+
return authedFunction({
|
|
136
|
+
method: 'GET',
|
|
137
|
+
url: getUrl(values.serviceKey, 'content/get', query),
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
getPublishedAvailableNews: (site, sourceId) => {
|
|
141
|
+
const query = {};
|
|
142
|
+
if (site) {
|
|
143
|
+
query.site = site;
|
|
144
|
+
}
|
|
145
|
+
if (sourceId) {
|
|
146
|
+
query.sourceId = sourceId;
|
|
147
|
+
}
|
|
148
|
+
return authedFunction({
|
|
149
|
+
method: 'GET',
|
|
150
|
+
url: getUrl(values.serviceKey, 'content/published', query),
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
};
|