@plusscommunities/pluss-core-web 1.4.23 → 1.4.25

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.cjs.js CHANGED
@@ -27,13 +27,13 @@ var _typeof = require('@babel/runtime/helpers/typeof');
27
27
  var Dropzone = require('react-dropzone');
28
28
  var reactRouter = require('react-router');
29
29
  var reactBootstrap = require('react-bootstrap');
30
+ var reactFontawesome = require('@fortawesome/react-fontawesome');
30
31
  var reactLottie = require('@crello/react-lottie');
31
32
  var reactCsv = require('react-csv');
32
33
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
33
34
  var reactColor = require('react-color');
34
35
  var tinycolor = require('tinycolor2');
35
36
  var reactRouterDom = require('react-router-dom');
36
- var reactFontawesome = require('@fortawesome/react-fontawesome');
37
37
  var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
38
38
 
39
39
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -958,6 +958,14 @@ var getSiteLevelFromState = function getSiteLevelFromState(state) {
958
958
  return siteConfig;
959
959
  };
960
960
 
961
+ var getMerchantsFromState = function getMerchantsFromState(state) {
962
+ if (!state || !state.auth || !state.auth.user) return [];
963
+ var currentSite = state.auth.user.Roles.find(function (r) {
964
+ return r.site === state.auth.site;
965
+ });
966
+ return currentSite && !___default['default'].isEmpty(currentSite.siteInfo.Accounts) ? currentSite.siteInfo.Accounts : [];
967
+ };
968
+
961
969
  var readJSONFromStorage = function readJSONFromStorage(storage, key, fallback) {
962
970
  var value = storage.getItem(key);
963
971
 
@@ -1098,6 +1106,18 @@ var getTimepickerTime = function getTimepickerTime(input) {
1098
1106
  hours: timeSplit[0],
1099
1107
  minutes: timeSplit[1].substring(0, 2)
1100
1108
  };
1109
+ }; //converts the result of getTimePickerTime into a number representing minutes since midnight
1110
+
1111
+ var timeToMinutes = function timeToMinutes(time) {
1112
+ return parseInt(time.hours, 10) * 60 + parseInt(time.minutes, 10);
1113
+ }; // checks whether there is an overlap between two time frames given time and end times in minutes since midnight
1114
+
1115
+ var hasTimeframeOverlap = function hasTimeframeOverlap(aStart, aEnd, bStart, bEnd) {
1116
+ return aStart < bEnd && bStart < aEnd || bStart < aEnd && aStart < bEnd;
1117
+ }; // converts a time picker input into midnights since midnight
1118
+
1119
+ var timepickerToMinutes = function timepickerToMinutes(input) {
1120
+ return timeToMinutes(getTimepickerTime(input));
1101
1121
  };
