@plusscommunities/pluss-circles-web-groups 1.0.17 → 1.0.18

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/dist/index.esm.js CHANGED
@@ -7,7 +7,7 @@ import _inherits from '@babel/runtime/helpers/inherits';
7
7
  import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
8
8
  import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
9
9
  import _regeneratorRuntime from '@babel/runtime/regenerator';
10
- import React, { Component } from 'react';
10
+ import React, { Component, useState, useEffect } from 'react';
11
11
  import { connect } from 'react-redux';
12
12
  import _ from 'lodash';
13
13
  import moment from 'moment';
@@ -17,6 +17,8 @@ import { Table } from 'react-bootstrap';
17
17
  import FontAwesome from 'react-fontawesome';
18
18
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
19
19
  import { withRouter } from 'react-router';
20
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
21
+ import { faUserGroup, faMessage, faUserTie, faUsers, faUsersRectangle, faPeopleArrows } from '@fortawesome/free-solid-svg-icons';
20
22
 
21
23
  var values = {
22
24
  featureKey: 'groups',
@@ -151,10 +153,10 @@ var circleRemoved = function circleRemoved(circleId) {
151
153
  };
152
154
 
153
155
  var Helper$3 = PlussCore.Helper,
154
- Session$3 = PlussCore.Session;
156
+ Session$4 = PlussCore.Session;
155
157
  var circleActions = {
156
158
  getAll: function getAll(site) {
157
- return Session$3.authedFunction({
159
+ return Session$4.authedFunction({
158
160
  method: 'GET',
159
161
  url: Helper$3.getUrl(values.serviceKey, 'get/all', {
160
162
  site: site
@@ -162,7 +164,7 @@ var circleActions = {
162
164
  });
163
165
  },
164
166
  getFiles: function getFiles(circleId) {
165
- return Session$3.authedFunction({
167
+ return Session$4.authedFunction({
166
168
  method: 'GET',
167
169
  url: Helper$3.getUrl(values.serviceKey, 'get/files', {
168
170
  circleId: circleId
@@ -170,7 +172,7 @@ var circleActions = {
170
172
  });
171
173
  },
172
174
  getImages: function getImages(circleId) {
173
- return Session$3.authedFunction({
175
+ return Session$4.authedFunction({
174
176
  method: 'GET',
175
177
  url: Helper$3.getUrl(values.serviceKey, 'get/images', {
176
178
  circleId: circleId
@@ -178,7 +180,7 @@ var circleActions = {
178
180
  });
179
181
  },
180
182
  add: function add(site, title, image, audience, isPublic) {
181
- return Session$3.authedFunction({
183
+ return Session$4.authedFunction({
182
184
  method: 'POST',
183
185
  url: Helper$3.getUrl(values.serviceKey, 'update/add'),
184
186
  data: {
@@ -191,7 +193,7 @@ var circleActions = {
191
193
  });
192
194
  },
193
195
  edit: function edit(circleId, title, image, audience, isPublic) {
194
- return Session$3.authedFunction({
196
+ return Session$4.authedFunction({
195
197
  method: 'POST',
196
198
  url: Helper$3.getUrl(values.serviceKey, 'update/edit'),
197
199
  data: {
@@ -204,7 +206,7 @@ var circleActions = {
204
206
  });
205
207
  },
206
208
  delete: function _delete(circleId) {
207
- return Session$3.authedFunction({
209
+ return Session$4.authedFunction({
208
210
  method: 'POST',
209
211
  url: Helper$3.getUrl(values.serviceKey, 'update/delete'),
210
212
  data: {
@@ -213,7 +215,7 @@ var circleActions = {
213
215
  });
214
216
  },
215
217
  addAdmin: function addAdmin(circleId, userId) {
216
- return Session$3.authedFunction({
218
+ return Session$4.authedFunction({
217
219
  method: 'POST',
218
220
  url: Helper$3.getUrl(values.serviceKey, 'update/addadmin'),
219
221
  data: {
@@ -223,7 +225,7 @@ var circleActions = {
223
225
  });
224
226
  },
225
227
  removeAdmin: function removeAdmin(circleId, userId) {
226
- return Session$3.authedFunction({
228
+ return Session$4.authedFunction({
227
229
  method: 'POST',
228
230
  url: Helper$3.getUrl(values.serviceKey, 'update/removeadmin'),
229
231
  data: {
@@ -255,7 +257,7 @@ var circleActions = {
255
257
  query.limit = limit;
256
258
  }
257
259
 
258
- return _context.abrupt("return", Session$3.authedFunction({
260
+ return _context.abrupt("return", Session$4.authedFunction({
259
261
  method: 'GET',
260
262
  url: Helper$3.getUrl(values.serviceKey, 'getMessages', query)
261
263
  }));
@@ -280,7 +282,7 @@ var circleActions = {
280
282
  while (1) {
281
283
  switch (_context2.prev = _context2.next) {
282
284
  case 0:
283
- return _context2.abrupt("return", Session$3.authedFunction({
285
+ return _context2.abrupt("return", Session$4.authedFunction({
284
286
  method: 'post',
285
287
  url: Helper$3.getUrl(values.serviceKey, 'sendMessage'),
286
288
  data: {
@@ -305,11 +307,14 @@ var circleActions = {
305
307
  }()
306
308
  };
307
309
 
310
+ var Apis$1 = PlussCore.Apis;
311
+ var analyticsActions = Apis$1.analyticsActions;
312
+
308
313
  function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
309
314
 
310
315
  function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
311
- var Components$3 = PlussCore.Components,
312
- Session$2 = PlussCore.Session,
316
+ var Components$4 = PlussCore.Components,
317
+ Session$3 = PlussCore.Session,
313
318
  Helper$2 = PlussCore.Helper;
314
319
 
315
320
  var Circles = /*#__PURE__*/function (_Component) {
@@ -372,13 +377,13 @@ var Circles = /*#__PURE__*/function (_Component) {
372
377
 
373
378
  _defineProperty(_assertThisInitialized(_this), "canAddNew", function () {
374
379
  var auth = _this.props.auth;
375
- return Session$2.validateAccess(auth.site, values.permission, auth);
380
+ return Session$3.validateAccess(auth.site, values.permission, auth);
376
381
  });
377
382
 
378
383
  _defineProperty(_assertThisInitialized(_this), "onAddNew", function () {
379
384
  var auth = _this.props.auth;
380
385
 
381
- if (Session$2.validateAccess(auth.site, values.permission, auth)) {
386
+ if (Session$3.validateAccess(auth.site, values.permission, auth)) {
382
387
  _this.props.history.push("/".concat(values.featureKey, "/add"));
383
388
  }
384
389
  });
@@ -535,7 +540,7 @@ var Circles = /*#__PURE__*/function (_Component) {
535
540
  value: function validateCircleAdmin(circle, onlyCreator) {
536
541
  var _this4 = this;
537
542
 
538
- if (Session$2.validateAccess(this.props.auth.site, values.permission, this.props.auth)) {
543
+ if (Session$3.validateAccess(this.props.auth.site, values.permission, this.props.auth)) {
539
544
  return true;
540
545
  }
541
546
 
@@ -559,7 +564,7 @@ var Circles = /*#__PURE__*/function (_Component) {
559
564
  }, /*#__PURE__*/React.createElement(Link, {
560
565
  to: "/".concat(values.featureKey, "/").concat(values.entityKey, "/").concat(circle.Id)
561
566
  }, this.getTitle(circle))), /*#__PURE__*/React.createElement("td", null, moment(circle.Changed).local().format('D MMM YYYY')), /*#__PURE__*/React.createElement("td", null, circle.Audience.map(function (user) {
562
- return /*#__PURE__*/React.createElement(Components$3.ProfilePic, {
567
+ return /*#__PURE__*/React.createElement(Components$4.ProfilePic, {
563
568
  size: 30,
564
569
  image: user.profilePic,
565
570
  hoverText: user.displayName,
@@ -599,24 +604,24 @@ var Circles = /*#__PURE__*/function (_Component) {
599
604
  }, {
600
605
  key: "renderFilters",
601
606
  value: function renderFilters() {
602
- var userFilter = /*#__PURE__*/React.createElement(Components$3.Tag, {
607
+ var userFilter = /*#__PURE__*/React.createElement(Components$4.Tag, {
603
608
  className: "marginRight-10",
604
609
  onClick: this.openUserFilter,
605
610
  text: "User"
606
611
  });
607
- var typeFilter = /*#__PURE__*/React.createElement(Components$3.Tag, {
612
+ var typeFilter = /*#__PURE__*/React.createElement(Components$4.Tag, {
608
613
  className: "marginRight-10",
609
614
  onClick: this.openTypeFilter,
610
615
  text: "Type"
611
616
  });
612
617
 
613
618
  if (this.state.selectedUserFilter) {
614
- userFilter = /*#__PURE__*/React.createElement(Components$3.Tag, {
619
+ userFilter = /*#__PURE__*/React.createElement(Components$4.Tag, {
615
620
  className: "marginRight-10",
616
621
  onClick: this.openUserFilter,
617
622
  rightIcon: "close",
618
623
  rightClick: this.removeUserFilter
619
- }, /*#__PURE__*/React.createElement(Components$3.UserListing, {
624
+ }, /*#__PURE__*/React.createElement(Components$4.UserListing, {
620
625
  size: 15,
621
626
  user: this.state.selectedUserFilter,
622
627
  textClass: "tag_text"
@@ -624,7 +629,7 @@ var Circles = /*#__PURE__*/function (_Component) {
624
629
  }
625
630
 
626
631
  if (this.state.selectedTypeFilter) {
627
- typeFilter = /*#__PURE__*/React.createElement(Components$3.Tag, {
632
+ typeFilter = /*#__PURE__*/React.createElement(Components$4.Tag, {
628
633
  className: "marginRight-10",
629
634
  onClick: this.openTypeFilter,
630
635
  rightIcon: "close",
@@ -635,7 +640,7 @@ var Circles = /*#__PURE__*/function (_Component) {
635
640
 
636
641
  return /*#__PURE__*/React.createElement("div", {
637
642
  className: "flex flex-center marginTop-20"
638
- }, /*#__PURE__*/React.createElement(Components$3.Text, {
643
+ }, /*#__PURE__*/React.createElement(Components$4.Text, {
639
644
  type: "h5",
640
645
  className: "marginRight-20"
641
646
  }, "Filter by"), userFilter, typeFilter);
@@ -649,14 +654,14 @@ var Circles = /*#__PURE__*/function (_Component) {
649
654
  return null;
650
655
  }
651
656
 
652
- return /*#__PURE__*/React.createElement(Components$3.Popup, {
657
+ return /*#__PURE__*/React.createElement(Components$4.Popup, {
653
658
  title: "Select User",
654
659
  maxWidth: 600,
655
660
  minWidth: 400,
656
661
  minHeight: 400,
657
662
  hasPadding: true,
658
663
  onClose: this.closeUserFilter
659
- }, /*#__PURE__*/React.createElement(Components$3.GenericInput, {
664
+ }, /*#__PURE__*/React.createElement(Components$4.GenericInput, {
660
665
  id: "userSearch",
661
666
  type: "text",
662
667
  label: "Search",
@@ -667,7 +672,7 @@ var Circles = /*#__PURE__*/function (_Component) {
667
672
  },
668
673
  alwaysShowLabel: true
669
674
  }), this.getUsers().map(function (user) {
670
- return /*#__PURE__*/React.createElement(Components$3.UserListing, {
675
+ return /*#__PURE__*/React.createElement(Components$4.UserListing, {
671
676
  key: user.userId,
672
677
  user: user,
673
678
  onClick: function onClick() {
@@ -685,19 +690,19 @@ var Circles = /*#__PURE__*/function (_Component) {
685
690
  return null;
686
691
  }
687
692
 
688
- return /*#__PURE__*/React.createElement(Components$3.Popup, {
693
+ return /*#__PURE__*/React.createElement(Components$4.Popup, {
689
694
  title: "Select Type",
690
695
  maxWidth: 600,
691
696
  minWidth: 400,
692
697
  hasPadding: true,
693
698
  onClose: this.closeTypeFilter
694
- }, /*#__PURE__*/React.createElement(Components$3.Tag, {
699
+ }, /*#__PURE__*/React.createElement(Components$4.Tag, {
695
700
  onClick: function onClick() {
696
701
  _this7.selectTypeFilter('circle');
697
702
  },
698
703
  text: _.capitalize(values.entityName),
699
704
  className: "marginRight-10"
700
- }), /*#__PURE__*/React.createElement(Components$3.Tag, {
705
+ }), /*#__PURE__*/React.createElement(Components$4.Tag, {
701
706
  onClick: function onClick() {
702
707
  _this7.selectTypeFilter('private');
703
708
  },
@@ -709,12 +714,12 @@ var Circles = /*#__PURE__*/function (_Component) {
709
714
  value: function render() {
710
715
  var _this8 = this;
711
716
 
712
- return /*#__PURE__*/React.createElement("div", null, this.renderTypeFilterPopup(), this.renderUserFilterPopup(), /*#__PURE__*/React.createElement(Components$3.Header, null, this.canAddNew() && /*#__PURE__*/React.createElement(Components$3.AddButton, {
717
+ return /*#__PURE__*/React.createElement("div", null, this.renderTypeFilterPopup(), this.renderUserFilterPopup(), /*#__PURE__*/React.createElement(Components$4.Header, null, this.canAddNew() && /*#__PURE__*/React.createElement(Components$4.AddButton, {
713
718
  onClick: this.onAddNew,
714
719
  text: "NEW ".concat(_.upperCase(values.entityName))
715
720
  })), /*#__PURE__*/React.createElement("div", {
716
721
  className: "pageContainer paddingVertical-20 paddingHorizontal-40"
717
- }, /*#__PURE__*/React.createElement(Components$3.Text, {
722
+ }, /*#__PURE__*/React.createElement(Components$4.Text, {
718
723
  type: "h1",
719
724
  className: ""
720
725
  }, values.textFeatureTitle), this.renderFilters(), /*#__PURE__*/React.createElement(Table, {
@@ -741,7 +746,7 @@ var Circles = /*#__PURE__*/function (_Component) {
741
746
  return Circles;
742
747
  }(Component);
743
748
 
744
- var mapStateToProps$2 = function mapStateToProps(state) {
749
+ var mapStateToProps$3 = function mapStateToProps(state) {
745
750
  var circles = state[values.reducerKey].circles;
746
751
  var auth = state.auth;
747
752
  return {
@@ -751,7 +756,7 @@ var mapStateToProps$2 = function mapStateToProps(state) {
751
756
  };
752
757
  };
753
758
 
754
- var Circles$1 = connect(mapStateToProps$2, {
759
+ var Circles$1 = connect(mapStateToProps$3, {
755
760
  circlesLoaded: circlesLoaded,
756
761
  circleRemoved: circleRemoved
757
762
  })(Circles);
@@ -760,8 +765,8 @@ function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeRefl
760
765
 
761
766
  function _isNativeReflectConstruct$6() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
762
767
  var Actions$1 = PlussCore.Actions,
763
- Components$2 = PlussCore.Components,
764
- Session$1 = PlussCore.Session,
768
+ Components$3 = PlussCore.Components,
769
+ Session$2 = PlussCore.Session,
765
770
  Apis = PlussCore.Apis,
766
771
  Colours$2 = PlussCore.Colours,
767
772
  Helper$1 = PlussCore.Helper;
@@ -1037,7 +1042,7 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1037
1042
  _createClass(AddCircle, [{
1038
1043
  key: "componentDidMount",
1039
1044
  value: function componentDidMount() {
1040
- Session$1.checkLoggedIn(this, this.props.auth);
1045
+ Session$2.checkLoggedIn(this, this.props.auth);
1041
1046
  this.props.addRecentlyCreated(values.entityKey);
1042
1047
  this.getUsers();
1043
1048
  this.checkGetCircle();
@@ -1083,7 +1088,7 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1083
1088
  key: "renderSuccess",
1084
1089
  value: function renderSuccess() {
1085
1090
  if (!this.state.success) return null;
1086
- return /*#__PURE__*/React.createElement(Components$2.SuccessPopup, {
1091
+ return /*#__PURE__*/React.createElement(Components$3.SuccessPopup, {
1087
1092
  text: "".concat(_.capitalize(values.entityName), " has been ").concat(this.state.circleId == null ? 'added' : 'edited'),
1088
1093
  buttons: [{
1089
1094
  type: 'outlined',
@@ -1100,12 +1105,12 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1100
1105
  var _this4 = this;
1101
1106
 
1102
1107
  if (this.state.updating) {
1103
- return /*#__PURE__*/React.createElement(Components$2.Button, {
1108
+ return /*#__PURE__*/React.createElement(Components$3.Button, {
1104
1109
  buttonType: "secondary"
1105
1110
  }, "Saving...");
1106
1111
  }
1107
1112
 
1108
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Components$2.Button, {
1113
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Components$3.Button, {
1109
1114
  inline: true,
1110
1115
  buttonType: "tertiary",
1111
1116
  onClick: function onClick() {
@@ -1115,7 +1120,7 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1115
1120
  style: {
1116
1121
  marginRight: 16
1117
1122
  }
1118
- }, "Cancel"), /*#__PURE__*/React.createElement(Components$2.Button, {
1123
+ }, "Cancel"), /*#__PURE__*/React.createElement(Components$3.Button, {
1119
1124
  inline: true,
1120
1125
  buttonType: "primary",
1121
1126
  onClick: this.onSave,
@@ -1129,7 +1134,7 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1129
1134
 
1130
1135
  return /*#__PURE__*/React.createElement("div", {
1131
1136
  className: "optionsContent_bottom"
1132
- }, /*#__PURE__*/React.createElement(Components$2.RadioButton, {
1137
+ }, /*#__PURE__*/React.createElement(Components$3.RadioButton, {
1133
1138
  label: "Do you want to make this ".concat(values.entityName, " a public ").concat(values.entityName, "?"),
1134
1139
  isActive: this.state.isPublic,
1135
1140
  options: [{
@@ -1184,7 +1189,7 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1184
1189
  return null;
1185
1190
  }
1186
1191
 
1187
- return /*#__PURE__*/React.createElement(Components$2.OptionsSection, {
1192
+ return /*#__PURE__*/React.createElement(Components$3.OptionsSection, {
1188
1193
  options: options,
1189
1194
  selected: this.state.selectedOption,
1190
1195
  selectOption: this.selectOption
@@ -1197,12 +1202,12 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1197
1202
 
1198
1203
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
1199
1204
  className: "padding-60 paddingVertical-40 bottomDivideBorder"
1200
- }, /*#__PURE__*/React.createElement(Components$2.Text, {
1205
+ }, /*#__PURE__*/React.createElement(Components$3.Text, {
1201
1206
  type: "formTitleLarge",
1202
1207
  className: "marginBottom-24"
1203
1208
  }, this.state.circleId == null ? 'New' : 'Edit', " ", _.capitalize(values.entityName)), /*#__PURE__*/React.createElement("div", {
1204
1209
  className: "flex flex-reverse"
1205
- }, /*#__PURE__*/React.createElement(Components$2.ImageInput, {
1210
+ }, /*#__PURE__*/React.createElement(Components$3.ImageInput, {
1206
1211
  ref: function ref(_ref2) {
1207
1212
  _this6.imageInput = _ref2;
1208
1213
  },
@@ -1214,7 +1219,7 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1214
1219
  }
1215
1220
  }), /*#__PURE__*/React.createElement("div", {
1216
1221
  className: "flex-1"
1217
- }, /*#__PURE__*/React.createElement(Components$2.GenericInput, {
1222
+ }, /*#__PURE__*/React.createElement(Components$3.GenericInput, {
1218
1223
  id: "title",
1219
1224
  type: "text",
1220
1225
  label: "Title",
@@ -1233,16 +1238,16 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1233
1238
  }
1234
1239
  })))), /*#__PURE__*/React.createElement("div", {
1235
1240
  className: "padding-60 paddingVertical-40 bottomDivideBorder"
1236
- }, /*#__PURE__*/React.createElement(Components$2.Text, {
1241
+ }, /*#__PURE__*/React.createElement(Components$3.Text, {
1237
1242
  type: "formTitleMedium"
1238
1243
  }, "Members"), /*#__PURE__*/React.createElement("div", {
1239
1244
  className: "flex marginTop-20"
1240
1245
  }, /*#__PURE__*/React.createElement("div", {
1241
1246
  className: "flex-1"
1242
- }, /*#__PURE__*/React.createElement(Components$2.Text, {
1247
+ }, /*#__PURE__*/React.createElement(Components$3.Text, {
1243
1248
  type: "formTitleSmall",
1244
1249
  className: "marginBottom-10"
1245
- }, "Select Users"), /*#__PURE__*/React.createElement(Components$2.GenericInput, {
1250
+ }, "Select Users"), /*#__PURE__*/React.createElement(Components$3.GenericInput, {
1246
1251
  id: "userSearch",
1247
1252
  type: "text",
1248
1253
  label: "Search",
@@ -1253,7 +1258,7 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1253
1258
  },
1254
1259
  alwaysShowLabel: true
1255
1260
  }), this.getShownUsers().map(function (user) {
1256
- return /*#__PURE__*/React.createElement(Components$2.UserListing, {
1261
+ return /*#__PURE__*/React.createElement(Components$3.UserListing, {
1257
1262
  key: user.userId,
1258
1263
  user: user,
1259
1264
  onClick: function onClick() {
@@ -1262,23 +1267,23 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1262
1267
  });
1263
1268
  })), /*#__PURE__*/React.createElement("div", {
1264
1269
  className: "flex-1"
1265
- }, /*#__PURE__*/React.createElement(Components$2.Text, {
1270
+ }, /*#__PURE__*/React.createElement(Components$3.Text, {
1266
1271
  type: "formTitleSmall",
1267
1272
  className: "marginBottom-10"
1268
1273
  }, "Selected"), this.state.selectedUsers.map(function (user) {
1269
- return /*#__PURE__*/React.createElement(Components$2.UserListing, {
1274
+ return /*#__PURE__*/React.createElement(Components$3.UserListing, {
1270
1275
  key: user.userId,
1271
1276
  user: user,
1272
1277
  rightContent: /*#__PURE__*/React.createElement("div", {
1273
1278
  className: "flex flex-reverse flex-center"
1274
- }, /*#__PURE__*/React.createElement(Components$2.SVGIcon, {
1279
+ }, /*#__PURE__*/React.createElement(Components$3.SVGIcon, {
1275
1280
  className: "removeIcon marginLeft-8",
1276
1281
  icon: "close",
1277
1282
  colour: Colours$2.COLOUR_DUSK,
1278
1283
  onClick: function onClick() {
1279
1284
  _this6.onSelectUser(user);
1280
1285
  }
1281
- }), /*#__PURE__*/React.createElement(Components$2.StatusButton, {
1286
+ }), /*#__PURE__*/React.createElement(Components$3.StatusButton, {
1282
1287
  isActive: user.isAdmin,
1283
1288
  activate: function activate() {
1284
1289
  _this6.addAdmin(user);
@@ -1298,18 +1303,18 @@ var AddCircle = /*#__PURE__*/function (_Component) {
1298
1303
  key: "render",
1299
1304
  value: function render() {
1300
1305
  var success = this.state.success;
1301
- return /*#__PURE__*/React.createElement(Components$2.OverlayPage, null, /*#__PURE__*/React.createElement(Components$2.OverlayPageContents, {
1306
+ return /*#__PURE__*/React.createElement(Components$3.OverlayPage, null, /*#__PURE__*/React.createElement(Components$3.OverlayPageContents, {
1302
1307
  noBottomButtons: success
1303
- }, /*#__PURE__*/React.createElement(Components$2.OverlayPageSection, {
1308
+ }, /*#__PURE__*/React.createElement(Components$3.OverlayPageSection, {
1304
1309
  className: "pageSectionWrapper--newPopup"
1305
- }, /*#__PURE__*/React.createElement("div", null, this.renderSuccess(), !success && this.renderMain()))), /*#__PURE__*/React.createElement(Components$2.OverlayPageBottomButtons, null, this.renderSubmit()));
1310
+ }, /*#__PURE__*/React.createElement("div", null, this.renderSuccess(), !success && this.renderMain()))), /*#__PURE__*/React.createElement(Components$3.OverlayPageBottomButtons, null, this.renderSubmit()));
1306
1311
  }
1307
1312
  }]);
1308
1313
 
1309
1314
  return AddCircle;
1310
1315
  }(Component);
1311
1316
 
1312
- var mapStateToProps$1 = function mapStateToProps(state) {
1317
+ var mapStateToProps$2 = function mapStateToProps(state) {
1313
1318
  var circles = state[values.reducerKey].circles;
1314
1319
  var auth = state.auth;
1315
1320
  return {
@@ -1319,7 +1324,7 @@ var mapStateToProps$1 = function mapStateToProps(state) {
1319
1324
  };
1320
1325
  };
1321
1326
 
1322
- var AddCircle$1 = connect(mapStateToProps$1, {
1327
+ var AddCircle$1 = connect(mapStateToProps$2, {
1323
1328
  circlesLoaded: circlesLoaded,
1324
1329
  circleUpdated: circleUpdated,
1325
1330
  addRecentlyCreated: Actions$1.addRecentlyCreated
@@ -1328,10 +1333,10 @@ var AddCircle$1 = connect(mapStateToProps$1, {
1328
1333
  function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1329
1334
 
1330
1335
  function _isNativeReflectConstruct$5() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1331
- var Components$1 = PlussCore.Components,
1336
+ var Components$2 = PlussCore.Components,
1332
1337
  Helper = PlussCore.Helper,
1333
1338
  Actions = PlussCore.Actions,
1334
- Session = PlussCore.Session,
1339
+ Session$1 = PlussCore.Session,
1335
1340
  Colours$1 = PlussCore.Colours;
1336
1341
 
1337
1342
  var Circle = /*#__PURE__*/function (_Component) {
@@ -1752,7 +1757,7 @@ var Circle = /*#__PURE__*/function (_Component) {
1752
1757
  value: function validateCircleAdmin() {
1753
1758
  var _this4 = this;
1754
1759
 
1755
- if (Session.validateAccess(this.props.auth.site, values.permission, this.props.auth)) {
1760
+ if (Session$1.validateAccess(this.props.auth.site, values.permission, this.props.auth)) {
1756
1761
  return true;
1757
1762
  }
1758
1763
 
@@ -1766,7 +1771,7 @@ var Circle = /*#__PURE__*/function (_Component) {
1766
1771
  var _this5 = this;
1767
1772
 
1768
1773
  if (!this.isMember()) {
1769
- return /*#__PURE__*/React.createElement(Components$1.Text, {
1774
+ return /*#__PURE__*/React.createElement(Components$2.Text, {
1770
1775
  type: "highlightedHelp",
1771
1776
  className: "chat_noMessage"
1772
1777
  }, "You can't send a message to this ", _.capitalize(values.entityName), " as you are not a member.");
@@ -1780,7 +1785,7 @@ var Circle = /*#__PURE__*/function (_Component) {
1780
1785
  onClick: this.sendMessage
1781
1786
  }), /*#__PURE__*/React.createElement("div", {
1782
1787
  className: "chat_inputContainer"
1783
- }, /*#__PURE__*/React.createElement(Components$1.GenericInput, {
1788
+ }, /*#__PURE__*/React.createElement(Components$2.GenericInput, {
1784
1789
  id: "messageInput",
1785
1790
  type: "textarea",
1786
1791
  className: "chat_input",
@@ -1807,7 +1812,7 @@ var Circle = /*#__PURE__*/function (_Component) {
1807
1812
  style: {
1808
1813
  display: this.state.imageInputShowing ? 'block' : 'none'
1809
1814
  }
1810
- }, /*#__PURE__*/React.createElement(Components$1.ImageInput, {
1815
+ }, /*#__PURE__*/React.createElement(Components$2.ImageInput, {
1811
1816
  ref: function ref(_ref4) {
1812
1817
  _this5.imageInput = _ref4;
1813
1818
  },
@@ -1822,7 +1827,7 @@ var Circle = /*#__PURE__*/function (_Component) {
1822
1827
  style: {
1823
1828
  display: this.state.fileInputShowing ? 'block' : 'none'
1824
1829
  }
1825
- }, /*#__PURE__*/React.createElement(Components$1.FileInput, {
1830
+ }, /*#__PURE__*/React.createElement(Components$2.FileInput, {
1826
1831
  ref: function ref(_ref5) {
1827
1832
  _this5.fileInput = _ref5;
1828
1833
  },
@@ -1843,7 +1848,7 @@ var Circle = /*#__PURE__*/function (_Component) {
1843
1848
  return /*#__PURE__*/React.createElement("div", {
1844
1849
  key: m._id,
1845
1850
  className: "message"
1846
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1851
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1847
1852
  type: "h5",
1848
1853
  className: "message_system"
1849
1854
  }, m.text));
@@ -1853,28 +1858,28 @@ var Circle = /*#__PURE__*/function (_Component) {
1853
1858
  return /*#__PURE__*/React.createElement("div", {
1854
1859
  key: m._id,
1855
1860
  className: "message".concat(isSelf ? ' message-self' : '').concat(m.uploading ? ' message-uploading' : '')
1856
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1861
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1857
1862
  type: "h5-noUpper",
1858
1863
  className: "message_time"
1859
1864
  }, moment.utc(m.createdAt).local().format('D MMM YYYY • h:mma')), /*#__PURE__*/React.createElement("div", {
1860
1865
  className: "message_inner"
1861
- }, /*#__PURE__*/React.createElement(Components$1.ProfilePic, {
1866
+ }, /*#__PURE__*/React.createElement(Components$2.ProfilePic, {
1862
1867
  size: 40,
1863
1868
  image: m.user.avatar,
1864
1869
  className: "message_profilePic"
1865
1870
  }), /*#__PURE__*/React.createElement("div", {
1866
1871
  className: "message_bubbleContainer"
1867
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1872
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1868
1873
  type: "body",
1869
1874
  className: "message_name"
1870
1875
  }, m.user.name, m.replyingTo ? " replied to ".concat(m.replyingTo.user.name) : ''), m.replyingTo && /*#__PURE__*/React.createElement("div", {
1871
1876
  className: "message_replyBubble"
1872
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1877
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1873
1878
  type: "body",
1874
1879
  className: "message_text"
1875
1880
  }, Helper.toParagraphed((m.replyingTo.text || '').substr(0, 100)))), /*#__PURE__*/React.createElement("div", {
1876
1881
  className: "message_bubble"
1877
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1882
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1878
1883
  type: "body",
1879
1884
  className: "message_text"
1880
1885
  }, Helper.toParagraphed(m.text)), /*#__PURE__*/React.createElement("div", null, (m.image || []).map(function (url, i) {
@@ -1888,14 +1893,14 @@ var Circle = /*#__PURE__*/function (_Component) {
1888
1893
  alt: Helper.getFileName(url)
1889
1894
  }));
1890
1895
  })), /*#__PURE__*/React.createElement("div", null, (m.attachments || []).map(function (url, i) {
1891
- return /*#__PURE__*/React.createElement(Components$1.Attachment, {
1896
+ return /*#__PURE__*/React.createElement(Components$2.Attachment, {
1892
1897
  source: url,
1893
1898
  key: i,
1894
1899
  white: isSelf
1895
1900
  });
1896
1901
  }))), /*#__PURE__*/React.createElement("div", {
1897
1902
  className: "message_reply"
1898
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1903
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1899
1904
  type: "button",
1900
1905
  onClick: function onClick() {
1901
1906
  _this6.onReply(m);
@@ -1944,12 +1949,12 @@ var Circle = /*#__PURE__*/function (_Component) {
1944
1949
  onClick: this.toggleMembers
1945
1950
  }), /*#__PURE__*/React.createElement("div", {
1946
1951
  className: "flex-1"
1947
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1952
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1948
1953
  type: "formTitleMedium"
1949
1954
  }, "Member", Helper.getPluralS(members.length), " (", members.length, ")"))), this.state.membersExpanded && /*#__PURE__*/React.createElement("div", {
1950
1955
  className: "paddingTop-8"
1951
1956
  }, members.map(function (user) {
1952
- return /*#__PURE__*/React.createElement(Components$1.UserListing, {
1957
+ return /*#__PURE__*/React.createElement(Components$2.UserListing, {
1953
1958
  user: user
1954
1959
  });
1955
1960
  }))), /*#__PURE__*/React.createElement("div", {
@@ -1962,7 +1967,7 @@ var Circle = /*#__PURE__*/function (_Component) {
1962
1967
  onClick: this.toggleImages
1963
1968
  }), /*#__PURE__*/React.createElement("div", {
1964
1969
  className: "flex-1"
1965
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1970
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1966
1971
  type: "formTitleMedium"
1967
1972
  }, "Image", Helper.getPluralS(this.state.images.length), " (", this.state.images.length, ")"))), this.state.imagesExpanded && /*#__PURE__*/React.createElement("div", {
1968
1973
  className: "paddingTop-8"
@@ -1985,12 +1990,12 @@ var Circle = /*#__PURE__*/function (_Component) {
1985
1990
  onClick: this.toggleFiles
1986
1991
  }), /*#__PURE__*/React.createElement("div", {
1987
1992
  className: "flex-1"
1988
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
1993
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
1989
1994
  type: "formTitleMedium"
1990
1995
  }, "File", Helper.getPluralS(this.state.files.length), " (", this.state.files.length, ")"))), this.state.filesExpanded && /*#__PURE__*/React.createElement("div", {
1991
1996
  className: "paddingTop-8"
1992
1997
  }, this.state.files.map(function (file, i) {
1993
- return /*#__PURE__*/React.createElement(Components$1.Attachment, {
1998
+ return /*#__PURE__*/React.createElement(Components$2.Attachment, {
1994
1999
  source: file.Url,
1995
2000
  key: i
1996
2001
  });
@@ -2010,13 +2015,13 @@ var Circle = /*#__PURE__*/function (_Component) {
2010
2015
  className: "chat_replyTo"
2011
2016
  }, /*#__PURE__*/React.createElement("div", {
2012
2017
  className: "chat_replyTo_container"
2013
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
2018
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
2014
2019
  type: "h5"
2015
- }, "Replying to ", m && m.user && !_.isEmpty(m.user.displayName) ? m.user.displayName : ''), m && !_.isEmpty(m.text) && /*#__PURE__*/React.createElement(Components$1.Text, {
2020
+ }, "Replying to ", m && m.user && !_.isEmpty(m.user.displayName) ? m.user.displayName : ''), m && !_.isEmpty(m.text) && /*#__PURE__*/React.createElement(Components$2.Text, {
2016
2021
  type: "body"
2017
2022
  }, m.text.substr(0, 50))), /*#__PURE__*/React.createElement("div", {
2018
2023
  className: "chat_replyTo_remove"
2019
- }, /*#__PURE__*/React.createElement(Components$1.SVGIcon, {
2024
+ }, /*#__PURE__*/React.createElement(Components$2.SVGIcon, {
2020
2025
  className: "removeIcon",
2021
2026
  icon: "close",
2022
2027
  onClick: function onClick() {
@@ -2030,13 +2035,13 @@ var Circle = /*#__PURE__*/function (_Component) {
2030
2035
  value: function render() {
2031
2036
  var _this8 = this;
2032
2037
 
2033
- return /*#__PURE__*/React.createElement(Components$1.OverlayPage, {
2038
+ return /*#__PURE__*/React.createElement(Components$2.OverlayPage, {
2034
2039
  fullPage: true,
2035
2040
  fullPageStyle: {
2036
2041
  display: 'flex',
2037
2042
  flexDirection: 'column'
2038
2043
  }
2039
- }, /*#__PURE__*/React.createElement(Components$1.Header, {
2044
+ }, /*#__PURE__*/React.createElement(Components$2.Header, {
2040
2045
  rightContent: this.renderHeaderRight()
2041
2046
  }, /*#__PURE__*/React.createElement(FontAwesome, {
2042
2047
  className: "header_back",
@@ -2044,21 +2049,21 @@ var Circle = /*#__PURE__*/function (_Component) {
2044
2049
  onClick: function onClick() {
2045
2050
  window.history.back();
2046
2051
  }
2047
- }), /*#__PURE__*/React.createElement(Components$1.Text, {
2052
+ }), /*#__PURE__*/React.createElement(Components$2.Text, {
2048
2053
  type: "formTitleLarge",
2049
2054
  className: "header_title"
2050
2055
  }, this.getTitle())), /*#__PURE__*/React.createElement("div", {
2051
2056
  className: "flex flex-1 flex-reverse overflow-hidden"
2052
2057
  }, this.renderSideBar(), /*#__PURE__*/React.createElement("div", {
2053
2058
  className: "flex-1 flex flex-column overflow-hidden"
2054
- }, /*#__PURE__*/React.createElement(Components$1.Header, {
2059
+ }, /*#__PURE__*/React.createElement(Components$2.Header, {
2055
2060
  onlyContainer: true
2056
2061
  }, /*#__PURE__*/React.createElement("div", {
2057
2062
  className: "flex flex-center flex-1 paddingHorizontal-16"
2058
- }, /*#__PURE__*/React.createElement(Components$1.Text, {
2063
+ }, /*#__PURE__*/React.createElement(Components$2.Text, {
2059
2064
  type: "h5",
2060
2065
  className: "marginRight-20"
2061
- }, "Filter by"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Components$1.GenericInput, {
2066
+ }, "Filter by"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Components$2.GenericInput, {
2062
2067
  id: "messageDate",
2063
2068
  label: "Date",
2064
2069
  alwaysShowLabel: true,
@@ -2069,13 +2074,13 @@ var Circle = /*#__PURE__*/function (_Component) {
2069
2074
  showMessageDate: !_this8.state.showMessageDate
2070
2075
  });
2071
2076
  },
2072
- rightContent: !_.isEmpty(this.state.messageDate) && /*#__PURE__*/React.createElement(Components$1.SVGIcon, {
2077
+ rightContent: !_.isEmpty(this.state.messageDate) && /*#__PURE__*/React.createElement(Components$2.SVGIcon, {
2073
2078
  colour: Colours$1.COLOUR_DUSK_LIGHT,
2074
2079
  icon: "close",
2075
2080
  className: "timepicker_clear",
2076
2081
  onClick: this.onClearDate
2077
2082
  })
2078
- }), this.state.showMessageDate && /*#__PURE__*/React.createElement(Components$1.DatePicker, {
2083
+ }), this.state.showMessageDate && /*#__PURE__*/React.createElement(Components$2.DatePicker, {
2079
2084
  hideTop: true,
2080
2085
  selectedDate: this.state.messageDate,
2081
2086
  selectDate: this.handleMessageDateChange
@@ -2097,7 +2102,7 @@ var Circle = /*#__PURE__*/function (_Component) {
2097
2102
  return Circle;
2098
2103
  }(Component);
2099
2104
 
2100
- var mapStateToProps = function mapStateToProps(state) {
2105
+ var mapStateToProps$1 = function mapStateToProps(state) {
2101
2106
  var circles = state[values.reducerKey].circles;
2102
2107
  var auth = state.auth;
2103
2108
  return {
@@ -2107,11 +2112,259 @@ var mapStateToProps = function mapStateToProps(state) {
2107
2112
  };
2108
2113
  };
2109
2114
 
2110
- var Circle$1 = connect(mapStateToProps, {
2115
+ var Circle$1 = connect(mapStateToProps$1, {
2111
2116
  circlesLoaded: circlesLoaded,
2112
2117
  setNavData: Actions.setNavData
2113
2118
  })(Circle);
2114
2119
 
2120
+ var Analytics$1 = PlussCore.Analytics,
2121
+ Session = PlussCore.Session,
2122
+ Components$1 = PlussCore.Components;
2123
+
2124
+ var getInitialState = function getInitialState() {
2125
+ return {
2126
+ isLoading: true,
2127
+ messages: 0,
2128
+ prevMessages: 0,
2129
+ staffMessages: 0,
2130
+ prevStaffMessages: 0,
2131
+ residentMessages: 0,
2132
+ prevResidentMessages: 0,
2133
+ groupMessages: 0,
2134
+ prevGroupMessages: 0,
2135
+ privateMessages: 0,
2136
+ prevPrivateMessages: 0,
2137
+ activeGroups: 0,
2138
+ prevActiveGroups: 0
2139
+ };
2140
+ }; // AnalyticsHub Component
2141
+
2142
+
2143
+ var AnalyticsHub = function AnalyticsHub(_ref) {
2144
+ var startTime = _ref.startTime,
2145
+ endTime = _ref.endTime,
2146
+ auth = _ref.auth,
2147
+ prevText = _ref.prevText,
2148
+ dayCount = _ref.dayCount,
2149
+ strings = _ref.strings;
2150
+
2151
+ var _useState = useState(getInitialState()),
2152
+ _useState2 = _slicedToArray(_useState, 2),
2153
+ analyticsData = _useState2[0],
2154
+ setAnalyticsData = _useState2[1];
2155
+
2156
+ var _useState3 = useState(false),
2157
+ _useState4 = _slicedToArray(_useState3, 2),
2158
+ isExportOpen = _useState4[0],
2159
+ setIsExportOpen = _useState4[1];
2160
+
2161
+ var hasAccess = Session.validateAccess(auth.site, values.permissionNewsletter, auth);
2162
+
2163
+ if (!hasAccess) {
2164
+ return null;
2165
+ }
2166
+
2167
+ var featureTitle = function (key) {
2168
+ if (!strings || !strings.sideNav || !strings.sideNav[key]) {
2169
+ return values.textFeatureTitle;
2170
+ }
2171
+
2172
+ return strings.sideNav[key];
2173
+ }();
2174
+
2175
+ var exportColumns = [{
2176
+ label: 'Select All',
2177
+ key: ''
2178
+ }, {
2179
+ label: 'Start Date',
2180
+ key: 'startDate'
2181
+ }, {
2182
+ label: 'End Date',
2183
+ key: 'endDate'
2184
+ }, {
2185
+ label: 'Messages',
2186
+ key: 'messages'
2187
+ }, {
2188
+ label: 'Messages by Staff',
2189
+ key: 'staffMessages'
2190
+ }, {
2191
+ label: 'Messages by Primary Users',
2192
+ key: 'residentMessages'
2193
+ }, {
2194
+ label: 'Group Messages',
2195
+ key: 'groupMessages'
2196
+ }, {
2197
+ label: 'Private Messages',
2198
+ key: 'privateMessages'
2199
+ }, {
2200
+ label: 'Groups with Messages',
2201
+ key: 'activeGroups'
2202
+ }];
2203
+ useEffect(function () {
2204
+ getData();
2205
+ }, [startTime, endTime]);
2206
+
2207
+ var getData = /*#__PURE__*/function () {
2208
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
2209
+ var timeDifference, _yield$Promise$all, _yield$Promise$all2, currentStatsResponse, prevStatsResponse, data;
2210
+
2211
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
2212
+ while (1) {
2213
+ switch (_context.prev = _context.next) {
2214
+ case 0:
2215
+ setAnalyticsData(getInitialState()); // Load analytics data here using startTime and endTime
2216
+
2217
+ timeDifference = endTime - startTime;
2218
+ _context.next = 4;
2219
+ return Promise.all([analyticsActions.getAggregateEntityStats(auth.site, values.entityKey, startTime, endTime, true), analyticsActions.getAggregateEntityStats(auth.site, values.entityKey, startTime - timeDifference, startTime, true)]);
2220
+
2221
+ case 4:
2222
+ _yield$Promise$all = _context.sent;
2223
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
2224
+ currentStatsResponse = _yield$Promise$all2[0];
2225
+ prevStatsResponse = _yield$Promise$all2[1];
2226
+ data = {
2227
+ messages: Analytics$1.countActivities(currentStatsResponse.data, 'Message', 'total'),
2228
+ prevMessages: Analytics$1.countActivities(prevStatsResponse.data, 'Message', 'total'),
2229
+ staffMessages: Analytics$1.countActivities(currentStatsResponse.data, 'StaffMessage', 'total'),
2230
+ prevStaffMessages: Analytics$1.countActivities(prevStatsResponse.data, 'StaffMessage', 'total'),
2231
+ residentMessages: Analytics$1.countActivities(currentStatsResponse.data, 'ResidentMessage', 'total'),
2232
+ prevResidentMessages: Analytics$1.countActivities(prevStatsResponse.data, 'ResidentMessage', 'total'),
2233
+ groupMessages: Analytics$1.countActivities(currentStatsResponse.data, 'GroupMessage', 'total'),
2234
+ prevGroupMessages: Analytics$1.countActivities(prevStatsResponse.data, 'GroupMessage', 'total'),
2235
+ privateMessages: Analytics$1.countActivities(currentStatsResponse.data, 'PrivateMessage', 'total'),
2236
+ prevPrivateMessages: Analytics$1.countActivities(prevStatsResponse.data, 'PrivateMessage', 'total'),
2237
+ activeGroups: Analytics$1.countActivities(currentStatsResponse.data, 'GroupMessage', 'unique'),
2238
+ prevActiveGroups: Analytics$1.countActivities(prevStatsResponse.data, 'GroupMessage', 'unique'),
2239
+ // uniquePageView: Analytics.countActivities(currentStatsResponse.data, 'UniquePageView', 'uniquearray'),
2240
+ // prevUniquePageView: Analytics.countActivities(prevStatsResponse.data, 'UniquePageView', 'uniquearray'),
2241
+ isLoading: false
2242
+ };
2243
+ setAnalyticsData(data);
2244
+
2245
+ case 10:
2246
+ case "end":
2247
+ return _context.stop();
2248
+ }
2249
+ }
2250
+ }, _callee);
2251
+ }));
2252
+
2253
+ return function getData() {
2254
+ return _ref2.apply(this, arguments);
2255
+ };
2256
+ }();
2257
+
2258
+ var isReadyToOpenCSV = function isReadyToOpenCSV() {
2259
+ return !analyticsData.isLoading;
2260
+ };
2261
+
2262
+ var getExportSource = function getExportSource() {
2263
+ return [{
2264
+ startDate: moment(startTime + 1).format('D-MM-YYYY'),
2265
+ endDate: moment(endTime).format('D-MM-YYYY'),
2266
+ messages: analyticsData.messages,
2267
+ staffMessages: analyticsData.staffMessages,
2268
+ residentMessages: analyticsData.residentMessages,
2269
+ groupMessages: analyticsData.groupMessages,
2270
+ privateMessages: analyticsData.privateMessages,
2271
+ activeGroups: analyticsData.activeGroups
2272
+ }];
2273
+ };
2274
+
2275
+ var csvPopup = function csvPopup() {
2276
+ if (!isExportOpen) {
2277
+ return null;
2278
+ }
2279
+
2280
+ var source = getExportSource();
2281
+ return /*#__PURE__*/React.createElement(Components$1.ExportCsvPopup, {
2282
+ onClose: function onClose() {
2283
+ setIsExportOpen(false);
2284
+ },
2285
+ columns: exportColumns,
2286
+ source: source,
2287
+ filename: "".concat(values.analyticsKey, "analytics_").concat(source[0].startDate, "_").concat(source[0].endDate, ".csv")
2288
+ });
2289
+ };
2290
+
2291
+ return /*#__PURE__*/React.createElement("div", {
2292
+ className: "dashboardSection"
2293
+ }, csvPopup(), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Components$1.Text, {
2294
+ type: "h4",
2295
+ className: "inlineBlock marginRight-40"
2296
+ }, featureTitle), /*#__PURE__*/React.createElement(Components$1.Button, {
2297
+ inline: true,
2298
+ buttonType: "primaryAction",
2299
+ onClick: function onClick() {
2300
+ if (!isReadyToOpenCSV()) return;
2301
+ setIsExportOpen(true);
2302
+ },
2303
+ isActive: isReadyToOpenCSV(),
2304
+ leftIcon: "file-code-o"
2305
+ }, "Export CSV")), /*#__PURE__*/React.createElement("div", {
2306
+ className: "analyticsSection dashboardSection_content"
2307
+ }, /*#__PURE__*/React.createElement(Components$1.StatBox, {
2308
+ title: "Groups with Messages",
2309
+ icon: faUserGroup,
2310
+ value: analyticsData.activeGroups,
2311
+ previousValue: analyticsData.prevActiveGroups,
2312
+ prevText: prevText,
2313
+ viewGraphLink: "/chart?entity=".concat(values.entityKey, "&startTime=").concat(startTime, "&endTime=").concat(endTime, "&key=GroupMessage&countType=unique&dayCount=").concat(dayCount),
2314
+ isLoading: analyticsData.isLoading
2315
+ }), /*#__PURE__*/React.createElement(Components$1.StatBox, {
2316
+ title: "Messages",
2317
+ icon: faMessage,
2318
+ value: analyticsData.messages,
2319
+ previousValue: analyticsData.prevMessages,
2320
+ prevText: prevText,
2321
+ viewGraphLink: "/chart?entity=".concat(values.entityKey, "&startTime=").concat(startTime, "&endTime=").concat(endTime, "&key=Message&countType=total&dayCount=").concat(dayCount),
2322
+ isLoading: analyticsData.isLoading
2323
+ }), /*#__PURE__*/React.createElement(Components$1.StatBox, {
2324
+ title: "Messages by Staff",
2325
+ icon: faUserTie,
2326
+ value: analyticsData.staffMessages,
2327
+ previousValue: analyticsData.prevStaffMessages,
2328
+ prevText: prevText,
2329
+ viewGraphLink: "/chart?entity=".concat(values.entityKey, "&startTime=").concat(startTime, "&endTime=").concat(endTime, "&key=StaffMessage&countType=total&dayCount=").concat(dayCount),
2330
+ isLoading: analyticsData.isLoading
2331
+ }), /*#__PURE__*/React.createElement(Components$1.StatBox, {
2332
+ title: "Messages by Primary Users",
2333
+ icon: faUsers,
2334
+ value: analyticsData.residentMessages,
2335
+ previousValue: analyticsData.prevResidentMessages,
2336
+ prevText: prevText,
2337
+ viewGraphLink: "/chart?entity=".concat(values.entityKey, "&startTime=").concat(startTime, "&endTime=").concat(endTime, "&key=ResidentMessage&countType=total&dayCount=").concat(dayCount),
2338
+ isLoading: analyticsData.isLoading
2339
+ }), /*#__PURE__*/React.createElement(Components$1.StatBox, {
2340
+ title: "Group Messages",
2341
+ icon: faUsersRectangle,
2342
+ value: analyticsData.groupMessages,
2343
+ previousValue: analyticsData.prevGroupMessages,
2344
+ prevText: prevText,
2345
+ viewGraphLink: "/chart?entity=".concat(values.entityKey, "&startTime=").concat(startTime, "&endTime=").concat(endTime, "&key=GroupMessage&countType=total&dayCount=").concat(dayCount),
2346
+ isLoading: analyticsData.isLoading
2347
+ }), /*#__PURE__*/React.createElement(Components$1.StatBox, {
2348
+ title: "Private Messages",
2349
+ icon: faPeopleArrows,
2350
+ value: analyticsData.privateMessages,
2351
+ previousValue: analyticsData.prevPrivateMessages,
2352
+ prevText: prevText,
2353
+ viewGraphLink: "/chart?entity=".concat(values.entityKey, "&startTime=").concat(startTime, "&endTime=").concat(endTime, "&key=PrivateMessage&countType=total&dayCount=").concat(dayCount),
2354
+ isLoading: analyticsData.isLoading
2355
+ })));
2356
+ };
2357
+
2358
+ var mapStateToProps = function mapStateToProps(state) {
2359
+ var auth = state.auth;
2360
+ return {
2361
+ auth: auth,
2362
+ strings: state.strings && state.strings.config || {}
2363
+ };
2364
+ };
2365
+
2366
+ var toExport = connect(mapStateToProps, {})(AnalyticsHub);
2367
+
2115
2368
  function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2116
2369
 
2117
2370
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -2416,5 +2669,6 @@ var FeaturePickerContent = (function () {
2416
2669
  var _Screens;
2417
2670
  var Reducers = _defineProperty({}, values.reducerKey, CircleReducer);
2418
2671
  var Screens = (_Screens = {}, _defineProperty(_Screens, values.componentCircles, Circles$1), _defineProperty(_Screens, values.componentAddCircle, AddCircle$1), _defineProperty(_Screens, values.componentCircle, Circle$1), _Screens);
2672
+ var Analytics = [toExport];
2419
2673
 
2420
- export { FeatureConfig as Config, FeaturePickerContent, PreviewFull, PreviewGrid, PreviewWidget, Reducers, Screens, ViewFull, ViewWidget };
2674
+ export { Analytics, FeatureConfig as Config, FeaturePickerContent, PreviewFull, PreviewGrid, PreviewWidget, Reducers, Screens, ViewFull, ViewWidget };