@ttt-productions/notification-core 0.2.1 → 0.2.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.
Files changed (90) hide show
  1. package/dist/components/NotificationEmptyState.d.ts +6 -0
  2. package/dist/components/NotificationEmptyState.d.ts.map +1 -0
  3. package/dist/components/NotificationEmptyState.js +9 -0
  4. package/dist/components/NotificationEmptyState.js.map +1 -0
  5. package/dist/components/NotificationHistoryList.d.ts +7 -0
  6. package/dist/components/NotificationHistoryList.d.ts.map +1 -0
  7. package/dist/components/NotificationHistoryList.js +41 -0
  8. package/dist/components/NotificationHistoryList.js.map +1 -0
  9. package/dist/components/NotificationList.d.ts +6 -0
  10. package/dist/components/NotificationList.d.ts.map +1 -0
  11. package/dist/components/NotificationList.js +79 -0
  12. package/dist/components/NotificationList.js.map +1 -0
  13. package/dist/components/NotificationUnreadBadge.d.ts +8 -0
  14. package/dist/components/NotificationUnreadBadge.d.ts.map +1 -0
  15. package/dist/components/NotificationUnreadBadge.js +21 -0
  16. package/dist/components/NotificationUnreadBadge.js.map +1 -0
  17. package/dist/components/index.d.ts +5 -0
  18. package/dist/components/index.d.ts.map +1 -0
  19. package/dist/components/index.js +5 -0
  20. package/dist/components/index.js.map +1 -0
  21. package/dist/components/relative-time.d.ts +5 -0
  22. package/dist/components/relative-time.d.ts.map +1 -0
  23. package/dist/components/relative-time.js +23 -0
  24. package/dist/components/relative-time.js.map +1 -0
  25. package/dist/hooks/index.d.ts +4 -7
  26. package/dist/hooks/index.d.ts.map +1 -1
  27. package/dist/hooks/index.js +4 -3
  28. package/dist/hooks/index.js.map +1 -1
  29. package/dist/hooks/useActiveNotifications.d.ts +7 -0
  30. package/dist/hooks/useActiveNotifications.d.ts.map +1 -0
  31. package/dist/hooks/useActiveNotifications.js +30 -0
  32. package/dist/hooks/useActiveNotifications.js.map +1 -0
  33. package/dist/hooks/useArchiveAllNotifications.d.ts +24 -0
  34. package/dist/hooks/useArchiveAllNotifications.d.ts.map +1 -0
  35. package/dist/hooks/useArchiveAllNotifications.js +87 -0
  36. package/dist/hooks/useArchiveAllNotifications.js.map +1 -0
  37. package/dist/hooks/useArchiveNotification.d.ts +23 -0
  38. package/dist/hooks/useArchiveNotification.d.ts.map +1 -0
  39. package/dist/hooks/useArchiveNotification.js +68 -0
  40. package/dist/hooks/useArchiveNotification.js.map +1 -0
  41. package/dist/hooks/useNotificationHistory.d.ts +16 -0
  42. package/dist/hooks/useNotificationHistory.d.ts.map +1 -0
  43. package/dist/hooks/useNotificationHistory.js +35 -0
  44. package/dist/hooks/useNotificationHistory.js.map +1 -0
  45. package/dist/hooks/useUnreadCount.d.ts +175 -15
  46. package/dist/hooks/useUnreadCount.d.ts.map +1 -1
  47. package/dist/hooks/useUnreadCount.js +27 -13
  48. package/dist/hooks/useUnreadCount.js.map +1 -1
  49. package/dist/index.d.ts +3 -3
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +3 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/server/archiveNotificationHelper.d.ts +31 -0
  54. package/dist/server/archiveNotificationHelper.d.ts.map +1 -0
  55. package/dist/server/archiveNotificationHelper.js +83 -0
  56. package/dist/server/archiveNotificationHelper.js.map +1 -0
  57. package/dist/server/createNotificationHelper.d.ts +25 -0
  58. package/dist/server/createNotificationHelper.d.ts.map +1 -0
  59. package/dist/server/createNotificationHelper.js +118 -0
  60. package/dist/server/createNotificationHelper.js.map +1 -0
  61. package/dist/server/index.d.ts +5 -0
  62. package/dist/server/index.d.ts.map +1 -0
  63. package/dist/server/index.js +5 -0
  64. package/dist/server/index.js.map +1 -0
  65. package/dist/server/processBatchHelper.d.ts +29 -0
  66. package/dist/server/processBatchHelper.d.ts.map +1 -0
  67. package/dist/server/processBatchHelper.js +158 -0
  68. package/dist/server/processBatchHelper.js.map +1 -0
  69. package/dist/server/types.d.ts +81 -0
  70. package/dist/server/types.d.ts.map +1 -0
  71. package/dist/server/types.js +6 -0
  72. package/dist/server/types.js.map +1 -0
  73. package/dist/types.d.ts +159 -44
  74. package/dist/types.d.ts.map +1 -1
  75. package/dist/types.js +6 -0
  76. package/dist/types.js.map +1 -1
  77. package/package.json +2 -2
  78. package/src/styles/notifications.css +206 -0
  79. package/dist/hooks/useMarkAllAsRead.d.ts +0 -30
  80. package/dist/hooks/useMarkAllAsRead.d.ts.map +0 -1
  81. package/dist/hooks/useMarkAllAsRead.js +0 -44
  82. package/dist/hooks/useMarkAllAsRead.js.map +0 -1
  83. package/dist/hooks/useMarkAsRead.d.ts +0 -30
  84. package/dist/hooks/useMarkAsRead.d.ts.map +0 -1
  85. package/dist/hooks/useMarkAsRead.js +0 -40
  86. package/dist/hooks/useMarkAsRead.js.map +0 -1
  87. package/dist/hooks/useNotifications.d.ts +0 -25
  88. package/dist/hooks/useNotifications.d.ts.map +0 -1
  89. package/dist/hooks/useNotifications.js +0 -31
  90. package/dist/hooks/useNotifications.js.map +0 -1
