feat(notifications): wire client Socket.IO to /notifications namespace with toast + E2E
- Connect to /notifications namespace (matches backend NotificationsGateway) - Pass JWT token in Socket.IO auth handshake for proper authentication - Listen for server-pushed notification:unread-count to sync badge - Show sonner toast on notification:new events - Add setUnreadCount action to notifications store - Add E2E round-trip tests (auth connect, reject invalid, multi-device) - Fix inquiry handler test: event name inquiry.created → inquiry.received Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -19,6 +19,8 @@ interface NotificationsState {
|
||||
markAllAsRead: () => Promise<void>;
|
||||
addNotification: (notification: NotificationDto) => void;
|
||||
incrementUnread: () => void;
|
||||
/** Set the unread count directly (from server-pushed WS event). */
|
||||
setUnreadCount: (count: number) => void;
|
||||
}
|
||||
|
||||
export const useNotificationsStore = create<NotificationsState>((set, get) => ({
|
||||
@@ -92,4 +94,8 @@ export const useNotificationsStore = create<NotificationsState>((set, get) => ({
|
||||
incrementUnread: () => {
|
||||
set((state) => ({ unreadCount: state.unreadCount + 1 }));
|
||||
},
|
||||
|
||||
setUnreadCount: (count) => {
|
||||
set({ unreadCount: count });
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user