Fix QC
# fix - authentication - profile - pencarian user - forum ## No issue
This commit is contained in:
@@ -37,17 +37,21 @@ import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funEditStatusPostingById } from "../../fun/edit/fun_edit_status_posting_by_id";
|
||||
import { forum_getListAllPosting } from "../../fun/get/get_list_all_posting";
|
||||
import { forum_getListPostingByAuhtorId } from "../../fun/get/get_list_posting_by_author_id";
|
||||
|
||||
export default function ComponentForum_PostingButtonMore({
|
||||
authorId,
|
||||
postingId,
|
||||
statusId,
|
||||
userLoginId,
|
||||
setData,
|
||||
}: {
|
||||
authorId: any;
|
||||
postingId?: any;
|
||||
statusId?: any;
|
||||
userLoginId: any;
|
||||
setData: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
@@ -170,7 +174,11 @@ export default function ComponentForum_PostingButtonMore({
|
||||
centered
|
||||
withCloseButton={false}
|
||||
>
|
||||
<ButtonDelete postingId={postingId} setOpenDel={setOpenDel} />
|
||||
<ButtonDelete
|
||||
postingId={postingId}
|
||||
setOpenDel={setOpenDel}
|
||||
setData={setData}
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
@@ -183,6 +191,9 @@ export default function ComponentForum_PostingButtonMore({
|
||||
postingId={postingId}
|
||||
setOpenStatus={setOpenStatusClose}
|
||||
statusId={statusId}
|
||||
setData={setData}
|
||||
userLoginId={userLoginId}
|
||||
authorId={authorId}
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
@@ -196,18 +207,22 @@ export default function ComponentForum_PostingButtonMore({
|
||||
function ButtonDelete({
|
||||
postingId,
|
||||
setOpenDel,
|
||||
setData,
|
||||
}: {
|
||||
postingId?: string;
|
||||
setOpenDel: any;
|
||||
setData: any;
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
setOpenDel(false);
|
||||
await forum_funDeletePostingById(postingId as any).then((res) => {
|
||||
await forum_funDeletePostingById(postingId as any).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(`Postingan Terhapus`, 2000);
|
||||
setLoading(true);
|
||||
const listForum = await forum_getListAllPosting();
|
||||
setData(listForum);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
@@ -242,37 +257,61 @@ function ButtonStatus({
|
||||
postingId,
|
||||
setOpenStatus,
|
||||
statusId,
|
||||
setData,
|
||||
userLoginId,
|
||||
authorId,
|
||||
}: {
|
||||
postingId?: string;
|
||||
setOpenStatus: any;
|
||||
statusId?: any;
|
||||
setData: any;
|
||||
userLoginId: string;
|
||||
authorId: string;
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onTutupForum() {
|
||||
setOpenStatus(false);
|
||||
|
||||
await forum_funEditStatusPostingById(postingId as any, 2).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(`Forum Ditutup`, 2000);
|
||||
setLoading(true);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
await forum_funEditStatusPostingById(postingId as any, 2).then(
|
||||
async (res) => {
|
||||
if (res.status === 200) {
|
||||
if (userLoginId === authorId) {
|
||||
await forum_getListPostingByAuhtorId(authorId).then((val: any) =>
|
||||
setData(val)
|
||||
);
|
||||
} else {
|
||||
await forum_getListAllPosting().then((val) => setData(val as any));
|
||||
}
|
||||
ComponentGlobal_NotifikasiBerhasil(`Forum Ditutup`, 2000);
|
||||
setLoading(true);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
async function onBukaForum() {
|
||||
setOpenStatus(false);
|
||||
|
||||
await forum_funEditStatusPostingById(postingId as any, 1).then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(`Forum Dibuka`, 2000);
|
||||
setLoading(true);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
await forum_funEditStatusPostingById(postingId as any, 1).then(
|
||||
async (res) => {
|
||||
if (res.status === 200) {
|
||||
if (userLoginId === authorId) {
|
||||
await forum_getListPostingByAuhtorId(authorId).then((val: any) =>
|
||||
setData(val)
|
||||
);
|
||||
} else {
|
||||
await forum_getListAllPosting().then((val) => setData(val as any));
|
||||
}
|
||||
ComponentGlobal_NotifikasiBerhasil(`Forum Dibuka`, 2000);
|
||||
setLoading(true);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user