30 lines
1 KiB
TypeScript
30 lines
1 KiB
TypeScript
// app/portal/layout.tsx
|
|
import { cookies } from "next/headers";
|
|
import { redirect } from "next/navigation";
|
|
import PortalTabs from "@/components/PortalTabs";
|
|
import SignOutButton from "@/components/SignOutButton";
|
|
|
|
export const metadata = { title: "MakerDash" };
|
|
|
|
export default async function PortalLayout({ children }: { children: React.ReactNode }) {
|
|
// Auth gate: require user access token cookie
|
|
const store = await cookies();
|
|
const at = store.get("ma_at")?.value;
|
|
if (!at) {
|
|
// preserve deep-link by defaulting to /portal
|
|
redirect(`/auth/sign-in?next=${encodeURIComponent("/portal")}`);
|
|
}
|
|
|
|
return (
|
|
<main className="mx-auto max-w-6xl px-6 py-6">
|
|
<header className="mb-6 flex items-center justify-between">
|
|
<h1 className="text-2xl font-semibold tracking-tight">Welcome to MakerDash</h1>
|
|
<SignOutButton className="text-sm opacity-75 hover:opacity-100" />
|
|
</header>
|
|
|
|
<PortalTabs />
|
|
|
|
<section className="mt-6">{children}</section>
|
|
</main>
|
|
);
|
|
}
|