Merge pull request #456 from bipproduction/amalia/02-jun-25

upd: api mobile
This commit is contained in:
Amalia
2025-06-02 17:36:00 +08:00
committed by GitHub
2 changed files with 9 additions and 8 deletions

View File

@@ -1,18 +1,19 @@
import { prisma } from "@/module/_global";
import { funGetUserByCookies } from "@/module/auth";
import { funGetUserById } from "@/module/auth";
import { NextResponse } from "next/server";
// GET LIST DIVISI BY ID DIVISI (CONTOH : UNTUK SHARE DOKUMEN)
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 idDivision = searchParams.get("division");
const name = searchParams.get('search');
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 dataDivision = await prisma.division.findUnique({
where: {
@@ -22,7 +23,7 @@ export async function GET(request: Request) {
})
if (!dataDivision) {
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan", }, { status: 404 });
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan", }, { status: 200 });
}
const data = await prisma.division.findMany({

View File

@@ -140,7 +140,7 @@ export async function PUT(request: Request) {
category,
extension,
idStorage: copyOnStorage.data.id,
createdBy: user.id
createdBy: userMobile.id
},
select: {
id: true