Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go
989 B
Raw Blame
"use client";

import type { ReactNode } from "react";
import { useDashboardGuard } from "./use-dashboard-guard";

interface DashboardGuardProps {
  children: ReactNode;
  /** Rendered when auth or workspace is loading */
  loadingFallback?: ReactNode;
}

/**
 * Shared guard for dashboard layouts.
 *
 * Handles: auth check → workspace check → render children.
 * Both web and desktop layouts compose their own UI structure inside this.
 *
 * WorkspaceIdProvider has been removed — useWorkspaceId() now derives from
 * the URL slug via useCurrentWorkspace(). The guard still gates on workspace
 * being resolved so downstream components can safely call useWorkspaceId().
 */
export function DashboardGuard({
  children,
  loadingFallback = null,
}: DashboardGuardProps) {
  const { user, isLoading, workspace, guestBlocked } = useDashboardGuard();

  if (isLoading || !workspace || guestBlocked) return <>{loadingFallback}</>;
  if (!user) return null;

  return <>{children}</>;
}