@copart/ops-tool-kit 1.8.1-alpha.1 → 1.8.1-alpha.2

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.
@@ -33,7 +33,7 @@ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
33
33
  var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
34
34
 
35
35
  const name$f = "@copart/ops-tool-kit";
36
- const version$5 = "1.8.1-alpha.1";
36
+ const version$5 = "1.8.1-alpha.2";
37
37
  const main$1 = "dist/ops-tool-kit.js";
38
38
  const style = "dist/ops-tool-kit.css";
39
39
  const files = [
@@ -8697,6 +8697,42 @@ _curry1(function values(obj) {
8697
8697
 
8698
8698
  var values$1 = values;
8699
8699
 
8700
+ /**
8701
+ * Makes an ascending comparator function out of a function that returns a value
8702
+ * that can be compared with `<` and `>`.
8703
+ *
8704
+ * @func
8705
+ * @memberOf R
8706
+ * @since v0.23.0
8707
+ * @category Function
8708
+ * @sig Ord b => (a -> b) -> a -> a -> Number
8709
+ * @param {Function} fn A function of arity one that returns a value that can be compared
8710
+ * @param {*} a The first item to be compared.
8711
+ * @param {*} b The second item to be compared.
8712
+ * @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0`
8713
+ * @see R.descend
8714
+ * @example
8715
+ *
8716
+ * const byAge = R.ascend(R.prop('age'));
8717
+ * const people = [
8718
+ * { name: 'Emma', age: 70 },
8719
+ * { name: 'Peter', age: 78 },
8720
+ * { name: 'Mikhail', age: 62 },
8721
+ * ];
8722
+ * const peopleByYoungestFirst = R.sort(byAge, people);
8723
+ * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
8724
+ */
8725
+
8726
+ var ascend =
8727
+ /*#__PURE__*/
8728
+ _curry3(function ascend(fn, a, b) {
8729
+ var aa = fn(a);
8730
+ var bb = fn(b);
8731
+ return aa < bb ? -1 : aa > bb ? 1 : 0;
8732
+ });
8733
+
8734
+ var ascend$1 = ascend;
8735
+
8700
8736
  /**
8701
8737
  * Makes a shallow clone of an object, setting or overriding the specified
8702
8738
  * property with the given value. Note that this copies and flattens prototype
@@ -10860,6 +10896,57 @@ _curry2(function sort(comparator, list) {
10860
10896
 
10861
10897
  var sort$1 = sort;
10862
10898
 
10899
+ /**
10900
+ * Sorts a list according to a list of comparators.
10901
+ *
10902
+ * @func
10903
+ * @memberOf R
10904
+ * @since v0.23.0
10905
+ * @category Relation
10906
+ * @sig [(a, a) -> Number] -> [a] -> [a]
10907
+ * @param {Array} functions A list of comparator functions.
10908
+ * @param {Array} list The list to sort.
10909
+ * @return {Array} A new list sorted according to the comarator functions.
10910
+ * @example
10911
+ *
10912
+ * const alice = {
10913
+ * name: 'alice',
10914
+ * age: 40
10915
+ * };
10916
+ * const bob = {
10917
+ * name: 'bob',
10918
+ * age: 30
10919
+ * };
10920
+ * const clara = {
10921
+ * name: 'clara',
10922
+ * age: 40
10923
+ * };
10924
+ * const people = [clara, bob, alice];
10925
+ * const ageNameSort = R.sortWith([
10926
+ * R.descend(R.prop('age')),
10927
+ * R.ascend(R.prop('name'))
10928
+ * ]);
10929
+ * ageNameSort(people); //=> [alice, clara, bob]
10930
+ */
10931
+
10932
+ var sortWith =
10933
+ /*#__PURE__*/
10934
+ _curry2(function sortWith(fns, list) {
10935
+ return Array.prototype.slice.call(list, 0).sort(function (a, b) {
10936
+ var result = 0;
10937
+ var i = 0;
10938
+
10939
+ while (result === 0 && i < fns.length) {
10940
+ result = fns[i](a, b);
10941
+ i += 1;
10942
+ }
10943
+
10944
+ return result;
10945
+ });
10946
+ });
10947
+
10948
+ var sortWith$1 = sortWith;
10949
+
10863
10950
  /**
10864
10951
  * Checks if a list starts with the provided sublist.
10865
10952
  *
@@ -11080,8 +11167,7 @@ var regexCountry = /\.co\.([a-z]{2})/;
11080
11167
  var regexCobaltCountry = /\.copart\.([a-z]{2})/;
11081
11168
  var isLogoutRoute = ['logout'].includes(getRouteName());
11082
11169
  var isAuthRoute = ['login', 'logout', ''].includes(getRouteName());
11083
- var isCoreRoute = ['settings', 'home', 'webChat', ''].includes(getRouteName());
11084
- var isIframeRoute = ['embedded-apps', 'embedded'].includes(getRouteName());
11170
+ var isCoreRoute = ['settings', 'home', 'webChat', 'embedded', ''].includes(getRouteName());
11085
11171
  var getDomain = function getDomain(url) {
11086
11172
  var country = url.match(regexCountry);
11087
11173
  var countryCode = (country && country.length > 1 && country[1] || 'US').toUpperCase();
@@ -35398,7 +35484,7 @@ function getNotificationSignatureToStore(notification) {
35398
35484
 
35399
35485
  function addNotificationToViewedList(notification) {
35400
35486
  try {
35401
- localStorage.setItem('viewedNotifications', _objectSpread2({}, getViewedNotifications(), _defineProperty({}, notification.notificationId, getNotificationSignatureToStore(notification))));
35487
+ localStorage.setItem('viewedNotifications', JSON.stringify(_objectSpread2({}, getViewedNotifications(), _defineProperty({}, notification.notificationId, getNotificationSignatureToStore(notification)))));
35402
35488
  } catch (err) {
35403
35489
  console.error(err);
35404
35490
  }
@@ -35422,8 +35508,13 @@ function isOutOfRange(startDate, endDate) {
35422
35508
  function filterOutExpiredNotifications(notifications) {
35423
35509
  return filter$1(function (_ref) {
35424
35510
  var startsAt = _ref.startsAt,
35425
- endsAt = _ref.endsAt;
35426
- return isOutOfRange(startsAt, endsAt);
35511
+ endsAt = _ref.endsAt,
35512
+ absStartsAt = _ref.absStartsAt,
35513
+ absEndsAt = _ref.absEndsAt,
35514
+ timeZoneType = _ref.timeZoneType;
35515
+ var startTime = timeZoneType === "RPTZ" ? absStartsAt : moment.utc(startsAt).local().format("YYYY-MM-DD HH:mm:ss");
35516
+ var endTime = timeZoneType === "RPTZ" ? absEndsAt : moment.utc(endsAt).local().format("YYYY-MM-DD HH:mm:ss");
35517
+ return isOutOfRange(startTime, endTime);
35427
35518
  })(notifications);
35428
35519
  }
35429
35520
 
@@ -35553,6 +35644,28 @@ function getLeafNodes(obj) {
35553
35644
  return [];
35554
35645
  }
35555
35646
  }
35647
+
35648
+ function getPriorityCode(category) {
35649
+ return {
35650
+ alert: 0,
35651
+ warning: 1,
35652
+ success: 1,
35653
+ information: 1
35654
+ }[category.toLowerCase()];
35655
+ }
35656
+
35657
+ function getDate(dateStr) {
35658
+ return new Date(dateStr) || '';
35659
+ }
35660
+
35661
+ function sortNotifications(notifications) {
35662
+ try {
35663
+ return sortWith$1([ascend$1(compose(getPriorityCode, prop$1('categoryDescription'))), descend$1(compose(getDate, prop$1('startsAt')))], notifications);
35664
+ } catch (err) {
35665
+ console.error(err);
35666
+ return notifications;
35667
+ }
35668
+ }
35556
35669
  var notificationKeysMapper = {
35557
35670
  applications: 'apps',
35558
35671
  facilities: 'facilities',
@@ -35659,20 +35772,20 @@ var useWindowSize = function useWindowSize() {
35659
35772
  };
35660
35773
 
35661
35774
  var alertBackgroundColorMapping = {
35662
- alert: '#f5f5cb',
35663
- warning: '#fab9b9',
35775
+ alert: '#fab9b9',
35776
+ warning: '#f5f5cb',
35664
35777
  information: '#c1dcf5',
35665
35778
  success: 'rgb(192 234 204 / 54%)'
35666
35779
  };
35667
35780
  var alertInfoColorMapping = {
35668
- alert: 'rgb(240 182 79)',
35669
- warning: 'var(--primaryRed)',
35781
+ alert: 'var(--primaryRed)',
35782
+ warning: 'rgb(240 182 79)',
35670
35783
  information: 'var(--blue)',
35671
35784
  success: 'rgb(50 179 55)'
35672
35785
  };
35673
35786
  var alertToIconMapping = {
35674
- alert: 'Warning',
35675
- warning: 'Info',
35787
+ alert: 'Info',
35788
+ warning: 'Warning',
35676
35789
  information: 'Info',
35677
35790
  success: 'Accept'
35678
35791
  };
@@ -35724,6 +35837,8 @@ var Banner = function Banner(_ref2) {
35724
35837
  dismissibleFlag = _ref2.dismissibleFlag,
35725
35838
  onDismiss = _ref2.onDismiss,
35726
35839
  startsAt = _ref2.startsAt,
35840
+ absStartsAt = _ref2.absStartsAt,
35841
+ timeZoneType = _ref2.timeZoneType,
35727
35842
  showSideBar = _ref2.showSideBar;
35728
35843
  var contentBarRef = React__default["default"].useRef(null);
35729
35844
 
@@ -35744,7 +35859,8 @@ var Banner = function Banner(_ref2) {
35744
35859
  setExpanded(false);
35745
35860
  contentBarRef.current && setIsContentOverFlow(contentBarRef.current.offsetHeight < contentBarRef.current.scrollHeight);
35746
35861
  }, [current]);
35747
- var timeDiff = getTimeDiff(startsAt);
35862
+ var startTime = timeZoneType === "RPTZ" ? absStartsAt : moment.utc(startsAt).local().format("YYYY-MM-DD HH:mm:ss");
35863
+ var timeDiff = getTimeDiff(startTime);
35748
35864
 
35749
35865
  var topNotificationBar = function topNotificationBar() {
35750
35866
  return React__default["default"].createElement("div", {
@@ -35866,7 +35982,7 @@ var Banner = function Banner(_ref2) {
35866
35982
  fontSize: '19px',
35867
35983
  color: alertInfoColorMapping[categoryDescription.toLowerCase()]
35868
35984
  }
35869
- })), React__default["default"].createElement("div", null, timeDiff, " -")), React__default["default"].createElement("div", null, showNavButtons && React__default["default"].createElement(Actions$1, {
35985
+ })), React__default["default"].createElement("div", null, timeDiff)), React__default["default"].createElement("div", null, showNavButtons && React__default["default"].createElement(Actions$1, {
35870
35986
  onLeftButtonClick: onLeftButtonClick,
35871
35987
  count: count,
35872
35988
  current: current,
@@ -35915,7 +36031,7 @@ var Banner = function Banner(_ref2) {
35915
36031
  };
35916
36032
 
35917
36033
  var mainNotificationBar = function mainNotificationBar() {
35918
- return React__default["default"].createElement(React__default["default"].Fragment, null, showSideBar ? sideNotificationBar() : width >= 760 ? topNotificationBar() : mobileNotificationBar());
36034
+ return React__default["default"].createElement(React__default["default"].Fragment, null, showSideBar ? sideNotificationBar() : width >= 768 ? topNotificationBar() : mobileNotificationBar());
35919
36035
  };
35920
36036
 
35921
36037
  return mainNotificationBar();
@@ -41912,11 +42028,11 @@ var browser = {
41912
42028
  'version': version$3
41913
42029
  };
41914
42030
 
41915
- function fetchG2Notifications(updateNotifications) {
41916
- var coreAppConfig = storage.getLocalItem('opsportal-core:config');
42031
+ function fetchG2Notifications(updateNotifications, updateAllNotificationsList) {
42032
+ var coreAppConfig = storage$1.getLocalItem('opsportal-core:config');
41917
42033
  var endpoints = coreAppConfig.endpoints;
41918
42034
  var headers = {
41919
- country: pathOr$1('', ['selectedCountryA3code'], storage.getSessionItem('dashboard'))
42035
+ country: pathOr$1('', ['selectedCountryA3code'], storage$1.getSessionItem('dashboard'))
41920
42036
  };
41921
42037
  fetcher.get(endpoints.getG2Notifications, {
41922
42038
  headers: headers
@@ -41924,6 +42040,7 @@ function fetchG2Notifications(updateNotifications) {
41924
42040
  if (resp.status === 200) {
41925
42041
  var notificationsList = pathOr$1([], ['data', 'response'], resp);
41926
42042
  compose(updateNotifications, filterNotifications)(notificationsList);
42043
+ updateAllNotificationsList(notificationsList);
41927
42044
  } else {
41928
42045
  console.log("Failed to Fetch Notifications");
41929
42046
  }
@@ -41932,13 +42049,20 @@ function fetchG2Notifications(updateNotifications) {
41932
42049
  });
41933
42050
  }
41934
42051
 
41935
- function startWebSocketConnection(updateNotifications) {
41936
- var coreAppConfig = storage.getLocalItem('opsportal-core:config');
41937
- var webSocketURL = coreAppConfig.webSocketURL;
42052
+ function startWebSocketConnection(updateNotifications, updateAllNotificationsList) {
42053
+ var _storage$getSessionIt, _storage$getSessionIt2;
42054
+
42055
+ var coreAppConfig = storage$1.getLocalItem('opsportal-core:config');
42056
+ var webSocketURL = "".concat(coreAppConfig.webSocketURL, "/").concat((_storage$getSessionIt = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt === void 0 ? void 0 : _storage$getSessionIt.selectedYard);
42057
+ browserCookies.set('notification_country', (_storage$getSessionIt2 = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt2 === void 0 ? void 0 : _storage$getSessionIt2.selectedCountryA3code, {
42058
+ domain: '.copart.com'
42059
+ });
42060
+ var access_token = "bearer ".concat(storage$1.accessToken);
42061
+ document.cookie = "notification_access_token=" + access_token + "; path=/;domain=.copart.com";
41938
42062
  var client = new browser.w3cwebsocket(webSocketURL);
41939
42063
 
41940
42064
  client.onerror = function (err) {
41941
- return console.log("this is the error- ".concat(err));
42065
+ return console.log("error ", err);
41942
42066
  };
41943
42067
 
41944
42068
  client.onopen = function () {
@@ -41946,11 +42070,20 @@ function startWebSocketConnection(updateNotifications) {
41946
42070
  };
41947
42071
 
41948
42072
  client.onmessage = function (message) {
41949
- var notification = message.data ? [JSON.parse(message.data)] : []; //const newNotification = filterNotifications(notification)
42073
+ var notification = [];
41950
42074
 
41951
- var newNotification = notification;
41952
- newNotification.length > 0 && updateNotifications(newNotification);
41953
- };
42075
+ try {
42076
+ notification = message.data ? [JSON.parse(message.data)] : [];
42077
+ var newNotification = notification;
42078
+ newNotification.length > 0 && compose(updateNotifications, filterNotifications)(newNotification);
42079
+ updateAllNotificationsList(newNotification);
42080
+ } catch (e) {
42081
+ console.log(e);
42082
+ }
42083
+ }; // storage.accessToken
42084
+
42085
+
42086
+ return client;
41954
42087
  }
41955
42088
 
41956
42089
  /******************************************************************************
@@ -49755,7 +49888,7 @@ var CountryFlag = function CountryFlag() {
49755
49888
  };
49756
49889
 
49757
49890
  var AppBar = function AppBar(_ref) {
49758
- var _storage$getSessionIt;
49891
+ var _storage$getSessionIt, _storage$getSessionIt2;
49759
49892
 
49760
49893
  var history = _ref.history,
49761
49894
  setAppBarMounted = _ref.setAppBarMounted,
@@ -49879,12 +50012,43 @@ var AppBar = function AppBar(_ref) {
49879
50012
  notifications = _useState6[0],
49880
50013
  setNotifications = _useState6[1];
49881
50014
 
50015
+ var _useState7 = React.useState([]),
50016
+ _useState8 = _slicedToArray(_useState7, 2),
50017
+ listOfAllNotifications = _useState8[0],
50018
+ setListOfAllNotifications = _useState8[1];
50019
+
50020
+ var _useState9 = React.useState(),
50021
+ _useState10 = _slicedToArray(_useState9, 2),
50022
+ socketClient = _useState10[0],
50023
+ setSocketClient = _useState10[1];
50024
+
50025
+ var _useState11 = React.useState(false),
50026
+ _useState12 = _slicedToArray(_useState11, 2),
50027
+ firebaseInitialized = _useState12[0],
50028
+ setFirebaseinitialized = _useState12[1];
50029
+
49882
50030
  var updateNotifications = function updateNotifications(newNotifications) {
49883
50031
  setNotifications(function (notifications) {
49884
- return [].concat(_toConsumableArray(notifications), _toConsumableArray(newNotifications));
50032
+ return filterDuplicateAndSave(notifications, newNotifications);
49885
50033
  });
49886
50034
  };
49887
50035
 
50036
+ var updateAllNotificationsList = function updateAllNotificationsList(newNotifications) {
50037
+ setListOfAllNotifications(function (notifications) {
50038
+ return filterDuplicateAndSave(notifications, newNotifications);
50039
+ });
50040
+ };
50041
+
50042
+ var filterDuplicateAndSave = function filterDuplicateAndSave(notifications, newNotifications) {
50043
+ var notificationIds = newNotifications.map(function (notification) {
50044
+ return notification.notificationId;
50045
+ });
50046
+ var filteredNewNotifications = notifications.filter(function (notification) {
50047
+ return !notificationIds.includes(notification.notificationId);
50048
+ });
50049
+ return sortNotifications([].concat(_toConsumableArray(newNotifications), _toConsumableArray(filteredNewNotifications)));
50050
+ };
50051
+
49888
50052
  var dismissNotification = function dismissNotification(notification) {
49889
50053
  addNotificationToViewedList(notification);
49890
50054
  setNotifications(function (notifications) {
@@ -49895,11 +50059,38 @@ var AppBar = function AppBar(_ref) {
49895
50059
  });
49896
50060
  };
49897
50061
 
50062
+ var selectedYard = (_storage$getSessionIt = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt === void 0 ? void 0 : _storage$getSessionIt.selectedYard;
49898
50063
  React.useEffect(function () {
49899
- notificationsSource.includes('Nchan') && fetchG2Notifications(updateNotifications) && startWebSocketConnection(updateNotifications);
49900
- notificationsSource.includes('Firebase') && getFireBaseNotifications(updateNotifications);
49901
- }, []);
49902
- console.log("thisis");
50064
+ setNotifications([]);
50065
+ setListOfAllNotifications([]);
50066
+ socketClient && socketClient.close();
50067
+
50068
+ if (history.location.pathname !== '/logout') {
50069
+ if (notificationsSource.includes('Nchan')) {
50070
+ fetchG2Notifications(updateNotifications, updateAllNotificationsList);
50071
+ setSocketClient(startWebSocketConnection(updateNotifications, updateAllNotificationsList));
50072
+ }
50073
+
50074
+ if (!firebaseInitialized && notificationsSource.includes('Firebase')) {
50075
+ getFireBaseNotifications(updateNotifications);
50076
+ setFirebaseinitialized(true);
50077
+ }
50078
+ }
50079
+ }, [selectedYard]);
50080
+ React.useEffect(function () {
50081
+ var interval = setInterval(function () {
50082
+ if (listOfAllNotifications.length) {
50083
+ compose(updateNotifications, filterNotifications)(listOfAllNotifications);
50084
+ }
50085
+
50086
+ if (notifications.length) {
50087
+ setNotifications(filterOutExpiredNotifications(notifications));
50088
+ }
50089
+ }, 10000);
50090
+ return function () {
50091
+ clearInterval(interval);
50092
+ };
50093
+ }, [listOfAllNotifications, notifications]);
49903
50094
  var STACK = process.env.STACK || 'c';
49904
50095
  var modifiedSettings = SETTINGS_ITEMS;
49905
50096
  modifiedSettings[0]['name'] = storage$1.userName;
@@ -49920,7 +50111,7 @@ var AppBar = function AppBar(_ref) {
49920
50111
  userEmail: storage$1.userEmail,
49921
50112
  language: storage$1.activeLanguage,
49922
50113
  showSearchBar: false,
49923
- homeYard: (_storage$getSessionIt = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt === void 0 ? void 0 : _storage$getSessionIt.homeYard,
50114
+ homeYard: (_storage$getSessionIt2 = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt2 === void 0 ? void 0 : _storage$getSessionIt2.homeYard,
49924
50115
  logoutItems: modifiedSettings,
49925
50116
  countryCode: storage$1.activeCountry,
49926
50117
  yardNumber: storage$1.activeYardNumber,
@@ -50046,7 +50237,6 @@ styleInject(css_248z$1);
50046
50237
  var PASS_FOR_AUTHENTICATION_ROUTE = 'Route is /login or /logout.';
50047
50238
  var FAILED_AUTHENTICATION_CHECK_REASON = 'User is not authenticated. (Check localStorage.login.isAuthenticated.)';
50048
50239
  var AUTHENTICATED_AND_ON_CORE_ROUTE = 'Authenticated and entering core route.';
50049
- var AUTHENTICATED_AND_ON_IFRAME_ROUTE = 'Authenticated and entering iframe route.';
50050
50240
  var PASS_BECAUSE_RESTRICTIONS_DISABLED = 'SecurityLevel and Yard restrictions disabled.';
50051
50241
  var PATH_NOT_FOUND = 'Tile/Path does not exist';
50052
50242
  var NO_TILE_PERMISSION = 'Could not verify user access for the tile.';
@@ -50175,14 +50365,6 @@ function (_React$PureComponent) {
50175
50365
  return fetcher.getPermissions(appTile.appAuthName);
50176
50366
 
50177
50367
  case 20:
50178
- if (!isIframeRoute) {
50179
- _context.next = 22;
50180
- break;
50181
- }
50182
-
50183
- return _context.abrupt("return", this.allowAccess(AUTHENTICATED_AND_ON_IFRAME_ROUTE));
50184
-
50185
- case 22:
50186
50368
  // If there are rules, evaluate and act accordingly.
50187
50369
  tileConfigAccess = userHasAccess(appTile);
50188
50370
 
@@ -50192,7 +50374,7 @@ function (_React$PureComponent) {
50192
50374
  this.denyAccess(NO_TILE_PERMISSION);
50193
50375
  }
50194
50376
 
50195
- case 24:
50377
+ case 22:
50196
50378
  case "end":
50197
50379
  return _context.stop();
50198
50380
  }