1102
1122
  var getDateFromTimeDatePickers = function getDateFromTimeDatePickers(dateInput, timeInput) {
1103
1123
  var dateObject = new Date(dateInput);
@@ -1106,6 +1126,22 @@ var getDateFromTimeDatePickers = function getDateFromTimeDatePickers(dateInput,
1106
1126
  dateObject.setMinutes(time.minutes);
1107
1127
  return dateObject;
1108
1128
  };
1129
+ var minutesToString = function minutesToString(minutes) {
1130
+ var hours = Math.floor(minutes / 60);
1131
+ var remainingMinutes = minutes % 60;
1132
+ var hoursString = hours > 1 ? "".concat(hours, " hours") : "".concat(hours, " hour");
1133
+ var minutesString = remainingMinutes > 1 ? "".concat(remainingMinutes, " minutes") : "".concat(remainingMinutes, " minute");
1134
+
1135
+ if (hours && remainingMinutes) {
1136
+ return "".concat(hoursString, " ").concat(minutesString);
1137
+ } else if (hours) {
1138
+ return hoursString;
1139
+ } else if (remainingMinutes) {
1140
+ return minutesString;
1141
+ } else {
1142
+ return '0 minutes';
1143
+ }
1144
+ };
1109
1145
  var getUTCFromTimeDatePickers = function getUTCFromTimeDatePickers(dateInput, timeInput) {
1110
1146
  var dateObject = getDateFromTimeDatePickers(dateInput, timeInput);
1111
1147
  return moment__default['default'].utc(dateObject);
@@ -1759,11 +1795,16 @@ var index$3 = /*#__PURE__*/Object.freeze({
1759
1795
  getSiteNameFromRoles: getSiteNameFromRoles,
1760
1796
  getSiteSettingFromState: getSiteSettingFromState,
1761
1797
  getSiteLevelFromState: getSiteLevelFromState,
1798
+ getMerchantsFromState: getMerchantsFromState,
1762
1799
  readJSONFromStorage: readJSONFromStorage,
1763
1800
  setLocalStorage: setLocalStorage,
1764
1801
  readStorageWithCookie: readStorageWithCookie,
1765
1802
  getTimepickerTime: getTimepickerTime,
1803
+ timeToMinutes: timeToMinutes,
1804
+ hasTimeframeOverlap: hasTimeframeOverlap,
1805
+ timepickerToMinutes: timepickerToMinutes,
1766
1806
  getDateFromTimeDatePickers: getDateFromTimeDatePickers,
1807
+ minutesToString: minutesToString,
1767
1808
  getUTCFromTimeDatePickers: getUTCFromTimeDatePickers,
1768
1809
  getPluralS: getPluralS,
1769
1810
  getPluralOptions: getPluralOptions,
@@ -5318,6 +5359,65 @@ var DatePicker = /*#__PURE__*/function (_Component) {
5318
5359
  return DatePicker;
5319
5360
  }(React.Component);
5320
5361
 
5362
+ function DurationInput(_ref) {
5363
+ var handleChange = _ref.handleChange,
5364
+ label = _ref.label,
5365
+ value = _ref.value,
5366
+ className = _ref.className,
5367
+ labelWidth = _ref.labelWidth;
5368
+ var hours = Math.floor(value / 60);
5369
+ var minutes = value % 60;
5370
+
5371
+ var handleHourChange = function handleHourChange(event) {
5372
+ var newHours = Math.max(0, Math.min(+event.target.value, 24));
5373
+ handleChange(newHours * 60 + minutes);
5374
+ };
5375
+
5376
+ var handleMinuteChange = function handleMinuteChange(event) {
5377
+ var newMinutes = Math.max(0, Math.min(+event.target.value, 59));
5378
+ handleChange(hours * 60 + newMinutes);
5379
+ };
5380
+
5381
+ return /*#__PURE__*/React__default['default'].createElement("div", {
5382
+ className: "flex flex-center ".concat(className ? className : '')
5383
+ }, label && /*#__PURE__*/React__default['default'].createElement(Text, {
5384
+ type: "formTitleSmall",
5385
+ style: {
5386
+ marginRight: '10px',
5387
+ width: labelWidth || 50
5388
+ }
5389
+ }, label), /*#__PURE__*/React__default['default'].createElement("input", {
5390
+ className: "genericInput",
5391
+ type: "number",
5392
+ min: "0",
5393
+ max: "24",
5394
+ value: hours,
5395
+ onChange: handleHourChange,
5396
+ style: {
5397
+ width: 50,
5398
+ marginRight: 5
5399
+ }
5400
+ }), /*#__PURE__*/React__default['default'].createElement(Text, {
5401
+ type: "formTitleSmall",
5402
+ style: {
5403
+ marginRight: 10
5404
+ }
5405
+ }, "Hour(s)"), /*#__PURE__*/React__default['default'].createElement("input", {
5406
+ className: "genericInput",
5407
+ type: "number",
5408
+ min: "0",
5409
+ max: "59",
5410
+ value: minutes,
5411
+ onChange: handleMinuteChange,
5412
+ style: {
5413
+ width: 50,
5414
+ marginRight: 5
5415
+ }
5416
+ }), /*#__PURE__*/React__default['default'].createElement(Text, {
5417
+ type: "formTitleSmall"
5418
+ }, "Minute(s)"));
5419
+ }
5420
+
5321
5421
  function ownKeys$f(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; }
5322
5422
 
5323
5423
  function _objectSpread$f(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$f(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$f(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -8785,6 +8885,55 @@ var UserListing = /*#__PURE__*/function (_Component) {
8785
8885
  value: function getSize() {
8786
8886
  return this.props.size || 30;
8787
8887
  }
8888
+ }, {
8889
+ key: "getImage",
8890
+ value: function getImage() {
8891
+ if (this.props.user && this.props.user.profilePic) {
8892
+ return this.props.user.profilePic;
8893
+ }
8894
+
8895
+ if (this.props.image) {
8896
+ return this.props.image;
8897
+ }
8898
+
8899
+ return undefined;
8900
+ }
8901
+ }, {
8902
+ key: "getKey",
8903
+ value: function getKey() {
8904
+ if (this.props.user && this.props.user.id) {
8905
+ return this.props.user.id;
8906
+ }
8907
+
8908
+ return this.props.id;
8909
+ }
8910
+ }, {
8911
+ key: "getText",
8912
+ value: function getText() {
8913
+ if (this.props.user && this.props.user.displayName) {
8914
+ return this.props.user.displayName;
8915
+ }
8916
+
8917
+ return this.props.title;
8918
+ }
8919
+ }, {
8920
+ key: "getBorderRadius",
8921
+ value: function getBorderRadius() {
8922
+ if (this.props.squareImage) {
8923
+ return 4;
8924
+ }
8925
+
8926
+ return this.getSize() / 2;
8927
+ }
8928
+ }, {
8929
+ key: "isLoading",
8930
+ value: function isLoading() {
8931
+ if (this.props.user && this.props.user.loading) {
8932
+ return this.props.user && this.props.user.loading;
8933
+ }
8934
+
8935
+ return this.props.isLoading;
8936
+ }
8788
8937
  }, {
8789
8938
  key: "renderRight",
8790
8939
  value: function renderRight() {
@@ -8803,25 +8952,45 @@ var UserListing = /*#__PURE__*/function (_Component) {
8803
8952
 
8804
8953
  return this.props.subContent;
8805
8954
  }
8955
+ }, {
8956
+ key: "renderImage",
8957
+ value: function renderImage() {
8958
+ if (this.props.squareImage) {
8959
+ return /*#__PURE__*/React__default['default'].createElement("div", {
8960
+ style: {
8961
+ height: this.getSize(),
8962
+ width: this.getSize(),
8963
+ borderRadius: this.getBorderRadius(),
8964
+ marginRight: 8,
8965
+ backgroundSize: 'cover',
8966
+ backgroundPosition: 'center',
8967
+ backgroundImage: "url(".concat(this.getImage(), ")")
8968
+ },
8969
+ alt: "".concat(this.getText(), " Image")
8970
+ });
8971
+ }
8972
+
8973
+ return /*#__PURE__*/React__default['default'].createElement(ProfilePic, {
8974
+ size: this.getSize(),
8975
+ className: "userListing_profilePic",
8976
+ image: this.getImage()
8977
+ });
8978
+ }
8806
8979
  }, {
8807
8980
  key: "render",
8808
8981
  value: function render() {
8809
8982
  return /*#__PURE__*/React__default['default'].createElement("div", {
8810
- key: this.props.user.userId || this.props.user.Id || this.props.user.id,
8983
+ key: this.getKey(),
8811
8984
  className: "userListing",
8812
8985
  style: {
8813
8986
  minHeight: this.getSize() + 5,
8814
8987
  cursor: this.props.onClick ? 'pointer' : 'inherit',
8815
- opacity: this.props.user && this.props.user.loading ? 0.5 : 1
8988
+ opacity: this.isLoading() ? 0.5 : 1
8816
8989
  },
8817
8990
  onClick: this.props.onClick
8818
8991
  }, /*#__PURE__*/React__default['default'].createElement("div", {
8819
8992
  className: "userListing_inner"
8820
- }, /*#__PURE__*/React__default['default'].createElement(ProfilePic, {
8821
- size: this.getSize(),
8822
- className: "userListing_profilePic",
8823
- image: this.props.user.profilePic
8824
- }), /*#__PURE__*/React__default['default'].createElement("div", {
8993
+ }, this.renderImage(), /*#__PURE__*/React__default['default'].createElement("div", {
8825
8994
  className: "userListing_middle",
8826
8995
  style: {
8827
8996
  height: this.getSize()
@@ -8832,7 +9001,7 @@ var UserListing = /*#__PURE__*/function (_Component) {
8832
9001
  color: '#fff'
8833
9002
  } : null,
8834
9003
  className: this.props.textClass
8835
- }, this.props.user.displayName), this.renderSub())), this.renderRight());
9004
+ }, this.getText()), this.renderSub())), this.renderRight());
8836
9005
  }
8837
9006
  }]);
8838
9007
 
@@ -10512,6 +10681,23 @@ var OptionsSection = /*#__PURE__*/function (_Component) {
10512
10681
 
10513
10682
  return selectedOption.text;
10514
10683
  }
10684
+ }, {
10685
+ key: "renderIcon",
10686
+ value: function renderIcon(o, isSelected) {
10687
+ switch (o.iconType) {
10688
+ case 'fa':
10689
+ return /*#__PURE__*/React__default['default'].createElement(reactFontawesome.FontAwesomeIcon, {
10690
+ className: "optionsButton_icon",
10691
+ icon: o.icon
10692
+ });
10693
+
10694
+ default:
10695
+ return /*#__PURE__*/React__default['default'].createElement(SVGIcon, {
10696
+ icon: o.icon,
10697
+ colour: isSelected ? '#fff' : COLOUR_BRANDING_MAIN
10698
+ });
10699
+ }
10700
+ }
10515
10701
  }, {
10516
10702
  key: "renderOptionButton",
10517
10703
  value: function renderOptionButton(o) {
@@ -10526,10 +10712,7 @@ var OptionsSection = /*#__PURE__*/function (_Component) {
10526
10712
  }
10527
10713
  }, /*#__PURE__*/React__default['default'].createElement("div", {
10528
10714
  className: "optionsButton_iconContainer"
10529
- }, /*#__PURE__*/React__default['default'].createElement(SVGIcon, {
10530
- icon: o.icon,
10531
- colour: isSelected ? '#fff' : COLOUR_BRANDING_MAIN
10532
- })), /*#__PURE__*/React__default['default'].createElement(Text, {
10715
+ }, this.renderIcon(o, isSelected)), /*#__PURE__*/React__default['default'].createElement(Text, {
10533
10716
  type: "formLabelSmall",
10534
10717
  className: "optionsButton_text"
10535
10718
  }, o.text));
@@ -11622,6 +11805,7 @@ var index = /*#__PURE__*/Object.freeze({
11622
11805
  Comment: Comment,
11623
11806
  CommentSection: CommentSection,
11624
11807
  DatePicker: DatePicker,
11808
+ DurationInput: DurationInput,
11625
11809
  FileInput: FileInput,
11626
11810
  GenericInput: GenericInput,
11627
11811
  Header: exportObj$4,
package/dist/index.esm.js CHANGED
@@ -23,13 +23,13 @@ import _typeof from '@babel/runtime/helpers/typeof';
23
23
  import Dropzone from 'react-dropzone';
24
24
  import { withRouter } from 'react-router';
25
25
  import { MenuItem, DropdownButton, FormGroup, ControlLabel, FormControl, HelpBlock } from 'react-bootstrap';
26
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
26
27
  import { Lottie } from '@crello/react-lottie';
27
28
  import { CSVLink } from 'react-csv';
28
29
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
29
30
  import { ChromePicker } from 'react-color';
30
31
  import tinycolor from 'tinycolor2';
31
32
  import { Link } from 'react-router-dom';
32
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
33
33
  import { faChartLine } from '@fortawesome/free-solid-svg-icons';
34
34
 
35
35
  var CoreConfig = {
@@ -928,6 +928,14 @@ var getSiteLevelFromState = function getSiteLevelFromState(state) {
928
928
  return siteConfig;
929
929
  };
930
930
 
931
+ var getMerchantsFromState = function getMerchantsFromState(state) {
932
+ if (!state || !state.auth || !state.auth.user) return [];
933
+ var currentSite = state.auth.user.Roles.find(function (r) {
934
+ return r.site === state.auth.site;
935
+ });
936
+ return currentSite && !_.isEmpty(currentSite.siteInfo.Accounts) ? currentSite.siteInfo.Accounts : [];
937
+ };
938
+
931
939
  var readJSONFromStorage = function readJSONFromStorage(storage, key, fallback) {
932
940
  var value = storage.getItem(key);
933
941
 
@@ -1068,6 +1076,18 @@ var getTimepickerTime = function getTimepickerTime(input) {
1068
1076
  hours: timeSplit[0],
1069
1077
  minutes: timeSplit[1].substring(0, 2)
1070
1078
  };
1079
+ }; //converts the result of getTimePickerTime into a number representing minutes since midnight
1080
+
1081
+ var timeToMinutes = function timeToMinutes(time) {
1082
+ return parseInt(time.hours, 10) * 60 + parseInt(time.minutes, 10);
1083
+ }; // checks whether there is an overlap between two time frames given time and end times in minutes since midnight
1084
+
1085
+ var hasTimeframeOverlap = function hasTimeframeOverlap(aStart, aEnd, bStart, bEnd) {
1086
+ return aStart < bEnd && bStart < aEnd || bStart < aEnd && aStart < bEnd;
1087
+ }; // converts a time picker input into midnights since midnight
1088
+
1089
+ var timepickerToMinutes = function timepickerToMinutes(input) {
1090
+ return timeToMinutes(getTimepickerTime(input));
1071
1091
  };
1072
1092
  var getDateFromTimeDatePickers = function getDateFromTimeDatePickers(dateInput, timeInput) {
1073
1093
  var dateObject = new Date(dateInput);
@@ -1076,6 +1096,22 @@ var getDateFromTimeDatePickers = function getDateFromTimeDatePickers(dateInput,
1076
1096
  dateObject.setMinutes(time.minutes);
1077
1097
  return dateObject;
1078
1098
  };
1099
+ var minutesToString = function minutesToString(minutes) {
1100
+ var hours = Math.floor(minutes / 60);
1101
+ var remainingMinutes = minutes % 60;
1102
+ var hoursString = hours > 1 ? "".concat(hours, " hours") : "".concat(hours, " hour");
1103
+ var minutesString = remainingMinutes > 1 ? "".concat(remainingMinutes, " minutes") : "".concat(remainingMinutes, " minute");
1104
+
1105
+ if (hours && remainingMinutes) {
1106
+ return "".concat(hoursString, " ").concat(minutesString);
1107
+ } else if (hours) {
1108
+ return hoursString;
1109
+ } else if (remainingMinutes) {
1110
+ return minutesString;
1111
+ } else {
1112
+ return '0 minutes';
1113
+ }
1114
+ };
1079
1115
  var getUTCFromTimeDatePickers = function getUTCFromTimeDatePickers(dateInput, timeInput) {
1080
1116
  var dateObject = getDateFromTimeDatePickers(dateInput, timeInput);
1081
1117
  return moment.utc(dateObject);
@@ -1729,11 +1765,16 @@ var index$3 = /*#__PURE__*/Object.freeze({
1729
1765
  getSiteNameFromRoles: getSiteNameFromRoles,
1730
1766
  getSiteSettingFromState: getSiteSettingFromState,
1731
1767
  getSiteLevelFromState: getSiteLevelFromState,
1768
+ getMerchantsFromState: getMerchantsFromState,
1732
1769
  readJSONFromStorage: readJSONFromStorage,
1733
1770
  setLocalStorage: setLocalStorage,
1734
1771
  readStorageWithCookie: readStorageWithCookie,
1735
1772
  getTimepickerTime: getTimepickerTime,
1773
+ timeToMinutes: timeToMinutes,
1774
+ hasTimeframeOverlap: hasTimeframeOverlap,
1775
+ timepickerToMinutes: timepickerToMinutes,
1736
1776
  getDateFromTimeDatePickers: getDateFromTimeDatePickers,
1777
+ minutesToString: minutesToString,
1737
1778
  getUTCFromTimeDatePickers: getUTCFromTimeDatePickers,
1738
1779
  getPluralS: getPluralS,
1739
1780
  getPluralOptions: getPluralOptions,
@@ -5288,6 +5329,65 @@ var DatePicker = /*#__PURE__*/function (_Component) {
5288
5329
  return DatePicker;
5289
5330
  }(Component);
5290
5331
 
5332
+ function DurationInput(_ref) {
5333
+ var handleChange = _ref.handleChange,
5334
+ label = _ref.label,
5335
+ value = _ref.value,
5336
+ className = _ref.className,
5337
+ labelWidth = _ref.labelWidth;
5338
+ var hours = Math.floor(value / 60);
5339
+ var minutes = value % 60;
5340
+
5341
+ var handleHourChange = function handleHourChange(event) {
5342
+ var newHours = Math.max(0, Math.min(+event.target.value, 24));
5343
+ handleChange(newHours * 60 + minutes);
5344
+ };
5345
+
5346
+ var handleMinuteChange = function handleMinuteChange(event) {
5347
+ var newMinutes = Math.max(0, Math.min(+event.target.value, 59));
5348
+ handleChange(hours * 60 + newMinutes);
5349
+ };
5350
+
5351
+ return /*#__PURE__*/React.createElement("div", {
5352
+ className: "flex flex-center ".concat(className ? className : '')
5353
+ }, label && /*#__PURE__*/React.createElement(Text, {
5354
+ type: "formTitleSmall",
5355
+ style: {
5356
+ marginRight: '10px',
5357
+ width: labelWidth || 50
5358
+ }
5359
+ }, label), /*#__PURE__*/React.createElement("input", {
5360
+ className: "genericInput",
5361
+ type: "number",
5362
+ min: "0",
5363
+ max: "24",
5364
+ value: hours,
5365
+ onChange: handleHourChange,
5366
+ style: {
5367
+ width: 50,
5368
+ marginRight: 5
5369
+ }
5370
+ }), /*#__PURE__*/React.createElement(Text, {
5371
+ type: "formTitleSmall",
5372
+ style: {
5373
+ marginRight: 10
5374
+ }
5375
+ }, "Hour(s)"), /*#__PURE__*/React.createElement("input", {
5376
+ className: "genericInput",
5377
+ type: "number",
5378
+ min: "0",
5379
+ max: "59",
5380
+ value: minutes,
5381
+ onChange: handleMinuteChange,
5382
+ style: {
5383
+ width: 50,
5384
+ marginRight: 5
5385
+ }
5386
+ }), /*#__PURE__*/React.createElement(Text, {
5387
+ type: "formTitleSmall"
5388
+ }, "Minute(s)"));
5389
+ }
5390
+
5291
5391
  function ownKeys$f(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; }
5292
5392
 
5293
5393
  function _objectSpread$f(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$f(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$f(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -8755,6 +8855,55 @@ var UserListing = /*#__PURE__*/function (_Component) {
8755
8855
  value: function getSize() {
8756
8856
  return this.props.size || 30;
8757
8857
  }
8858
+ }, {
8859
+ key: "getImage",
8860
+ value: function getImage() {
8861
+ if (this.props.user && this.props.user.profilePic) {
8862
+ return this.props.user.profilePic;
8863
+ }
8864
+
8865
+ if (this.props.image) {
8866
+ return this.props.image;
8867
+ }
8868
+
8869
+ return undefined;
8870
+ }
8871
+ }, {
8872
+ key: "getKey",
8873
+ value: function getKey() {
8874
+ if (this.props.user && this.props.user.id) {
8875
+ return this.props.user.id;
8876
+ }
8877
+
8878
+ return this.props.id;
8879
+ }
8880
+ }, {
8881
+ key: "getText",
8882
+ value: function getText() {
8883
+ if (this.props.user && this.props.user.displayName) {
8884
+ return this.props.user.displayName;
8885
+ }
8886
+
8887
+ return this.props.title;
8888
+ }
8889
+ }, {
8890
+ key: "getBorderRadius",
8891
+ value: function getBorderRadius() {
8892
+ if (this.props.squareImage) {
8893
+ return 4;
8894
+ }
8895
+
8896
+ return this.getSize() / 2;
8897
+ }
8898
+ }, {
8899
+ key: "isLoading",
8900
+ value: function isLoading() {
8901
+ if (this.props.user && this.props.user.loading) {
8902
+ return this.props.user && this.props.user.loading;
8903
+ }
8904
+
8905
+ return this.props.isLoading;
8906
+ }
8758
8907
  }, {
8759
8908
  key: "renderRight",
8760
8909
  value: function renderRight() {
@@ -8773,25 +8922,45 @@ var UserListing = /*#__PURE__*/function (_Component) {
8773
8922
 
8774
8923
  return this.props.subContent;
8775
8924
  }
8925
+ }, {
8926
+ key: "renderImage",
8927
+ value: function renderImage() {
8928
+ if (this.props.squareImage) {
8929
+ return /*#__PURE__*/React.createElement("div", {
8930
+ style: {
8931
+ height: this.getSize(),
8932
+ width: this.getSize(),
8933
+ borderRadius: this.getBorderRadius(),
8934
+ marginRight: 8,
8935
+ backgroundSize: 'cover',
8936
+ backgroundPosition: 'center',
8937
+ backgroundImage: "url(".concat(this.getImage(), ")")
8938
+ },
8939
+ alt: "".concat(this.getText(), " Image")
8940
+ });
8941
+ }
8942
+
8943
+ return /*#__PURE__*/React.createElement(ProfilePic, {
8944
+ size: this.getSize(),
8945
+ className: "userListing_profilePic",
8946
+ image: this.getImage()
8947
+ });
8948
+ }
8776
8949
  }, {
8777
8950
  key: "render",
8778
8951
  value: function render() {
8779
8952
  return /*#__PURE__*/React.createElement("div", {
8780
- key: this.props.user.userId || this.props.user.Id || this.props.user.id,
8953
+ key: this.getKey(),
8781
8954
  className: "userListing",
8782
8955
  style: {
8783
8956
  minHeight: this.getSize() + 5,
8784
8957
  cursor: this.props.onClick ? 'pointer' : 'inherit',
8785
- opacity: this.props.user && this.props.user.loading ? 0.5 : 1
8958
+ opacity: this.isLoading() ? 0.5 : 1
8786
8959
  },
8787
8960
  onClick: this.props.onClick
8788
8961
  }, /*#__PURE__*/React.createElement("div", {
8789
8962
  className: "userListing_inner"
8790
- }, /*#__PURE__*/React.createElement(ProfilePic, {
8791
- size: this.getSize(),
8792
- className: "userListing_profilePic",
8793
- image: this.props.user.profilePic
8794
- }), /*#__PURE__*/React.createElement("div", {
8963
+ }, this.renderImage(), /*#__PURE__*/React.createElement("div", {
8795
8964
  className: "userListing_middle",
8796
8965
  style: {
8797
8966
  height: this.getSize()
@@ -8802,7 +8971,7 @@ var UserListing = /*#__PURE__*/function (_Component) {
8802
8971
  color: '#fff'
8803
8972
  } : null,
8804
8973
  className: this.props.textClass
8805
- }, this.props.user.displayName), this.renderSub())), this.renderRight());
8974
+ }, this.getText()), this.renderSub())), this.renderRight());
8806
8975
  }
8807
8976
  }]);
8808
8977
 
@@ -10482,6 +10651,23 @@ var OptionsSection = /*#__PURE__*/function (_Component) {
10482
10651
 
10483
10652
  return selectedOption.text;
10484
10653
  }
10654
+ }, {
10655
+ key: "renderIcon",
10656
+ value: function renderIcon(o, isSelected) {
10657
+ switch (o.iconType) {
10658
+ case 'fa':
10659
+ return /*#__PURE__*/React.createElement(FontAwesomeIcon, {
10660
+ className: "optionsButton_icon",
10661
+ icon: o.icon
10662
+ });
10663
+
10664
+ default:
10665
+ return /*#__PURE__*/React.createElement(SVGIcon, {
10666
+ icon: o.icon,
10667
+ colour: isSelected ? '#fff' : COLOUR_BRANDING_MAIN
10668
+ });
10669
+ }
10670
+ }
10485
10671
  }, {
10486
10672
  key: "renderOptionButton",
10487
10673
  value: function renderOptionButton(o) {
@@ -10496,10 +10682,7 @@ var OptionsSection = /*#__PURE__*/function (_Component) {
10496
10682
  }
10497
10683
  }, /*#__PURE__*/React.createElement("div", {
10498
10684
  className: "optionsButton_iconContainer"
10499
- }, /*#__PURE__*/React.createElement(SVGIcon, {
10500
- icon: o.icon,
10501
- colour: isSelected ? '#fff' : COLOUR_BRANDING_MAIN
10502
- })), /*#__PURE__*/React.createElement(Text, {
10685
+ }, this.renderIcon(o, isSelected)), /*#__PURE__*/React.createElement(Text, {
10503
10686
  type: "formLabelSmall",
10504
10687
  className: "optionsButton_text"
10505
10688
  }, o.text));
@@ -11592,6 +11775,7 @@ var index = /*#__PURE__*/Object.freeze({
11592
11775
  Comment: Comment,
11593
11776
  CommentSection: CommentSection,
11594
11777
  DatePicker: DatePicker,
11778
+ DurationInput: DurationInput,
11595
11779
  FileInput: FileInput,
11596
11780
  GenericInput: GenericInput,
11597
11781
  Header: exportObj$4,
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('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('@crello/react-lottie'), require('react-csv'), require('@babel/runtime/helpers/objectWithoutProperties'), require('react-color'), require('tinycolor2'), require('react-router-dom'), require('@fortawesome/react-fontawesome'), 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', '@crello/react-lottie', 'react-csv', '@babel/runtime/helpers/objectWithoutProperties', 'react-color', 'tinycolor2', 'react-router-dom', '@fortawesome/react-fontawesome', '@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.reactLottie, global.reactCsv, global._objectWithoutProperties, global.reactColor, global.tinycolor, global.reactRouterDom, global.reactFontawesome, 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, reactLottie, reactCsv, _objectWithoutProperties, reactColor, tinycolor, reactRouterDom, reactFontawesome, 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
 
@@ -926,6 +926,14 @@
926
926
  return siteConfig;
927
927
  };
928
928
 
929
+ var getMerchantsFromState = function getMerchantsFromState(state) {
930
+ if (!state || !state.auth || !state.auth.user) return [];
931
+ var currentSite = state.auth.user.Roles.find(function (r) {
932
+ return r.site === state.auth.site;
933
+ });
934
+ return currentSite && !___default['default'].isEmpty(currentSite.siteInfo.Accounts) ? currentSite.siteInfo.Accounts : [];
935
+ };
936
+
929
937
  var readJSONFromStorage = function readJSONFromStorage(storage, key, fallback) {
930
938
  var value = storage.getItem(key);
931
939
 
@@ -1066,6 +1074,18 @@
1066
1074
  hours: timeSplit[0],
1067
1075
  minutes: timeSplit[1].substring(0, 2)
1068
1076
  };
1077
+ }; //converts the result of getTimePickerTime into a number representing minutes since midnight
1078
+
1079
+ var timeToMinutes = function timeToMinutes(time) {
1080
+ return parseInt(time.hours, 10) * 60 + parseInt(time.minutes, 10);
1081
+ }; // checks whether there is an overlap between two time frames given time and end times in minutes since midnight
1082
+
1083
+ var hasTimeframeOverlap = function hasTimeframeOverlap(aStart, aEnd, bStart, bEnd) {
1084
+ return aStart < bEnd && bStart < aEnd || bStart < aEnd && aStart < bEnd;
1085
+ }; // converts a time picker input into midnights since midnight
1086
+
1087
+ var timepickerToMinutes = function timepickerToMinutes(input) {
1088
+ return timeToMinutes(getTimepickerTime(input));
1069
1089
  };
1070
1090
  var getDateFromTimeDatePickers = function getDateFromTimeDatePickers(dateInput, timeInput) {
1071
1091
  var dateObject = new Date(dateInput);
@@ -1074,6 +1094,22 @@
1074
1094
  dateObject.setMinutes(time.minutes);
1075
1095
  return dateObject;
1076
1096
  };
1097
+ var minutesToString = function minutesToString(minutes) {
1098
+ var hours = Math.floor(minutes / 60);
1099
+ var remainingMinutes = minutes % 60;
1100
+ var hoursString = hours > 1 ? "".concat(hours, " hours") : "".concat(hours, " hour");
1101
+ var minutesString = remainingMinutes > 1 ? "".concat(remainingMinutes, " minutes") : "".concat(remainingMinutes, " minute");
1102
+
1103
+ if (hours && remainingMinutes) {
1104
+ return "".concat(hoursString, " ").concat(minutesString);
1105
+ } else if (hours) {
1106
+ return hoursString;
1107
+ } else if (remainingMinutes) {
1108
+ return minutesString;
1109
+ } else {
1110
+ return '0 minutes';
1111
+ }
1112
+ };
1077
1113
  var getUTCFromTimeDatePickers = function getUTCFromTimeDatePickers(dateInput, timeInput) {
1078
1114
  var dateObject = getDateFromTimeDatePickers(dateInput, timeInput);
1079
1115
  return moment__default['default'].utc(dateObject);
@@ -1727,11 +1763,16 @@
1727
1763
  getSiteNameFromRoles: getSiteNameFromRoles,
1728
1764
  getSiteSettingFromState: getSiteSettingFromState,
1729
1765
  getSiteLevelFromState: getSiteLevelFromState,
1766
+ getMerchantsFromState: getMerchantsFromState,
1730
1767
  readJSONFromStorage: readJSONFromStorage,
1731
1768
  setLocalStorage: setLocalStorage,
1732
1769
  readStorageWithCookie: readStorageWithCookie,
1733
1770
  getTimepickerTime: getTimepickerTime,
1771
+ timeToMinutes: timeToMinutes,
1772
+ hasTimeframeOverlap: hasTimeframeOverlap,
1773
+ timepickerToMinutes: timepickerToMinutes,
1734
1774
  getDateFromTimeDatePickers: getDateFromTimeDatePickers,
1775
+ minutesToString: minutesToString,
1735
1776
  getUTCFromTimeDatePickers: getUTCFromTimeDatePickers,
1736
1777
  getPluralS: getPluralS,
1737
1778
  getPluralOptions: getPluralOptions,
@@ -5286,6 +5327,65 @@
5286
5327
  return DatePicker;
5287
5328
  }(React.Component);
5288
5329
 
5330
+ function DurationInput(_ref) {
5331
+ var handleChange = _ref.handleChange,
5332
+ label = _ref.label,
5333
+ value = _ref.value,
5334
+ className = _ref.className,
5335
+ labelWidth = _ref.labelWidth;
5336
+ var hours = Math.floor(value / 60);
5337
+ var minutes = value % 60;
5338
+
5339
+ var handleHourChange = function handleHourChange(event) {
5340
+ var newHours = Math.max(0, Math.min(+event.target.value, 24));
5341
+ handleChange(newHours * 60 + minutes);
5342
+ };
5343
+
5344
+ var handleMinuteChange = function handleMinuteChange(event) {
5345
+ var newMinutes = Math.max(0, Math.min(+event.target.value, 59));
5346
+ handleChange(hours * 60 + newMinutes);
5347
+ };
5348
+
5349
+ return /*#__PURE__*/React__default['default'].createElement("div", {
5350
+ className: "flex flex-center ".concat(className ? className : '')
5351
+ }, label && /*#__PURE__*/React__default['default'].createElement(Text, {
5352
+ type: "formTitleSmall",
5353
+ style: {
5354
+ marginRight: '10px',
5355
+ width: labelWidth || 50
5356
+ }
5357
+ }, label), /*#__PURE__*/React__default['default'].createElement("input", {
5358
+ className: "genericInput",
5359
+ type: "number",
5360
+ min: "0",
5361
+ max: "24",
5362
+ value: hours,
5363
+ onChange: handleHourChange,
5364
+ style: {
5365
+ width: 50,
5366
+ marginRight: 5
5367
+ }
5368
+ }), /*#__PURE__*/React__default['default'].createElement(Text, {
5369
+ type: "formTitleSmall",
5370
+ style: {
5371
+ marginRight: 10
5372
+ }
5373
+ }, "Hour(s)"), /*#__PURE__*/React__default['default'].createElement("input", {
5374
+ className: "genericInput",
5375
+ type: "number",
5376
+ min: "0",
5377
+ max: "59",
5378
+ value: minutes,
5379
+ onChange: handleMinuteChange,
5380
+ style: {
5381
+ width: 50,
5382
+ marginRight: 5
5383
+ }
5384
+ }), /*#__PURE__*/React__default['default'].createElement(Text, {
5385
+ type: "formTitleSmall"
5386
+ }, "Minute(s)"));
5387
+ }
5388
+
5289
5389
  function ownKeys$f(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; }
5290
5390
 
5291
5391
  function _objectSpread$f(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$f(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$f(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -8753,6 +8853,55 @@
8753
8853
  value: function getSize() {
8754
8854
  return this.props.size || 30;
8755
8855
  }
8856
+ }, {
8857
+ key: "getImage",
8858
+ value: function getImage() {
8859
+ if (this.props.user && this.props.user.profilePic) {
8860
+ return this.props.user.profilePic;
8861
+ }
8862
+
8863
+ if (this.props.image) {
8864
+ return this.props.image;
8865
+ }
8866
+
8867
+ return undefined;
8868
+ }
8869
+ }, {
8870
+ key: "getKey",
8871
+ value: function getKey() {
8872
+ if (this.props.user && this.props.user.id) {
8873
+ return this.props.user.id;
8874
+ }
8875
+
8876
+ return this.props.id;
8877
+ }
8878
+ }, {
8879
+ key: "getText",
8880
+ value: function getText() {
8881
+ if (this.props.user && this.props.user.displayName) {
8882
+ return this.props.user.displayName;
8883
+ }
8884
+
8885
+ return this.props.title;
8886
+ }
8887
+ }, {
8888
+ key: "getBorderRadius",
8889
+ value: function getBorderRadius() {
8890
+ if (this.props.squareImage) {
8891
+ return 4;
8892
+ }
8893
+
8894
+ return this.getSize() / 2;
8895
+ }
8896
+ }, {
8897
+ key: "isLoading",
8898
+ value: function isLoading() {
8899
+ if (this.props.user && this.props.user.loading) {
8900
+ return this.props.user && this.props.user.loading;
8901
+ }
8902
+
8903
+ return this.props.isLoading;
8904
+ }
8756
8905
  }, {
8757
8906
  key: "renderRight",
8758
8907
  value: function renderRight() {
@@ -8771,25 +8920,45 @@
8771
8920
 
8772
8921
  return this.props.subContent;
8773
8922
  }
8923
+ }, {
8924
+ key: "renderImage",
8925
+ value: function renderImage() {
8926
+ if (this.props.squareImage) {
8927
+ return /*#__PURE__*/React__default['default'].createElement("div", {
8928
+ style: {
8929
+ height: this.getSize(),
8930
+ width: this.getSize(),
8931
+ borderRadius: this.getBorderRadius(),
8932
+ marginRight: 8,
8933
+ backgroundSize: 'cover',
8934
+ backgroundPosition: 'center',
8935
+ backgroundImage: "url(".concat(this.getImage(), ")")
8936
+ },
8937
+ alt: "".concat(this.getText(), " Image")
8938
+ });
8939
+ }
8940
+
8941
+ return /*#__PURE__*/React__default['default'].createElement(ProfilePic, {
8942
+ size: this.getSize(),
8943
+ className: "userListing_profilePic",
8944
+ image: this.getImage()
8945
+ });
8946
+ }
8774
8947
  }, {
8775
8948
  key: "render",
8776
8949
  value: function render() {
8777
8950
  return /*#__PURE__*/React__default['default'].createElement("div", {
8778
- key: this.props.user.userId || this.props.user.Id || this.props.user.id,
8951
+ key: this.getKey(),
8779
8952
  className: "userListing",
8780
8953
  style: {
8781
8954
  minHeight: this.getSize() + 5,
8782
8955
  cursor: this.props.onClick ? 'pointer' : 'inherit',
8783
- opacity: this.props.user && this.props.user.loading ? 0.5 : 1
8956
+ opacity: this.isLoading() ? 0.5 : 1
8784
8957
  },
8785
8958
  onClick: this.props.onClick
8786
8959
  }, /*#__PURE__*/React__default['default'].createElement("div", {
8787
8960
  className: "userListing_inner"
8788
- }, /*#__PURE__*/React__default['default'].createElement(ProfilePic, {
8789
- size: this.getSize(),
8790
- className: "userListing_profilePic",
8791
- image: this.props.user.profilePic
8792
- }), /*#__PURE__*/React__default['default'].createElement("div", {
8961
+ }, this.renderImage(), /*#__PURE__*/React__default['default'].createElement("div", {
8793
8962
  className: "userListing_middle",
8794
8963
  style: {
8795
8964
  height: this.getSize()
@@ -8800,7 +8969,7 @@
8800
8969
  color: '#fff'
8801
8970
  } : null,
8802
8971
  className: this.props.textClass
8803
- }, this.props.user.displayName), this.renderSub())), this.renderRight());
8972
+ }, this.getText()), this.renderSub())), this.renderRight());
8804
8973
  }
8805
8974
  }]);
8806
8975
 
@@ -10480,6 +10649,23 @@
10480
10649
 
10481
10650
  return selectedOption.text;
10482
10651
  }
