Refactor trial routes to be study-scoped and update navigation

This commit is contained in:
2025-09-24 15:19:55 -04:00
parent 51096b7194
commit 9431bb549b
9 changed files with 312 additions and 580 deletions

View File

@@ -199,7 +199,9 @@ export default function ExperimentDetailPage({
</Link>
</Button>
<Button asChild>
<Link href={`/trials/new?experimentId=${experiment.id}`}>
<Link
href={`/studies/${experiment.study.id}/trials/new?experimentId=${experiment.id}`}
>
<Play className="mr-2 h-4 w-4" />
Start Trial
</Link>
@@ -318,7 +320,7 @@ export default function ExperimentDetailPage({
>
<div className="mb-2 flex items-center justify-between">
<Link
href={`/trials/${trial.id}`}
href={`/studies/${experiment.study.id}/trials/${trial.id}`}
className="font-medium hover:underline"
>
Trial #{trial.id.slice(-6)}
@@ -370,7 +372,9 @@ export default function ExperimentDetailPage({
action={
canEdit && (
<Button asChild>
<Link href={`/trials/new?experimentId=${experiment.id}`}>
<Link
href={`/studies/${experiment.study.id}/trials/new?experimentId=${experiment.id}`}
>
Start Trial
</Link>
</Button>

View File

@@ -2,6 +2,7 @@
import { useParams } from "next/navigation";
import { Suspense, useEffect } from "react";
import Link from "next/link";
import { TestTube, Plus } from "lucide-react";
import { TrialsTable } from "~/components/trials/TrialsTable";
import { PageHeader } from "~/components/ui/page-header";
@@ -39,10 +40,10 @@ export default function StudyTrialsPage() {
icon={TestTube}
actions={
<Button asChild>
<a href={`/studies/${studyId}/trials/new`}>
<Link href={`/studies/${studyId}/trials/new`}>
<Plus className="mr-2 h-4 w-4" />
Schedule Trial
</a>
</Link>
</Button>
}
/>

View File

@@ -1,65 +0,0 @@
"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";
import { TestTube, ArrowRight } from "lucide-react";
import { Button } from "~/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "~/components/ui/card";
import { useStudyContext } from "~/lib/study-context";
export default function TrialsRedirect() {
const router = useRouter();
const { selectedStudyId } = useStudyContext();
useEffect(() => {
// If user has a selected study, redirect to study trials
if (selectedStudyId) {
router.replace(`/studies/${selectedStudyId}/trials`);
}
}, [selectedStudyId, router]);
return (
<div className="flex min-h-[60vh] items-center justify-center p-4">
<Card className="w-full max-w-md">
<CardHeader className="text-center">
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-orange-50">
<TestTube className="h-8 w-8 text-orange-500" />
</div>
<CardTitle className="text-2xl">Trials Moved</CardTitle>
<CardDescription>
Trial management is now organized by study for better workflow
organization.
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<div className="text-muted-foreground space-y-2 text-center text-sm">
<p>To manage trials:</p>
<ul className="space-y-1 text-left">
<li> Select a study from your studies list</li>
<li> Navigate to that study&apos;s trials page</li>
<li> Schedule and monitor trials for that specific study</li>
</ul>
</div>
<div className="flex flex-col gap-2 pt-4">
<Button asChild className="w-full">
<Link href="/studies">
<ArrowRight className="mr-2 h-4 w-4" />
Browse Studies
</Link>
</Button>
<Button asChild variant="outline" className="w-full">
<Link href="/dashboard">Go to Dashboard</Link>
</Button>
</div>
</CardContent>
</Card>
</div>
);
}