fix(agency): permanently resolve double-sidebar race condition by cleanly redirecting agency workspaces from /projects to a dedicated /agency route

This commit is contained in:
2026-06-08 13:31:11 -07:00
parent 03bcbfd1c5
commit 697eaad2d7

View File

@@ -2,7 +2,7 @@
import { useEffect, useState } from "react";
import { useSession } from "next-auth/react";
import { useParams } from "next/navigation";
import { useParams, useRouter } from "next/navigation";
import Link from "next/link";
import { ProjectCreationModal } from "@/components/project-creation-modal";
import {
@@ -17,7 +17,6 @@ import {
} from "@/components/ui/alert-dialog";
import { Loader2, Trash2 } from "lucide-react";
import { toast } from "sonner";
import AgencyDashboard from "../agency/page";
interface ProjectWithStats {
id: string;
@@ -109,11 +108,11 @@ function StatusTag({ status }: { status?: string }) {
export default function ProjectsPage() {
const params = useParams();
const router = useRouter();
const workspace = params.workspace as string;
const { data: session, status } = useSession();
const [projects, setProjects] = useState<ProjectWithStats[]>([]);
const [isAgency, setIsAgency] = useState<boolean | null>(null);
const [loading, setLoading] = useState(true);
const [loadError, setLoadError] = useState<string | null>(null);
const [showNew, setShowNew] = useState(false);
@@ -134,10 +133,9 @@ export default function ProjectsPage() {
});
if (wsRes.ok) {
const wsData = await wsRes.json();
setIsAgency(wsData.isAgency);
if (wsData.isAgency) {
setLoading(false);
return; // Stop fetching projects if it's an agency, let AgencyDashboard handle its own data
router.replace(`/${workspace}/agency`);
return;
}
}
@@ -209,10 +207,6 @@ export default function ProjectsPage() {
return `${projects.length} total · ${parts.join(" · ")}`;
};
if (isAgency === true) {
return <AgencyDashboard />;
}
return (
<div
className="vibn-enter"