@plusscommunities/pluss-core-web 1.6.9-auth.0 → 1.6.10-beta.1

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.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/regenerator'), require('lodash'), require('axios'), require('@babel/runtime/helpers/defineProperty'), require('moment'), require('react'), require('jquery'), require('js-cookie'), require('aws-amplify'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('react-fontawesome'), require('@babel/runtime/helpers/extends'), require('@babel/runtime/helpers/assertThisInitialized'), require('react-redux'), require('react-textarea-autosize'), require('@babel/runtime/helpers/toConsumableArray'), require('@babel/runtime/helpers/typeof'), require('react-dropzone'), require('react-router'), require('react-bootstrap'), require('@fortawesome/react-fontawesome'), require('@crello/react-lottie'), require('react-csv'), require('@babel/runtime/helpers/objectWithoutProperties'), require('react-color'), require('tinycolor2'), require('react-router-dom'), require('@fortawesome/free-solid-svg-icons')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/regenerator', 'lodash', 'axios', '@babel/runtime/helpers/defineProperty', 'moment', 'react', 'jquery', 'js-cookie', 'aws-amplify', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', 'react-fontawesome', '@babel/runtime/helpers/extends', '@babel/runtime/helpers/assertThisInitialized', 'react-redux', 'react-textarea-autosize', '@babel/runtime/helpers/toConsumableArray', '@babel/runtime/helpers/typeof', 'react-dropzone', 'react-router', 'react-bootstrap', '@fortawesome/react-fontawesome', '@crello/react-lottie', 'react-csv', '@babel/runtime/helpers/objectWithoutProperties', 'react-color', 'tinycolor2', 'react-router-dom', '@fortawesome/free-solid-svg-icons'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-core-web'] = {}, global._asyncToGenerator, global._regeneratorRuntime, global._, global.axios, global._defineProperty, global.moment, global.React, global.$, global.Cookies, global.awsAmplify, global._classCallCheck, global._createClass, global._inherits, global._possibleConstructorReturn, global._getPrototypeOf, global.FontAwesome, global._extends, global._assertThisInitialized, global.reactRedux, global.Textarea, global._toConsumableArray, global._typeof, global.Dropzone, global.reactRouter, global.reactBootstrap, global.reactFontawesome, global.reactLottie, global.reactCsv, global._objectWithoutProperties, global.reactColor, global.tinycolor, global.reactRouterDom, global.freeSolidSvgIcons));
5
- }(this, (function (exports, _asyncToGenerator, _regeneratorRuntime, _, axios, _defineProperty, moment, React, $, Cookies, awsAmplify, _classCallCheck, _createClass, _inherits, _possibleConstructorReturn, _getPrototypeOf, FontAwesome, _extends, _assertThisInitialized, reactRedux, Textarea, _toConsumableArray, _typeof, Dropzone, reactRouter, reactBootstrap, reactFontawesome, reactLottie, reactCsv, _objectWithoutProperties, reactColor, tinycolor, reactRouterDom, freeSolidSvgIcons) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/regenerator'), require('lodash'), require('axios'), require('aws-amplify'), require('@babel/runtime/helpers/defineProperty'), require('moment'), require('react'), require('jquery'), require('js-cookie'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('react-fontawesome'), require('@babel/runtime/helpers/extends'), require('@babel/runtime/helpers/assertThisInitialized'), require('react-redux'), require('react-textarea-autosize'), require('@babel/runtime/helpers/toConsumableArray'), require('@babel/runtime/helpers/typeof'), require('react-dropzone'), require('react-router'), require('react-bootstrap'), require('@fortawesome/react-fontawesome'), require('@crello/react-lottie'), require('react-csv'), require('@babel/runtime/helpers/objectWithoutProperties'), require('react-color'), require('tinycolor2'), require('react-router-dom'), require('@fortawesome/free-solid-svg-icons')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/regenerator', 'lodash', 'axios', 'aws-amplify', '@babel/runtime/helpers/defineProperty', 'moment', 'react', 'jquery', 'js-cookie', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', 'react-fontawesome', '@babel/runtime/helpers/extends', '@babel/runtime/helpers/assertThisInitialized', 'react-redux', 'react-textarea-autosize', '@babel/runtime/helpers/toConsumableArray', '@babel/runtime/helpers/typeof', 'react-dropzone', 'react-router', 'react-bootstrap', '@fortawesome/react-fontawesome', '@crello/react-lottie', 'react-csv', '@babel/runtime/helpers/objectWithoutProperties', 'react-color', 'tinycolor2', 'react-router-dom', '@fortawesome/free-solid-svg-icons'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-core-web'] = {}, global._asyncToGenerator, global._regeneratorRuntime, global._, global.axios, global.awsAmplify, global._defineProperty, global.moment, global.React, global.$, global.Cookies, global._classCallCheck, global._createClass, global._inherits, global._possibleConstructorReturn, global._getPrototypeOf, global.FontAwesome, global._extends, global._assertThisInitialized, global.reactRedux, global.Textarea, global._toConsumableArray, global._typeof, global.Dropzone, global.reactRouter, global.reactBootstrap, global.reactFontawesome, global.reactLottie, global.reactCsv, global._objectWithoutProperties, global.reactColor, global.tinycolor, global.reactRouterDom, global.freeSolidSvgIcons));
5
+ }(this, (function (exports, _asyncToGenerator, _regeneratorRuntime, _, axios, awsAmplify, _defineProperty, moment, React, $, Cookies, _classCallCheck, _createClass, _inherits, _possibleConstructorReturn, _getPrototypeOf, FontAwesome, _extends, _assertThisInitialized, reactRedux, Textarea, _toConsumableArray, _typeof, Dropzone, reactRouter, reactBootstrap, reactFontawesome, reactLottie, reactCsv, _objectWithoutProperties, reactColor, tinycolor, reactRouterDom, freeSolidSvgIcons) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -47,75 +47,7 @@
47
47
  defaultAllowComments: true,
48
48
  makeApiKey: '',
49
49
  logo: '',
50
- clientName: '',
51
- AuthStrategy: {
52
- getAccessToken: function () {
53
- var _getAccessToken = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
54
- return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
55
- while (1) {
56
- switch (_context.prev = _context.next) {
57
- case 0:
58
- return _context.abrupt("return", null);
59
-
60
- case 1:
61
- case "end":
62
- return _context.stop();
63
- }
64
- }
65
- }, _callee);
66
- }));
67
-
68
- function getAccessToken() {
69
- return _getAccessToken.apply(this, arguments);
70
- }
71
-
72
- return getAccessToken;
73
- }(),
74
- getCurrentUserId: function () {
75
- var _getCurrentUserId = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
76
- return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
77
- while (1) {
78
- switch (_context2.prev = _context2.next) {
79
- case 0:
80
- return _context2.abrupt("return", null);
81
-
82
- case 1:
83
- case "end":
84
- return _context2.stop();
85
- }
86
- }
87
- }, _callee2);
88
- }));
89
-
90
- function getCurrentUserId() {
91
- return _getCurrentUserId.apply(this, arguments);
92
- }
93
-
94
- return getCurrentUserId;
95
- }(),
96
- hasActiveSession: function () {
97
- var _hasActiveSession = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
98
- return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
99
- while (1) {
100
- switch (_context3.prev = _context3.next) {
101
- case 0:
102
- return _context3.abrupt("return", false);
103
-
104
- case 1:
105
- case "end":
106
- return _context3.stop();
107
- }
108
- }
109
- }, _callee3);
110
- }));
111
-
112
- function hasActiveSession() {
113
- return _hasActiveSession.apply(this, arguments);
114
- }
115
-
116
- return hasActiveSession;
117
- }()
118
- }
50
+ clientName: ''
119
51
  },
