analytica-frontend-lib 1.1.45 → 1.1.46

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.mjs CHANGED
@@ -10848,6 +10848,116 @@ var NotificationCard_default = NotificationCard;
10848
10848
  var createUseNotificationStore = (apiClient) => {
10849
10849
  return createNotificationStore(apiClient);
10850
10850
  };
10851
+
10852
+ // src/hooks/useNotifications.ts
10853
+ import { useCallback as useCallback5 } from "react";
10854
+ var createUseNotifications = (apiClient) => {
10855
+ const useNotificationStore = createUseNotificationStore(apiClient);
10856
+ return () => {
10857
+ const {
10858
+ notifications,
10859
+ unreadCount,
10860
+ loading,
10861
+ error,
10862
+ hasMore,
10863
+ currentPage,
10864
+ fetchNotifications,
10865
+ markAsRead,
10866
+ markAllAsRead,
10867
+ deleteNotification,
10868
+ clearNotifications,
10869
+ resetError,
10870
+ getGroupedNotifications
10871
+ } = useNotificationStore();
10872
+ const handleNavigate = useCallback5(
10873
+ (entityType, entityId) => {
10874
+ if (entityType && entityId) {
10875
+ switch (entityType.toUpperCase()) {
10876
+ case "ACTIVITY" /* ACTIVITY */:
10877
+ window.location.href = `/atividades/${entityId}`;
10878
+ break;
10879
+ case "GOAL" /* GOAL */:
10880
+ window.location.href = `/painel/trilhas/${entityId}`;
10881
+ break;
10882
+ default:
10883
+ break;
10884
+ }
10885
+ }
10886
+ },
10887
+ []
10888
+ );
10889
+ const getActionLabel = useCallback5(
10890
+ (entityType) => {
10891
+ if (!entityType) return void 0;
10892
+ switch (entityType.toUpperCase()) {
10893
+ case "ACTIVITY" /* ACTIVITY */:
10894
+ return "Ver atividade";
10895
+ case "GOAL" /* GOAL */:
10896
+ return "Ver meta";
10897
+ default:
10898
+ return void 0;
10899
+ }
10900
+ },
10901
+ []
10902
+ );
10903
+ const markAsReadAndNavigate = useCallback5(
10904
+ async (id, entityType, entityId) => {
10905
+ await markAsRead(id);
10906
+ if (entityType && entityId) {
10907
+ handleNavigate(entityType, entityId);
10908
+ }
10909
+ },
10910
+ [markAsRead, handleNavigate]
10911
+ );
10912
+ const refreshNotifications = useCallback5(async () => {
10913
+ resetError();
10914
+ await fetchNotifications();
10915
+ }, [resetError, fetchNotifications]);
10916
+ const formatNotification = useCallback5(
10917
+ (notification) => ({
10918
+ ...notification,
10919
+ time: formatTimeAgo(notification.createdAt),
10920
+ entityType: notification.entityType || void 0,
10921
+ entityId: notification.entityId || void 0
10922
+ }),
10923
+ []
10924
+ );
10925
+ const getFormattedGroupedNotifications = useCallback5(() => {
10926
+ const groups = getGroupedNotifications();
10927
+ return groups.map((group) => ({
10928
+ ...group,
10929
+ notifications: group.notifications.map(formatNotification)
10930
+ }));
10931
+ }, [getGroupedNotifications, formatNotification]);
10932
+ return {
10933
+ // State
10934
+ notifications,
10935
+ unreadCount,
10936
+ loading,
10937
+ error,
10938
+ hasMore,
10939
+ currentPage,
10940
+ // Actions
10941
+ fetchNotifications,
10942
+ markAsRead,
10943
+ markAllAsRead,
10944
+ deleteNotification,
10945
+ clearNotifications,
10946
+ resetError,
10947
+ markAsReadAndNavigate,
10948
+ refreshNotifications,
10949
+ // Navigation
10950
+ handleNavigate,
10951
+ // Helpers
10952
+ getActionLabel,
10953
+ getGroupedNotifications,
10954
+ getFormattedGroupedNotifications
10955
+ };
10956
+ };
10957
+ };
10958
+ var createNotificationsHook = (apiClient) => {
10959
+ return createUseNotifications(apiClient);
10960
+ };
10851
10961
  export {
10852
10962
  ANSWER_STATUS,
10853
10963
  Alert_default as Alert,
@@ -10952,7 +11062,9 @@ export {
10952
11062
  VideoPlayer_default as VideoPlayer,
10953
11063
  Whiteboard_default as Whiteboard,
10954
11064
  createNotificationStore,
11065
+ createNotificationsHook,
10955
11066
  createUseNotificationStore,
11067
+ createUseNotifications,
10956
11068
  createZustandAuthAdapter,
10957
11069
  formatTimeAgo,
10958
11070
  getDeviceType,