feat : update filter dll

Deskripsi
- position
- project
- announcement
- calneder
- division
- document
- home

No Issue
This commit is contained in:
lukman
2024-08-29 15:52:54 +08:00
parent 390c46e2da
commit e2df0beb9f
16 changed files with 444 additions and 175 deletions

View File

@@ -9,9 +9,9 @@ import { NextResponse } from "next/server";
export async function GET(request: Request) {
try {
let grupFix
let grup
const { searchParams } = new URL(request.url);
const groupID = searchParams.get('group');
const idGroup = searchParams.get("group");
const active = searchParams.get('active');
const name = searchParams.get('search')
const user = await funGetUserByCookies()
@@ -19,15 +19,15 @@ export async function GET(request: Request) {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
}
if (groupID == "null") {
grupFix = user.idGroup
} else {
grupFix = groupID
}
if (idGroup == "null" || idGroup == undefined) {
grup = user.idGroup
} else {
grup = idGroup
}
const cek = await prisma.group.count({
where: {
id: String(grupFix),
id: grup,
isActive: true
}
})
@@ -38,7 +38,7 @@ export async function GET(request: Request) {
const positions = await prisma.position.findMany({
where: {
idGroup: String(grupFix),
idGroup: grup,
isActive: (active == "true" ? true : false),
name: {
contains: (name == undefined || name == null) ? "" : name,

View File

@@ -16,18 +16,25 @@ export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
let grup
const name = searchParams.get('search');
const status = searchParams.get('status');
const idGroup = searchParams.get("group");
const villageId = user.idVillage
const groupId = user.idGroup
const userId = user.id
if (idGroup == "null" || idGroup == undefined) {
grup = user.idGroup
} else {
grup = idGroup
}
const data = await prisma.project.findMany({
where: {
isActive: true,
idVillage: String(villageId),
idGroup: String(groupId),
idGroup: grup,
createdBy: String(userId),
title: {
contains: (name == undefined || name == "null") ? "" : name,