Merge pull request 'Integrasi API: Collaboration & Forum' (#22) from mobile/24-sep-25 into staging
Reviewed-on: bip/hipmi#22
This commit is contained in:
@@ -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.
|
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.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.40](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.39...v1.4.40) (2025-09-22)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.4.41",
|
"version": "1.4.42",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
99
src/app/api/mobile/collaboration/[id]/message/route.ts
Normal file
99
src/app/api/mobile/collaboration/[id]/message/route.ts
Normal file
@@ -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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/app/api/mobile/forum/[id]/route.ts
Normal file
11
src/app/api/mobile/forum/[id]/route.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export { GET };
|
||||||
|
|
||||||
|
async function GET(request: Request) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
96
src/app/api/mobile/forum/route.ts
Normal file
96
src/app/api/mobile/forum/route.ts
Normal file
@@ -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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user