bs-unified-ui 1.0.913 → 1.0.917

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.
@@ -83,7 +83,7 @@ declare class NotificationService {
83
83
  }>;
84
84
  markAsRead(notificationId: string): Promise<void>;
85
85
  markAllAsRead(bsOrgId?: string): Promise<void>;
86
- getAudioRepeat(bsOrgId: string): Promise<any>;
86
+ getAudioRepeat(bsOrgId: string, warehousesConfig?: string[]): Promise<any>;
87
87
  getIndicators(bsOrgId: string, categories?: Record<string, string[]>): Promise<any>;
88
88
  updateIndicators(indicators: Partial<{
89
89
  order: boolean;
@@ -14,4 +14,6 @@ export declare class ObservableSet<T> {
14
14
  values(): IterableIterator<T>;
15
15
  entries(): IterableIterator<[T, T]>;
16
16
  keys(): IterableIterator<T>;
17
+ deleteBy(predicate: (value: T) => boolean): number;
18
+ filter(predicate: (value: T) => boolean): T[];
17
19
  }
@@ -79,6 +79,7 @@ export interface UseNotificationsOptions extends NotificationConfig {
79
79
  navigate?: any;
80
80
  soundConfig?: SoundConfig;
81
81
  triggerEvents?: TriggerEvents;
82
+ warehousesConfig?: string[];
82
83
  }
83
84
  declare const useNotifications: (options?: UseNotificationsOptions) => UseNotificationsResult;
84
85
  export default useNotifications;
@@ -53,6 +53,7 @@ export interface UseNotificationsOptions extends NotificationConfig {
53
53
  navigate?: any;
54
54
  soundConfig?: SoundConfig;
55
55
  triggerEvents?: TriggerEvents;
56
+ warehousesConfig?: string[];
56
57
  }
57
58
  declare const useNotificationsV2: (options?: UseNotificationsOptions) => UseNotificationsV2Result;
58
59
  export default useNotificationsV2;
package/index.js CHANGED
@@ -41890,7 +41890,7 @@ var NotificationService = /** @class */ (function () {
41890
41890
  });
41891
41891
  });
41892
41892
  };