120
52
  init: function init(environment) {
121
53
  CoreConfig.env = environment;
@@ -124,28 +56,29 @@
124
56
 
125
57
  var getSessionTokenAWS = /*#__PURE__*/function () {
126
58
  var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(prefix) {
127
- var token;
59
+ var data, token;
128
60
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
129
61
  while (1) {
130
62
  switch (_context.prev = _context.next) {
131
63
  case 0:
132
64
  _context.next = 2;
133
- return CoreConfig.env.AuthStrategy.getAccessToken();
65
+ return awsAmplify.Auth.currentSession();
134
66
 
135
67
  case 2:
136
- token = _context.sent;
68
+ data = _context.sent;
69
+ token = data.getAccessToken().getJwtToken();
137
70
 
138
71
  if (!___default['default'].isUndefined(prefix)) {
139
- _context.next = 5;
72
+ _context.next = 6;
140
73
  break;
141
74
  }
142
75
 
143
76
  return _context.abrupt("return", token);
144
77
 
145
- case 5:
78
+ case 6:
146
79
  return _context.abrupt("return", "".concat(prefix, " ").concat(token));
147
80
 
148
- case 6:
81
+ case 7:
149
82
  case "end":
150
83
  return _context.stop();
151
84
  }
@@ -205,28 +138,30 @@
205
138
  };
206
139
  var getCurrentUserSub = /*#__PURE__*/function () {
207
140
  var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
141
+ var user;
208
142
  return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
209
143
  while (1) {
210
144
  switch (_context3.prev = _context3.next) {
211
145
  case 0:
212
146
  _context3.prev = 0;
213
147
  _context3.next = 3;
214
- return CoreConfig.env.AuthStrategy.getCurrentUserId();
148
+ return awsAmplify.Auth.currentUserInfo();
215
149
 
216
150
  case 3:
217
- return _context3.abrupt("return", _context3.sent);
151
+ user = _context3.sent;
152
+ return _context3.abrupt("return", user.id);
218
153
 
219
- case 6:
220
- _context3.prev = 6;
154
+ case 7:
155
+ _context3.prev = 7;
221
156
  _context3.t0 = _context3["catch"](0);
222
157
  return _context3.abrupt("return", null);
223
158
 
224
- case 9:
159
+ case 10:
225
160
  case "end":
226
161
  return _context3.stop();
227
162
  }
228
163
  }
229
- }, _callee3, null, [[0, 6]]);
164
+ }, _callee3, null, [[0, 7]]);
230
165
  }));
