251208:0010 Backend & Frontend Debug
Some checks failed
Spec Validation / validate-markdown (push) Has been cancelled
Spec Validation / validate-diagrams (push) Has been cancelled
Spec Validation / check-todos (push) Has been cancelled

This commit is contained in:
2025-12-08 00:10:37 +07:00
parent 32d820ea6b
commit dcd126d704
99 changed files with 2775 additions and 1480 deletions

View File

@@ -1,28 +1,30 @@
import { AdminSidebar } from "@/components/admin/sidebar";
import { redirect } from "next/navigation";
// import { getServerSession } from "next-auth"; // Commented out for now as we are mocking auth
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
export default async function AdminLayout({
children,
}: {
children: React.ReactNode;
}) {
// Mock Admin Check
// const session = await getServerSession();
// if (!session?.user?.roles?.some((r) => r.role_name === 'ADMIN')) {
// redirect('/');
// }
const session = await getServerSession(authOptions);
// For development, we assume user is admin
const isAdmin = true;
if (!isAdmin) {
redirect("/");
// Check if user has admin role
// This depends on your Session structure. Assuming user.roles exists (mapped in callback).
// If not, you might need to check DB or use Can component logic but server-side.
const isAdmin = session?.user?.roles?.some((r: any) => r.role_name === 'ADMIN');
if (!session || !isAdmin) {
// If not admin, redirect to dashboard or login
redirect("/");
}
return (
<div className="flex h-[calc(100vh-4rem)]"> {/* Subtract header height */}
<div className="flex h-screen w-full bg-background">
<AdminSidebar />
<div className="flex-1 overflow-auto bg-muted/10">
<div className="flex-1 overflow-auto bg-muted/10 p-4">
{children}
</div>
</div>