diff --git a/src/app/layout.tsx b/src/app/layout.tsx index a7b38f0..a4199e0 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,15 +1,27 @@ import type { ReactNode } from "react"; import "./globals.css"; +import { auth } from "@/auth"; +import { Nav } from "@/components/nav"; export const metadata = { title: "Asset & License Management", description: "Internal IT asset & license management — Ubisoft VN local IT", }; -export default function RootLayout({ children }: { children: ReactNode }) { +// Root layout wraps every route, including /login (middleware.ts can't +// exclude it — it's the one page unauthenticated users must be able to +// reach). Gate on session presence here rather than rendering it +// unconditionally, so it only shows on authenticated pages as intended, +// without needing a client-side pathname check. +export default async function RootLayout({ children }: { children: ReactNode }) { + const session = await auth(); + return ( -
{children} + + {session ? : null} + {children} + ); } diff --git a/src/components/nav.tsx b/src/components/nav.tsx new file mode 100644 index 0000000..53ab92e --- /dev/null +++ b/src/components/nav.tsx @@ -0,0 +1,55 @@ +"use client"; + +import Link from "next/link"; +import { signOut } from "next-auth/react"; +import { Button } from "@/components/ui/button"; + +// Shared top nav for every authenticated page. Links point at the entity +// routes each later task in this "basic functional UI" batch will build +// (Employee, Vendor, AssetCategory, AssetCategoryAttributeDef, AssetModel, +// PurchaseOrder, AssetItem, License, Request, Assignment) — most of these +// routes don't exist yet and will 404 until their own task lands, which is +// expected (see task scope: no conditional hiding needed). +const ENTITY_LINKS = [ + { href: "/employees", label: "Employees" }, + { href: "/vendors", label: "Vendors" }, + { href: "/asset-categories", label: "Asset Categories" }, + { href: "/asset-category-attribute-defs", label: "Attribute Defs" }, + { href: "/asset-models", label: "Asset Models" }, + { href: "/assets", label: "Assets" }, + { href: "/licenses", label: "Licenses" }, + { href: "/purchase-orders", label: "Purchase Orders" }, + { href: "/requests", label: "Requests" }, + { href: "/assignments", label: "Assignments" }, +] as const; + +export function Nav() { + return ( + + ); +} diff --git a/src/components/ui/label.tsx b/src/components/ui/label.tsx new file mode 100644 index 0000000..1ac80f7 --- /dev/null +++ b/src/components/ui/label.tsx @@ -0,0 +1,24 @@ +"use client" + +import * as React from "react" +import { Label as LabelPrimitive } from "radix-ui" + +import { cn } from "@/lib/utils" + +function Label({ + className, + ...props +}: React.ComponentProps