231
166
 
232
167
  return function getCurrentUserSub() {
@@ -235,19 +170,19 @@
235
170
  }();
236
171
  var checkLoggedIn = /*#__PURE__*/function () {
237
172
  var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(self) {
238
- var isLoggedIn;
173
+ var user;
239
174
  return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
240
175
  while (1) {
241
176
  switch (_context4.prev = _context4.next) {
242
177
  case 0:
243
178
  _context4.prev = 0;
244
179
  _context4.next = 3;
245
- return CoreConfig.env.AuthStrategy.hasActiveSession();
180
+ return awsAmplify.Auth.currentAuthenticatedUser();
246
181
 
247
182
  case 3:
248
- isLoggedIn = _context4.sent;
183
+ user = _context4.sent;
249
184
 
250
- if (!isLoggedIn) {
185
+ if (___default['default'].isUndefined(user) || user == null || user.username == null) {
251
186
  console.log('redirecting to login');
252
187
  self.props.history.push('/login');
253
188
  }
@@ -1688,35 +1623,31 @@
1688
1623
  var fileActions = {
1689
1624
  uploadMediaAsync: function () {
1690
1625
  var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
1691
- var newFilename, signedUrlRes, baseUploadsUrl;
1626
+ var newFilename, userId, url, _Config$env, baseUploadsUrl, uploadBucket;
1627
+
1692
1628
  return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
1693
1629
  while (1) {
1694
1630
  switch (_context.prev = _context.next) {
1695
1631
  case 0:
1696
1632
  newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
1697
1633
  _context.next = 3;
1698
- return authedFunction({
1699
- method: 'GET',
1700
- url: getUrl('media', 'get/presignedurl', {
1701
- filename: newFilename,
1702
- contentType: file.type
1703
- })
1704
- });
1634
+ return getCurrentUserSub();
1705
1635
 
1706
1636
  case 3:
1707
- signedUrlRes = _context.sent;
1708
- _context.next = 6;
1709
- return axios__default['default'].put(signedUrlRes.data.url, file, {
1710
- headers: {
1711
- 'Content-Type': file.type
1712
- }
1637
+ userId = _context.sent;
1638
+ url = "uploads/users/".concat(userId, "/public/").concat(randomString(), "/").concat(newFilename);
1639
+ _Config$env = CoreConfig.env, baseUploadsUrl = _Config$env.baseUploadsUrl, uploadBucket = _Config$env.uploadBucket;
1640
+ _context.next = 8;
1641
+ return awsAmplify.Storage.put(url, file, {
1642
+ level: 'public',
1643
+ bucket: uploadBucket
1713
1644
  });
1714
1645
 
1715
- case 6:
1716
- baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
1717
- return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
1718
-
1719
1646
  case 8:
1647
+ console.log('uploaded file', "".concat(baseUploadsUrl).concat(url));
1648
+ return _context.abrupt("return", "".concat(baseUploadsUrl).concat(url));
1649
+
1650
+ case 10:
1720
1651
  case "end":
1721
1652
  return _context.stop();
1722
1653
  }
@@ -1730,15 +1661,6 @@
1730
1661
 
1731
1662
  return uploadMediaAsync;
1732
1663
  }(),
1733
- // uploadMediaAsync: async (file, filename) => {
1734
- // const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
1735
- // const userId = await getCurrentUserSub();
1736
- // const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
1737
- // const { baseUploadsUrl, uploadBucket } = Config.env;
1738
- // await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
1739
- // console.log('uploaded file', `${baseUploadsUrl}${url}`);
1740
- // return `${baseUploadsUrl}${url}`;
1741
- // },
1742
1664
  // readBase64: async (file) => {
1743
1665
  // return new Promise((resolve, reject) => {
1744
1666
  // var reader = new FileReader();
@@ -1752,14 +1674,6 @@
1752
1674
  // };
1753
1675
  // });
1754
1676
  // },
1755
- getPresignedUrl: function getPresignedUrl(filename) {
1756
- return authedFunction({
1757
- method: 'GET',
1758
- url: getUrl('media', 'get/presignedurl', {
1759
- filename: filename
1760
- })
1761
- });
1762
- },
1763
1677
  compressImage: function compressImage(file, maxSize, quality, noCompress) {
1764
1678
  return new Promise(function (resolve, reject) {
1765
1679
  if (noCompress) {
@@ -4894,7 +4808,7 @@
4894
4808
  function _isNativeReflectConstruct$u() { 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; } }
4895
4809
  var DEFAULT_INPUT$1 = {
4896
4810
  uploadingFile: false,
4897
- value: ''
4811
+ value: ""
4898
4812
  };
4899
4813
 
4900
4814
  var FileInputComponent = /*#__PURE__*/function (_Component) {
@@ -4916,17 +4830,17 @@
4916
4830
  _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "state", {
4917
4831
  inputs: [{
4918
4832
  uploadingFile: false,
4919
- value: ''
4833
+ value: ""
4920
4834
  }]
4921
4835
  });
4922
4836
 
4923
4837
  _defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "getAccept", function () {
4924
- if (_typeof__default['default'](_this.props.accept) === 'object') {
4838
+ if (_typeof__default['default'](_this.props.accept) === "object") {
4925
4839
  return _this.props.accept;
4926
4840
  }
4927
4841
 
4928
- if (typeof _this.props.accept === 'string') {
4929
- var accept = _defineProperty__default['default']({}, _this.props.accept, [".".concat(___default['default'].last(_this.props.accept.split('/')))]);
4842
+ if (typeof _this.props.accept === "string") {
4843
+ var accept = _defineProperty__default['default']({}, _this.props.accept, [".".concat(___default['default'].last(_this.props.accept.split("/")))]);
4930
4844
 
4931
4845
  return accept;
4932
4846
  }
@@ -5020,7 +4934,7 @@
5020
4934
  return _this.props.handleFile(file, newInputs);
5021
4935
 
5022
4936
  case 9:
5023
- _this.checkSetDisplayValue(input, '');
4937
+ _this.checkSetDisplayValue(input, "");
5024
4938
 
5025
4939
  _context.next = 24;
5026
4940
  break;
@@ -5042,7 +4956,7 @@
5042
4956
  case 20:
5043
4957
  _context.prev = 20;
5044
4958
  _context.t0 = _context["catch"](12);
5045
- console.log('handleFile error', _context.t0);
4959
+ console.log("handleFile error", _context.t0);
5046
4960
 
5047
4961
  _this.setState({
5048
4962
  uploadingFile: false
@@ -5087,7 +5001,7 @@
5087
5001
  }, {
5088
5002
  key: "setValue",
5089
5003
  value: function setValue(val) {
5090
- if (typeof val === 'string') {
5004
+ if (typeof val === "string") {
5091
5005
  this.setState({
5092
5006
  inputs: [{
5093
5007
  uploadingImage: false,
@@ -5113,20 +5027,20 @@
5113
5027
  }, {
5114
5028
  key: "getClassNames",
5115
5029
  value: function getClassNames(input, inputsLength) {
5116
- var classes = 'clearfix imageInput';
5030
+ var classes = "clearfix imageInput";
5117
5031
 
5118
5032
  if (input.uploadingFile) {
5119
- classes += ' imageInput-uploading';
5033
+ classes += " imageInput-uploading";
5120
5034
  } else if (!___default['default'].isEmpty(input.value) && !this.props.onlyAllowUpload) {
5121
- classes += ' imageInput-hasImage';
5035
+ classes += " imageInput-hasImage";
5122
5036
  }
5123
5037
 
5124
5038
  if (inputsLength === 1) {
5125
- classes += ' imageInput-only';
5039
+ classes += " imageInput-only";
5126
5040
  }
5127
5041
 
5128
5042
  if (this.props.style && this.props.style.height && this.props.style.height < 150) {
5129
- classes += ' imageInput-condensed';
5043
+ classes += " imageInput-condensed";
5130
5044
  }
5131
5045
 
5132
5046
  return classes;
@@ -5135,10 +5049,10 @@
5135
5049
  key: "getErrorState",
5136
5050
  value: function getErrorState() {
5137
5051
  if (!___default['default'].isUndefined(this.props.showError) && this.props.showError()) {
5138
- return ' imageInput_upload--error';
5052
+ return " imageInput_upload--error";
5139
5053
  }
5140
5054
 
5141
- return '';
5055
+ return "";
5142
5056
  }
5143
5057
  }, {
5144
5058
  key: "checkSetDisplayValue",
@@ -5157,7 +5071,7 @@
5157
5071
  key: "removeFile",
5158
5072
  value: function removeFile(input) {
5159
5073
  var newState = {};
5160
- input.value = '';
5074
+ input.value = "";
5161
5075
 
5162
5076
  var newInputs = ___default['default'].clone(this.state.inputs);
5163
5077
 
@@ -5266,7 +5180,7 @@
5266
5180
  className: "imageInput_upload ".concat(_this3.getErrorState()),
5267
5181
  style: _objectSpread$f({}, _this3.props.style)
5268
5182
  }, getRootProps()), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement("div", {
5269
- className: "".concat(isDragActive ? 'imageInput_dropZoneActive' : '')
5183
+ className: "".concat(isDragActive ? "imageInput_dropZoneActive" : "")
5270
5184
  }, !_this3.props.simpleStyle && /*#__PURE__*/React__default['default'].createElement("img", {
5271
5185
  src: "https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg",
5272
5186
  className: "imageInput_icon",
@@ -5292,7 +5206,7 @@
5292
5206
  var _this4 = this;
5293
5207
 
5294
5208
  return /*#__PURE__*/React__default['default'].createElement("div", {
5295
- className: "imageInputContainer clearfix ".concat(inputs.length === 1 ? 'imageInputContainer-noPadding' : '', " ").concat(this.props.simpleStyle ? 'imageInputContainer-simple' : ''),
5209
+ className: "imageInputContainer clearfix ".concat(inputs.length === 1 ? "imageInputContainer-noPadding" : "", " ").concat(this.props.simpleStyle ? "imageInputContainer-simple" : ""),
5296
5210
  style: _objectSpread$f({}, this.props.style)
5297
5211
  }, inputs.map(function (input, index) {
5298
5212
  return _this4.renderInput(input, index, inputs.length);
@@ -9314,7 +9228,7 @@
9314
9228
  AudienceTagList = _this$state.AudienceTagList;
9315
9229
  var categoryTags = categories.map(function (c) {
9316
9230
  return {
9317
- AudienceType: 'Category',
9231
+ AudienceType: "Category",
9318
9232
  AudienceTypeSelection: c.Key,
9319
9233
  Id: "category_".concat(c.Key),
9320
9234
  Title: c.Title
@@ -9322,7 +9236,7 @@
9322
9236
  });
9323
9237
  var userTypeTags = types.map(function (t) {
9324
9238
  return {
9325
- AudienceType: 'UserType',
9239
+ AudienceType: "UserType",
9326
9240
  AudienceTypeSelection: t.typeName,
9327
9241
  Id: "userType_".concat(t.typeName),
9328
9242
  Title: "User Type: ".concat(t.displayName)
@@ -9330,7 +9244,7 @@
9330
9244
  });
9331
9245
  var userTagTags = tagList.map(function (t) {
9332
9246
  return {
9333
- AudienceType: 'UserTags',
9247
+ AudienceType: "UserTags",
9334
9248
  AudienceTypeSelection: t.Id,
9335
9249
  Id: "userTag_".concat(t.Id),
9336
9250
  Title: "User Tag: ".concat(t.Title)
@@ -9364,26 +9278,26 @@
9364
9278
 
9365
9279
  _this.state = {
9366
9280
  categories: [{
9367
- Title: 'All Primary Users',
9368
- Key: 'resident',
9369
- ShortName: 'Primary'
9281
+ Title: "All Primary Users",
9282
+ Key: "resident",
9283
+ ShortName: "Primary"
9370
9284
  }, {
9371
- Title: 'All Staff Users',
9372
- Key: 'staff',
9373
- ShortName: 'Staff'
9285
+ Title: "All Staff Users",
9286
+ Key: "staff",
9287
+ ShortName: "Staff"
9374
9288
  }, {
9375
- Title: 'All Linked Users',
9376
- Key: 'family',
9377
- ShortName: 'Linked'
9289
+ Title: "All Linked Users",
9290
+ Key: "family",
9291
+ ShortName: "Linked"
9378
9292
  }],
9379
9293
  types: [],
9380
- AudienceType: props.audienceType || 'All',
9294
+ AudienceType: props.audienceType || "All",
9381
9295
  showInclude: false,
9382
9296
  includeList: [],
9383
9297
  showExclude: false,
9384
9298
  excludeList: [],
9385
- Type: '',
9386
- Category: '',
9299
+ Type: "",
9300
+ Category: "",
9387
9301
  userList: [],
9388
9302
  tagList: [],
9389
9303
  AudienceTagList: props.audienceTypeSelection || []
@@ -9413,7 +9327,7 @@
9413
9327
  }, {
9414
9328
  key: "onSubmit",
9415
9329
  value: function onSubmit() {
9416
- if (this.state.AudienceType === 'User' && ___default['default'].isEmpty(this.state.includeList)) {
9330
+ if (this.state.AudienceType === "User" && ___default['default'].isEmpty(this.state.includeList)) {
9417
9331
  this.setState({
9418
9332
  showInclude: true
9419
9333
  });
@@ -9433,9 +9347,9 @@
9433
9347
  Category = _this$state2.Category,
9434
9348
  Tag = _this$state2.Tag,
9435
9349
  Type = _this$state2.Type;
9436
- if (AudienceType === 'Custom') return AudienceTagList || [];
9437
- if (AudienceType === 'Category') return Category;
9438
- if (AudienceType === 'UserTags') return Tag;
9350
+ if (AudienceType === "Custom") return AudienceTagList || [];
9351
+ if (AudienceType === "Category") return Category;
9352
+ if (AudienceType === "UserTags") return Tag;
9439
9353
  return Type;
9440
9354
  }
9441
9355
  }, {
@@ -9480,9 +9394,9 @@
9480
9394
  var newState = {
9481
9395
  AudienceType: type
9482
9396
  };
9483
- if (type === 'Custom') newState.AudienceTagList = selection;
9484
- if (type === 'UserType') newState.Type = selection;
9485
- if (type === 'Category') newState.Category = selection;
9397
+ if (type === "Custom") newState.AudienceTagList = selection;
9398
+ if (type === "UserType") newState.Type = selection;
9399
+ if (type === "Category") newState.Category = selection;
9486
9400
  this.setState(newState);
9487
9401
  }
9488
9402
  }, {
@@ -9490,8 +9404,8 @@
9490
9404
  value: function onChangeOption(type) {
9491
9405
  this.setState({
9492
9406
  AudienceType: type,
9493
- Type: '',
9494
- Category: '',
9407
+ Type: "",
9408
+ Category: "",
9495
9409
  includeList: [],
9496
9410
  excludeList: [],
9497
9411
  AudienceTagList: []
@@ -9504,57 +9418,57 @@
9504
9418
  var _this4 = this;
9505
9419
 
9506
9420
  var options = [{
9507
- Label: 'All users',
9508
- Value: 'All',
9421
+ Label: "All users",
9422
+ Value: "All",
9509
9423
  onChange: function onChange() {
9510
- return _this4.onChangeOption('All');
9424
+ return _this4.onChangeOption("All");
9511
9425
  }
9512
9426
  }];
9513
9427
 
9514
9428
  if (this.props.custom) {
9515
9429
  options.push({
9516
- Label: 'Custom',
9517
- Value: 'Custom',
9430
+ Label: "Custom",
9431
+ Value: "Custom",
9518
9432
  onChange: function onChange() {
9519
- return _this4.onChangeOption('Custom');
9433
+ return _this4.onChangeOption("Custom");
9520
9434
  }
9521
9435
  });
9522
9436
  } else {
9523
9437
  options.push({
9524
- Label: 'By user category',
9525
- Value: 'Category',
9438
+ Label: "By user category",
9439
+ Value: "Category",
9526
9440
  onChange: function onChange() {
9527
- return _this4.onChangeOption('Category');
9441
+ return _this4.onChangeOption("Category");
9528
9442
  }
9529
9443
  });
9530
9444
  }
9531
9445
 
9532
9446
  if (!this.props.disallowUserType) {
9533
9447
  options.push({
9534
- Label: 'By user type',
9535
- Value: 'UserType',
9448
+ Label: "By user type",
9449
+ Value: "UserType",
9536
9450
  onChange: function onChange() {
9537
- return _this4.onChangeOption('UserType');
9451
+ return _this4.onChangeOption("UserType");
9538
9452
  }
9539
9453
  });
9540
9454
  }
9541
9455
 
9542
9456
  if (this.props.allowTags) {
9543
9457
  options.push({
9544
- Label: 'By user tag',
9545
- Value: 'UserTags',
9458
+ Label: "By user tag",
9459
+ Value: "UserTags",
9546
9460
  onChange: function onChange() {
9547
- return _this4.onChangeOption('UserTags');
9461
+ return _this4.onChangeOption("UserTags");
9548
9462
  }
9549
9463
  });
9550
9464
  }
9551
9465
 
9552
9466
  if (!this.props.disallowSingleUsers) {
9553
9467
  options.push({
9554
- Label: 'To single users',
9555
- Value: 'User',
9468
+ Label: "To single users",
9469
+ Value: "User",
9556
9470
  onChange: function onChange() {
9557
- return _this4.onChangeOption('User');
9471
+ return _this4.onChangeOption("User");
9558
9472
  }
9559
9473
  });
9560
9474
  }
@@ -9567,11 +9481,11 @@
9567
9481
  var _this$state3 = this.state,
9568
9482
  AudienceType = _this$state3.AudienceType,
9569
9483
  includeList = _this$state3.includeList;
9570
- if (AudienceType === 'Custom' && !this.validateCustom()) return false;
9571
- if (AudienceType === 'Category' && !this.validateCategory()) return false;
9572
- if (AudienceType === 'UserType' && !this.validateType()) return false;
9573
- if (AudienceType === 'User' && ___default['default'].isEmpty(includeList)) return false;
9574
- if (AudienceType === 'UserTags' && !this.validateTag()) return false;
9484
+ if (AudienceType === "Custom" && !this.validateCustom()) return false;
9485
+ if (AudienceType === "Category" && !this.validateCategory()) return false;
9486
+ if (AudienceType === "UserType" && !this.validateType()) return false;
9487
+ if (AudienceType === "User" && ___default['default'].isEmpty(includeList)) return false;
9488
+ if (AudienceType === "UserTags" && !this.validateTag()) return false;
9575
9489
  return true;
9576
9490
  }
9577
9491
  }, {
@@ -9597,7 +9511,7 @@
9597
9511
  return typeObject.displayName;
9598
9512
  }
9599
9513
 
9600
- return '';
9514
+ return "";
9601
9515
  }
9602
9516
  }, {
9603
9517
  key: "getTagTitle",
@@ -9612,7 +9526,7 @@
9612
9526
  return tag.Title;
9613
9527
  }
9614
9528
 
9615
- return '';
9529
+ return "";
9616
9530
  }
9617
9531
  }, {
9618
9532
  key: "getUserTypes",
@@ -9633,7 +9547,7 @@
9633
9547
  return c.Key === e.category;
9634
9548
  });
9635
9549
 
9636
- var shortName = category ? "(".concat(category.ShortName, ") ") : '';
9550
+ var shortName = category ? "(".concat(category.ShortName, ") ") : "";
9637
9551
  e.Title = "".concat(shortName, " ").concat(e.Title);
9638
9552
  }
9639
9553
  });
@@ -9642,10 +9556,10 @@
9642
9556
  };
9643
9557
 
9644
9558
  if (!___default['default'].some(res.data, function (t) {
9645
- return t.category === 'family';
9559
+ return t.category === "family";
9646
9560
  })) {
9647
9561
  newState.categories = ___default['default'].filter(_this7.state.categories, function (c) {
9648
- return c.Key !== 'family';
9562
+ return c.Key !== "family";
9649
9563
  });
9650
9564
  }
9651
9565
 
@@ -9657,15 +9571,15 @@
9657
9571
  value: function getUserList() {
9658
9572
  var _this8 = this;
9659
9573
 
9660
- if (this.state.AudienceType === 'UserType' && !___default['default'].isEmpty(this.state.Type)) {
9574
+ if (this.state.AudienceType === "UserType" && !___default['default'].isEmpty(this.state.Type)) {
9661
9575
  var users = [];
9662
9576
  this.state.userList.forEach(function (element) {
9663
9577
  if (element.type !== _this8.state.Type) users.push(element);
9664
9578
  });
9665
- return ___default['default'].sortBy(users, 'displayName');
9579
+ return ___default['default'].sortBy(users, "displayName");
9666
9580
  }
9667
9581
 
9668
- if (this.state.AudienceType === 'Category' && !___default['default'].isEmpty(this.state.Category)) {
9582
+ if (this.state.AudienceType === "Category" && !___default['default'].isEmpty(this.state.Category)) {
9669
9583
  var _users = [];
9670
9584
 
9671
9585
  var types = ___default['default'].filter(this.state.types, function (type) {
@@ -9679,10 +9593,10 @@
9679
9593
  _users.push(element);
9680
9594
  }
9681
9595
  });
9682
- return ___default['default'].sortBy(_users, 'displayName');
9596
+ return ___default['default'].sortBy(_users, "displayName");
9683
9597
  }
9684
9598
 
9685
- return ___default['default'].sortBy(this.state.userList, 'displayName');
9599
+ return ___default['default'].sortBy(this.state.userList, "displayName");
9686
9600
  }
9687
9601
  }, {
9688
9602
  key: "selectCat",
@@ -9707,7 +9621,7 @@
9707
9621
  return typeObject.Title;
9708
9622
  }
9709
9623
 
9710
- return '';
9624
+ return "";
9711
9625
  }
9712
9626
  }, {
9713
9627
  key: "validateCategory",
@@ -9727,7 +9641,7 @@
9727
9641
  }, {
9728
9642
  key: "showUserPickers",
9729
9643
  value: function showUserPickers(isInclude) {
9730
- if (isInclude && this.state.AudienceType === 'User') {
9644
+ if (isInclude && this.state.AudienceType === "User") {
9731
9645
  return true;
9732
9646
  }
9733
9647
 
@@ -9739,15 +9653,15 @@
9739
9653
  return false;
9740
9654
  }
9741
9655
 
9742
- if (isInclude && this.state.AudienceType === 'All') {
9656
+ if (isInclude && this.state.AudienceType === "All") {
9743
9657
  return false;
9744
9658
  }
9745
9659
 
9746
- if (!isInclude && this.state.AudienceType === 'User') {
9660
+ if (!isInclude && this.state.AudienceType === "User") {
9747
9661
  return false;
9748
9662
  }
9749
9663
 
9750
- if (this.state.AudienceType === 'Category' && ___default['default'].isEmpty(this.state.Category) || this.state.AudienceType === 'UserType' && ___default['default'].isEmpty(this.state.Type)) {
9664
+ if (this.state.AudienceType === "Category" && ___default['default'].isEmpty(this.state.Category) || this.state.AudienceType === "UserType" && ___default['default'].isEmpty(this.state.Type)) {
9751
9665
  return false;
9752
9666
  }
9753
9667
 
@@ -9758,15 +9672,15 @@
9758
9672
  value: function getUserExcludeList() {
9759
9673
  var _this10 = this;
9760
9674
 
9761
- if (this.state.AudienceType === 'UserType' && !___default['default'].isEmpty(this.state.Type)) {
9675
+ if (this.state.AudienceType === "UserType" && !___default['default'].isEmpty(this.state.Type)) {
9762
9676
  var users = [];
9763
9677
  this.state.userList.forEach(function (element) {
9764
9678
  if (element.type === _this10.state.Type) users.push(element);
9765
9679
  });
9766
- return ___default['default'].sortBy(users, 'displayName');
9680
+ return ___default['default'].sortBy(users, "displayName");
9767
9681
  }
9768
9682
 
9769
- if (this.state.AudienceType === 'Category' && !___default['default'].isEmpty(this.state.Category)) {
9683
+ if (this.state.AudienceType === "Category" && !___default['default'].isEmpty(this.state.Category)) {
9770
9684
  var _users2 = [];
9771
9685
 
9772
9686
  var types = ___default['default'].filter(this.state.types, function (type) {
@@ -9780,10 +9694,10 @@
9780
9694
  _users2.push(element);
9781
9695
  }
9782
9696
  });
9783
- return ___default['default'].sortBy(_users2, 'displayName');
9697
+ return ___default['default'].sortBy(_users2, "displayName");
9784
9698
  }
9785
9699
 
9786
- return ___default['default'].sortBy(this.state.userList, 'displayName');
9700
+ return ___default['default'].sortBy(this.state.userList, "displayName");
9787
9701
  }
9788
9702
  }, {
9789
9703
  key: "addToInc",
@@ -9857,12 +9771,12 @@
9857
9771
  }, /*#__PURE__*/React__default['default'].createElement(Text, {
9858
9772
  type: "formTitleSmall",
9859
9773
  className: "marginBottom-16"
9860
- }, "Exclude Users From Selection ", "(".concat(this.state.excludeList.length, ")"))), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
9774
+ }, "Exclude Users From Selection", " ", "(".concat(this.state.excludeList.length, ")"))), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
9861
9775
  style: {
9862
9776
  color: COLOUR_DUSK,
9863
9777
  fontSize: 12
9864
9778
  },
9865
- name: this.state.showExclude ? 'chevron-up' : 'chevron-down'
9779
+ name: this.state.showExclude ? "chevron-up" : "chevron-down"
9866
9780
  })), this.state.showExclude && /*#__PURE__*/React__default['default'].createElement(exportObj$1, {
9867
9781
  add: this.addToEx.bind(this),
9868
9782
  remove: this.removeUserEx.bind(this),
@@ -9894,12 +9808,12 @@
9894
9808
  }, /*#__PURE__*/React__default['default'].createElement(Text, {
9895
9809
  type: "formTitleSmall",
9896
9810
  className: "marginBottom-16"
9897
- }, this.state.AudienceType !== 'User' ? 'Add Other' : 'Select', " Users ", "(".concat(this.state.includeList.length, ")"))), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
9811
+ }, this.state.AudienceType !== "User" ? "Add Other" : "Select", " ", "Users ", "(".concat(this.state.includeList.length, ")"))), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
9898
9812
  style: {
9899
9813
  color: COLOUR_DUSK,
9900
9814
  fontSize: 12
9901
9815
  },
9902
- name: this.state.showInclude ? 'chevron-up' : 'chevron-down'
9816
+ name: this.state.showInclude ? "chevron-up" : "chevron-down"
9903
9817
  })), this.state.showInclude && /*#__PURE__*/React__default['default'].createElement(exportObj$1, {
9904
9818
  add: this.addToInc.bind(this),
9905
9819
  remove: this.removeUserInc.bind(this),
@@ -9960,7 +9874,7 @@
9960
9874
  }, {
9961
9875
  key: "renderCustom",
9962
9876
  value: function renderCustom() {
9963
- if (this.state.AudienceType !== 'Custom') return null;
9877
+ if (this.state.AudienceType !== "Custom") return null;
9964
9878
  return /*#__PURE__*/React__default['default'].createElement("div", {
9965
9879
  className: "optionsContent_bottom"
9966
9880
  }, /*#__PURE__*/React__default['default'].createElement(Text, {
@@ -9978,17 +9892,17 @@
9978
9892
  return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(Text, {
9979
9893
  type: "formTitleSmall",
9980
9894
  className: "marginBottom-16"
9981
- }, this.props.title || 'Target Audience'), /*#__PURE__*/React__default['default'].createElement(RadioButton, {
9895
+ }, this.props.title || "Target Audience"), /*#__PURE__*/React__default['default'].createElement(RadioButton, {
9982
9896
  isActive: this.state.AudienceType,
9983
9897
  rowStyle: {
9984
- flexDirection: 'column'
9898
+ flexDirection: "column"
9985
9899
  },
9986
9900
  buttonStyle: {
9987
9901
  marginBottom: 8
9988
9902
  },
9989
9903
  options: this.getOptions(),
9990
9904
  disabled: this.props.disabled
9991
- }), this.state.AudienceType === 'Category' && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
9905
+ }), this.state.AudienceType === "Category" && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
9992
9906
  id: "typeSelect" // label='User Category'
9993
9907
  ,
9994
9908
  alwaysShowLabel: true,
@@ -10008,7 +9922,7 @@
10008
9922
  },
10009
9923
  isRequired: true,
10010
9924
  disabled: this.props.disabled
10011
- }), this.state.AudienceType === 'UserType' && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
9925
+ }), this.state.AudienceType === "UserType" && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
10012
9926
  id: "typeSelect" // label='User Type'
10013
9927
  ,
10014
9928
  alwaysShowLabel: true,
@@ -10028,7 +9942,7 @@
10028
9942
  },
10029
9943
  isRequired: true,
10030
9944
  disabled: this.props.disabled
10031
- }), this.state.AudienceType === 'UserTags' && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
9945
+ }), this.state.AudienceType === "UserTags" && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
10032
9946
  id: "tagSelect",
10033
9947
  alwaysShowLabel: true,
10034
9948
  placeholder: "User Tag",