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 { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import prisma from "@/lib/prisma";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } }
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import _ from "lodash";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: { id: string } }
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import backendLogger from "@/util/backendLogger";
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
export { GET };
|
export { GET };
|
||||||
|
|
||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
|||||||
@@ -86,15 +86,13 @@ function ButtonDeleteKomentar({
|
|||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
async function onDelete() {
|
async function onDelete() {
|
||||||
await adminForum_funDeleteKomentarById(komentarId).then(async (res) => {
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const res = await adminForum_funDeleteKomentarById(komentarId);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setLoadingDel2(false);
|
|
||||||
close();
|
|
||||||
router.back();
|
|
||||||
|
|
||||||
// const dataKomentar = await adminForum_funGetOneKomentarById({
|
// const dataKomentar = await adminForum_funGetOneKomentarById({
|
||||||
// komentarId: komentarId,
|
// komentarId: komentarId,
|
||||||
// });
|
// });
|
||||||
@@ -121,10 +119,17 @@ function ButtonDeleteKomentar({
|
|||||||
}
|
}
|
||||||
|
|
||||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||||
|
setLoading(false);
|
||||||
|
close();
|
||||||
|
router.back();
|
||||||
} else {
|
} else {
|
||||||
ComponentGlobal_NotifikasiGagal(res.message);
|
ComponentGlobal_NotifikasiGagal(res.message);
|
||||||
}
|
}
|
||||||
});
|
} catch (error) {
|
||||||
|
console.log("error delete", error);
|
||||||
|
setLoading(false);
|
||||||
|
ComponentGlobal_NotifikasiGagal("Terjadi kesalahan, silahkan coba lagi");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -149,12 +154,12 @@ function ButtonDeleteKomentar({
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
loaderPosition="center"
|
loaderPosition="center"
|
||||||
loading={loadingDel2 ? true : false}
|
loading={loading}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
color="red"
|
color="red"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onDelete();
|
onDelete();
|
||||||
setLoadingDel2(true);
|
setLoading(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Hapus
|
Hapus
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
Group,
|
Group,
|
||||||
Modal,
|
|
||||||
Paper,
|
Paper,
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
Spoiler,
|
Spoiler,
|
||||||
@@ -30,6 +29,7 @@ import { IconTrash } from "@tabler/icons-react";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { Admin_ComponentModal } from "../../_admin_global/_component/comp_admin_modal";
|
||||||
import Admin_ComponentBackButton from "../../_admin_global/back_button";
|
import Admin_ComponentBackButton from "../../_admin_global/back_button";
|
||||||
import ComponentAdminGlobal_IsEmptyData from "../../_admin_global/is_empty_data";
|
import ComponentAdminGlobal_IsEmptyData from "../../_admin_global/is_empty_data";
|
||||||
import { Admin_V3_ComponentPaginationBreakpoint } from "../../_components_v3/comp_pagination_breakpoint";
|
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 ComponentAdminForum_ViewOneDetailPosting from "../component/detail_one_posting";
|
||||||
import { adminForum_funDeletePostingById } from "../fun/delete/fun_delete_posting_by_id";
|
import { adminForum_funDeletePostingById } from "../fun/delete/fun_delete_posting_by_id";
|
||||||
import { adminForum_getListReportPostingById } from "../fun/get/get_list_report_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({
|
export default function AdminForum_HasilReportPosting({
|
||||||
dataPosting,
|
dataPosting,
|
||||||
@@ -77,35 +75,42 @@ function ButtonDeletePosting({
|
|||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
async function onDelete() {
|
async function onDelete() {
|
||||||
const del = await adminForum_funDeletePostingById(dataPosting.id);
|
try {
|
||||||
if (del.status === 200) {
|
setLoading(true);
|
||||||
setLoadingDel2(false);
|
const del = await adminForum_funDeletePostingById(dataPosting.id);
|
||||||
close();
|
if (del.status === 200) {
|
||||||
router.back();
|
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 = {
|
ComponentGlobal_NotifikasiBerhasil(del.message);
|
||||||
appId: dataPosting.id,
|
setLoading(false);
|
||||||
status: "Report Posting",
|
close();
|
||||||
userId: dataPosting.authorId,
|
router.back();
|
||||||
pesan: dataPosting.diskusi,
|
} else {
|
||||||
kategoriApp: "FORUM",
|
ComponentGlobal_NotifikasiGagal(del.message);
|
||||||
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 })
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
ComponentGlobal_NotifikasiBerhasil(del.message);
|
console.log("error delete", error);
|
||||||
} else {
|
setLoading(false);
|
||||||
ComponentGlobal_NotifikasiGagal(del.message);
|
ComponentGlobal_NotifikasiGagal("Terjadi kesalahan, silahkan coba lagi");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@@ -130,12 +135,12 @@ function ButtonDeletePosting({
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
loaderPosition="center"
|
loaderPosition="center"
|
||||||
loading={loadingDel2 ? true : false}
|
loading={loading ? true : false}
|
||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
color="red"
|
color="red"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onDelete();
|
onDelete();
|
||||||
setLoadingDel2(true);
|
setLoading(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Hapus
|
Hapus
|
||||||
|
|||||||
@@ -80,11 +80,24 @@ export function ComponentForum_UiDetailReportKomentar() {
|
|||||||
|
|
||||||
<Stack spacing={"xs"}>
|
<Stack spacing={"xs"}>
|
||||||
<Text fw={"bold"}>Komentar anda</Text>
|
<Text fw={"bold"}>Komentar anda</Text>
|
||||||
<Paper withBorder p={"sm"}>
|
<Box
|
||||||
<Text>
|
style={{
|
||||||
<div dangerouslySetInnerHTML={{ __html: data.komentar }} />
|
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>
|
</Text>
|
||||||
</Paper>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Stack spacing={"xs"}>
|
<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 UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate";
|
||||||
import { ComponentForum_UiDetailReportKomentar } from "../component/detail_component/ui_report_komentar";
|
import { ComponentForum_UiDetailReportKomentar } from "../component/detail_component/ui_report_komentar";
|
||||||
|
|
||||||
|
|
||||||
export default function Forum_DetailReportKomentar() {
|
export default function Forum_DetailReportKomentar() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UIGlobal_LayoutTamplate
|
<UIGlobal_LayoutTamplate
|
||||||
header={<UIGlobal_LayoutHeaderTamplate title="Report Komentar" />}
|
header={<UIGlobal_LayoutHeaderTamplate title="Report Komentar" />}
|
||||||
>
|
>
|
||||||
{<ComponentForum_UiDetailReportKomentar />}
|
<ComponentForum_UiDetailReportKomentar />
|
||||||
</UIGlobal_LayoutTamplate>
|
</UIGlobal_LayoutTamplate>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user