From d0fa33badcbbf7018d2f0138b1dd1d0dc8f78e37 Mon Sep 17 00:00:00 2001 From: nabillah Date: Thu, 16 Oct 2025 14:51:53 +0800 Subject: [PATCH] Mobile API: Collaboration Fix: - /api/mobile/admin/collaboration/[id]/route.ts - /api/mobile/admin/collaboration/route.ts ### No Issue --- .../mobile/admin/collaboration/[id]/route.ts | 84 ++++++++++++++++++- .../api/mobile/admin/collaboration/route.ts | 2 - 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/src/app/api/mobile/admin/collaboration/[id]/route.ts b/src/app/api/mobile/admin/collaboration/[id]/route.ts index 7f1f7337..11c30486 100644 --- a/src/app/api/mobile/admin/collaboration/[id]/route.ts +++ b/src/app/api/mobile/admin/collaboration/[id]/route.ts @@ -1,7 +1,7 @@ import { NextResponse } from "next/server"; import prisma from "@/lib/prisma"; -export { GET }; +export { GET, PUT }; async function GET(request: Request, { params }: { params: { id: string } }) { const { id } = params; @@ -10,7 +10,7 @@ async function GET(request: Request, { params }: { params: { id: string } }) { let fixData; try { - if (category === "publish") { + if (category === "publish" || category === "reject") { fixData = await prisma.projectCollaboration.findUnique({ where: { id: id, @@ -53,6 +53,45 @@ async function GET(request: Request, { params }: { params: { id: string } }) { }, }, }); + } else if (category === "group") { + fixData = await prisma.projectCollaboration_RoomChat.findUnique({ + where: { + id: id, + }, + select: { + id: true, + name: true, + ProjectCollaboration: { + select: { + id: true, + isActive: true, + title: true, + lokasi: true, + purpose: true, + benefit: true, + createdAt: true, + ProjectCollaborationMaster_Industri: true, + Author: true, + }, + }, + ProjectCollaboration_AnggotaRoomChat: { + select: { + User: { + select: { + username: true, + id: true, + Profile: { + select: { + id: true, + name: true, + }, + }, + }, + }, + }, + }, + }, + }); } return NextResponse.json( @@ -74,3 +113,44 @@ async function GET(request: Request, { params }: { params: { id: string } }) { ); } } + +async function PUT(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + const { data } = await request.json(); + // const {searchParams} = new URL(request.url); + // const status = searchParams.get("status"); + + try { + const projectUpdate = await prisma.projectCollaboration.update({ + where: { + id: id, + }, + data: { + isActive: false, + isReject: true, + report: data, + }, + select: { + userId: true, + }, + }); + + return NextResponse.json( + { + success: true, + message: "Success update data collaboration", + // data: projectUpdate, + }, + { status: 200 } + ); + } catch (error) { + return NextResponse.json( + { + success: false, + message: "Error update data collaboration", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/admin/collaboration/route.ts b/src/app/api/mobile/admin/collaboration/route.ts index fcf7a5f5..8703665e 100644 --- a/src/app/api/mobile/admin/collaboration/route.ts +++ b/src/app/api/mobile/admin/collaboration/route.ts @@ -8,8 +8,6 @@ async function GET(request: Request, { params }: { params: { name: string } }) { const category = searchParams.get("category"); let fixData; - console.log(["CATEGORY", category]); - try { if (category === "dashboard") { const publish = await prisma.projectCollaboration.count({