Update Versi 1.5.27 #32

Merged
bagasbanuna merged 1009 commits from staging into main 2025-12-17 12:22:28 +08:00
2171 changed files with 95259 additions and 24374 deletions
Showing only changes of commit a9b57be0a6 - Show all commits

View File

@@ -0,0 +1,149 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { POST, GET, DELETE };
async function POST(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const { data } = await request.json();
console.log("[ID COMMENT]", id);
console.log("[DATA COMMENT]", data);
try {
const createComment = await prisma.forum_Komentar.create({
data: {
forum_PostingId: id,
komentar: data.comment,
authorId: data.authorId,
},
select: {
id: true,
isActive: true,
komentar: true,
createdAt: true,
authorId: true,
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
imageId: true,
},
},
},
},
},
});
if (!createComment) {
return NextResponse.json({
status: 400,
success: false,
message: "Gagal update data",
});
}
return NextResponse.json({
status: 200,
success: true,
message: "Berhasil update data",
data: createComment,
});
} catch (error) {
console.log("[ERROR COMMENT]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal update data",
reason: (error as Error).message || error,
});
}
}
async function GET(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
try {
const data = await prisma.forum_Komentar.findMany({
orderBy: {
createdAt: "desc",
},
where: {
forum_PostingId: id,
isActive: true,
},
select: {
id: true,
isActive: true,
komentar: true,
createdAt: true,
authorId: true,
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
imageId: true,
},
},
},
},
},
});
return NextResponse.json({
status: 200,
success: true,
message: "Berhasil mendapatkan data",
data: data,
});
} catch (error) {
console.log("[ERROR COMMENT]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal mendapatkan data",
reason: (error as Error).message || error,
});
}
}
async function DELETE(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
try {
const deleteComment = await prisma.forum_Komentar.delete({
where: {
id: id,
},
});
if (!deleteComment) {
return NextResponse.json({
status: 400,
success: false,
message: "Gagal hapus komentar",
});
}
return NextResponse.json({
status: 200,
success: true,
message: "Berhasil hapus komentar",
});
} catch (error) {
console.log("[ERROR COMMENT]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal hapus komentar",
reason: (error as Error).message || error,
});
}
}

View File

@@ -0,0 +1,61 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { POST };
async function POST(request: Request, { params }: { params: { id: string } }) {
let fixData;
const { id } = params;
const { data } = await request.json();
console.log("[DATA]", data);
console.log("[ID]", id);
try {
fixData = await prisma.forum_ReportKomentar.create({
data: {
forum_KomentarId: id,
userId: data.authorId,
forumMaster_KategoriReportId: data.categoryId as any,
},
});
// if (data.categoryId) {
// fixData = await prisma.forum_ReportKomentar.create({
// data: {
// forum_KomentarId: id,
// userId: data.authorId,
// forumMaster_KategoriReportId: data.categoryId as any,
// },
// });
// } else {
// fixData = await prisma.forum_ReportKomentar.create({
// data: {
// forum_KomentarId: id,
// userId: data.authorId,
// deskripsi: data.description,
// },
// });
// }
// if (!fixData) {
// return NextResponse.json({
// status: 400,
// success: false,
// message: "Gagal membuat report komentar",
// });
// }
return NextResponse.json({
status: 201,
success: true,
message: "Berhasil membuat report komentar",
});
} catch (error) {
console.log("[ERROR]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal membuat report komentar",
reason: (error as Error).message,
});
}
}

View File

@@ -0,0 +1,54 @@
import { prisma } from "@/lib";
import { NextResponse } from "next/server";
export { POST };
async function POST(request: Request, { params }: { params: { id: string } }) {
let fixData;
const { id } = params;
const { data } = await request.json();
console.log("[DATA]", data);
console.log("[ID]", id);
try {
if (data.categoryId) {
fixData = await prisma.forum_ReportKomentar.create({
data: {
forum_KomentarId: id,
userId: data.authorId,
forumMaster_KategoriReportId: data.categoryId as any,
},
});
} else {
fixData = await prisma.forum_ReportKomentar.create({
data: {
forum_KomentarId: id,
userId: data.authorId,
deskripsi: data.description,
},
});
}
if (!fixData) {
return NextResponse.json({
status: 400,
success: false,
message: "Gagal membuat report komentar",
});
}
return NextResponse.json({
status: 201,
success: true,
message: "Berhasil membuat report komentar",
});
} catch (error) {
console.log("[ERROR]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal membuat report komentar",
reason: (error as Error).message,
});
}
}

View File

@@ -0,0 +1,54 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { POST };
async function POST(request: Request, { params }: { params: { id: string } }) {
let fixData;
const { id } = params;
const { data } = await request.json();
console.log("[DATA]", data);
console.log("[ID]", id);
try {
if (data.categoryId) {
fixData = await prisma.forum_ReportPosting.create({
data: {
forum_PostingId: id,
userId: data.authorId,
forumMaster_KategoriReportId: data.categoryId,
},
});
} else {
fixData = await prisma.forum_ReportPosting.create({
data: {
forum_PostingId: id,
userId: data.authorId,
deskripsi: data.description,
},
});
}
if (!fixData) {
return NextResponse.json({
status: 400,
success: false,
message: "Gagal membuat report posting",
});
}
return NextResponse.json({
status: 201,
success: true,
message: "Berhasil membuat report posting",
});
} catch (error) {
console.log("[ERROR]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal membuat report posting",
reason: (error as Error).message,
});
}
}

