import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { getUserIdFromRequest } from "@/lib/auth";

export async function GET(req: Request) {
  const userId = getUserIdFromRequest(req);
  if (!userId) return NextResponse.json({ items: [] });
  const items = await prisma.adminNotification.findMany({
    orderBy: { createdAt: "desc" },
    take: 5,
    select: { id: true, type: true, message: true, createdAt: true },
  });
  return NextResponse.json({ items });
}


