mirror of
https://github.com/soconnor0919/hristudio.git
synced 2026-03-23 19:27:51 -04:00
- Install better-auth and @better-auth/drizzle-adapter - Create src/lib/auth.ts with Better Auth configuration using bcrypt - Update database schema: change auth table IDs from uuid to text - Update route handler from /api/auth/[...nextauth] to /api/auth/[...all] - Update tRPC context and middleware for Better Auth session handling - Update client components to use Better Auth APIs (signIn, signOut) - Update seed script with text-based IDs and correct account schema - Fix type errors in wizard components (robotId, optional chaining) - Fix API paths: api.robots.initialize -> api.robots.plugins.initialize - Update auth router to use text IDs for Better Auth compatibility Note: Auth tables were reset - users will need to re-register.
66 lines
2.1 KiB
TypeScript
Executable File
66 lines
2.1 KiB
TypeScript
Executable File
import { redirect } from "next/navigation";
|
|
import { cookies, headers } from "next/headers";
|
|
import {
|
|
SidebarInset,
|
|
SidebarProvider,
|
|
SidebarTrigger,
|
|
} from "~/components/ui/sidebar";
|
|
import { Separator } from "~/components/ui/separator";
|
|
import { AppSidebar } from "~/components/dashboard/app-sidebar";
|
|
import { auth } from "~/lib/auth";
|
|
import {
|
|
BreadcrumbProvider,
|
|
BreadcrumbDisplay,
|
|
} from "~/components/ui/breadcrumb-provider";
|
|
import { StudyProvider } from "~/lib/study-context";
|
|
import { TourProvider } from "~/components/onboarding/TourProvider";
|
|
|
|
interface DashboardLayoutProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export default async function DashboardLayout({
|
|
children,
|
|
}: DashboardLayoutProps) {
|
|
const session = await auth.api.getSession({
|
|
headers: await headers(),
|
|
});
|
|
|
|
if (!session?.user) {
|
|
redirect("/auth/signin");
|
|
}
|
|
|
|
const userRole = "researcher"; // Default role for dashboard access
|
|
|
|
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 initialStudyId={selectedStudyCookie}>
|
|
<TourProvider>
|
|
<BreadcrumbProvider>
|
|
<SidebarProvider defaultOpen={defaultOpen}>
|
|
<AppSidebar userRole={userRole} />
|
|
<SidebarInset>
|
|
<header className="flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-[[data-collapsible=icon]]/sidebar-wrapper:h-12">
|
|
<div className="flex items-center gap-2 px-4">
|
|
<SidebarTrigger className="-ml-1" />
|
|
<Separator orientation="vertical" className="mr-2 h-4" />
|
|
<BreadcrumbDisplay />
|
|
</div>
|
|
</header>
|
|
<div className="flex min-h-0 min-w-0 flex-1 flex-col gap-4 overflow-hidden p-4 pt-0">
|
|
{children}
|
|
</div>
|
|
</SidebarInset>
|
|
</SidebarProvider>
|
|
</BreadcrumbProvider>
|
|
</TourProvider>
|
|
</StudyProvider>
|
|
);
|
|
}
|