feat: 게시판 상세 및 삭제 기능 작업

This commit is contained in:
2025-04-29 19:56:56 +09:00
parent 50b97a466e
commit 8a9e4bbf96
10 changed files with 176 additions and 16 deletions
@@ -0,0 +1,51 @@
import { useRouter } from "next/navigation";
import { useMutation } from "@tanstack/react-query";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
import { Button } from "@common/components/ui";
import { PostApi } from "@/entities/post";
type PostActionProps = {
bbsId: string;
pstNo: string;
children: React.ReactNode;
};
function PostAction({ children, bbsId, pstNo }: PostActionProps) {
const router = useRouter();
const { confirm } = useConfirm();
const { mutate: deletePost } = useMutation({
mutationFn: () => PostApi.deletePost(bbsId, pstNo),
onSuccess: () => {
router.back();
},
});
const onDelete = async () => {
if (await confirm("삭제하시겠습니까?")) deletePost();
};
return (
<div>
{children}
<div className="flex justify-center gap-4 pb-12 pt-10">
<Button
size="lg"
color="white"
type="button"
onClick={() => router.back()}
>
목록
</Button>
<Button size="lg" type="submit">
수정
</Button>
<Button size="lg" color="red" type="button" onClick={onDelete}>
삭제
</Button>
</div>
</div>
);
}
export { PostAction };