10652
+ }, {
10653
+ key: "renderIcon",
10654
+ value: function renderIcon(o, isSelected) {
10655
+ switch (o.iconType) {
10656
+ case 'fa':
10657
+ return /*#__PURE__*/React__default['default'].createElement(reactFontawesome.FontAwesomeIcon, {
10658
+ className: "optionsButton_icon",
10659
+ icon: o.icon
10660
+ });
10661
+
10662
+ default:
10663
+ return /*#__PURE__*/React__default['default'].createElement(SVGIcon, {
10664
+ icon: o.icon,
10665
+ colour: isSelected ? '#fff' : COLOUR_BRANDING_MAIN
10666
+ });
10667
+ }
10668
+ }
10483
10669
  }, {
10484
10670
  key: "renderOptionButton",
10485
10671
  value: function renderOptionButton(o) {
@@ -10494,10 +10680,7 @@
10494
10680
  }
10495
10681
  }, /*#__PURE__*/React__default['default'].createElement("div", {
10496
10682
  className: "optionsButton_iconContainer"
10497
- }, /*#__PURE__*/React__default['default'].createElement(SVGIcon, {
10498
- icon: o.icon,
10499
- colour: isSelected ? '#fff' : COLOUR_BRANDING_MAIN
10500
- })), /*#__PURE__*/React__default['default'].createElement(Text, {
10683
+ }, this.renderIcon(o, isSelected)), /*#__PURE__*/React__default['default'].createElement(Text, {
10501
10684
  type: "formLabelSmall",
10502
10685
  className: "optionsButton_text"
10503
10686
  }, o.text));
