forked from cardosofelipe/fast-next-template
fix(dashboard): disable SSE in demo mode and remove unused hooks
- Skip SSE connection in demo mode (MSW doesn't support SSE). - Remove unused `useProjectEvents` and related real-time hooks from `Dashboard`. - Temporarily disable activity feed SSE until a global endpoint is available.
This commit is contained in:
@@ -31,8 +31,6 @@ import { PendingApprovals } from './PendingApprovals';
|
|||||||
import { EmptyState } from './EmptyState';
|
import { EmptyState } from './EmptyState';
|
||||||
import { useDashboard, type PendingApproval } from '@/lib/api/hooks/useDashboard';
|
import { useDashboard, type PendingApproval } from '@/lib/api/hooks/useDashboard';
|
||||||
import { useAuth } from '@/lib/auth/AuthContext';
|
import { useAuth } from '@/lib/auth/AuthContext';
|
||||||
import { useProjectEvents } from '@/lib/hooks/useProjectEvents';
|
|
||||||
import { useProjectEventsFromStore } from '@/lib/stores/eventStore';
|
|
||||||
|
|
||||||
export interface DashboardProps {
|
export interface DashboardProps {
|
||||||
/** Additional CSS classes */
|
/** Additional CSS classes */
|
||||||
@@ -43,13 +41,6 @@ export function Dashboard({ className }: DashboardProps) {
|
|||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { data, isLoading, error } = useDashboard();
|
const { data, isLoading, error } = useDashboard();
|
||||||
|
|
||||||
// Real-time events - using a generic project ID for dashboard-wide events
|
|
||||||
// In production, this would be a dedicated dashboard events endpoint
|
|
||||||
const { connectionState } = useProjectEvents('dashboard', {
|
|
||||||
autoConnect: true,
|
|
||||||
});
|
|
||||||
const events = useProjectEventsFromStore('dashboard');
|
|
||||||
|
|
||||||
// Get user's first name for empty state
|
// Get user's first name for empty state
|
||||||
const firstName = user?.first_name || user?.email?.split('@')[0] || 'there';
|
const firstName = user?.first_name || user?.email?.split('@')[0] || 'there';
|
||||||
|
|
||||||
@@ -108,11 +99,13 @@ export function Dashboard({ className }: DashboardProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Activity Feed Sidebar */}
|
{/* Activity Feed Sidebar */}
|
||||||
|
{/* TODO: Enable when global activity SSE endpoint is implemented */}
|
||||||
|
{/* Currently disabled - there's no dashboard-wide SSE endpoint */}
|
||||||
<div className="hidden lg:block">
|
<div className="hidden lg:block">
|
||||||
<Card className="sticky top-4">
|
<Card className="sticky top-4">
|
||||||
<ActivityFeed
|
<ActivityFeed
|
||||||
events={events}
|
events={[]}
|
||||||
connectionState={connectionState}
|
connectionState="disconnected"
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
maxHeight={600}
|
maxHeight={600}
|
||||||
showHeader
|
showHeader
|
||||||
|
|||||||
@@ -247,6 +247,15 @@ export function useProjectEvents(
|
|||||||
* Connect to SSE endpoint
|
* Connect to SSE endpoint
|
||||||
*/
|
*/
|
||||||
const connect = useCallback(() => {
|
const connect = useCallback(() => {
|
||||||
|
// In frontend demo mode (MSW), SSE is not supported - skip connection
|
||||||
|
if (config.demo.enabled) {
|
||||||
|
if (config.debug.api) {
|
||||||
|
console.log('[SSE] Demo mode enabled - SSE connections disabled');
|
||||||
|
}
|
||||||
|
updateConnectionState('disconnected');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent connection if not authenticated or no project ID
|
// Prevent connection if not authenticated or no project ID
|
||||||
/* istanbul ignore next -- early return guard, tested via connection state */
|
/* istanbul ignore next -- early return guard, tested via connection state */
|
||||||
if (!isAuthenticated || !accessToken || !projectId) {
|
if (!isAuthenticated || !accessToken || !projectId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user