Notifiaksi Forum

# feat
- Notifikasi user to user
- Realtime user to user
## No issuee
This commit is contained in:
2024-06-20 21:52:14 +08:00
parent edd13ffe0f
commit d904042dfb
32 changed files with 1182 additions and 443 deletions

View File

@@ -8,13 +8,18 @@ import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_glob
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 mqtt_client from "@/util/mqtt_client";
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
export default function Forum_ReportPosting({
postingId,
listReport,
userLoginId,
}: {
postingId: string;
listReport: MODEL_FORUM_MASTER_REPORT[];
userLoginId: string;
}) {
const [reportValue, setReportValue] = useState("Kebencian");
@@ -34,7 +39,11 @@ export default function Forum_ReportPosting({
))}
</Stack>
</Radio.Group>
<ButtonAction value={reportValue} postingId={postingId} />
<ButtonAction
value={reportValue}
postingId={postingId}
userLoginId={userLoginId}
/>
</Stack>
</>
);
@@ -43,36 +52,55 @@ export default function Forum_ReportPosting({
function ButtonAction({
value,
postingId,
userLoginId,
}: {
value: string;
postingId: string;
userLoginId: 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);
}
});
const report = await forum_funCreateReportPosting(postingId, value);
if (report.status === 201) {
ComponentGlobal_NotifikasiBerhasil(report.message, 2000);
setLoading(true);
router.back();
// const dataNotif = {
// appId: postingId,
// pesan: value,
// kategoriApp: "FORUM",
// title: "Report Posting",
// userId: userLoginId,
// };
// const notif = await notifikasiToAdmin_funCreate({
// data: dataNotif as any,
// });
// if (notif.status === 201) {
// mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 }));
// }
} else {
ComponentGlobal_NotifikasiGagal(report.message);
}
}
return (
<>
<Stack mt={"md"}>
<Button
radius={"xl"}
onClick={() => router.replace(RouterForum.report_posting_lainnya + postingId)}
onClick={() =>
router.replace(RouterForum.report_posting_lainnya + postingId)
}
>
Lainnya
</Button>
<Button
radius={"xl"}
color="red"
color="orange"
loaderPosition="center"
loading={loading ? true : false}
onClick={() => onReport()}

View File

@@ -62,7 +62,15 @@ function ButtonAction({
>
Batal
</Button>
<Button radius={"xl"} color="red" onClick={() => onReport()}>
<Button
style={{
transition: "0.5s"
}}
disabled={deskripsi === "" ? true : false}
radius={"xl"}
color="orange"
onClick={() => onReport()}
>
Report
</Button>
</Group>