@@ -11590,6 +11773,7 @@
11590
11773
  Comment: Comment,
11591
11774
  CommentSection: CommentSection,
11592
11775
  DatePicker: DatePicker,
11776
+ DurationInput: DurationInput,
11593
11777
  FileInput: FileInput,
11594
11778
  GenericInput: GenericInput,
11595
11779
  Header: exportObj$4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-web",
3
- "version": "1.4.23",
3
+ "version": "1.4.25",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "main": "dist/index.cjs.js",
6
6
  "scripts": {
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { Text } from './Text';
3
+
4
+ function DurationInput({ handleChange, label, value, className, labelWidth }) {
5
+ const hours = Math.floor(value / 60);
6
+ const minutes = value % 60;
7
+
8
+ const handleHourChange = (event) => {
9
+ const newHours = Math.max(0, Math.min(+event.target.value, 24));
10
+ handleChange(newHours * 60 + minutes);
11
+ };
12
+
13
+ const handleMinuteChange = (event) => {
14
+ const newMinutes = Math.max(0, Math.min(+event.target.value, 59));
15
+ handleChange(hours * 60 + newMinutes);
16
+ };
17
+
18
+ return (
19
+ <div className={`flex flex-center ${className ? className : ''}`}>
20
+ {label && (
21
+ <Text type="formTitleSmall" style={{ marginRight: '10px', width: labelWidth || 50 }}>
22
+ {label}
23
+ </Text>
24
+ )}
25
+ <input
26
+ className="genericInput"
27
+ type="number"
28
+ min="0"
29
+ max="24"
30
+ value={hours}
31
+ onChange={handleHourChange}
32
+ style={{ width: 50, marginRight: 5 }}
33
+ />
34
+ <Text type="formTitleSmall" style={{ marginRight: 10 }}>
35
+ Hour(s)
36
+ </Text>
37
+ <input
38
+ className="genericInput"
39
+ type="number"
40
+ min="0"
41
+ max="59"
42
+ value={minutes}
43
+ onChange={handleMinuteChange}
44
+ style={{ width: 50, marginRight: 5 }}
45
+ />
46
+ <Text type="formTitleSmall">Minute(s)</Text>
47
+ </div>
48
+ );
49
+ }
50
+
51
+ export { DurationInput };
@@ -1,5 +1,6 @@
1
1
  import React, { Component } from 'react';
2
2
  import _ from 'lodash';
3
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
4
  import { COLOUR_BRANDING_MAIN } from '../colours';
4
5
  import { SVGIcon } from './SVGIcon';
5
6
  import { Text } from './Text';
@@ -17,6 +18,15 @@ class OptionsSection extends Component {
17
18
  return selectedOption.text;
18
19
  }
19
20
 
21
+ renderIcon(o, isSelected) {
22
+ switch (o.iconType) {
23
+ case 'fa':
24
+ return <FontAwesomeIcon className="optionsButton_icon" icon={o.icon} />;
25
+ default:
26
+ return <SVGIcon icon={o.icon} colour={isSelected ? '#fff' : COLOUR_BRANDING_MAIN} />;
27
+ }
28
+ }
29
+
20
30
  renderOptionButton(o) {
21
31
  const isSelected = this.props.selected === o.key;
22
32
  return (
@@ -27,9 +37,7 @@ class OptionsSection extends Component {
27
37
  this.props.selectOption(o.key);
28
38
  }}
29
39
  >
30
- <div className="optionsButton_iconContainer">
31
- <SVGIcon icon={o.icon} colour={isSelected ? '#fff' : COLOUR_BRANDING_MAIN} />
32
- </div>
40
+ <div className="optionsButton_iconContainer">{this.renderIcon(o, isSelected)}</div>
33
41
  <Text type="formLabelSmall" className="optionsButton_text">
34
42
  {o.text}
35
43
  </Text>
@@ -7,6 +7,44 @@ class UserListing extends Component {
7
7
  return this.props.size || 30;
8
8
  }
9
9
 
10
+ getImage() {
11
+ if (this.props.user && this.props.user.profilePic) {
12
+ return this.props.user.profilePic;
13
+ }
14
+ if (this.props.image) {
15
+ return this.props.image;
16
+ }
17
+ return undefined;
18
+ }
19
+
20
+ getKey() {
21
+ if (this.props.user && this.props.user.id) {
22
+ return this.props.user.id;
23
+ }
24
+ return this.props.id;
25
+ }
26
+
27
+ getText() {
28
+ if (this.props.user && this.props.user.displayName) {
29
+ return this.props.user.displayName;
30
+ }
31
+ return this.props.title;
32
+ }
33
+
34
+ getBorderRadius() {
35
+ if (this.props.squareImage) {
36
+ return 4;
37
+ }
38
+ return this.getSize() / 2;
39
+ }
40
+
41
+ isLoading() {
42
+ if (this.props.user && this.props.user.loading) {
43
+ return this.props.user && this.props.user.loading;
44
+ }
45
+ return this.props.isLoading;
46
+ }
47
+
10
48
  renderRight() {
11
49
  if (!this.props.rightContent) {
12
50
  return null;
@@ -21,23 +59,43 @@ class UserListing extends Component {
21
59
  return this.props.subContent;
22
60
  }
23
61
 
62
+ renderImage() {
63
+ if (this.props.squareImage) {
64
+ return (
65
+ <div
66
+ style={{
67
+ height: this.getSize(),
68
+ width: this.getSize(),
69
+ borderRadius: this.getBorderRadius(),
70
+ marginRight: 8,
71
+ backgroundSize: 'cover',
72
+ backgroundPosition: 'center',
73
+ backgroundImage: `url(${this.getImage()})`,
74
+ }}
75
+ alt={`${this.getText()} Image`}
76
+ />
77
+ );
78
+ }
79
+ return <ProfilePic size={this.getSize()} className="userListing_profilePic" image={this.getImage()} />;
80
+ }
81
+
24
82
  render() {
25
83
  return (
26
84
  <div
27
- key={this.props.user.userId || this.props.user.Id || this.props.user.id}
85
+ key={this.getKey()}
28
86
  className="userListing"
29
87
  style={{
30
88
  minHeight: this.getSize() + 5,
31
89
  cursor: this.props.onClick ? 'pointer' : 'inherit',
32
- opacity: this.props.user && this.props.user.loading ? 0.5 : 1,
90
+ opacity: this.isLoading() ? 0.5 : 1,
33
91
  }}
34
92
  onClick={this.props.onClick}
35
93
  >
36
94
  <div className="userListing_inner">
37
- <ProfilePic size={this.getSize()} className="userListing_profilePic" image={this.props.user.profilePic} />
95
+ {this.renderImage()}
38
96
  <div className="userListing_middle" style={{ height: this.getSize() }}>
39
97
  <Text type="name" style={this.props.whiteText ? { color: '#fff' } : null} className={this.props.textClass}>
40
- {this.props.user.displayName}
98
+ {this.getText()}
41
99
  </Text>
42
100
  {this.renderSub()}
43
101
  </div>
@@ -5,6 +5,7 @@ export * from './CheckBox';
5
5
  export * from './Comment';
6
6
  export * from './CommentSection';
7
7
  export * from './DatePicker';
8
+ export * from './DurationInput';
8
9
  export * from './FileInput';
9
10
  export * from './GenericInput';
10
11
  export * from './Header';
@@ -111,6 +111,21 @@ export const getTimepickerTime = (input) => {
111
111
  };
112
112
  };
113
113
 
114
+ //converts the result of getTimePickerTime into a number representing minutes since midnight
115
+ export const timeToMinutes = (time) => {
116
+ return parseInt(time.hours, 10) * 60 + parseInt(time.minutes, 10);
117
+ };
118
+
119
+ // checks whether there is an overlap between two time frames given time and end times in minutes since midnight
120
+ export const hasTimeframeOverlap = (aStart, aEnd, bStart, bEnd) => {
121
+ return (aStart < bEnd && bStart < aEnd) || (bStart < aEnd && aStart < bEnd);
122
+ };
123
+
124
+ // converts a time picker input into midnights since midnight
125
+ export const timepickerToMinutes = (input) => {
126
+ return timeToMinutes(getTimepickerTime(input));
127
+ };
128
+
114
129
  export const getDateFromTimeDatePickers = (dateInput, timeInput) => {
115
130
  const dateObject = new Date(dateInput);
116
131
  const time = getTimepickerTime(timeInput);
@@ -119,6 +134,24 @@ export const getDateFromTimeDatePickers = (dateInput, timeInput) => {
119
134
  return dateObject;
120
135
  };
121
136
 
137
+ export const minutesToString = (minutes) => {
138
+ let hours = Math.floor(minutes / 60);
139
+ let remainingMinutes = minutes % 60;
140
+
141
+ let hoursString = hours > 1 ? `${hours} hours` : `${hours} hour`;
142
+ let minutesString = remainingMinutes > 1 ? `${remainingMinutes} minutes` : `${remainingMinutes} minute`;
143
+
144
+ if (hours && remainingMinutes) {
145
+ return `${hoursString} ${minutesString}`;
146
+ } else if (hours) {
147
+ return hoursString;
148
+ } else if (remainingMinutes) {
149
+ return minutesString;
150
+ } else {
151
+ return '0 minutes';
152
+ }
153
+ };
154
+
122
155
  export const getUTCFromTimeDatePickers = (dateInput, timeInput) => {
123
156
  const dateObject = getDateFromTimeDatePickers(dateInput, timeInput);
124
157
  return moment.utc(dateObject);
@@ -32,6 +32,7 @@ export { default as getSiteName } from './site/getSiteName';
32
32
  export { default as getSiteNameFromRoles } from './site/getSiteNameFromRoles';
33
33
  export { default as getSiteSettingFromState } from './site/getSiteSettingFromState';
34
34
  export { default as getSiteLevelFromState } from './site/getSiteLevelFromState';
35
+ export { default as getMerchantsFromState } from './site/getMerchantsFromState';
35
36
 
36
37
  // storage
37
38
  export { default as readJSONFromStorage } from './storage/readJSONFromStorage';
@@ -0,0 +1,9 @@
1
+ import _ from 'lodash';
2
+
3
+ const getMerchantsFromState = (state) => {
4
+ if (!state || !state.auth || !state.auth.user) return [];
5
+ const currentSite = state.auth.user.Roles.find((r) => r.site === state.auth.site);
6
+ return currentSite && !_.isEmpty(currentSite.siteInfo.Accounts) ? currentSite.siteInfo.Accounts : [];
7
+ };
8
+
9
+ export default getMerchantsFromState;