Fix QC
# fix - authentication - profile - pencarian user - forum ## No issue
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
"use client";
|
||||
|
||||
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
|
||||
import {
|
||||
Stack,
|
||||
Grid,
|
||||
Avatar,
|
||||
Divider,
|
||||
Text,
|
||||
Group,
|
||||
Badge,
|
||||
Loader,
|
||||
} from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import moment from "moment";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import {
|
||||
IconCircleFilled,
|
||||
IconDots,
|
||||
IconEdit,
|
||||
IconFlag3,
|
||||
IconMessageCircle,
|
||||
IconTrash,
|
||||
} from "@tabler/icons-react";
|
||||
import { IconCircle } from "@tabler/icons-react";
|
||||
import { IoIosMore } from "react-icons/io";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { useState } from "react";
|
||||
import ComponentForum_PostingButtonMore from "../more_button/posting_button_more";
|
||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2";
|
||||
import { data } from "autoprefixer";
|
||||
import ComponentForum_BerandaButtonMore from "./beranda_button_more";
|
||||
|
||||
export default function ComponentForum_BerandaAuthorNameOnHeader({
|
||||
authorId,
|
||||
postingId,
|
||||
imagesId,
|
||||
authorName,
|
||||
tglPublish,
|
||||
isPembatas,
|
||||
isMoreButton,
|
||||
statusId,
|
||||
userLoginId,
|
||||
setData,
|
||||
}: {
|
||||
authorId?: string;
|
||||
postingId?: string;
|
||||
imagesId?: string;
|
||||
authorName?: string;
|
||||
tglPublish?: Date;
|
||||
isPembatas?: boolean;
|
||||
isMoreButton?: boolean;
|
||||
statusId?: string;
|
||||
userLoginId: string;
|
||||
setData?: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"}>
|
||||
<Grid>
|
||||
<Grid.Col
|
||||
span={"content"}
|
||||
onClick={() => {
|
||||
if (authorId) {
|
||||
setLoading(true);
|
||||
router.push(RouterForum.forumku + authorId);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan("Id tidak ditemukan");
|
||||
}
|
||||
}}
|
||||
>
|
||||
{loading ? (
|
||||
<Loader color="gray" variant="dots" />
|
||||
) : (
|
||||
<Avatar
|
||||
size={40}
|
||||
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
|
||||
radius={"xl"}
|
||||
bg={"gray.1"}
|
||||
src={
|
||||
imagesId
|
||||
? RouterProfile.api_foto_profile + imagesId
|
||||
: "/aset/global/avatar.png"
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</Grid.Col>
|
||||
|
||||
<Grid.Col span={"auto"}>
|
||||
<Stack justify="center" h={"100%"} spacing={0}>
|
||||
<Grid>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1} fz={"sm"} fw={"bold"}>
|
||||
{authorName ? authorName : "Nama author "}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"content"}></Grid.Col>
|
||||
</Grid>
|
||||
<Badge
|
||||
w={70}
|
||||
variant="light"
|
||||
color={(statusId as any) === 1 ? "green" : "red"}
|
||||
>
|
||||
<Text fz={10}>
|
||||
{(statusId as any) === 1 ? "Open" : "Close"}
|
||||
</Text>
|
||||
</Badge>
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
|
||||
<Grid.Col span={"content"}>
|
||||
<Group position="center" spacing={"xs"}>
|
||||
<Group spacing={3}>
|
||||
<Text c={"gray"} fz={"sm"}>
|
||||
{tglPublish
|
||||
? tglPublish.toLocaleDateString(["id-ID"], {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
})
|
||||
: new Date().toLocaleDateString(["id-ID"], {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
})}
|
||||
<IconCircle
|
||||
size={5}
|
||||
color="gray"
|
||||
style={{ marginLeft: "5px" }}
|
||||
/>
|
||||
</Text>
|
||||
</Group>
|
||||
|
||||
{isMoreButton ? (
|
||||
<Group position="right">
|
||||
<ComponentForum_BerandaButtonMore
|
||||
authorId={authorId}
|
||||
postingId={postingId as any}
|
||||
statusId={statusId}
|
||||
userLoginId={userLoginId}
|
||||
setData={setData}
|
||||
/>
|
||||
</Group>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Group>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
{isPembatas ? <Divider /> : ""}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
352
src/app_modules/forum/component/beranda/beranda_button_more.tsx
Normal file
352
src/app_modules/forum/component/beranda/beranda_button_more.tsx
Normal file
@@ -0,0 +1,352 @@
|
||||
"use client";
|
||||
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import {
|
||||
Drawer,
|
||||
Stack,
|
||||
Grid,
|
||||
Button,
|
||||
Modal,
|
||||
Title,
|
||||
Group,
|
||||
ActionIcon,
|
||||
Text,
|
||||
Box,
|
||||
Center,
|
||||
Loader,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconTrash,
|
||||
IconEdit,
|
||||
IconFlag3,
|
||||
IconDots,
|
||||
IconSquareRoundedX,
|
||||
IconSquareCheck,
|
||||
} from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { createStyles } from "@mantine/core";
|
||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2";
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_forum_loading_edit_posting } from "../../global_state";
|
||||
import ComponentForum_LoadingDrawer from "../loading_drawer";
|
||||
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_BerandaButtonMore({
|
||||
authorId,
|
||||
postingId,
|
||||
statusId,
|
||||
userLoginId,
|
||||
setData,
|
||||
}: {
|
||||
authorId: any;
|
||||
postingId?: any;
|
||||
statusId?: any;
|
||||
userLoginId: any;
|
||||
setData: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
// modal & drawer
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [openDel, setOpenDel] = useState(false);
|
||||
const [openStatusClose, setOpenStatusClose] = useState(false);
|
||||
|
||||
// loading
|
||||
const [loadingEdit, setLoadingEdit] = useState(false);
|
||||
const [loadingReport, setLoadingReport] = useState(false);
|
||||
|
||||
// if (loadingEdit) return <ComponentGlobal_V2_LoadingPage />;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
// className={classes.radiusCustom}
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
withCloseButton={false}
|
||||
overlayProps={{ opacity: 0.1, blur: 1 }}
|
||||
position="bottom"
|
||||
size={"auto"}
|
||||
>
|
||||
<Stack>
|
||||
{userLoginId != authorId ? (
|
||||
""
|
||||
) : (
|
||||
<Stack>
|
||||
<Grid
|
||||
onClick={() => {
|
||||
close();
|
||||
setOpenStatusClose(true);
|
||||
}}
|
||||
>
|
||||
<Grid.Col span={"content"}>
|
||||
{statusId === 1 ? (
|
||||
<IconSquareRoundedX color="red" />
|
||||
) : (
|
||||
<IconSquareCheck />
|
||||
)}
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
{statusId === 1 ? (
|
||||
<Text c={"red"}>Tutup forum</Text>
|
||||
) : (
|
||||
<Text>Buka forum</Text>
|
||||
)}
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Grid
|
||||
onClick={() => {
|
||||
close();
|
||||
setOpenDel(true);
|
||||
}}
|
||||
>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconTrash color="red" />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text c={"red"}>Hapus</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
<Grid
|
||||
onClick={() => {
|
||||
setLoadingEdit(true);
|
||||
router.push(RouterForum.edit_posting + postingId);
|
||||
}}
|
||||
>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconEdit color={loadingEdit ? "gray" : "black"} />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Group>
|
||||
<Text c={loadingEdit ? "gray" : "black"}>Edit posting</Text>{" "}
|
||||
{loadingEdit ? <Loader size={"sm"} /> : ""}
|
||||
</Group>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{userLoginId == authorId ? (
|
||||
""
|
||||
) : (
|
||||
<Grid
|
||||
onClick={() => {
|
||||
setLoadingReport(true);
|
||||
router.push(RouterForum.report_posting + postingId);
|
||||
}}
|
||||
>
|
||||
<Grid.Col span={"content"}>
|
||||
<IconFlag3 color={loadingReport ? "gray" : "black"} />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Group>
|
||||
<Text c={loadingReport ? "gray" : "black"}>
|
||||
Laporkan posting
|
||||
</Text>{" "}
|
||||
{loadingReport ? <Loader size={"sm"} /> : ""}
|
||||
</Group>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
)}
|
||||
|
||||
<Button variant="outline" radius={"xl"} onClick={close}>
|
||||
Batal
|
||||
</Button>
|
||||
</Stack>
|
||||
</Drawer>
|
||||
|
||||
<Modal
|
||||
opened={openDel}
|
||||
onClose={() => {
|
||||
setOpenDel(false);
|
||||
}}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
>
|
||||
<ButtonDelete
|
||||
postingId={postingId}
|
||||
setOpenDel={setOpenDel}
|
||||
setData={setData}
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
opened={openStatusClose}
|
||||
onClose={() => setOpenStatusClose(false)}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
>
|
||||
<ButtonStatus
|
||||
postingId={postingId}
|
||||
setOpenStatus={setOpenStatusClose}
|
||||
statusId={statusId}
|
||||
setData={setData}
|
||||
userLoginId={userLoginId}
|
||||
authorId={authorId}
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
<ActionIcon variant="transparent" onClick={() => open()}>
|
||||
<IconDots size={20} />
|
||||
</ActionIcon>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
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(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);
|
||||
}
|
||||
});
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Title order={6}>Yakin menghapus posting ini ?</Title>
|
||||
<Group position="center">
|
||||
<Button radius={"xl"} onClick={() => setOpenDel(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loading ? true : false}
|
||||
color="red"
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
async (res) => {
|
||||
if (res.status === 200) {
|
||||
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(
|
||||
async (res) => {
|
||||
if (res.status === 200) {
|
||||
await forum_getListAllPosting().then((val) => {
|
||||
setData(val as any);
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(`Forum Dibuka`, 2000);
|
||||
setLoading(true);
|
||||
});
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
{statusId === 1 ? (
|
||||
<Title order={6}>Yakin menutup forum ini ?</Title>
|
||||
) : (
|
||||
<Title order={6}>Yakin membuka forum ini ?</Title>
|
||||
)}
|
||||
<Group position="center">
|
||||
<Button radius={"xl"} onClick={() => setOpenStatus(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
|
||||
{statusId === 1 ? (
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loading ? true : false}
|
||||
color="orange"
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onTutupForum();
|
||||
}}
|
||||
>
|
||||
Tutup
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loading ? true : false}
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onBukaForum();
|
||||
}}
|
||||
>
|
||||
Buka
|
||||
</Button>
|
||||
)}
|
||||
</Group>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
101
src/app_modules/forum/component/beranda/beranda_card.tsx
Normal file
101
src/app_modules/forum/component/beranda/beranda_card.tsx
Normal file
@@ -0,0 +1,101 @@
|
||||
"use client";
|
||||
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import { Stack, Card, Group, ActionIcon, Divider, Text } from "@mantine/core";
|
||||
import { IconMessageCircle, IconMessageCircleOff } from "@tabler/icons-react";
|
||||
|
||||
|
||||
|
||||
import { useState } from "react";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useAtom } from "jotai";
|
||||
|
||||
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
|
||||
import { IconMessageCircleX } from "@tabler/icons-react";
|
||||
import { MODEL_FORUM_POSTING } from "../../model/interface";
|
||||
import ComponentForum_BerandaAuthorNameOnHeader from "./beranda_author_header";
|
||||
|
||||
export default function ComponentForum_BerandaCardView({
|
||||
data,
|
||||
setData,
|
||||
setLoadingKomen,
|
||||
setLoadingDetail,
|
||||
userLoginId,
|
||||
}: {
|
||||
data: MODEL_FORUM_POSTING[];
|
||||
setData: any;
|
||||
setLoadingKomen: any;
|
||||
setLoadingDetail: any;
|
||||
userLoginId: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xl"}>
|
||||
{data.map((e, i) => (
|
||||
<Card key={i}>
|
||||
<Card.Section>
|
||||
{/* <pre>{JSON.stringify(e.Author.id, null, 2)}</pre>
|
||||
<pre>{JSON.stringify(userLoginId, null, 2)}</pre> */}
|
||||
|
||||
<ComponentForum_BerandaAuthorNameOnHeader
|
||||
authorName={e?.Author?.Profile?.name}
|
||||
imagesId={e?.Author?.Profile?.imagesId}
|
||||
tglPublish={e?.createdAt}
|
||||
isMoreButton={true}
|
||||
authorId={e?.Author?.id}
|
||||
postingId={e?.id}
|
||||
statusId={e?.ForumMaster_StatusPosting?.id}
|
||||
userLoginId={userLoginId}
|
||||
setData={setData}
|
||||
/>
|
||||
</Card.Section>
|
||||
<Card.Section
|
||||
sx={{ zIndex: 0 }}
|
||||
p={"lg"}
|
||||
onClick={() => {
|
||||
// console.log("halaman forum");
|
||||
setLoadingDetail(true);
|
||||
router.push(RouterForum.main_detail + e.id);
|
||||
}}
|
||||
>
|
||||
<Text fz={"sm"} lineClamp={4}>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.diskusi }} />
|
||||
</Text>
|
||||
</Card.Section>
|
||||
<Card.Section>
|
||||
<Stack>
|
||||
<Group spacing={"xs"} px={"sm"}>
|
||||
<ActionIcon
|
||||
// loading={loadingKomen ? true : false}
|
||||
variant="transparent"
|
||||
sx={{ zIndex: 1 }}
|
||||
onClick={() => {
|
||||
(e?.ForumMaster_StatusPosting.id as any) === 1
|
||||
? (router.push(RouterForum.komentar + e?.id),
|
||||
setLoadingKomen(true))
|
||||
: router.push(RouterForum.main_detail + e?.id);
|
||||
}}
|
||||
>
|
||||
{(e?.ForumMaster_StatusPosting?.id as any) === 1 ? (
|
||||
<IconMessageCircle color="gray" size={25} />
|
||||
) : (
|
||||
<IconMessageCircleX color="gray" size={25} />
|
||||
)}
|
||||
</ActionIcon>
|
||||
|
||||
{/* <TotalKomentar postingId={e?.id} /> */}
|
||||
|
||||
<Text c={"gray"}>{e?._count}</Text>
|
||||
</Group>
|
||||
<Divider />
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
))}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -32,9 +32,8 @@ export default function ComponentForum_HeaderTamplate({
|
||||
bg?: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
if (loading) return <ComponentGlobal_V2_LoadingPage />;
|
||||
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header
|
||||
@@ -47,6 +46,7 @@ export default function ComponentForum_HeaderTamplate({
|
||||
<ActionIcon variant="transparent" disabled></ActionIcon>
|
||||
) : (
|
||||
<ActionIcon
|
||||
loading={isLoading ? true : false}
|
||||
variant="transparent"
|
||||
onClick={() => {
|
||||
setLoading(true);
|
||||
|
||||
@@ -29,6 +29,7 @@ import { useDisclosure } from "@mantine/hooks";
|
||||
import { useState } from "react";
|
||||
import ComponentForum_PostingButtonMore from "../more_button/posting_button_more";
|
||||
import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2";
|
||||
import { data } from "autoprefixer";
|
||||
|
||||
export default function ComponentForum_PostingAuthorNameOnHeader({
|
||||
authorId,
|
||||
@@ -40,6 +41,7 @@ export default function ComponentForum_PostingAuthorNameOnHeader({
|
||||
isMoreButton,
|
||||
statusId,
|
||||
userLoginId,
|
||||
setData,
|
||||
}: {
|
||||
authorId?: string;
|
||||
postingId?: string;
|
||||
@@ -50,6 +52,7 @@ export default function ComponentForum_PostingAuthorNameOnHeader({
|
||||
isMoreButton?: boolean;
|
||||
statusId?: string;
|
||||
userLoginId: string;
|
||||
setData?:any
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -128,6 +131,7 @@ export default function ComponentForum_PostingAuthorNameOnHeader({
|
||||
/>
|
||||
</Text>
|
||||
</Group>
|
||||
|
||||
{isMoreButton ? (
|
||||
<Group position="right">
|
||||
<ComponentForum_PostingButtonMore
|
||||
@@ -135,6 +139,7 @@ export default function ComponentForum_PostingAuthorNameOnHeader({
|
||||
postingId={postingId as any}
|
||||
statusId={statusId}
|
||||
userLoginId={userLoginId}
|
||||
setData={setData}
|
||||
/>
|
||||
</Group>
|
||||
) : (
|
||||
|
||||
@@ -17,14 +17,16 @@ import { IconMessageCircleX } from "@tabler/icons-react";
|
||||
|
||||
export default function ComponentForum_MainCardView({
|
||||
data,
|
||||
setData,
|
||||
setLoadingKomen,
|
||||
setLoadingDetail,
|
||||
userLoginId,
|
||||
}: {
|
||||
data: MODEL_FORUM_POSTING[];
|
||||
setData: any,
|
||||
setLoadingKomen: any;
|
||||
setLoadingDetail: any;
|
||||
userLoginId: any
|
||||
userLoginId: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
@@ -33,7 +35,9 @@ export default function ComponentForum_MainCardView({
|
||||
{data.map((e, i) => (
|
||||
<Card key={i}>
|
||||
<Card.Section>
|
||||
{/* <pre>{JSON.stringify( typeof e.ForumMaster_StatusPosting.id)}</pre> */}
|
||||
{/* <pre>{JSON.stringify(e.Author.id, null, 2)}</pre>
|
||||
<pre>{JSON.stringify(userLoginId, null, 2)}</pre> */}
|
||||
|
||||
<ComponentForum_PostingAuthorNameOnHeader
|
||||
authorName={e?.Author?.Profile?.name}
|
||||
imagesId={e?.Author?.Profile?.imagesId}
|
||||
@@ -43,6 +47,7 @@ export default function ComponentForum_MainCardView({
|
||||
postingId={e?.id}
|
||||
statusId={e?.ForumMaster_StatusPosting?.id}
|
||||
userLoginId={userLoginId}
|
||||
setData={setData}
|
||||
/>
|
||||
</Card.Section>
|
||||
<Card.Section
|
||||
|
||||
@@ -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