# Forum Report
## feat - Repot posting - Report komentar ### No issuee
This commit is contained in:
@@ -1,11 +1,88 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import { Stack } from "@mantine/core"
|
||||
import { Box, Button, Paper, Radio, Stack, Text, Title } from "@mantine/core";
|
||||
import { MODEL_FORUM_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 { forum_funCreateReportKomentar } from "../../fun/create/fun_create_report_komentar";
|
||||
|
||||
export default function Forum_ReportKomentar({id}: {id: string}){
|
||||
return <>
|
||||
<Stack>
|
||||
ini laporan
|
||||
</Stack>
|
||||
export default function Forum_ReportKomentar({
|
||||
komentarId,
|
||||
listReport,
|
||||
}: {
|
||||
komentarId: string;
|
||||
listReport: MODEL_FORUM_REPORT[];
|
||||
}) {
|
||||
const [reportValue, setReportValue] = useState("Kebencian");
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"sm"}>
|
||||
<Radio.Group value={reportValue as any} onChange={setReportValue}>
|
||||
<Stack spacing={"xl"}>
|
||||
{listReport.map((e) => (
|
||||
<Stack key={e.id}>
|
||||
<Radio
|
||||
value={e.title}
|
||||
label={<Title order={5}>{e.title}</Title>}
|
||||
/>
|
||||
<Text>{e.deskripsi}</Text>
|
||||
</Stack>
|
||||
))}
|
||||
</Stack>
|
||||
</Radio.Group>
|
||||
<ButtonAction value={reportValue} komentarId={komentarId} />
|
||||
</Stack>
|
||||
</>
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({
|
||||
value,
|
||||
komentarId,
|
||||
}: {
|
||||
value: string;
|
||||
komentarId: 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Stack mt={"md"}>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() =>
|
||||
router.replace(RouterForum.report_komentar_lainnya + komentarId)
|
||||
}
|
||||
>
|
||||
Lainnya
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
loaderPosition="center"
|
||||
loading={loading ? true : false}
|
||||
onClick={() => onReport()}
|
||||
>
|
||||
Report
|
||||
</Button>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
70
src/app_modules/forum/report/komentar/lainnya.tsx
Normal file
70
src/app_modules/forum/report/komentar/lainnya.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
"use client";
|
||||
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { Button, Group, Stack, Textarea } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
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 { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funCreateReportPostingLainnya } from "../../fun/create/fun_create_report_posting_lainnya";
|
||||
import { forum_funCreateReportKomentarLainnya } from "../../fun/create/fun_create_report_komentar_lainnya";
|
||||
|
||||
export default function Forum_ReportKomentarLainnya({ komentarId }: { komentarId: string }) {
|
||||
const [deskripsi, setDeskripsi] = useState("");
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Textarea
|
||||
label={"Kirimkan Laporan"}
|
||||
placeholder="Ketik laporan anda tentang komentar ini ..."
|
||||
minRows={5}
|
||||
onChange={(val) => {
|
||||
setDeskripsi(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
<ButtonAction komentarId={komentarId} deskripsi={deskripsi} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({
|
||||
komentarId,
|
||||
deskripsi,
|
||||
}: {
|
||||
komentarId: string;
|
||||
deskripsi: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
async function onReport() {
|
||||
await forum_funCreateReportKomentarLainnya(komentarId, deskripsi).then(
|
||||
(res) => {
|
||||
if (res.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Group position="apart" grow>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() =>
|
||||
router.replace(RouterForum.report_komentar + komentarId)
|
||||
}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button radius={"xl"} color="red" onClick={() => onReport()}>
|
||||
Report
|
||||
</Button>
|
||||
</Group>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,85 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import { Stack } from "@mantine/core"
|
||||
import { Box, Button, Paper, Radio, Stack, Text, Title } from "@mantine/core";
|
||||
import { MODEL_FORUM_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";
|
||||
|
||||
export default function Forum_ReportPosting({id}: {id: string}){
|
||||
return <>
|
||||
<Stack>
|
||||
ini laporan
|
||||
</Stack>
|
||||
export default function Forum_ReportPosting({
|
||||
postingId,
|
||||
listReport,
|
||||
}: {
|
||||
postingId: string;
|
||||
listReport: MODEL_FORUM_REPORT[];
|
||||
}) {
|
||||
const [reportValue, setReportValue] = useState("Kebencian");
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack px={"sm"}>
|
||||
<Radio.Group value={reportValue as any} onChange={setReportValue}>
|
||||
<Stack spacing={"xl"}>
|
||||
{listReport.map((e) => (
|
||||
<Stack key={e.id}>
|
||||
<Radio
|
||||
value={e.title}
|
||||
label={<Title order={5}>{e.title}</Title>}
|
||||
/>
|
||||
<Text>{e.deskripsi}</Text>
|
||||
</Stack>
|
||||
))}
|
||||
</Stack>
|
||||
</Radio.Group>
|
||||
<ButtonAction value={reportValue} postingId={postingId} />
|
||||
</Stack>
|
||||
</>
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({
|
||||
value,
|
||||
postingId,
|
||||
}: {
|
||||
value: string;
|
||||
postingId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onReport() {
|
||||
await forum_funCreateReportPosting(postingId, value).then((res) => {
|
||||
if (res.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
setLoading(true);
|
||||
router.back();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Stack mt={"md"}>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => router.replace(RouterForum.report_posting_lainnya + postingId)}
|
||||
>
|
||||
Lainnya
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
loaderPosition="center"
|
||||
loading={loading ? true : false}
|
||||
onClick={() => onReport()}
|
||||
>
|
||||
Report
|
||||
</Button>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
71
src/app_modules/forum/report/posting/lainnya.tsx
Normal file
71
src/app_modules/forum/report/posting/lainnya.tsx
Normal file
@@ -0,0 +1,71 @@
|
||||
"use client";
|
||||
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { Button, Group, Stack, Textarea } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
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 { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funCreateReportPostingLainnya } from "../../fun/create/fun_create_report_posting_lainnya";
|
||||
|
||||
export default function Forum_ReportPostingLainnya({
|
||||
postingIg,
|
||||
}: {
|
||||
postingIg: string;
|
||||
}) {
|
||||
const [deskripsi, setDeskripsi] = useState("");
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Textarea
|
||||
label={"Kirimkan Laporan"}
|
||||
placeholder="Ketik laporan anda tentang postingan ini ..."
|
||||
minRows={5}
|
||||
onChange={(val) => {
|
||||
setDeskripsi(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
<ButtonAction postingIg={postingIg} deskripsi={deskripsi} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({
|
||||
postingIg,
|
||||
deskripsi,
|
||||
}: {
|
||||
postingIg: string;
|
||||
deskripsi: 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);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Group position="apart" grow>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => router.replace(RouterForum.report_posting + postingIg)}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button radius={"xl"} color="red" onClick={() => onReport()}>
|
||||
Report
|
||||
</Button>
|
||||
</Group>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export default function LayoutForum_ReportPosting({
|
||||
<>
|
||||
<AppShell
|
||||
header={
|
||||
<ComponentForum_HeaderRataKiri title="Mengumpulkan Informasi Posting"/>
|
||||
<ComponentForum_HeaderRataKiri title="Mengumpulkan Informasi Posting" />
|
||||
}
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user