chore: clean diagnostics and prepare for designer structural refactor (stub legacy useActiveStudy)

This commit is contained in:
2025-08-11 16:38:29 -04:00
parent 524eff89fd
commit 779c639465
33 changed files with 5147 additions and 882 deletions

View File

@@ -1,5 +1,5 @@
import { notFound } from "next/navigation";
import { BlockDesigner } from "~/components/experiments/designer/BlockDesigner";
import { DesignerShell } from "~/components/experiments/designer/DesignerShell";
import type { ExperimentStep } from "~/lib/experiment-designer/types";
import { api } from "~/trpc/server";
@@ -44,7 +44,7 @@ export default async function ExperimentDesignerPage({
: undefined;
return (
<BlockDesigner
<DesignerShell
experimentId={experiment.id}
initialDesign={initialDesign}
/>

View File

@@ -35,8 +35,12 @@ export default async function DashboardLayout({
const cookieStore = await cookies();
const defaultOpen = cookieStore.get("sidebar_state")?.value === "true";
// Pre-seed selected study from cookie (SSR) to avoid client flash
const selectedStudyCookie =
cookieStore.get("hristudio_selected_study")?.value ?? null;
return (
<StudyProvider>
<StudyProvider initialStudyId={selectedStudyCookie}>
<BreadcrumbProvider>
<SidebarProvider defaultOpen={defaultOpen}>
<AppSidebar userRole={userRole} />

View File

@@ -4,19 +4,21 @@ import { useParams } from "next/navigation";
import { Suspense, useEffect } from "react";
import { ParticipantsTable } from "~/components/participants/ParticipantsTable";
import { ManagementPageLayout } from "~/components/ui/page-layout";
import { useActiveStudy } from "~/hooks/useActiveStudy";
import { useStudyContext } from "~/lib/study-context";
import { useSelectedStudyDetails } from "~/hooks/useSelectedStudyDetails";
export default function StudyParticipantsPage() {
const params = useParams();
const studyId: string = typeof params.id === "string" ? params.id : "";
const { setActiveStudy, activeStudy } = useActiveStudy();
const { setSelectedStudyId, selectedStudyId } = useStudyContext();
const { study } = useSelectedStudyDetails();
// Set the active study if it doesn't match the current route
// Sync selected study (unified study-context)
useEffect(() => {
if (studyId && activeStudy?.id !== studyId) {
setActiveStudy(studyId);
if (studyId && selectedStudyId !== studyId) {
setSelectedStudyId(studyId);
}
}, [studyId, activeStudy?.id, setActiveStudy]);
}, [studyId, selectedStudyId, setSelectedStudyId]);
return (
<ManagementPageLayout
@@ -25,7 +27,7 @@ export default function StudyParticipantsPage() {
breadcrumb={[
{ label: "Dashboard", href: "/dashboard" },
{ label: "Studies", href: "/studies" },
{ label: activeStudy?.title ?? "Study", href: `/studies/${studyId}` },
{ label: study?.name ?? "Study", href: `/studies/${studyId}` },
{ label: "Participants" },
]}
createButton={{

View File

@@ -4,19 +4,21 @@ import { useParams } from "next/navigation";
import { Suspense, useEffect } from "react";
import { TrialsTable } from "~/components/trials/TrialsTable";
import { ManagementPageLayout } from "~/components/ui/page-layout";
import { useActiveStudy } from "~/hooks/useActiveStudy";
import { useStudyContext } from "~/lib/study-context";
import { useSelectedStudyDetails } from "~/hooks/useSelectedStudyDetails";
export default function StudyTrialsPage() {
const params = useParams();
const studyId: string = typeof params.id === "string" ? params.id : "";
const { setActiveStudy, activeStudy } = useActiveStudy();
const { setSelectedStudyId, selectedStudyId } = useStudyContext();
const { study } = useSelectedStudyDetails();
// Set the active study if it doesn't match the current route
useEffect(() => {
if (studyId && activeStudy?.id !== studyId) {
setActiveStudy(studyId);
if (studyId && selectedStudyId !== studyId) {
setSelectedStudyId(studyId);
}
}, [studyId, activeStudy?.id, setActiveStudy]);
}, [studyId, selectedStudyId, setSelectedStudyId]);
return (
<ManagementPageLayout
@@ -25,7 +27,7 @@ export default function StudyTrialsPage() {
breadcrumb={[
{ label: "Dashboard", href: "/dashboard" },
{ label: "Studies", href: "/studies" },
{ label: activeStudy?.title ?? "Study", href: `/studies/${studyId}` },
{ label: study?.name ?? "Study", href: `/studies/${studyId}` },
{ label: "Trials" },
]}
createButton={{