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

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.3";
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('timeZoneType') === "SPTZ" ? moment.utc(prop$1('startsAt')).local().format("YYYY-MM-DD HH:mm:ss") : prop$1('absStartsAt')))], 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,25 +42049,45 @@ 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;
41938
- var client = new browser.w3cwebsocket(webSocketURL);
42052
+ function startWebSocketConnection(updateNotifications, updateAllNotificationsList) {
42053
+ var _storage$getSessionIt, _storage$getSessionIt2;
41939
42054
 
41940
- client.onerror = function (err) {
41941
- return console.log("this is the error- ".concat(err));
41942
- };
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
+ "bearer ".concat(storage$1.accessToken);
42061
+ document.cookie = "access_token=" + storage$1.accessToken + "; path=/;domain=.copart.com";
41943
42062
 
41944
- client.onopen = function () {
41945
- console.log("WebSocket connection has been opened");
41946
- };
42063
+ try {
42064
+ var client = new browser.w3cwebsocket(webSocketURL);
41947
42065
 
41948
- client.onmessage = function (message) {
41949
- var notification = message.data ? [JSON.parse(message.data)] : []; //const newNotification = filterNotifications(notification)
42066
+ client.onerror = function (err) {
42067
+ return console.log("error ", err);
42068
+ };
41950
42069
 
41951
- var newNotification = notification;
41952
- newNotification.length > 0 && updateNotifications(newNotification);
41953
- };
42070
+ client.onopen = function () {
42071
+ console.log("WebSocket connection has been opened");
42072
+ };
42073
+
42074
+ client.onmessage = function (message) {
42075
+ var notification = [];
42076
+
42077
+ try {
42078
+ notification = message.data ? [JSON.parse(message.data)] : [];
42079
+ var newNotification = notification;
42080
+ newNotification.length > 0 && compose(updateNotifications, filterNotifications)(newNotification);
42081
+ updateAllNotificationsList(newNotification);
42082
+ } catch (e) {
42083
+ console.log(e);
42084
+ }
42085
+ };
42086
+
42087
+ return client;
42088
+ } catch (e) {
42089
+ console.log("Web socket error ", e);
42090
+ }
41954
42091
  }
41955
42092
 
