feat: add real-time notification system and fix admin login bug

- Fix login: role field was missing from session (admin page inaccessible)
- Add onlineUsers map in socket/state.ts to track connected users
- Join personal user:${id} socket room on connect for targeted notifications
- Emit friendRequestReceived/friendRequestAccepted socket events from friends controller
- Add sendGameInvite socket event handler on server
- New NotificationContext: global socket provider for registered users
- New NotificationPanel: bell icon with unread badge and dropdown in header
- Friends page: inline game invite input per friend with sendGameInvite

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Michess
2026-04-14 12:35:09 +02:00
parent 1501b859b2
commit 4825a57a54
10 changed files with 267 additions and 11 deletions

12
types/index.d.ts vendored
View File

@@ -93,6 +93,18 @@ export interface TournamentPlayer {
gamesPlayed?: number;
}
export type NotificationType = "friendRequest" | "friendAccepted" | "gameInvite";
export interface AppNotification {
id: string;
type: NotificationType;
fromId: number;
fromName: string;
gameCode?: string;
createdAt: number;
read: boolean;
}
export interface TournamentRound {
id?: number;
tournamentId?: number;