upd: announcement

Deskripsi:
- pembatasan pengumuman
- fix get all

No Issues
This commit is contained in:
amel
2024-09-05 13:44:35 +08:00
parent 26d7ba7c46
commit 28eb4d72a2
6 changed files with 109 additions and 31 deletions

View File

@@ -1,6 +1,5 @@
import { prisma } from "@/module/_global";
import { funGetUserByCookies } from "@/module/auth";
import { revalidatePath, revalidateTag } from "next/cache";
import { NextResponse } from "next/server";
export const dynamic = 'force-dynamic'
@@ -11,13 +10,24 @@ export async function GET(request: Request) {
if (user.id == undefined) {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
}
const role = user.idUserRole
const villaId = user.idVillage
const data = await prisma.group.findMany({
where: {
const group = user.idGroup
let kondisi: any = {
isActive: true,
idVillage: String(villaId)
}
if (role != "supadmin") {
kondisi = {
isActive: true,
idVillage: String(villaId)
},
idVillage: String(villaId),
id: String(group)
}
}
const data = await prisma.group.findMany({
where: kondisi,
select: {
id: true,
name: true,