41956
42093
  /******************************************************************************
@@ -49755,7 +49892,7 @@ var CountryFlag = function CountryFlag() {
49755
49892
  };
49756
49893
 
49757
49894
  var AppBar = function AppBar(_ref) {
49758
- var _storage$getSessionIt;
49895
+ var _storage$getSessionIt, _storage$getSessionIt2;
49759
49896
 
49760
49897
  var history = _ref.history,
49761
49898
  setAppBarMounted = _ref.setAppBarMounted,
@@ -49879,10 +50016,41 @@ var AppBar = function AppBar(_ref) {
49879
50016
  notifications = _useState6[0],
49880
50017
  setNotifications = _useState6[1];
49881
50018
 
50019
+ var _useState7 = React.useState([]),
50020
+ _useState8 = _slicedToArray(_useState7, 2),
50021
+ listOfAllNotifications = _useState8[0],
50022
+ setListOfAllNotifications = _useState8[1];
50023
+
50024
+ var _useState9 = React.useState(),
50025
+ _useState10 = _slicedToArray(_useState9, 2),
50026
+ socketClient = _useState10[0],
50027
+ setSocketClient = _useState10[1];
50028
+
50029
+ var _useState11 = React.useState(false),
50030
+ _useState12 = _slicedToArray(_useState11, 2),
50031
+ firebaseInitialized = _useState12[0],
50032
+ setFirebaseinitialized = _useState12[1];
50033
+
49882
50034
  var updateNotifications = function updateNotifications(newNotifications) {
49883
50035
  setNotifications(function (notifications) {
49884
- return [].concat(_toConsumableArray(notifications), _toConsumableArray(newNotifications));
50036
+ return filterDuplicateAndSave(notifications, newNotifications);
50037
+ });
50038
+ };
50039
+
50040
+ var updateAllNotificationsList = function updateAllNotificationsList(newNotifications) {
50041
+ setListOfAllNotifications(function (notifications) {
50042
+ return filterDuplicateAndSave(notifications, newNotifications);
50043
+ });
50044
+ };
50045
+
50046
+ var filterDuplicateAndSave = function filterDuplicateAndSave(notifications, newNotifications) {
50047
+ var notificationIds = newNotifications.map(function (notification) {
50048
+ return notification.notificationId;
50049
+ });
50050
+ var filteredNotifications = notifications.filter(function (notification) {
50051
+ return !notificationIds.includes(notification.notificationId);
49885
50052
  });
50053
+ return sortNotifications([].concat(_toConsumableArray(newNotifications), _toConsumableArray(filteredNotifications)));
49886
50054
  };
49887
50055
 
49888
50056
  var dismissNotification = function dismissNotification(notification) {
@@ -49895,11 +50063,44 @@ var AppBar = function AppBar(_ref) {
49895
50063
  });
49896
50064
  };
49897
50065
 
50066
+ var selectedYard = (_storage$getSessionIt = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt === void 0 ? void 0 : _storage$getSessionIt.selectedYard;
49898
50067
  React.useEffect(function () {
49899
- notificationsSource.includes('Nchan') && fetchG2Notifications(updateNotifications) && startWebSocketConnection(updateNotifications);
49900
- notificationsSource.includes('Firebase') && getFireBaseNotifications(updateNotifications);
49901
- }, []);
49902
- console.log("thisis");
50068
+ setNotifications([]);
50069
+ setListOfAllNotifications([]);
50070
+ socketClient && socketClient.close();
50071
+
50072
+ if (history.location.pathname !== '/logout') {
50073
+ if (notificationsSource.includes('Nchan')) {
50074
+ fetchG2Notifications(updateNotifications, updateAllNotificationsList);
50075
+ setSocketClient(startWebSocketConnection(updateNotifications, updateAllNotificationsList));
50076
+ }
50077
+
50078
+ if (!firebaseInitialized && notificationsSource.includes('Firebase')) {
50079
+ getFireBaseNotifications(updateNotifications);
50080
+ setFirebaseinitialized(true);
50081
+ }
50082
+ }
50083
+ }, [selectedYard]);
50084
+ React.useEffect(function () {
50085
+ var interval = setInterval(function () {
50086
+ if (listOfAllNotifications.length) {
50087
+ compose(updateNotifications, filterNotifications)(listOfAllNotifications);
50088
+ }
50089
+ }, 20000);
50090
+ return function () {
50091
+ clearInterval(interval);
50092
+ };
50093
+ }, [listOfAllNotifications]);
50094
+ React.useEffect(function () {
50095
+ var expireNotificationsInterval = setInterval(function () {
50096
+ if (notifications.length) {
50097
+ setNotifications(filterOutExpiredNotifications(notifications));
50098
+ }
50099
+ }, 10000);
50100
+ return function () {
50101
+ clearInterval(expireNotificationsInterval);
50102
+ };
50103
+ }, [notifications]);
49903
50104
  var STACK = process.env.STACK || 'c';
49904
50105
  var modifiedSettings = SETTINGS_ITEMS;
49905
50106
  modifiedSettings[0]['name'] = storage$1.userName;
@@ -49920,7 +50121,7 @@ var AppBar = function AppBar(_ref) {
49920
50121
  userEmail: storage$1.userEmail,
49921
50122
  language: storage$1.activeLanguage,
49922
50123
  showSearchBar: false,
49923
- homeYard: (_storage$getSessionIt = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt === void 0 ? void 0 : _storage$getSessionIt.homeYard,
50124
+ homeYard: (_storage$getSessionIt2 = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt2 === void 0 ? void 0 : _storage$getSessionIt2.homeYard,
49924
50125
  logoutItems: modifiedSettings,
49925
50126
  countryCode: storage$1.activeCountry,
49926
50127
  yardNumber: storage$1.activeYardNumber,
@@ -50046,7 +50247,6 @@ styleInject(css_248z$1);
50046
50247
  var PASS_FOR_AUTHENTICATION_ROUTE = 'Route is /login or /logout.';
50047
50248
  var FAILED_AUTHENTICATION_CHECK_REASON = 'User is not authenticated. (Check localStorage.login.isAuthenticated.)';
50048
50249
  var AUTHENTICATED_AND_ON_CORE_ROUTE = 'Authenticated and entering core route.';
50049
- var AUTHENTICATED_AND_ON_IFRAME_ROUTE = 'Authenticated and entering iframe route.';
50050
50250
  var PASS_BECAUSE_RESTRICTIONS_DISABLED = 'SecurityLevel and Yard restrictions disabled.';
50051
50251
  var PATH_NOT_FOUND = 'Tile/Path does not exist';
50052
50252
  var NO_TILE_PERMISSION = 'Could not verify user access for the tile.';
@@ -50175,14 +50375,6 @@ function (_React$PureComponent) {
50175
50375
  return fetcher.getPermissions(appTile.appAuthName);
50176
50376
 
50177
50377
  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
50378
  // If there are rules, evaluate and act accordingly.
50187
50379
  tileConfigAccess = userHasAccess(appTile);
50188
50380
 
@@ -50192,7 +50384,7 @@ function (_React$PureComponent) {
50192
50384
  this.denyAccess(NO_TILE_PERMISSION);
50193
50385
  }
50194
50386
 
50195
- case 24:
50387
+ case 22:
50196
50388
  case "end":
50197
50389
  return _context.stop();
50198
50390
  }