Merge pull request #456 from bipproduction/amalia/02-jun-25
upd: api mobile
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user