@copart/ops-tool-kit 1.8.1-alpha.25 → 1.8.1-alpha.27

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__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
33
33
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
34
34
 
35
35
  const name$f = "@copart/ops-tool-kit";
36
- const version$5 = "1.8.1-alpha.25";
36
+ const version$5 = "1.8.1-alpha.27";
37
37
  const main$1 = "dist/ops-tool-kit.js";
38
38
  const style = "dist/ops-tool-kit.css";
39
39
  const files = [
@@ -35227,9 +35227,10 @@ function filterOutExpiredNotifications(notifications) {
35227
35227
  return filter$1(function (_ref) {
35228
35228
  var startsAt = _ref.startsAt,
35229
35229
  endsAt = _ref.endsAt,
35230
- timeZoneType = _ref.timeZoneType;
35230
+ timeZoneType = _ref.timeZoneType,
35231
+ endDateTimeZone = _ref.endDateTimeZone;
35231
35232
  var startTime = timeZoneType === "Recipient TimeZone" || timeZoneType === "RPTZ" ? startsAt : moment.utc(startsAt).local().format("YYYY-MM-DD HH:mm:ss");
35232
- var endTime = timeZoneType === "Recipient TimeZone" || timeZoneType === "RPTZ" ? endsAt : moment.utc(endsAt).local().format("YYYY-MM-DD HH:mm:ss");
35233
+ var endTime = (timeZoneType === "Recipient TimeZone" || timeZoneType === "RPTZ") && endDateTimeZone !== 'UTC' ? endsAt : moment.utc(endsAt).local().format("YYYY-MM-DD HH:mm:ss");
35233
35234
  return isOutOfRange(startTime, endTime);
35234
35235
  })(notifications);
35235
35236
  }
@@ -35374,16 +35375,19 @@ function getPriorityCode(category) {
35374
35375
  }[category.toLowerCase()];
35375
35376
  }
35376
35377
 
35377
- function getDate(dateStr) {
35378
- return new Date(dateStr) || '';
35379
- }
35380
-
35381
35378
  function sortNotifications(notifications) {
35379
+ var newNotifications = clone$1(notifications);
35380
+ var dateSortedNotifications = newNotifications.sort(function (a, b) {
35381
+ var startDateA = a.timeZoneType === "Recipient TimeZone" || a.timeZoneType === "RPTZ" ? a.startsAt : moment.utc(a.startsAt).local().format("YYYY-MM-DD HH:mm:ss");
35382
+ var startDateB = b.timeZoneType === "Recipient TimeZone" || b.timeZoneType === "RPTZ" ? b.startsAt : moment.utc(b.startsAt).local().format("YYYY-MM-DD HH:mm:ss");
35383
+ return new Date(startDateB) - new Date(startDateA);
35384
+ });
35385
+
35382
35386
  try {
35383
- return sortWith$1([ascend$1(compose(getPriorityCode, prop$1('categoryDescription'))), descend$1(compose(getDate, prop$1('timeZoneType') === "SPTZ" || prop$1('timeZoneType') === "Specific TimeZone" ? moment.utc(prop$1('startsAt')).local().format("YYYY-MM-DD HH:mm:ss") : prop$1('startsAt')))], notifications);
35387
+ return sortWith$1([ascend$1(compose(getPriorityCode, prop$1('categoryDescription')))], dateSortedNotifications);
35384
35388
  } catch (err) {
35385
35389
  console.error(err);
35386
- return notifications;
35390
+ return dateSortedNotifications;
35387
35391
  }
35388
35392
  }
