fix: forum
deskripsi: - fix penggunaan use server menjadi API
This commit is contained in:
@@ -2,6 +2,8 @@ import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export { GET };
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
@@ -2,6 +2,8 @@ import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
|
||||
@@ -2,6 +2,8 @@ import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
|
||||
@@ -2,6 +2,8 @@ import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export { GET };
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
|
||||
@@ -86,15 +86,13 @@ function ButtonDeleteKomentar({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
await adminForum_funDeleteKomentarById(komentarId).then(async (res) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await adminForum_funDeleteKomentarById(komentarId);
|
||||
if (res.status === 200) {
|
||||
setLoadingDel2(false);
|
||||
close();
|
||||
router.back();
|
||||
|
||||
// const dataKomentar = await adminForum_funGetOneKomentarById({
|
||||
// komentarId: komentarId,
|
||||
// });
|
||||
@@ -121,10 +119,17 @@ function ButtonDeleteKomentar({
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setLoading(false);
|
||||
close();
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("error delete", error);
|
||||
setLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal("Terjadi kesalahan, silahkan coba lagi");
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -149,12 +154,12 @@ function ButtonDeleteKomentar({
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loadingDel2 ? true : false}
|
||||
loading={loading}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
setLoadingDel2(true);
|
||||
setLoading(true);
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
@@ -30,6 +29,7 @@ import { IconTrash } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { Admin_ComponentModal } from "../../_admin_global/_component/comp_admin_modal";
|
||||
import Admin_ComponentBackButton from "../../_admin_global/back_button";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../_admin_global/is_empty_data";
|
||||
import { Admin_V3_ComponentPaginationBreakpoint } from "../../_components_v3/comp_pagination_breakpoint";
|
||||
@@ -38,8 +38,6 @@ import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_cre
|
||||
import ComponentAdminForum_ViewOneDetailPosting from "../component/detail_one_posting";
|
||||
import { adminForum_funDeletePostingById } from "../fun/delete/fun_delete_posting_by_id";
|
||||
import { adminForum_getListReportPostingById } from "../fun/get/get_list_report_posting_by_id";
|
||||
import { UIGlobal_Modal } from "@/app_modules/_global/ui";
|
||||
import { Admin_ComponentModal } from "../../_admin_global/_component/comp_admin_modal";
|
||||
|
||||
export default function AdminForum_HasilReportPosting({
|
||||
dataPosting,
|
||||
@@ -77,35 +75,42 @@ function ButtonDeletePosting({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
const del = await adminForum_funDeletePostingById(dataPosting.id);
|
||||
if (del.status === 200) {
|
||||
setLoadingDel2(false);
|
||||
close();
|
||||
router.back();
|
||||
try {
|
||||
setLoading(true);
|
||||
const del = await adminForum_funDeletePostingById(dataPosting.id);
|
||||
if (del.status === 200) {
|
||||
const dataNotif = {
|
||||
appId: dataPosting.id,
|
||||
status: "Report Posting",
|
||||
userId: dataPosting.authorId,
|
||||
pesan: dataPosting.diskusi,
|
||||
kategoriApp: "FORUM",
|
||||
title: "Postingan anda telah di laporkan",
|
||||
};
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: dataPosting.authorId, count: 1 })
|
||||
);
|
||||
}
|
||||
|
||||
const dataNotif = {
|
||||
appId: dataPosting.id,
|
||||
status: "Report Posting",
|
||||
userId: dataPosting.authorId,
|
||||
pesan: dataPosting.diskusi,
|
||||
kategoriApp: "FORUM",
|
||||
title: "Postingan anda telah di laporkan",
|
||||
};
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
if (notif.status === 201) {
|
||||
mqtt_client.publish(
|
||||
"USER",
|
||||
JSON.stringify({ userId: dataPosting.authorId, count: 1 })
|
||||
);
|
||||
ComponentGlobal_NotifikasiBerhasil(del.message);
|
||||
setLoading(false);
|
||||
close();
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(del.message);
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(del.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(del.message);
|
||||
} catch (error) {
|
||||
console.log("error delete", error);
|
||||
setLoading(false);
|
||||
ComponentGlobal_NotifikasiGagal("Terjadi kesalahan, silahkan coba lagi");
|
||||
}
|
||||
}
|
||||
return (
|
||||
@@ -130,12 +135,12 @@ function ButtonDeletePosting({
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loadingDel2 ? true : false}
|
||||
loading={loading ? true : false}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
setLoadingDel2(true);
|
||||
setLoading(true);
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
|
||||
@@ -80,11 +80,24 @@ export function ComponentForum_UiDetailReportKomentar() {
|
||||
|
||||
<Stack spacing={"xs"}>
|
||||
<Text fw={"bold"}>Komentar anda</Text>
|
||||
<Paper withBorder p={"sm"}>
|
||||
<Text>
|
||||
<div dangerouslySetInnerHTML={{ __html: data.komentar }} />
|
||||
<Box
|
||||
style={{
|
||||
backgroundColor: MainColor.soft_darkblue,
|
||||
padding: 10,
|
||||
borderRadius: 8,
|
||||
}}
|
||||
>
|
||||
<Text fz={"sm"} color="white">
|
||||
{data?.komentar ? (
|
||||
<Comp_V3_SetInnerHTMLWithStiker
|
||||
props={data.komentar}
|
||||
className="chat-content"
|
||||
/>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Text>
|
||||
</Paper>
|
||||
</Box>
|
||||
</Stack>
|
||||
|
||||
<Stack spacing={"xs"}>
|
||||
|
||||
@@ -2,17 +2,14 @@ import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_ta
|
||||
import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
||||
import { ComponentForum_UiDetailReportKomentar } from "../component/detail_component/ui_report_komentar";
|
||||
|
||||
|
||||
export default function Forum_DetailReportKomentar() {
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={<UIGlobal_LayoutHeaderTamplate title="Report Komentar" />}
|
||||
>
|
||||
{<ComponentForum_UiDetailReportKomentar />}
|
||||
<ComponentForum_UiDetailReportKomentar />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user