feat: 게시글 삭제 기능 작업
This commit is contained in:
@@ -53,9 +53,14 @@ export class PostApiService implements PostService {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async deletePost(bbsId: string, pstNo: string): Promise<void> {
|
||||
public async deletePost(
|
||||
bbsId: string,
|
||||
pstNo: string,
|
||||
pstPswd?: string,
|
||||
): Promise<void> {
|
||||
await client.delete(
|
||||
`${ENDPOINT.BOARD_SERVICE.POSTS_USER}/${bbsId}/${pstNo}`,
|
||||
{ params: { pstPswd } },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,5 +79,5 @@ export interface PostService {
|
||||
pstNo: string,
|
||||
data: PostUpdateFormData,
|
||||
): Promise<Post>;
|
||||
deletePost(bbsId: string, pstNo: string): Promise<void>;
|
||||
deletePost(bbsId: string, pstNo: string, pstPswd?: string): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useMutation } from "@tanstack/react-query";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { Button } from "@common/components";
|
||||
import { PostApi } from "@/entities/post";
|
||||
import { useAlertStore, useUserStore } from "@/shared/lib";
|
||||
|
||||
type PostActionProps = {
|
||||
bbsId: string;
|
||||
@@ -16,10 +17,13 @@ function PostAction({ children, bbsId, pstNo }: PostActionProps) {
|
||||
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const { userInfo } = useUserStore((state) => state);
|
||||
|
||||
const { mutate: deletePost } = useMutation({
|
||||
mutationFn: () => PostApi.deletePost(bbsId, pstNo),
|
||||
mutationFn: () => PostApi.deletePost(bbsId, pstNo, userInfo?.userUnqId),
|
||||
onSuccess: () => {
|
||||
router.back();
|
||||
alert("삭제되었습니다.", router.back);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user