View File

@@ -1,11 +1,188 @@
export { GET };
import prisma from "@/lib/prisma";
import _ from "lodash";
import { NextResponse } from "next/server";
async function GET(request: Request) {
try {
} catch (error) {
export { GET, PUT, DELETE, POST };
async function GET(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
try {
const data = await prisma.forum_Posting.findUnique({
where: {
id: id,
},
select: {
id: true,
diskusi: true,
isActive: true,
createdAt: true,
authorId: true,
Author: {
select: {
id: true,
username: true,
Profile: true,
},
},
Forum_Komentar: {
where: {
isActive: true,
},
},
ForumMaster_StatusPosting: true,
forumMaster_StatusPostingId: true,
},
});
const count = data?.Forum_Komentar?.length ?? 0;
const newData = {
..._.omit(data, ["Forum_Komentar"]),
count,
};
return NextResponse.json({
success: true,
message: "Berhasil mendapatkan data",
data: newData,
});
} catch (error) {
console.log("[ERROR FORUM]", error);
return NextResponse.json({
success: false,
message: "Gagal mendapatkan data",
reason: (error as Error).message || error,
});
}
}
async function PUT(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const { data } = await request.json();
console.log("[DATA]", data);
try {
const update = await prisma.forum_Posting.update({
where: {
id: id,
},
data: {
diskusi: data,
},
});
if (!update) {
return NextResponse.json({
status: 400,
success: false,
message: "Gagal update data",
});
}
return NextResponse.json({
status: 200,
success: true,
message: "Berhasil update data",
});
} catch (error) {
console.log("[ERROR FORUM]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal update data",
reason: (error as Error).message || error,
});
}
}
async function DELETE(
request: Request,
{ params }: { params: { id: string } }
) {
const { id } = params;
try {
const dlt = await prisma.forum_Posting.delete({
where: {
id: id,
},
});
if (!dlt) {
return NextResponse.json({
status: 400,
success: false,
message: "Gagal hapus data",
});
}
return NextResponse.json({
status: 200,
success: true,
message: "Berhasil hapus data",
});
} catch (error) {
console.log("[ERROR FORUM]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Error hapus data",
reason: (error as Error).message || error,
});
}
}
// Update Status
async function POST(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const { data } = await request.json();
console.log("[DATA]", data);
const status = await prisma.forumMaster_StatusPosting.findFirst({
where: {
status: data,
},
});
console.log("[STATUS]", status);
try {
const update = await prisma.forum_Posting.update({
where: {
id: id,
},
data: {
forumMaster_StatusPostingId: status?.id,
},
});
if (!update) {
return NextResponse.json({
status: 400,
success: false,
message: "Gagal update data",
});
}
const fixData = status?.status;
return NextResponse.json({
status: 200,
success: true,
message: "Berhasil update data",
data: fixData,
});
}
} catch (error) {
console.log("[ERROR FORUM]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal update data",
reason: (error as Error).message || error,
});
}
}

View File

@@ -1,6 +1,8 @@
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { POST , GET};
export { POST, GET };
async function POST(request: Request) {
const { data } = await request.json();
@@ -31,60 +33,127 @@ async function POST(request: Request) {
}
async function GET(request: Request) {
let fixData;
const { searchParams } = new URL(request.url);
const authorId = searchParams.get("authorId");
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,
if (authorId) {
const data = await prisma.forum_Posting.findMany({
orderBy: {
createdAt: "desc",
},
where: {
isActive: true,
authorId: authorId,
},
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,
},
Forum_Komentar: {
where: {
isActive: true,
});
const newData = data.map((item) => {
const count = item.Forum_Komentar?.length ?? 0;
return {
..._.omit(item, ["Forum_Komentar"]),
count,
};
});
fixData = newData;
} else {
const data = await prisma.forum_Posting.findMany({
orderBy: {
createdAt: "desc",
},
where: {
isActive: true,
diskusi: {
mode: "insensitive",
contains: search || "",
},
},
ForumMaster_StatusPosting: {
select: {
id: true,
status: true,
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,
},
forumMaster_StatusPostingId: true,
},
});
});
const newData = data.map((item) => {
const count = item.Forum_Komentar?.length ?? 0;
return {
..._.omit(item, ["Forum_Komentar"]),
count,
};
});
fixData = newData;
}
return NextResponse.json({
success: true,
message: "Berhasil mendapatkan data",
data: data,
data: fixData,
});
} catch (error) {
console.log("[ERROR]", error);
return NextResponse.json({

View File

@@ -0,0 +1,28 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export async function GET(request: Request) {
try {
const data = await prisma.forumMaster_KategoriReport.findMany({
orderBy: {
createdAt: "asc",
},
where: {
isActive: 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,
});
}
}

View File

@@ -9,7 +9,7 @@ import { useShallowEffect } from "@mantine/hooks";
import { Comp_V3_SetInnerHTMLWithStiker } from "@/app_modules/_global/component/new/comp_V3_set_html_with_stiker";
import { MainColor } from "@/app_modules/_global/color";
export default function ComponentForum_DetailForumView({
export default function ComponentForum_DetailForumView({
data,
totalKomentar,
userLoginId,