Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/web/src/apis/community/deletePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const useDeletePost = () => {
// ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก ํŽ˜์ด์ง€ ์ด๋™
router.replace(`/community/${variables.boardCode || "FREE"}`);
},
onError: () => {
showIconToast("logo", "๊ฒŒ์‹œ๊ธ€ ์‚ญ์ œ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ์ž ์‹œ ํ›„ ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”.");
},
Comment on lines +62 to +64

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Suppress the global error toast for this mutation

When the delete request fails with a non-401 Axios error, MutationCache.onError in apps/web/src/lib/react-query/queryClient.ts already calls showIconToast, and this callback emits another toast with a usually different message. Because toast deduplication uses the icon and message together, users receive two failure notifications for one request; either set meta: SKIP_GLOBAL_ERROR_TOAST_META on this mutation or rely solely on the global handler.

Useful? React with ๐Ÿ‘ย / ๐Ÿ‘Ž.

});
};

Expand Down
30 changes: 23 additions & 7 deletions apps/web/src/app/community/[boardCode]/[postId]/KebabMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement | null>, handler: (event: MouseEvent | TouchEvent) => void) => {
Expand Down Expand Up @@ -52,7 +53,7 @@ type KebabMenuProps = {

const KebabMenu = ({ postId, boardCode, isOwner = false, authorId }: KebabMenuProps) => {
const dropdownRef = useRef<HTMLDivElement>(null);
const { mutate: deletePost } = useDeletePost();
const { mutate: deletePost, isPending: isDeleting } = useDeletePost();
const router = useRouter();
const { handleBlockUser, isBlocking } = useBlockCommunityUser({
onBlocked: () => router.replace(`/community/${boardCode}`),
Expand All @@ -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 (
<div className="relative" ref={dropdownRef}>
<button
Expand Down Expand Up @@ -136,12 +154,10 @@ const KebabMenu = ({ postId, boardCode, isOwner = false, authorId }: KebabMenuPr
</li>
<li key={"์‚ญ์ œํ•˜๊ธฐ"}>
<button
onClick={() => {
if (confirm("์ •๋ง๋กœ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?")) {
deletePost({ postId, boardCode });
}
}}
className={`flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-gray-700 typo-regular-2 hover:bg-k-50`}
type="button"
onClick={() => void handleDeletePost()}
disabled={isDeleting}
className="flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-gray-700 typo-regular-2 hover:bg-k-50 disabled:cursor-not-allowed disabled:opacity-50"
>
<span>{"์‚ญ์ œํ•˜๊ธฐ"}</span>
</button>
Expand Down
Loading