diff --git a/apps/web/src/apis/reports/postReport.ts b/apps/web/src/apis/reports/postReport.ts index acb3f013..1a5d4beb 100644 --- a/apps/web/src/apis/reports/postReport.ts +++ b/apps/web/src/apis/reports/postReport.ts @@ -1,7 +1,6 @@ import { useMutation } from "@tanstack/react-query"; import type { AxiosError } from "axios"; -import { useRouter } from "next/navigation"; import { toast } from "@/lib/zustand/useToastStore"; import { reportsApi, type UsePostReportsRequest } from "./api"; @@ -10,12 +9,10 @@ import { reportsApi, type UsePostReportsRequest } from "./api"; * @description 신고 등록 훅 */ const usePostReports = () => { - const router = useRouter(); return useMutation, UsePostReportsRequest>({ mutationFn: reportsApi.postReport, onSuccess: () => { toast.success("신고가 성공적으로 등록되었습니다."); - router.back(); }, onError: (_error) => { toast.error("신고 등록에 실패했습니다. 잠시 후 다시 시도해주세요."); diff --git a/apps/web/src/app/community/[boardCode]/CommunityPageContent.tsx b/apps/web/src/app/community/[boardCode]/CommunityPageContent.tsx index d1177b4f..4d0ac283 100644 --- a/apps/web/src/app/community/[boardCode]/CommunityPageContent.tsx +++ b/apps/web/src/app/community/[boardCode]/CommunityPageContent.tsx @@ -1,14 +1,22 @@ "use client"; import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useMemo, useState } from "react"; import { useGetPostList } from "@/apis/community"; import ButtonTab from "@/components/ui/ButtonTab"; import { COMMUNITY_BOARDS, COMMUNITY_CATEGORIES } from "@/constants/community"; +import useReportedPostsStore from "@/lib/zustand/useReportedPostsStore"; +import type { ListPost } from "@/types/community"; import CommunityRegionSelector from "./CommunityRegionSelector"; import PostCards from "./PostCards"; import PostWriteButton from "./PostWriteButton"; +type ListPostWithAuthor = ListPost & { + postFindSiteUserResponse?: { + id: number; + }; +}; + interface CommunityPageContentProps { boardCode: string; } @@ -16,13 +24,37 @@ interface CommunityPageContentProps { const CommunityPageContent = ({ boardCode }: CommunityPageContentProps) => { const router = useRouter(); const [category, setCategory] = useState("전체"); + const reportedPostIds = useReportedPostsStore((state) => state.reportedPostIds); + const blockedUserIds = useReportedPostsStore((state) => state.blockedUserIds); - // HydrationBoundary로부터 자동으로 prefetch된 데이터 사용 const { data: posts = [] } = useGetPostList({ boardCode, category, }); + const visiblePosts = useMemo(() => { + if (reportedPostIds.length === 0 && blockedUserIds.length === 0) { + return posts; + } + + const reportedIdSet = new Set(reportedPostIds); + const blockedUserIdSet = new Set(blockedUserIds); + + return posts.filter((post) => { + if (reportedIdSet.has(post.id)) { + return false; + } + + const authorId = (post as ListPostWithAuthor).postFindSiteUserResponse?.id; + + if (typeof authorId === "number" && blockedUserIdSet.has(authorId)) { + return false; + } + + return true; + }); + }, [posts, reportedPostIds, blockedUserIds]); + const handleBoardChange = (newBoard: string) => { router.push(`/community/${newBoard}`); }; @@ -49,7 +81,7 @@ const CommunityPageContent = ({ boardCode }: CommunityPageContentProps) => { setChoice={setCategory} style={{ padding: "10px 0 10px 18px" }} /> - {} + {} ); diff --git a/apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx b/apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx index 969fd10b..5582f8dc 100644 --- a/apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx +++ b/apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx @@ -45,9 +45,10 @@ type KebabMenuProps = { postId: number; boardCode: string; isOwner?: boolean; + authorId?: number; }; -const KebabMenu = ({ postId, boardCode, isOwner = false }: KebabMenuProps) => { +const KebabMenu = ({ postId, boardCode, isOwner = false, authorId }: KebabMenuProps) => { const dropdownRef = useRef(null); const { mutate: deletePost } = useDeletePost(); const router = useRouter(); @@ -87,7 +88,7 @@ const KebabMenu = ({ postId, boardCode, isOwner = false }: KebabMenuProps) => {
  • - +