upd: api mobile

Deskripsi:
- update load divisi
- tambah anggota
- hapus anggota
- update status admin divisi
- info divisi

- detail divisi

No Issues
This commit is contained in:
amel
2025-05-21 15:58:27 +08:00
parent 13ec913984
commit 589fa01bf6
3 changed files with 59 additions and 47 deletions

View File

@@ -1,26 +1,28 @@
import { prisma } from "@/module/_global";
import { funGetUserByCookies } from "@/module/auth";
import { funGetUserById } from "@/module/auth";
import _, { ceil } from "lodash";
import moment from "moment";
import { NextResponse } from "next/server";
export async function GET(request: Request) {
try {
const user = await funGetUserByCookies()
const { searchParams } = new URL(request.url)
const idGroup = searchParams.get("group")
const division = searchParams.get("division")
const date = searchParams.get("date")
const dateAkhir = searchParams.get("date-end")
const kat = searchParams.get("cat")
const user = searchParams.get("user")
let grup
if (user.id == undefined) {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 })
const userMobile = await funGetUserById({ id: String(user) })
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
}
if (idGroup == "null" || idGroup == undefined || idGroup == "") {
grup = user.idGroup
if (idGroup == "null" || idGroup == undefined || idGroup == "" || idGroup == null || idGroup == "undefined") {
grup = userMobile.idGroup
} else {
grup = idGroup
}