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:
Ho Ngoc Hai
2026-04-21 05:35:44 +07:00
parent ecb217cf5e
commit 0676b8c7f2
4 changed files with 160 additions and 14 deletions

View File

@@ -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 });
},
}));