import { NextResponse } from "next/server";

export function middleware(request) {
  const role = request.cookies.get("role")?.value;

  if (!role && request.nextUrl.pathname.startsWith("/dashboard")) {
    return NextResponse.redirect(new URL("/login", request.url));
  }

  return NextResponse.next();
}

export const config = {
  matcher: ["/dashboard/:path*"],
};
