upd: api mobile

Deskriipsi:
- api announcement get all
- api announcement create
- api division get
- api announcement get one

No Issues
This commit is contained in:
amel
2025-05-07 17:34:31 +08:00
parent 0cf69518b5
commit f8181ae9b1
3 changed files with 488 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
import { prisma } from "@/module/_global";
import { funGetUserByCookies } from "@/module/auth";
import { funGetUserById } from "@/module/auth";
import { NextResponse } from "next/server";
export const dynamic = 'force-dynamic'
export const revalidate = true
@@ -7,19 +7,23 @@ export const revalidate = true
export async function GET(request: Request) {
try {
const user = await funGetUserByCookies()
if (user.id == undefined) {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
const { searchParams } = new URL(request.url);
const user = searchParams.get("user")
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 });
}
const role = user.idUserRole
const villaId = user.idVillage
const group = user.idGroup
const role = userMobile.idUserRole
const villaId = userMobile.idVillage
const group = userMobile.idGroup
let kondisi: any = {
isActive: true,
idVillage: String(villaId)
}
if (role != "supadmin") {
if (role != "supadmin" && role != "developer") {
kondisi = {
isActive: true,
idVillage: String(villaId),