fix: forum

deskripsi:
- metode pengambilan user id dari use server menjadi menggunakan metode API
This commit is contained in:
2025-06-03 11:33:56 +08:00
parent b849fead02
commit 512d170c3e
22 changed files with 276 additions and 188 deletions

View File

@@ -14,6 +14,7 @@ import {
AccentColor,
MainColor,
} from "@/app_modules/_global/color/color_pallet";
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
import { clientLogger } from "@/util/clientLogger";
@@ -22,17 +23,31 @@ import { apiGetMasterReportForum } from "../../component/api_fetch_forum";
import forum_getOneKategoriById from "../../fun/get/get_one_kategori_by_id";
import { MODEL_FORUM_MASTER_REPORT } from "../../model/interface";
export default function Forum_ReportKomentar({
userLoginId,
}: {
userLoginId: string;
}) {
export default function Forum_ReportKomentar() {
const param = useParams<{ id: string }>();
const komentarId = param.id;
const [listReport, setListReport] = useState<
MODEL_FORUM_MASTER_REPORT[] | null
>(null);
const [reportValue, setReportValue] = useState("1");
const [userLoginId, setUserLoginId] = useState<string | null>(null);
useShallowEffect(() => {
handleGetUserLoginId();
}, []);
async function handleGetUserLoginId() {
try {
const response = await apiNewGetUserIdByToken();
if (response.success) {
setUserLoginId(response.userId);
} else {
setUserLoginId(null);
}
} catch (error) {
setUserLoginId(null);
}
}
useShallowEffect(() => {
handleLoadMasterReport();
@@ -49,7 +64,8 @@ export default function Forum_ReportKomentar({
}
};
if (!listReport) return <CustomSkeleton height={50} width={"100%"} />;
if (!listReport || !userLoginId)
return <CustomSkeleton height={400} width={"100%"} />;
return (
<>

View File

@@ -1,26 +1,45 @@
"use client";
import { RouterForum } from "@/lib/router_hipmi/router_forum";
import { Button, Group, Stack, Textarea } from "@mantine/core";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import { forum_funCreateReportPosting } from "../../fun/create/fun_create_report_posting";
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_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";
import mqtt_client from "@/util/mqtt_client";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
import { RouterForum } from "@/lib/router_hipmi/router_forum";
import { clientLogger } from "@/util/clientLogger";
import mqtt_client from "@/util/mqtt_client";
import { Button, Group, Stack, Textarea } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import { forum_funCreateReportKomentarLainnya } from "../../fun/create/fun_create_report_komentar_lainnya";
export default function Forum_ReportKomentarLainnya({
userLoginId,
}: {
userLoginId: string;
}) {
export default function Forum_ReportKomentarLainnya() {
const param = useParams<{ id: string }>();
const komentarId = param.id;
const [deskripsi, setDeskripsi] = useState("");
const [userLoginId, setUserLoginId] = useState<string | null>(null);
useShallowEffect(() => {
handleGetUserLoginId();
}, []);
async function handleGetUserLoginId() {
try {
const response = await apiNewGetUserIdByToken();
if (response.success) {
setUserLoginId(response.userId);
} else {
setUserLoginId(null);
}
} catch (error) {
setUserLoginId(null);
}
}
if (!userLoginId) {
return <CustomSkeleton height={400} width={"100%"} />;
}
return (
<>

View File

@@ -1,35 +1,52 @@
"use client";
import { RouterForum } from "@/lib/router_hipmi/router_forum";
import {
AccentColor,
MainColor,
} from "@/app_modules/_global/color/color_pallet";
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
import { RouterForum } from "@/lib/router_hipmi/router_forum";
import { clientLogger } from "@/util/clientLogger";
import mqtt_client from "@/util/mqtt_client";
import { Button, Radio, Stack, Text, Title } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { toNumber } from "lodash";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import { apiGetMasterReportForum } from "../../component/api_fetch_forum";
import { forum_funCreateReportPosting } from "../../fun/create/fun_create_report_posting";
import forum_getOneKategoriById from "../../fun/get/get_one_kategori_by_id";
import { MODEL_FORUM_MASTER_REPORT } from "../../model/interface";
import { useShallowEffect } from "@mantine/hooks";
import { apiGetMasterReportForum } from "../../component/api_fetch_forum";
import { clientLogger } from "@/util/clientLogger";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
export default function Forum_ReportPosting({
userLoginId,
}: {
userLoginId: string;
}) {
export default function Forum_ReportPosting() {
const param = useParams<{ id: string }>();
const postingId = param.id;
const [listReport, setListReport] = useState<MODEL_FORUM_MASTER_REPORT[] | null>(null);
const [listReport, setListReport] = useState<
MODEL_FORUM_MASTER_REPORT[] | null
>(null);
const [reportValue, setReportValue] = useState("1");
const [userLoginId, setUserLoginId] = useState<string | null>(null);
useShallowEffect(() => {
handleGetUserLoginId();
}, []);
async function handleGetUserLoginId() {
try {
const response = await apiNewGetUserIdByToken();
if (response.success) {
setUserLoginId(response.userId);
} else {
setUserLoginId(null);
}
} catch (error) {
setUserLoginId(null);
}
}
useShallowEffect(() => {
handleLoadMasterReport();
@@ -46,7 +63,8 @@ export default function Forum_ReportPosting({
}
};
if (!listReport) return <CustomSkeleton height={50} width={"100%"} />;
if (!listReport || !userLoginId)
return <CustomSkeleton height={400} width={"100%"} />;
return (
<>

View File

@@ -1,25 +1,45 @@
"use client";
import { RouterForum } from "@/lib/router_hipmi/router_forum";
import { Button, Group, Stack, Textarea } from "@mantine/core";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import { forum_funCreateReportPosting } from "../../fun/create/fun_create_report_posting";
import { apiNewGetUserIdByToken } from "@/app_modules/_global/lib/api_fetch_global";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { forum_funCreateReportPostingLainnya } from "../../fun/create/fun_create_report_posting_lainnya";
import mqtt_client from "@/util/mqtt_client";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin";
import { RouterForum } from "@/lib/router_hipmi/router_forum";
import { clientLogger } from "@/util/clientLogger";
import mqtt_client from "@/util/mqtt_client";
import { Button, Group, Stack, Textarea } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import { forum_funCreateReportPostingLainnya } from "../../fun/create/fun_create_report_posting_lainnya";
export default function Forum_ReportPostingLainnya({
userLoginId,
}: {
userLoginId: string;
}) {
export default function Forum_ReportPostingLainnya() {
const param = useParams<{ id: string }>();
const postingId = param.id;
const [deskripsi, setDeskripsi] = useState("");
const [userLoginId, setUserLoginId] = useState<string | null>(null);
useShallowEffect(() => {
handleGetUserLoginId();
}, []);
async function handleGetUserLoginId() {
try {
const response = await apiNewGetUserIdByToken();
if (response.success) {
setUserLoginId(response.userId);
} else {
setUserLoginId(null);
}
} catch (error) {
setUserLoginId(null);
}
}
if (!userLoginId) {
return <CustomSkeleton height={400} width={"100%"} />;
}
return (
<>