35389
35393
  var notificationKeysMapper = {
@@ -39863,7 +39867,6 @@ function startWebSocketConnection(updateNotifications, updateAllNotificationsLis
39863
39867
 
39864
39868
  notification = message.data ? [JSON.parse(message.data)] : [];
39865
39869
  var newNotification = notification;
39866
- console.log('***newNotification in socket resp=', newNotification);
39867
39870
 
39868
39871
  if (newNotification.length > 0 && ((_newNotification$ = newNotification[0]) === null || _newNotification$ === void 0 ? void 0 : _newNotification$.status) === 'A') {
39869
39872
  compose(updateNotifications, filterNotifications)(newNotification);
@@ -47930,29 +47933,41 @@ var AppBar = function AppBar(_ref) {
47930
47933
  });
47931
47934
  };
47932
47935
 
47936
+ var removeNotification = function removeNotification(newNotification) {
47937
+ setNotifications(function (notifications) {
47938
+ var currentNotifications = clone$1(notifications);
47939
+ var filteredNotifications = currentNotifications.filter(function (notification) {
47940
+ return notification.notificationId !== newNotification.notificationId;
47941
+ });
47942
+ return filteredNotifications;
47943
+ });
47944
+ setListOfAllNotifications(function (notifications) {
47945
+ var currentNotifications = clone$1(notifications);
47946
+ var filteredNotifications = currentNotifications.filter(function (notification) {
47947
+ return notification.notificationId !== newNotification.notificationId;
47948
+ });
47949
+ return filteredNotifications;
47950
+ });
47951
+ };
47952
+
47933
47953
  var updateAllNotificationsList = function updateAllNotificationsList(newNotifications) {
47934
47954
  if (newNotifications.length === 1) {
47955
+ var check = filterNotifications(newNotifications);
47956
+
47935
47957
  var newNotification = _objectSpread2({}, newNotifications[0]);
47936
47958
 
47937
- console.log('***newNotification=', newNotification);
47938
47959
  var startTime = newNotification.timeZoneType === "RPTZ" ? newNotification.startsAt : moment.utc(newNotification.startsAt).local().format("YYYY-MM-DD HH:mm:ss");
47939
- var endTime = newNotification.timeZoneType === "RPTZ" ? newNotification.endsAt : moment.utc(newNotification.endsAt).local().format("YYYY-MM-DD HH:mm:ss");
47940
- console.log('***condition=', (newNotification === null || newNotification === void 0 ? void 0 : newNotification.status) !== 'A' || !isOutOfRange(startTime, endTime));
47941
-
47942
- if ((newNotification === null || newNotification === void 0 ? void 0 : newNotification.status) !== 'A' || !isOutOfRange(startTime, endTime)) {
47943
- newNotification.endsAt = '2020-01-01 00:00:00';
47944
- var currentNotifications = clone$1(notifications);
47945
- console.log('***currentNotifications=', currentNotifications);
47946
- var notificationindex = currentNotifications.findIndex(function (notification) {
47947
- return notification.notificationId === newNotification.notificationId;
47948
- });
47949
- console.log('***notificationindex=', notificationindex);
47960
+ var endTime = newNotification.timeZoneType === "RPTZ" && newNotification.endDateTimeZone !== 'UTC' ? newNotification.endsAt : moment.utc(newNotification.endsAt).local().format("YYYY-MM-DD HH:mm:ss");
47961
+ var currentDate = new Date();
47950
47962
 
47951
- if (notificationindex !== -1) {
47952
- currentNotifications[notificationindex] = newNotification;
47953
- setNotifications(currentNotifications);
47954
- console.log('***setNotifications done=', currentNotifications);
47955
- }
47963
+ if (!check.length) {
47964
+ removeNotification(newNotification);
47965
+ } else if (new Date(startTime) > currentDate && (newNotification === null || newNotification === void 0 ? void 0 : newNotification.status) === 'A') {
47966
+ setListOfAllNotifications(function (notifications) {
47967
+ return filterDuplicateAndSave(notifications, newNotifications);
47968
+ });
47969
+ } else if ((newNotification === null || newNotification === void 0 ? void 0 : newNotification.status) !== 'A' || !isOutOfRange(startTime, endTime)) {
47970
+ removeNotification(newNotification);
47956
47971
  } else {
47957
47972
  setListOfAllNotifications(function (notifications) {
47958
47973
  return filterDuplicateAndSave(notifications, newNotifications);