client: realtime socket and shared UI components

Add Socket.IO client wrapper (auto-reconnect, auth token), and
reusable components: Layout (nav bar), Toast notifications, and
Countdown timer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 23:42:30 +02:00
parent 9e65fe5a3c
commit 95864ce392
4 changed files with 181 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import { io, type Socket } from 'socket.io-client';
import { API_URL } from '../config';
let socket: Socket | null = null;
/** Connette il socket realtime (path /ws) autenticandosi con il JWT. */
export function connectSocket(token: string): Socket {
disconnectSocket();
socket = io(API_URL, { path: '/ws', auth: { token } });
return socket;
}
export function getSocket(): Socket | null {
return socket;
}
export function disconnectSocket(): void {
socket?.disconnect();
socket = null;
}