diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ddffd34..1da15473 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.42](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.41...v1.4.42) (2025-09-24) + ## [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) diff --git a/package.json b/package.json index d9fc6541..51672211 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.4.41", + "version": "1.4.42", "private": true, "prisma": { "seed": "bun prisma/seed.ts" diff --git a/src/app/api/mobile/collaboration/[id]/message/route.ts b/src/app/api/mobile/collaboration/[id]/message/route.ts new file mode 100644 index 00000000..28079bdf --- /dev/null +++ b/src/app/api/mobile/collaboration/[id]/message/route.ts @@ -0,0 +1,99 @@ +import { NextResponse } from "next/server"; +import prisma from "@/lib/prisma"; + +export async function GET( + request: Request, + { params }: { params: { id: string } } +) { + const { id } = params; + + try { + const data = await prisma.projectCollaboration_Message.findMany({ + orderBy: { + createdAt: "asc", + }, + where: { + projectCollaboration_RoomChatId: id, + }, + select: { + id: true, + createdAt: true, + isActive: true, + message: true, + isFile: true, + userId: true, + User: { + select: { + id: true, + username: true, + }, + }, + }, + }); + + return NextResponse.json({ + success: true, + message: "Berhasil mendapatkan data", + data: data, + }); + } catch (error) { + console.log("[ERROR]", error); + return NextResponse.json({ + success: false, + message: "Gagal mendapatkan data", + reason: (error as Error).message || error, + }); + } +} + +export async function POST( + request: Request, + { params }: { params: { id: string } } +) { + const { id } = params; + const { data } = await request.json(); + + console.log("[ID]", id); + console.log("[DATA]", data); + + try { + const msg = await prisma.projectCollaboration_Message.create({ + data: { + userId: data.userId, + message: data.message, + projectCollaboration_RoomChatId: id, + }, + // select: { + // id: true, + // createdAt: true, + // isActive: true, + // message: true, + // isFile: true, + // User: { + // select: { + // id: true, + // Profile: { + // select: { + // id: true, + // name: true, + // }, + // }, + // }, + // }, + // }, + }); + + return NextResponse.json({ + success: true, + message: "Berhasil mengirim pesan", + data: msg, + }); + } catch (error) { + console.log("[ERROR]", error); + return NextResponse.json({ + success: false, + message: "Gagal mengirim pesan", + reason: (error as Error).message || error, + }); + } +} diff --git a/src/app/api/mobile/forum/[id]/route.ts b/src/app/api/mobile/forum/[id]/route.ts new file mode 100644 index 00000000..dfb1f2f2 --- /dev/null +++ b/src/app/api/mobile/forum/[id]/route.ts @@ -0,0 +1,11 @@ +export { GET }; + +async function GET(request: Request) { + try { + + + } catch (error) { + + } + +} \ No newline at end of file diff --git a/src/app/api/mobile/forum/route.ts b/src/app/api/mobile/forum/route.ts new file mode 100644 index 00000000..cec54a6a --- /dev/null +++ b/src/app/api/mobile/forum/route.ts @@ -0,0 +1,96 @@ +import { NextResponse } from "next/server"; + +export { POST , GET}; + +async function POST(request: Request) { + const { data } = await request.json(); + console.log("[DATA]", data); + + try { + const create = await prisma.forum_Posting.create({ + data: { + diskusi: data.diskusi, + authorId: data.authorId, + forumMaster_StatusPostingId: 1, + }, + }); + + return NextResponse.json({ + success: true, + message: "Berhasil membuat postingan", + data: create, + }); + } catch (error) { + console.log("[ERROR]", error); + return NextResponse.json({ + success: false, + message: "Gagal membuat postingan", + reason: (error as Error).message || error, + }); + } +} + +async function GET(request: Request) { + const { searchParams } = new URL(request.url); + const search = searchParams.get("search"); + + try { + const data = await prisma.forum_Posting.findMany({ + orderBy: { + createdAt: "desc", + }, + where: { + isActive: true, + diskusi: { + mode: "insensitive", + contains: search || "", + }, + }, + select: { + id: true, + diskusi: true, + createdAt: true, + isActive: true, + authorId: true, + Author: { + select: { + id: true, + username: true, + Profile: { + select: { + id: true, + name: true, + imageId: true, + }, + }, + }, + }, + Forum_Komentar: { + where: { + isActive: true, + }, + }, + ForumMaster_StatusPosting: { + select: { + id: true, + status: true, + }, + }, + forumMaster_StatusPostingId: true, + }, + }); + + return NextResponse.json({ + success: true, + message: "Berhasil mendapatkan data", + data: data, + }); + } catch (error) { + console.log("[ERROR]", error); + return NextResponse.json({ + success: false, + message: "Gagal mendapatkan data", + reason: (error as Error).message || error, + }); + } +}