Perbaikan UI pada Forum
# style: - Tampilan keseluruhan forum di ganti menguikuti UI ## No Issue
This commit is contained in:
@@ -1,28 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { Box, Button, Paper, Radio, Stack, Text, Title } from "@mantine/core";
|
||||
import { MODEL_FORUM_MASTER_REPORT } from "../../model/interface";
|
||||
import { useState } from "react";
|
||||
import { forum_funCreateReportPosting } from "../../fun/create/fun_create_report_posting";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { Button, Radio, Stack, Text, Title } from "@mantine/core";
|
||||
import { toNumber } from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { forum_funCreateReportKomentar } from "../../fun/create/fun_create_report_komentar";
|
||||
import forum_funCreateNotifikasiToAdmin from "../../fun/forum_notifikasi/fun_create_notifikasi";
|
||||
|
||||
import { MODEL_FORUM_MASTER_REPORT } from "../../model/interface";
|
||||
import forum_getOneKategoriById from "../../fun/get/get_one_kategori_by_id";
|
||||
import getMaster_NamaBank from "@/app_modules/investasi/fun/master/get_nama_bank";
|
||||
|
||||
export default function Forum_ReportKomentar({
|
||||
komentarId,
|
||||
listReport,
|
||||
userLoginId,
|
||||
}: {
|
||||
komentarId: string;
|
||||
listReport: MODEL_FORUM_MASTER_REPORT[];
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const [reportValue, setReportValue] = useState("Kebencian");
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"sm"}>
|
||||
<Radio.Group value={reportValue as any} onChange={setReportValue}>
|
||||
<Radio.Group
|
||||
value={reportValue as any}
|
||||
onChange={(val) => {
|
||||
setReportValue(val);
|
||||
}}
|
||||
>
|
||||
<Stack spacing={"xl"}>
|
||||
{listReport.map((e) => (
|
||||
<Stack key={e.id}>
|
||||
@@ -35,32 +47,67 @@ export default function Forum_ReportKomentar({
|
||||
))}
|
||||
</Stack>
|
||||
</Radio.Group>
|
||||
<ButtonAction value={reportValue} komentarId={komentarId} />
|
||||
<ButtonAction
|
||||
kategoriId={reportValue}
|
||||
komentarId={komentarId}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({
|
||||
value,
|
||||
kategoriId,
|
||||
komentarId,
|
||||
userLoginId,
|
||||
}: {
|
||||
value: string;
|
||||
kategoriId: string;
|
||||
komentarId: string;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onReport() {
|
||||
await forum_funCreateReportKomentar(komentarId, value).then((res) => {
|
||||
if (res.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
setLoading(true);
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
const report = await forum_funCreateReportKomentar({
|
||||
komentarId: komentarId,
|
||||
kategoriId: kategoriId,
|
||||
});
|
||||
|
||||
if (report.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil(report.message, 2000);
|
||||
setLoading(true);
|
||||
router.back();
|
||||
|
||||
// const get = await getMaster_NamaBank();
|
||||
// console.log(get);
|
||||
|
||||
// await forum_getOneKategoriById({
|
||||
// kategoriId: kategoriId,
|
||||
// });
|
||||
|
||||
// console.log(getKategori);
|
||||
|
||||
// const dataNotif = {
|
||||
// appId: komentarId,
|
||||
// pesan: getKategori?.deskripsi,
|
||||
// kategoriApp: "FORUM",
|
||||
// title: getKategori?.title,
|
||||
// userId: userLoginId,
|
||||
// status: "Report Komentar",
|
||||
// };
|
||||
|
||||
// const createNotif = await forum_funCreateNotifikasiToAdmin({
|
||||
// data: dataNotif as any,
|
||||
// });
|
||||
|
||||
// if (createNotif.status === 201) {
|
||||
// mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
// }
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(report.message);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
@@ -75,7 +122,7 @@ function ButtonAction({
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
color="orange"
|
||||
loaderPosition="center"
|
||||
loading={loading ? true : false}
|
||||
onClick={() => onReport()}
|
||||
|
||||
@@ -61,7 +61,7 @@ function ButtonAction({
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button radius={"xl"} color="red" onClick={() => onReport()}>
|
||||
<Button radius={"xl"} color="orange" onClick={() => onReport()}>
|
||||
Report
|
||||
</Button>
|
||||
</Group>
|
||||
|
||||
@@ -77,10 +77,9 @@ function ButtonAction({
|
||||
const getKategori = await forum_getOneKategoriById({
|
||||
kategoriId: toNumber(kategoriId),
|
||||
});
|
||||
console.log(getKategori);
|
||||
// console.log(getKategori);
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(report.message, 2000);
|
||||
setLoading(true);
|
||||
router.back();
|
||||
|
||||
const dataNotif = {
|
||||
@@ -99,6 +98,8 @@ function ButtonAction({
|
||||
if (createNotifikasi.status === 201) {
|
||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
}
|
||||
setLoading(true);
|
||||
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(report.message);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,15 @@ import { forum_funCreateReportPosting } from "../../fun/create/fun_create_report
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funCreateReportPostingLainnya } from "../../fun/create/fun_create_report_posting_lainnya";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
|
||||
|
||||
export default function Forum_ReportPostingLainnya({
|
||||
postingIg,
|
||||
postingId,
|
||||
userLoginId,
|
||||
}: {
|
||||
postingIg: string;
|
||||
postingId: string;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const [deskripsi, setDeskripsi] = useState("");
|
||||
return (
|
||||
@@ -26,46 +30,69 @@ export default function Forum_ReportPostingLainnya({
|
||||
setDeskripsi(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
<ButtonAction postingIg={postingIg} deskripsi={deskripsi} />
|
||||
<ButtonAction
|
||||
postingId={postingId}
|
||||
deskripsi={deskripsi}
|
||||
userLoginId={userLoginId}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({
|
||||
postingIg,
|
||||
postingId,
|
||||
deskripsi,
|
||||
userLoginId,
|
||||
}: {
|
||||
postingIg: string;
|
||||
postingId: string;
|
||||
deskripsi: string;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
async function onReport() {
|
||||
await forum_funCreateReportPostingLainnya(postingIg, deskripsi).then(
|
||||
(res) => {
|
||||
if (res.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
const report = await forum_funCreateReportPostingLainnya(
|
||||
postingId,
|
||||
deskripsi
|
||||
);
|
||||
if (report.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil(report.message);
|
||||
router.back();
|
||||
|
||||
const dataNotif = {
|
||||
appId: postingId,
|
||||
pesan: deskripsi,
|
||||
kategoriApp: "FORUM",
|
||||
title: "Lainnya",
|
||||
userId: userLoginId,
|
||||
status: "Report Posting",
|
||||
};
|
||||
|
||||
const createNotifikasi = await notifikasiToAdmin_funCreate({
|
||||
data: dataNotif as any,
|
||||
});
|
||||
|
||||
if (createNotifikasi.status === 201) {
|
||||
mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(report.message);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Group position="apart" grow>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => router.replace(RouterForum.report_posting + postingIg)}
|
||||
onClick={() => router.replace(RouterForum.report_posting + postingId)}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s"
|
||||
}}
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
disabled={deskripsi === "" ? true : false}
|
||||
radius={"xl"}
|
||||
color="orange"
|
||||
|
||||
Reference in New Issue
Block a user