From f1cfb6e2133ac32b25e576cee077f27e51e72945 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Tue, 23 Sep 2025 17:48:41 +0800 Subject: [PATCH 1/2] chore(release): 1.4.41 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1037dbcc..4ddffd34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [1.4.41](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.40...v1.4.41) (2025-09-23) + ## [1.4.40](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.39...v1.4.40) (2025-09-22) ## [1.4.39](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.38...v1.4.39) (2025-09-19) diff --git a/package.json b/package.json index 79907966..d9fc6541 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.4.40", + "version": "1.4.41", "private": true, "prisma": { "seed": "bun prisma/seed.ts" From 2f8416375d5cbebb3705a67277cc89d1dc487c26 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Tue, 23 Sep 2025 17:50:03 +0800 Subject: [PATCH 2/2] Mobile: API Collaboration Add: - api/mobile/collaboration/[id]/group Fix: - api/mobile/collaboration/route - api/mobile/collaboration/[id]/route ### No Isuue --- .../mobile/collaboration/[id]/group/route.ts | 69 ++++++++ .../api/mobile/collaboration/[id]/route.ts | 162 +++++++++++++++++- src/app/api/mobile/collaboration/route.ts | 159 +++++++++++++---- 3 files changed, 356 insertions(+), 34 deletions(-) create mode 100644 src/app/api/mobile/collaboration/[id]/group/route.ts diff --git a/src/app/api/mobile/collaboration/[id]/group/route.ts b/src/app/api/mobile/collaboration/[id]/group/route.ts new file mode 100644 index 00000000..21ecdcc8 --- /dev/null +++ b/src/app/api/mobile/collaboration/[id]/group/route.ts @@ -0,0 +1,69 @@ +import prisma from "@/lib/prisma"; +import { NextResponse } from "next/server"; + +export { GET }; + +async function GET(request: Request, { params }: { params: { id: string } }) { + let fixData; + const { id } = params; + + try { + fixData = await prisma.projectCollaboration_RoomChat.findFirst({ + 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, + }, + }, + ProjectCollaboration_AnggotaRoomChat: { + select: { + User: { + select: { + id: true, + username: true, + Profile: { + select: { + id: true, + name: true, + imageId: true, + }, + }, + }, + }, + }, + }, + }, + }); + + return NextResponse.json( + { + success: true, + message: "Berhasil Mendapatkan Data", + data: fixData, + }, + { status: 200 } + ); + } catch (error) { + console.log("[ERROR]", error); + return NextResponse.json( + { + success: false, + message: "Gagal Mendapatkan Data", + reason: (error as Error).message || error, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/collaboration/[id]/route.ts b/src/app/api/mobile/collaboration/[id]/route.ts index 488d5a1d..bab0938b 100644 --- a/src/app/api/mobile/collaboration/[id]/route.ts +++ b/src/app/api/mobile/collaboration/[id]/route.ts @@ -1,10 +1,8 @@ import { prisma } from "@/lib"; import { NextResponse } from "next/server"; -export async function GET( - request: Request, - { params }: { params: { id: string } } -) { +export { GET, POST, PUT }; +async function GET(request: Request, { params }: { params: { id: string } }) { let fixData; const { id } = params; @@ -21,6 +19,7 @@ export async function GET( purpose: true, benefit: true, createdAt: true, + projectCollaborationMaster_IndustriId: true, Author: { select: { id: true, @@ -67,3 +66,158 @@ export async function GET( ); } } + +// Buat grup +async function POST(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + const { data } = await request.json(); + + // NEED : authorId, listSelected, nameGroup + + console.log("[ID]", id); + console.log("[DATA]", data); + + try { + const createRoom = await prisma.projectCollaboration_RoomChat.create({ + data: { + name: data.nameGroup, + userId: data.authorId, + projectCollaborationId: id, + }, + }); + + if (!createRoom) { + return NextResponse.json({ + status: 400, + success: false, + message: "Gagal Membuat Room", + }); + } + + for (let v of data.listSelect) { + console.log("[LIST SELECTED]", v); + const createAnggota = + await prisma.projectCollaboration_AnggotaRoomChat.create({ + data: { + userId: v, + projectCollaboration_RoomChatId: createRoom.id, + }, + }); + + if (!createAnggota) + return NextResponse.json({ + status: 400, + success: false, + message: "Gagal Menambah Anggota", + }); + + // const createdNotifikasi = await prisma.notifikasi.create({ + // data: { + // userId: v, + // appId: createRoom.id, + // status: "Collaboration Group", + // title: "Grup Kolaborasi Baru", + // pesan: createRoom.name, + // kategoriApp: "COLLABORATION", + // userRoleId: "1", + // }, + // }); + // if (!createdNotifikasi) + // return { status: 400, message: "Gagal mengirim notifikasi" }; + } + + const createForAuthor = + await prisma.projectCollaboration_AnggotaRoomChat.create({ + data: { + userId: data.authorId, + projectCollaboration_RoomChatId: createRoom.id, + }, + }); + + if (!createForAuthor) + return NextResponse.json({ + status: 400, + success: false, + message: "Gagal Menambahkan Author", + }); + + const hideProyek = await prisma.projectCollaboration.update({ + where: { + id: id, + }, + data: { + isActive: false, + }, + }); + + if (!hideProyek) + return NextResponse.json({ + status: 400, + success: false, + message: "Gagal Menyimpan Proyek", + }); + + return NextResponse.json({ + status: 201, + success: true, + message: "Berhasil Membuat Room", + }); + } catch (error) { + console.log("[ERROR]", error); + return NextResponse.json( + { + success: false, + message: "Gagal Membuat Room", + reason: (error as Error).message || error, + }, + { status: 500 } + ); + } +} + +async function PUT(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + const { data } = await request.json(); + + console.log("[ID]", id); + console.log("[DATA]", data); + + try { + const updt = await prisma.projectCollaboration.update({ + where: { + id: id, + }, + data: { + title: data.title, + lokasi: data.lokasi, + purpose: data.purpose, + benefit: data.benefit, + projectCollaborationMaster_IndustriId: + data.projectCollaborationMaster_IndustriId as any, + }, + }); + + if (!updt) + return NextResponse.json({ + status: 400, + success: false, + message: "Update gagal", + }); + + return NextResponse.json({ + status: 200, + success: true, + message: "Update berhasil", + }); + } catch (error) { + console.log("[ERROR]", error); + return NextResponse.json( + { + success: false, + message: "Update data error", + reason: (error as Error).message || error, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/mobile/collaboration/route.ts b/src/app/api/mobile/collaboration/route.ts index 4d60f135..9f8925ac 100644 --- a/src/app/api/mobile/collaboration/route.ts +++ b/src/app/api/mobile/collaboration/route.ts @@ -40,43 +40,142 @@ async function POST(request: Request) { async function GET(request: Request) { let fixData; + const { searchParams } = new URL(request.url); + const category = searchParams.get("category"); + const authorId = searchParams.get("authorId"); + + console.log("[CATEGORY]", category); + console.log("[AUTHOR_ID]", authorId); + try { - fixData = await prisma.projectCollaboration.findMany({ - orderBy: { - createdAt: "desc", - }, - where: { - projectCollaborationMaster_StatusId: 1, - isActive: true, - }, - select: { - id: true, - isActive: true, - title: true, - lokasi: true, - purpose: true, - benefit: true, - Author: { - select: { - id: true, - username: true, - Profile: { - select: { - id: true, - name: true, - imageId: true, + if (category === "beranda") { + fixData = await prisma.projectCollaboration.findMany({ + orderBy: { + createdAt: "desc", + }, + where: { + projectCollaborationMaster_StatusId: 1, + isActive: true, + }, + select: { + id: true, + isActive: true, + title: true, + lokasi: true, + purpose: true, + benefit: true, + Author: { + select: { + id: true, + username: true, + Profile: { + select: { + id: true, + name: true, + imageId: true, + }, + }, + }, + }, + ProjectCollaborationMaster_Industri: true, + ProjectCollaboration_Partisipasi: { + where: { + isActive: true, + }, + }, + }, + }); + } else if (category === "participant") { + fixData = await prisma.projectCollaboration_Partisipasi.findMany({ + orderBy: { + createdAt: "desc", + }, + where: { + userId: authorId, + isActive: true, + AND: { + ProjectCollaboration: { + isActive: true, + }, + }, + }, + select: { + id: true, + isActive: true, + ProjectCollaboration: { + select: { + id: true, + isActive: true, + title: true, + lokasi: true, + purpose: true, + benefit: true, + Author: { + select: { + id: true, + Profile: true, + }, + }, + ProjectCollaborationMaster_Industri: true, + ProjectCollaboration_Partisipasi: { + where: { + isActive: true, + }, }, }, }, }, - ProjectCollaborationMaster_Industri: true, - ProjectCollaboration_Partisipasi: { - where: { - isActive: true, + }); + } else if (category === "my-project") { + fixData = await prisma.projectCollaboration.findMany({ + orderBy: { createdAt: "desc" }, + where: { userId: authorId, isActive: true }, + select: { + id: true, + isActive: true, + title: true, + lokasi: true, + purpose: true, + benefit: true, + // jumlah_partisipan: true, + Author: { + select: { + id: true, + Profile: true, + }, + }, + ProjectCollaborationMaster_Industri: true, + ProjectCollaboration_Partisipasi: { + where: { + isActive: true, + }, }, }, - }, - }); + }); + } else if (category === "group") { + fixData = await prisma.projectCollaboration_AnggotaRoomChat.findMany({ + orderBy: { + createdAt: "desc", + }, + where: { + userId: authorId as any, + }, + select: { + ProjectCollaboration_RoomChat: { + select: { + id: true, + name: true, + isActive: true, + ProjectCollaboration_AnggotaRoomChat: { + select: { + User: true, + }, + }, + }, + }, + }, + }); + } return NextResponse.json( {