diff --git a/apps/web/src/apis/community/deletePost.ts b/apps/web/src/apis/community/deletePost.ts index 01ed96b1..7390a355 100644 --- a/apps/web/src/apis/community/deletePost.ts +++ b/apps/web/src/apis/community/deletePost.ts @@ -59,6 +59,9 @@ const useDeletePost = () => { // 게시글 목록 페이지 이동 router.replace(`/community/${variables.boardCode || "FREE"}`); }, + onError: () => { + showIconToast("logo", "게시글 삭제에 실패했습니다. 잠시 후 다시 시도해주세요."); + }, }); }; diff --git a/apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx b/apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx index 88ae377a..89dacbb6 100644 --- a/apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx +++ b/apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx @@ -7,6 +7,7 @@ import { useDeletePost } from "@/apis/community"; import useBlockCommunityUser from "@/app/community/_hooks/useBlockCommunityUser"; import ReportPanel from "@/components/ui/ReportPanel"; import { showIconToast } from "@/lib/toast/showIconToast"; +import { customConfirm } from "@/lib/zustand/useConfirmModalStore"; import { IconSetting } from "@/public/svgs/mentor"; const useClickOutside = (ref: RefObject, handler: (event: MouseEvent | TouchEvent) => void) => { @@ -52,7 +53,7 @@ type KebabMenuProps = { const KebabMenu = ({ postId, boardCode, isOwner = false, authorId }: KebabMenuProps) => { const dropdownRef = useRef(null); - const { mutate: deletePost } = useDeletePost(); + const { mutate: deletePost, isPending: isDeleting } = useDeletePost(); const router = useRouter(); const { handleBlockUser, isBlocking } = useBlockCommunityUser({ onBlocked: () => router.replace(`/community/${boardCode}`), @@ -77,6 +78,23 @@ const KebabMenu = ({ postId, boardCode, isOwner = false, authorId }: KebabMenuPr } }; + const handleDeletePost = async () => { + setIsDropdownOpen(false); + + const confirmed = await customConfirm({ + title: "게시글 삭제", + content: "삭제한 게시글은 복구할 수 없습니다.\n정말 삭제하시겠습니까?", + approveMessage: "삭제하기", + rejectMessage: "취소", + }); + + if (!confirmed) { + return; + } + + deletePost({ postId, boardCode }); + }; + return (