fix notifikasi admin

This commit is contained in:
2025-05-20 17:18:10 +08:00
parent 6103dbfbea
commit 923552681f
11 changed files with 395 additions and 324 deletions

View File

@@ -0,0 +1,46 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib";
export const dynamic = "force-dynamic";
export async function GET(request: Request) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json(
{ success: false, message: "Method not allowed" },
{ status: 405 }
);
}
try {
const { searchParams } = new URL(request.url);
const userId = searchParams.get("id");
const data = await prisma.notifikasi.count({
where: {
adminId: userId,
userRoleId: "2",
isRead: false,
},
});
return NextResponse.json(
{
success: true,
message: "Data fetched successfully",
data: data,
},
{ status: 200 }
);
} catch (error) {
console.error("Error get count notifikasi", error);
return NextResponse.json(
{
success: false,
message: "Failed to get count notifikasi",
data: null,
},
{ status: 500 }
);
}
}