@ttt-productions/notification-core 0.2.1 → 0.2.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.
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/react/components/NotificationEmptyState.d.ts +6 -0
- package/dist/react/components/NotificationEmptyState.d.ts.map +1 -0
- package/dist/react/components/NotificationEmptyState.js +9 -0
- package/dist/react/components/NotificationEmptyState.js.map +1 -0
- package/dist/react/components/NotificationHistoryList.d.ts +7 -0
- package/dist/react/components/NotificationHistoryList.d.ts.map +1 -0
- package/dist/react/components/NotificationHistoryList.js +41 -0
- package/dist/react/components/NotificationHistoryList.js.map +1 -0
- package/dist/react/components/NotificationList.d.ts +6 -0
- package/dist/react/components/NotificationList.d.ts.map +1 -0
- package/dist/react/components/NotificationList.js +79 -0
- package/dist/react/components/NotificationList.js.map +1 -0
- package/dist/react/components/NotificationUnreadBadge.d.ts +8 -0
- package/dist/react/components/NotificationUnreadBadge.d.ts.map +1 -0
- package/dist/react/components/NotificationUnreadBadge.js +21 -0
- package/dist/react/components/NotificationUnreadBadge.js.map +1 -0
- package/dist/react/components/index.d.ts +5 -0
- package/dist/react/components/index.d.ts.map +1 -0
- package/dist/react/components/index.js +5 -0
- package/dist/react/components/index.js.map +1 -0
- package/dist/react/components/relative-time.d.ts +5 -0
- package/dist/react/components/relative-time.d.ts.map +1 -0
- package/dist/react/components/relative-time.js +23 -0
- package/dist/react/components/relative-time.js.map +1 -0
- package/dist/react/hooks/index.d.ts +6 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/index.js +6 -0
- package/dist/react/hooks/index.js.map +1 -0
- package/dist/react/hooks/useActiveNotifications.d.ts +7 -0
- package/dist/react/hooks/useActiveNotifications.d.ts.map +1 -0
- package/dist/react/hooks/useActiveNotifications.js +30 -0
- package/dist/react/hooks/useActiveNotifications.js.map +1 -0
- package/dist/react/hooks/useArchiveAllNotifications.d.ts +24 -0
- package/dist/react/hooks/useArchiveAllNotifications.d.ts.map +1 -0
- package/dist/react/hooks/useArchiveAllNotifications.js +87 -0
- package/dist/react/hooks/useArchiveAllNotifications.js.map +1 -0
- package/dist/react/hooks/useArchiveNotification.d.ts +23 -0
- package/dist/react/hooks/useArchiveNotification.d.ts.map +1 -0
- package/dist/react/hooks/useArchiveNotification.js +68 -0
- package/dist/react/hooks/useArchiveNotification.js.map +1 -0
- package/dist/react/hooks/useNotificationHistory.d.ts +16 -0
- package/dist/react/hooks/useNotificationHistory.d.ts.map +1 -0
- package/dist/react/hooks/useNotificationHistory.js +35 -0
- package/dist/react/hooks/useNotificationHistory.js.map +1 -0
- package/dist/react/hooks/useUnreadCount.d.ts +184 -0
- package/dist/react/hooks/useUnreadCount.d.ts.map +1 -0
- package/dist/react/hooks/useUnreadCount.js +45 -0
- package/dist/react/hooks/useUnreadCount.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +5 -0
- package/dist/react/index.js.map +1 -0
- package/dist/server/archiveNotificationHelper.d.ts +31 -0
- package/dist/server/archiveNotificationHelper.d.ts.map +1 -0
- package/dist/server/archiveNotificationHelper.js +83 -0
- package/dist/server/archiveNotificationHelper.js.map +1 -0
- package/dist/server/createNotificationHelper.d.ts +25 -0
- package/dist/server/createNotificationHelper.d.ts.map +1 -0
- package/dist/server/createNotificationHelper.js +118 -0
- package/dist/server/createNotificationHelper.js.map +1 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/processBatchHelper.d.ts +29 -0
- package/dist/server/processBatchHelper.d.ts.map +1 -0
- package/dist/server/processBatchHelper.js +158 -0
- package/dist/server/processBatchHelper.js.map +1 -0
- package/dist/server/types.d.ts +81 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +6 -0
- package/dist/server/types.js.map +1 -0
- package/dist/types.d.ts +159 -44
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -1
- package/package.json +10 -6
- package/src/styles/notifications.css +206 -0
- package/dist/hooks/index.d.ts +0 -9
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -5
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useMarkAllAsRead.d.ts +0 -30
- package/dist/hooks/useMarkAllAsRead.d.ts.map +0 -1
- package/dist/hooks/useMarkAllAsRead.js +0 -44
- package/dist/hooks/useMarkAllAsRead.js.map +0 -1
- package/dist/hooks/useMarkAsRead.d.ts +0 -30
- package/dist/hooks/useMarkAsRead.d.ts.map +0 -1
- package/dist/hooks/useMarkAsRead.js +0 -40
- package/dist/hooks/useMarkAsRead.js.map +0 -1
- package/dist/hooks/useNotifications.d.ts +0 -25
- package/dist/hooks/useNotifications.d.ts.map +0 -1
- package/dist/hooks/useNotifications.js +0 -31
- package/dist/hooks/useNotifications.js.map +0 -1
- package/dist/hooks/useUnreadCount.d.ts +0 -24
- package/dist/hooks/useUnreadCount.d.ts.map +0 -1
- package/dist/hooks/useUnreadCount.js +0 -31
- package/dist/hooks/useUnreadCount.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
|
+
}
|
package/dist/hooks/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { useNotifications } from './useNotifications.js';
|
|
2
|
-
export type { UseNotificationsOptions } from './useNotifications.js';
|
|
3
|
-
export { useUnreadCount } from './useUnreadCount.js';
|
|
4
|
-
export type { UseUnreadCountOptions } from './useUnreadCount.js';
|
|
5
|
-
export { useMarkAsRead } from './useMarkAsRead.js';
|
|
6
|
-
export type { UseMarkAsReadOptions } from './useMarkAsRead.js';
|
|
7
|
-
export { useMarkAllAsRead } from './useMarkAllAsRead.js';
|
|
8
|
-
export type { UseMarkAllAsReadOptions } from './useMarkAllAsRead.js';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/hooks/index.js
DELETED
package/dist/hooks/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -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"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface UseUnreadCountOptions {
|
|
2
|
-
/** User ID to fetch unread count for */
|
|
3
|
-
userId: string;
|
|
4
|
-
/** Enable/disable the query */
|
|
5
|
-
enabled?: boolean;
|
|
6
|
-
/** Enable realtime updates (default: true) */
|
|
7
|
-
subscribe?: boolean;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Get the count of unread notifications for a user.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* const { data: unreadCount } = useUnreadCount({
|
|
15
|
-
* userId: currentUser.uid,
|
|
16
|
-
* subscribe: true,
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function useUnreadCount({ userId, enabled, subscribe, }: UseUnreadCountOptions): {
|
|
21
|
-
data: any;
|
|
22
|
-
notifications: any;
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=useUnreadCount.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUnreadCount.d.ts","sourceRoot":"","sources":["../../src/hooks/useUnreadCount.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,qBAAqB;IACpC,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,OAAc,EACd,SAAgB,GACjB,EAAE,qBAAqB;;;EAiBvB"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useFirestoreCollection } from '@ttt-productions/query-core';
|
|
3
|
-
import { where } from 'firebase/firestore';
|
|
4
|
-
/**
|
|
5
|
-
* Get the count of unread notifications for a user.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* const { data: unreadCount } = useUnreadCount({
|
|
10
|
-
* userId: currentUser.uid,
|
|
11
|
-
* subscribe: true,
|
|
12
|
-
* });
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export function useUnreadCount({ userId, enabled = true, subscribe = true, }) {
|
|
16
|
-
const constraints = [
|
|
17
|
-
where('isRead', '==', false),
|
|
18
|
-
];
|
|
19
|
-
const { data: notifications } = useFirestoreCollection({
|
|
20
|
-
collectionPath: `userData/${userId}/metadata/notifications`,
|
|
21
|
-
queryKey: ['notifications-unread-count', userId],
|
|
22
|
-
constraints,
|
|
23
|
-
enabled: enabled && !!userId,
|
|
24
|
-
subscribe,
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
data: notifications?.length ?? 0,
|
|
28
|
-
notifications,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=useUnreadCount.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUnreadCount.js","sourceRoot":"","sources":["../../src/hooks/useUnreadCount.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,KAAK,EAAwB,MAAM,oBAAoB,CAAC;AAYjE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,MAAM,EACN,OAAO,GAAG,IAAI,EACd,SAAS,GAAG,IAAI,GACM;IACtB,MAAM,WAAW,GAAsB;QACrC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC;KAC7B,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,sBAAsB,CAAe;QACnE,cAAc,EAAE,YAAY,MAAM,yBAAyB;QAC3D,QAAQ,EAAE,CAAC,4BAA4B,EAAE,MAAM,CAAC;QAChD,WAAW;QACX,OAAO,EAAE,OAAO,IAAI,CAAC,CAAC,MAAM;QAC5B,SAAS;KACV,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;QAChC,aAAa;KACd,CAAC;AACJ,CAAC"}
|