@@ -0,0 +1,206 @@
1
+ /* ============================================================================
2
+ * @ttt-productions/notification-core — Notification Styles
3
+ *
4
+ * Uses theme-core CSS variables for automatic light/dark/high-contrast support.
5
+ * All classes use the `ntf-` prefix to avoid collisions.
6
+ * Apps can override any class for custom branding.
7
+ * ============================================================================ */
8
+
9
+ /* === NOTIFICATION LIST === */
10
+ .ntf-list {
11
+ display: flex;
12
+ flex-direction: column;
13
+ max-height: 24rem;
14
+ overflow-y: auto;
15
+ }
16
+
17
+ .ntf-list-header {
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: space-between;
21
+ padding: 0.75rem 1rem;
22
+ border-bottom: 1px solid hsl(var(--border));
23
+ }
24
+
25
+ .ntf-list-header-title {
26
+ font-weight: 600;
27
+ font-size: 0.875rem;
28
+ color: hsl(var(--foreground));
29
+ }
30
+
31
+ .ntf-list-footer {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ padding: 0.5rem 1rem;
36
+ border-top: 1px solid hsl(var(--border));
37
+ }
38
+
39
+ /* === NOTIFICATION ITEM === */
40
+ .ntf-item {
41
+ display: flex;
42
+ align-items: flex-start;
43
+ gap: 0.75rem;
44
+ padding: 0.75rem 1rem;
45
+ cursor: pointer;
46
+ border-bottom: 1px solid hsl(var(--border) / 0.5);
47
+ transition: background-color 150ms ease;
48
+ }
49
+
50
+ .ntf-item:hover {
51
+ background-color: hsl(var(--muted));
52
+ }
53
+
54
+ .ntf-item:last-child {
55
+ border-bottom: none;
56
+ }
57
+
58
+ .ntf-item-icon {
59
+ flex-shrink: 0;
60
+ width: 2rem;
61
+ height: 2rem;
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ border-radius: 0.5rem;
66
+ background-color: hsl(var(--primary) / 0.10);
67
+ color: hsl(var(--primary));
68
+ font-size: 1rem;
69
+ }
70
+
71
+ .ntf-item-content {
72
+ flex: 1;
73
+ min-width: 0;
74
+ }
75
+
76
+ .ntf-item-title {
77
+ font-size: 0.875rem;
78
+ font-weight: 600;
79
+ color: hsl(var(--foreground));
80
+ line-height: 1.25rem;
81
+ }
82
+
83
+ .ntf-item-message {
84
+ font-size: 0.75rem;
85
+ font-weight: 500;
86
+ color: hsl(var(--muted-foreground));
87
+ line-height: 1rem;
88
+ margin-top: 0.125rem;
89
+ }
90
+
91
+ .ntf-item-timestamp {
92
+ font-size: 0.625rem;
93
+ font-weight: 500;
94
+ color: hsl(var(--muted-foreground));
95
+ margin-top: 0.25rem;
96
+ }
97
+
98
+ .ntf-item-count {
99
+ flex-shrink: 0;
100
+ align-self: center;
101
+ }
102
+
103
+ /* === EMPTY STATE === */
104
+ .ntf-empty {
105
+ display: flex;
106
+ flex-direction: column;
107
+ align-items: center;
108
+ justify-content: center;
109
+ padding: 2rem 1rem;
110
+ gap: 0.5rem;
111
+ }
112
+
113
+ .ntf-empty-icon {
114
+ color: hsl(var(--success));
115
+ }
116
+
117
+ .ntf-empty-text {
118
+ font-size: 0.875rem;
119
+ font-weight: 500;
120
+ color: hsl(var(--muted-foreground));
121
+ }
122
+
123
+ /* === UNREAD BADGE === */
124
+ .ntf-badge {
125
+ display: flex;
126
+ align-items: center;
127
+ justify-content: center;
128
+ min-width: 1.25rem;
129
+ height: 1.25rem;
130
+ padding: 0 0.25rem;
131
+ border-radius: 9999px;
132
+ font-size: 0.625rem;
133
+ font-weight: 700;
134
+ background-color: hsl(var(--destructive));
135
+ color: hsl(var(--destructive-foreground));
136
+ }
137
+
138
+ .ntf-badge--hidden {
139
+ display: none;
140
+ }
141
+
142
+ /* === HISTORY LIST === */
143
+ .ntf-history-item {
144
+ display: flex;
145
+ align-items: flex-start;
146
+ gap: 0.75rem;
147
+ padding: 0.75rem 1rem;
148
+ border-bottom: 1px solid hsl(var(--border) / 0.5);
149
+ opacity: 0.7;
150
+ }
151
+
152
+ .ntf-history-item:last-child {
153
+ border-bottom: none;
154
+ }
155
+
156
+ .ntf-history-item--clickable {
157
+ cursor: pointer;
158
+ transition: opacity 150ms ease;
159
+ }
160
+
161
+ .ntf-history-item--clickable:hover {
162
+ opacity: 1;
163
+ }
164
+
165
+ /* === LOADING STATE === */
166
+ .ntf-loading {
167
+ display: flex;
168
+ align-items: center;
169
+ justify-content: center;
170
+ padding: 2rem 1rem;
171
+ color: hsl(var(--muted-foreground));
172
+ font-size: 0.875rem;
173
+ }
174
+
175
+ /* === HIGH CONTRAST MODE === */
176
+ .high-contrast .ntf-item {
177
+ border-bottom-width: 2px;
178
+ border-color: hsl(var(--border));
179
+ }
180
+
181
+ .high-contrast .ntf-item:hover {
182
+ background-color: hsl(var(--foreground));
183
+ color: hsl(var(--background));
184
+ }
185
+
186
+ .high-contrast .ntf-item:hover .ntf-item-title,
187
+ .high-contrast .ntf-item:hover .ntf-item-message,
188
+ .high-contrast .ntf-item:hover .ntf-item-timestamp {
189
+ color: hsl(var(--background));
190
+ }
191
+
192
+ .high-contrast .ntf-item-icon {
193
+ background-color: hsl(var(--background));
194
+ color: hsl(var(--foreground));
195
+ border: 2px solid hsl(var(--border));
196
+ }
197
+
198
+ .high-contrast .ntf-badge {
199
+ background-color: hsl(var(--foreground));
200
+ color: hsl(var(--background));
201
+ border: 2px solid hsl(var(--border));
202
+ }
203
+
204
+ .high-contrast .ntf-list-header {
205
+ border-bottom-width: 2px;
206
+ }
@@ -1,30 +0,0 @@
1
- export interface UseMarkAllAsReadOptions {
2
- /** User ID */
3
- userId: string;
4
- /** Query keys to invalidate after marking all as read */
5
- invalidateKeys?: readonly unknown[][];
6
- }
7
- /**
8
- * Mark all unread notifications as read in a batch operation.
9
- *
10
- * @example
11
- * ```tsx
12
- * const markAllAsRead = useMarkAllAsRead({ userId: currentUser.uid });
13
- *
14
- * const handleMarkAllRead = (unreadNotifications: Notification[]) => {
15
- * markAllAsRead.mutate({ notifications: unreadNotifications });
16
- * };
17
- * ```
18
- */
19
- export declare function useMarkAllAsRead({ userId, invalidateKeys, }: UseMarkAllAsReadOptions): {
20
- mutate: ({ notificationIds }: {
21
- notificationIds: string[];
22
- }) => void;
23
- mutateAsync: ({ notificationIds }: {
24
- notificationIds: string[];
25
- }) => Promise<any>;
26
- isPending: any;
27
- isError: any;
28
- error: any;
29
- };
30
- //# sourceMappingURL=useMarkAllAsRead.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMarkAllAsRead.d.ts","sourceRoot":"","sources":["../../src/hooks/useMarkAllAsRead.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,cAAc,CAAC,EAAE,SAAS,OAAO,EAAE,EAAE,CAAC;CACvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,cAAc,GACf,EAAE,uBAAuB;kCASQ;QAAE,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE;uCASlB;QAAE,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE;;;;EAazE"}
@@ -1,44 +0,0 @@
1
- 'use client';
2
- import { useFirestoreBatch } from '@ttt-productions/query-core';
3
- /**
4
- * Mark all unread notifications as read in a batch operation.
5
- *
6
- * @example
7
- * ```tsx
8
- * const markAllAsRead = useMarkAllAsRead({ userId: currentUser.uid });
9
- *
10
- * const handleMarkAllRead = (unreadNotifications: Notification[]) => {
11
- * markAllAsRead.mutate({ notifications: unreadNotifications });
12
- * };
13
- * ```
14
- */
15
- export function useMarkAllAsRead({ userId, invalidateKeys, }) {
16
- const batchMutation = useFirestoreBatch({
17
- invalidateKeys: invalidateKeys ?? [
18
- ['notifications', userId],
19
- ['notifications-unread-count', userId],
20
- ],
21
- });
22
- return {
23
- mutate: ({ notificationIds }) => {
24
- const operations = notificationIds.map((id) => ({
25
- type: 'update',
26
- docPath: `userData/${userId}/metadata/notifications/${id}`,
27
- data: { isRead: true },
28
- }));
29
- batchMutation.mutate({ operations });
30
- },
31
- mutateAsync: async ({ notificationIds }) => {
32
- const operations = notificationIds.map((id) => ({
33
- type: 'update',
34
- docPath: `userData/${userId}/metadata/notifications/${id}`,
35
- data: { isRead: true },
36
- }));
37
- return batchMutation.mutateAsync({ operations });
38
- },
39
- isPending: batchMutation.isPending,
40
- isError: batchMutation.isError,
41
- error: batchMutation.error,
42
- };
43
- }
44
- //# sourceMappingURL=useMarkAllAsRead.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMarkAllAsRead.js","sourceRoot":"","sources":["../../src/hooks/useMarkAllAsRead.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAUhE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,cAAc,GACU;IACxB,MAAM,aAAa,GAAG,iBAAiB,CAAC;QACtC,cAAc,EAAE,cAAc,IAAI;YAChC,CAAC,eAAe,EAAE,MAAM,CAAC;YACzB,CAAC,4BAA4B,EAAE,MAAM,CAAC;SACvC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,MAAM,EAAE,CAAC,EAAE,eAAe,EAAiC,EAAE,EAAE;YAC7D,MAAM,UAAU,GAAwB,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACnE,IAAI,EAAE,QAAiB;gBACvB,OAAO,EAAE,YAAY,MAAM,2BAA2B,EAAE,EAAE;gBAC1D,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;aACvB,CAAC,CAAC,CAAC;YAEJ,aAAa,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QACvC,CAAC;QACD,WAAW,EAAE,KAAK,EAAE,EAAE,eAAe,EAAiC,EAAE,EAAE;YACxE,MAAM,UAAU,GAAwB,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACnE,IAAI,EAAE,QAAiB;gBACvB,OAAO,EAAE,YAAY,MAAM,2BAA2B,EAAE,EAAE;gBAC1D,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;aACvB,CAAC,CAAC,CAAC;YAEJ,OAAO,aAAa,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,SAAS,EAAE,aAAa,CAAC,SAAS;QAClC,OAAO,EAAE,aAAa,CAAC,OAAO;QAC9B,KAAK,EAAE,aAAa,CAAC,KAAK;KAC3B,CAAC;AACJ,CAAC"}
@@ -1,30 +0,0 @@
1
- export interface UseMarkAsReadOptions {
2
- /** User ID */
3
- userId: string;
4
- /** Query keys to invalidate after marking as read */
5
- invalidateKeys?: readonly unknown[][];
6
- }
7
- /**
8
- * Mark a single notification as read.
9
- *
10
- * @example
11
- * ```tsx
12
- * const markAsRead = useMarkAsRead({ userId: currentUser.uid });
13
- *
14
- * const handleNotificationClick = (notificationId: string) => {
15
- * markAsRead.mutate({ notificationId });
16
- * };
17
- * ```
18
- */
19
- export declare function useMarkAsRead({ userId, invalidateKeys, }: UseMarkAsReadOptions): {
20
- mutate: ({ notificationId }: {
21
- notificationId: string;
22
- }) => void;
23
- mutateAsync: ({ notificationId }: {
24
- notificationId: string;
25
- }) => Promise<any>;
26
- isPending: any;
27
- isError: any;
28
- error: any;
29
- };
30
- //# sourceMappingURL=useMarkAsRead.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMarkAsRead.d.ts","sourceRoot":"","sources":["../../src/hooks/useMarkAsRead.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACnC,cAAc;IACd,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,cAAc,CAAC,EAAE,SAAS,OAAO,EAAE,EAAE,CAAC;CACvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,cAAc,GACf,EAAE,oBAAoB;iCASU;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;sCAMf;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;;;;EAUrE"}
@@ -1,40 +0,0 @@
1
- 'use client';
2
- import { useFirestoreUpdate } from '@ttt-productions/query-core';
3
- /**
4
- * Mark a single notification as read.
5
- *
6
- * @example
7
- * ```tsx
8
- * const markAsRead = useMarkAsRead({ userId: currentUser.uid });
9
- *
10
- * const handleNotificationClick = (notificationId: string) => {
11
- * markAsRead.mutate({ notificationId });
12
- * };
13
- * ```
14
- */
15
- export function useMarkAsRead({ userId, invalidateKeys, }) {
16
- const updateMutation = useFirestoreUpdate({
17
- invalidateKeys: invalidateKeys ?? [
18
- ['notifications', userId],
19
- ['notifications-unread-count', userId],
20
- ],
21
- });
22
- return {
23
- mutate: ({ notificationId }) => {
24
- updateMutation.mutate({
25
- docPath: `userData/${userId}/metadata/notifications/${notificationId}`,
26
- data: { isRead: true },
27
- });
28
- },
29
- mutateAsync: async ({ notificationId }) => {
30
- return updateMutation.mutateAsync({
31
- docPath: `userData/${userId}/metadata/notifications/${notificationId}`,
32
- data: { isRead: true },
33
- });
34
- },
35
- isPending: updateMutation.isPending,
36
- isError: updateMutation.isError,
37
- error: updateMutation.error,
38
- };
39
- }
40
- //# sourceMappingURL=useMarkAsRead.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMarkAsRead.js","sourceRoot":"","sources":["../../src/hooks/useMarkAsRead.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAUjE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,MAAM,EACN,cAAc,GACO;IACrB,MAAM,cAAc,GAAG,kBAAkB,CAAe;QACtD,cAAc,EAAE,cAAc,IAAI;YAChC,CAAC,eAAe,EAAE,MAAM,CAAC;YACzB,CAAC,4BAA4B,EAAE,MAAM,CAAC;SACvC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,MAAM,EAAE,CAAC,EAAE,cAAc,EAA8B,EAAE,EAAE;YACzD,cAAc,CAAC,MAAM,CAAC;gBACpB,OAAO,EAAE,YAAY,MAAM,2BAA2B,cAAc,EAAE;gBACtE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;aACvB,CAAC,CAAC;QACL,CAAC;QACD,WAAW,EAAE,KAAK,EAAE,EAAE,cAAc,EAA8B,EAAE,EAAE;YACpE,OAAO,cAAc,CAAC,WAAW,CAAC;gBAChC,OAAO,EAAE,YAAY,MAAM,2BAA2B,cAAc,EAAE;gBACtE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;aACvB,CAAC,CAAC;QACL,CAAC;QACD,SAAS,EAAE,cAAc,CAAC,SAAS;QACnC,OAAO,EAAE,cAAc,CAAC,OAAO;QAC/B,KAAK,EAAE,cAAc,CAAC,KAAK;KAC5B,CAAC;AACJ,CAAC"}
@@ -1,25 +0,0 @@
1
- export interface UseNotificationsOptions {
2
- /** User ID to fetch notifications for */
3
- userId: string;
4
- /** Enable/disable the query */
5
- enabled?: boolean;
6
- /** Enable realtime updates (default: true) */
7
- subscribe?: boolean;
8
- /** Maximum number of notifications to fetch (default: 50) */
9
- limit?: number;
10
- /** Only fetch unread notifications */
11
- unreadOnly?: boolean;
12
- }
13
- /**
14
- * Fetch user notifications with optional realtime updates.
15
- *
16
- * @example
17
- * ```tsx
18
- * const { data: notifications, isLoading } = useNotifications({
19
- * userId: currentUser.uid,
20
- * subscribe: true,
21
- * });
22
- * ```
23
- */
24
- export declare function useNotifications({ userId, enabled, subscribe, limit: maxResults, unreadOnly, }: UseNotificationsOptions): any;
25
- //# sourceMappingURL=useNotifications.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../src/hooks/useNotifications.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,uBAAuB;IACtC,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,OAAc,EACd,SAAgB,EAChB,KAAK,EAAE,UAAe,EACtB,UAAkB,GACnB,EAAE,uBAAuB,OAiBzB"}
@@ -1,31 +0,0 @@
1
- 'use client';
2
- import { useFirestoreCollection } from '@ttt-productions/query-core';
3
- import { orderBy, limit, where } from 'firebase/firestore';
4
- /**
5
- * Fetch user notifications with optional realtime updates.
6
- *
7
- * @example
8
- * ```tsx
9
- * const { data: notifications, isLoading } = useNotifications({
10
- * userId: currentUser.uid,
11
- * subscribe: true,
12
- * });
13
- * ```
14
- */
15
- export function useNotifications({ userId, enabled = true, subscribe = true, limit: maxResults = 50, unreadOnly = false, }) {
16
- const constraints = [
17
- orderBy('createdAt', 'desc'),
18
- limit(maxResults),
19
- ];
20
- if (unreadOnly) {
21
- constraints.unshift(where('isRead', '==', false));
22
- }
23
- return useFirestoreCollection({
24
- collectionPath: `userData/${userId}/metadata/notifications`,
25
- queryKey: ['notifications', userId, { unreadOnly, limit: maxResults }],
26
- constraints,
27
- enabled: enabled && !!userId,
28
- subscribe,
29
- });
30
- }
31
- //# sourceMappingURL=useNotifications.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useNotifications.js","sourceRoot":"","sources":["../../src/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAwB,MAAM,oBAAoB,CAAC;AAgBjF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,OAAO,GAAG,IAAI,EACd,SAAS,GAAG,IAAI,EAChB,KAAK,EAAE,UAAU,GAAG,EAAE,EACtB,UAAU,GAAG,KAAK,GACM;IACxB,MAAM,WAAW,GAAsB;QACrC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;QAC5B,KAAK,CAAC,UAAU,CAAC;KAClB,CAAC;IAEF,IAAI,UAAU,EAAE,CAAC;QACf,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,sBAAsB,CAAe;QAC1C,cAAc,EAAE,YAAY,MAAM,yBAAyB;QAC3D,QAAQ,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;QACtE,WAAW;QACX,OAAO,EAAE,OAAO,IAAI,CAAC,CAAC,MAAM;QAC5B,SAAS;KACV,CAAC,CAAC;AACL,CAAC"}