41893
- NotificationService.prototype.getAudioRepeat = function (bsOrgId) {
41893
+ NotificationService.prototype.getAudioRepeat = function (bsOrgId, warehousesConfig) {
41894
41894
  return __awaiter(this, void 0, void 0, function () {
41895
41895
  var headers, sessionToken, queryParams, url, response, res, error_8;
41896
41896
  return __generator(this, function (_a) {
@@ -41916,6 +41916,9 @@ var NotificationService = /** @class */ (function () {
41916
41916
  case 3:
41917
41917
  queryParams = new URLSearchParams();
41918
41918
  queryParams.append('bsOrgId', bsOrgId);
41919
+ if (warehousesConfig && warehousesConfig.length > 0) {
41920
+ queryParams.append('warehouses', warehousesConfig.join(','));
41921
+ }
41919
41922
  url = "".concat(this.config.apiBaseUrl, "/notifications/me/get-audio-repeat?").concat(queryParams.toString());
41920
41923
  return [4 /*yield*/, fetch(url, { headers: headers })];
41921
41924
  case 4:
@@ -45693,22 +45696,47 @@ var ObservableSet = /** @class */ (function () {
45693
45696
  ObservableSet.prototype.keys = function () {
45694
45697
  return this.set.keys();
45695
45698
  };
45699
+ // Delete all items matching a predicate
45700
+ ObservableSet.prototype.deleteBy = function (predicate) {
45701
+ var _this = this;
45702
+ var toDelete = [];
45703
+ this.set.forEach(function (value) {
45704
+ if (predicate(value)) {
45705
+ toDelete.push(value);
45706
+ }
45707
+ });
45708
+ toDelete.forEach(function (value) { return _this.set.delete(value); });
45709
+ if (toDelete.length > 0) {
45710
+ this.notifyListeners();
45711
+ }
45712
+ return toDelete.length;
45713
+ };
45714
+ // Find all items matching a predicate
45715
+ ObservableSet.prototype.filter = function (predicate) {
45716
+ var result = [];
45717
+ this.set.forEach(function (value) {
45718
+ if (predicate(value)) {
45719
+ result.push(value);
45720
+ }
45721
+ });
45722
+ return result;
45723
+ };
45696
45724
  return ObservableSet;
45697
45725
  }());
45698
45726
 
45699
45727
  var useNotificationsV2 = function (options) {
45700
45728
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
45701
45729
  if (options === void 0) { options = {}; }
45702
- var onNotification = options.onNotification, onConnectionChange = options.onConnectionChange, onError = options.onError, _k = options.timezone, timezone = _k === void 0 ? 'America/Vancouver' : _k, navigate = options.navigate, bsOrgId = options.bsOrgId, cfWsId = options.cfWsId, soundConfig = options.soundConfig, triggerEvents = options.triggerEvents;
45703
- var _l = React.useState([]), popoverNotifications = _l[0], setPopoverNotifications = _l[1];
45704
- var _m = React.useState(true), popoverLoading = _m[0], setPopoverLoading = _m[1];
45705
- var _o = React.useState(false), popoverHasNextPage = _o[0], setPopoverHasNextPage = _o[1];
45706
- var _p = React.useState(false), isUnreadPopover = _p[0], setIsUnreadPopover = _p[1];
45707
- var _q = React.useState(0), unreadCount = _q[0], setUnreadCount = _q[1];
45708
- var _r = React.useState(false), isActiveNotificationPage = _r[0], setIsActiveNotificationPage = _r[1];
45709
- var _s = React.useState([]), notifications = _s[0], setNotifications = _s[1];
45710
- var _t = React.useState(true), notificationLoading = _t[0], setNotificationLoading = _t[1];
45711
- var _u = React.useState({
45730
+ var onNotification = options.onNotification, onConnectionChange = options.onConnectionChange, onError = options.onError, _k = options.timezone, timezone = _k === void 0 ? 'America/Vancouver' : _k, navigate = options.navigate, bsOrgId = options.bsOrgId, cfWsId = options.cfWsId, soundConfig = options.soundConfig, triggerEvents = options.triggerEvents, _l = options.warehousesConfig, warehousesConfig = _l === void 0 ? [] : _l;
45731
+ var _m = React.useState([]), popoverNotifications = _m[0], setPopoverNotifications = _m[1];
45732
+ var _o = React.useState(true), popoverLoading = _o[0], setPopoverLoading = _o[1];
45733
+ var _p = React.useState(false), popoverHasNextPage = _p[0], setPopoverHasNextPage = _p[1];
45734
+ var _q = React.useState(false), isUnreadPopover = _q[0], setIsUnreadPopover = _q[1];
45735
+ var _r = React.useState(0), unreadCount = _r[0], setUnreadCount = _r[1];
45736
+ var _s = React.useState(false), isActiveNotificationPage = _s[0], setIsActiveNotificationPage = _s[1];
45737
+ var _t = React.useState([]), notifications = _t[0], setNotifications = _t[1];
45738
+ var _u = React.useState(true), notificationLoading = _u[0], setNotificationLoading = _u[1];
45739
+ var _v = React.useState({
45712
45740
  search: '',
45713
45741
  sortBy: '',
45714
45742
  sortOrder: '',
@@ -45718,19 +45746,19 @@ var useNotificationsV2 = function (options) {
45718
45746
  limit: 20,
45719
45747
  startDate: '',
45720
45748
  endDate: '',
45721
- }), filter = _u[0], setFilter = _u[1];
45749
+ }), filter = _v[0], setFilter = _v[1];
45722
45750
  var filterRef = React.useRef(filter);
45723
- var _v = React.useState(true), hasNextPage = _v[0], setHasNextPage = _v[1];
45724
- var _w = React.useState(true), loading = _w[0], setLoading = _w[1];
45725
- var _x = React.useState(false), isConnected = _x[0], setIsConnected = _x[1];
45726
- var _y = React.useState(null), error = _y[0], setError = _y[1];
45727
- var _z = React.useState(false), isInitialized = _z[0], setIsInitialized = _z[1];
45728
- var _0 = React.useState({
45751
+ var _w = React.useState(true), hasNextPage = _w[0], setHasNextPage = _w[1];
45752
+ var _x = React.useState(true), loading = _x[0], setLoading = _x[1];
45753
+ var _y = React.useState(false), isConnected = _y[0], setIsConnected = _y[1];
45754
+ var _z = React.useState(null), error = _z[0], setError = _z[1];
45755
+ var _0 = React.useState(false), isInitialized = _0[0], setIsInitialized = _0[1];
45756
+ var _1 = React.useState({
45729
45757
  order: false,
45730
45758
  chat: false,
45731
45759
  task_update: false,
45732
45760
  new_driver: false,
45733
- }), indicators = _0[0], setIndicators = _0[1];
45761
+ }), indicators = _1[0], setIndicators = _1[1];
45734
45762
  var serviceRef = React.useRef(null);
45735
45763
  var unsubscribeRef = React.useRef(null);
45736
45764
  var initPromiseRef = React.useRef(null);
@@ -46129,11 +46157,11 @@ var useNotificationsV2 = function (options) {
46129
46157
  }, []);
46130
46158
  // Helper: Stop audio for group if no reminders remain for that group
46131
46159
  var stopAudioRepeatForGroupIfNoReminders = React.useCallback(function (group) {
46132
- var hasRemindersForGroup = Array.from(allRemindersRef.current).some(function (key) {
46160
+ var remindersForGroup = allRemindersRef.current.filter(function (key) {
46133
46161
  var eventType = key.includes(':') ? key.split(':')[0] : key;
46134
46162
  return getEventGroup(eventType) === group;
46135
46163
  });
46136
- if (!hasRemindersForGroup) {
46164
+ if (remindersForGroup.length === 0) {
46137
46165
  stopAudioRepeatForGroup(group);
46138
46166
  }
46139
46167
  }, [stopAudioRepeatForGroup]);
@@ -46150,7 +46178,7 @@ var useNotificationsV2 = function (options) {
46150
46178
  _a.label = 1;
46151
46179
  case 1:
46152
46180
  _a.trys.push([1, 3, , 4]);
46153
- return [4 /*yield*/, serviceRef.current.getAudioRepeat(bsOrgId)];
46181
+ return [4 /*yield*/, serviceRef.current.getAudioRepeat(bsOrgId, warehousesConfig)];
46154
46182
  case 2:
46155
46183
  response = _a.sent();
46156
46184
  data = response === null || response === void 0 ? void 0 : response.data;
@@ -46443,14 +46471,11 @@ var useNotificationsV2 = function (options) {
46443
46471
  });
46444
46472
  setUnreadCount(0);
46445
46473
  // Clear notification-based reminders (orders + delivery)
46446
- var remindersToDelete = Array.from(allRemindersRef.current).filter(function (key) {
46474
+ allRemindersRef.current.deleteBy(function (key) {
46447
46475
  return NOTIFICATION_BASED_REMINDER_EVENTS.some(function (subType) {
46448
46476
  return key.startsWith("".concat(subType, ":"));
46449
46477
  });
46450
46478
  });
46451
- remindersToDelete.forEach(function (key) {
46452
- return allRemindersRef.current.delete(key);
46453
- });
46454
46479
  // Stop audio for online_store and delivery groups if no reminders remain
46455
46480
  ['online_store', 'delivery'].forEach(stopAudioRepeatForGroupIfNoReminders);
46456
46481
  break;
@@ -46481,15 +46506,11 @@ var useNotificationsV2 = function (options) {
46481
46506
  // Handle special case: event without id but with metadata.ids (DELIVERY_REMINDER_EVENTS only)
46482
46507
  if (((_k = incoming_notification === null || incoming_notification === void 0 ? void 0 : incoming_notification.metadata) === null || _k === void 0 ? void 0 : _k.ids) &&
46483
46508
  Array.isArray((_l = incoming_notification === null || incoming_notification === void 0 ? void 0 : incoming_notification.metadata) === null || _l === void 0 ? void 0 : _l.ids)) {
46484
- var idsToRemove = incoming_notification.metadata.ids;
46485
- idsToRemove.forEach(function (notificationId) {
46486
- // Try to map this id with each DELIVERY_REMINDER_EVENTS subType
46487
- var deliverySubTypes = Object.values(DELIVERY_EVENTS);
46488
- deliverySubTypes.forEach(function (deliverySubType) {
46489
- var compositeKey = "".concat(deliverySubType, ":").concat(notificationId);
46490
- if (allRemindersRef.current.has(compositeKey)) {
46491
- allRemindersRef.current.delete(compositeKey);
46492
- }
46509
+ var idsToRemove_1 = incoming_notification.metadata.ids;
46510
+ // Delete all reminders matching any of the notification IDs in one call
46511
+ allRemindersRef.current.deleteBy(function (key) {
46512
+ return idsToRemove_1.some(function (notificationId) {
46513
+ return key.includes(":".concat(notificationId));
46493
46514
  });
46494
46515
  });
46495
46516
  // Check if we should stop audio for delivery group
@@ -46846,16 +46867,16 @@ var useNotificationsV2 = function (options) {
46846
46867
  if (!memoizedReminderEvents)
46847
46868
  return;
46848
46869
  // Find reminders for disabled events
46849
- var remindersToDelete = [];
46850
- allRemindersRef.current.forEach(function (key) {
46870
+ var remindersToDelete = allRemindersRef.current.filter(function (key) {
46851
46871
  var subType = key.includes(':') ? key.split(':')[0] : key;
46852
- if (!memoizedReminderEvents[subType]) {
46853
- remindersToDelete.push(key);
46854
- }
46872
+ return !memoizedReminderEvents[subType];
46855
46873
  });
46856
46874
  if (remindersToDelete.length > 0) {
46857
46875
  // Delete reminders
46858
- remindersToDelete.forEach(function (key) { return allRemindersRef.current.delete(key); });
46876
+ allRemindersRef.current.deleteBy(function (key) {
46877
+ var subType = key.includes(':') ? key.split(':')[0] : key;
46878
+ return !memoizedReminderEvents[subType];
46879
+ });
46859
46880
  // Get unique groups from deleted reminders and check if audio should stop
46860
46881
  var reminderGroupsToCheck = getReminderGroups(new Set(remindersToDelete));
46861
46882
  reminderGroupsToCheck.forEach(stopAudioRepeatForGroupIfNoReminders);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bs-unified-ui",
3
- "version": "1.0.913",
3
+ "version": "1.0.917",
4
4
  "license": "MIT",
5
5
  "author": "Advesa",
6
6
  "description": "UI Components for Unified Breadstack UI",