feat: add superadmin
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-10-26 11:58:10 +01:00
parent 072cda111c
commit 4e43521da7
45 changed files with 3531 additions and 65 deletions
+6 -3
View File
@@ -4,6 +4,7 @@ import { createContext, useContext, useEffect, useState, ReactNode } from 'react
import { useQueryClient } from '@tanstack/react-query';
import { io } from 'socket.io-client';
import { API_URL, getAccessToken, refreshAccessToken } from '@/lib/api/client';
import { useSession } from '@/lib/session';
// Server topics mapped to the dashboard queries that show that data
const TOPIC_QUERIES: Record<string, string[][]> = {
@@ -20,12 +21,14 @@ const RealtimeContext = createContext({ connected: false });
export function RealtimeProvider({ children }: { children: ReactNode }) {
const queryClient = useQueryClient();
const { venueId } = useSession();
const [connected, setConnected] = useState(false);
useEffect(() => {
const socket = io(`${new URL(API_URL).origin}/realtime`, {
// Read on every (re)connect so a refreshed token is used
auth: (cb) => cb({ token: getAccessToken() }),
// Read on every (re)connect so a refreshed token is used. The venue is only used for a superadmin viewing
// another venue; everyone else follows their own
auth: (cb) => cb({ token: getAccessToken(), venueId }),
transports: ['websocket', 'polling'],
});
@@ -64,7 +67,7 @@ export function RealtimeProvider({ children }: { children: ReactNode }) {
return () => {
socket.disconnect();
};
}, [queryClient]);
}, [queryClient, venueId]);
return <RealtimeContext.Provider value={{ connected }}>{children}</RealtimeContext.Provider>;
}