From 1ea8489fb7c64c5f44facf9de1346a4992ab2e74 Mon Sep 17 00:00:00 2001 From: bicochan Date: Thu, 8 May 2025 19:24:38 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/features/src/entities/post/api/post-service.ts | 7 ++++++- .../features/src/entities/post/model/post-interface.ts | 2 +- apps/common/features/src/widgets/post/ui/post-action.tsx | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/common/features/src/entities/post/api/post-service.ts b/apps/common/features/src/entities/post/api/post-service.ts index dd145de23..a07fc4d2a 100644 --- a/apps/common/features/src/entities/post/api/post-service.ts +++ b/apps/common/features/src/entities/post/api/post-service.ts @@ -53,9 +53,14 @@ export class PostApiService implements PostService { return response.data; } - public async deletePost(bbsId: string, pstNo: string): Promise { + public async deletePost( + bbsId: string, + pstNo: string, + pstPswd?: string, + ): Promise { await client.delete( `${ENDPOINT.BOARD_SERVICE.POSTS_USER}/${bbsId}/${pstNo}`, + { params: { pstPswd } }, ); } } diff --git a/apps/common/features/src/entities/post/model/post-interface.ts b/apps/common/features/src/entities/post/model/post-interface.ts index 09f08ac31..c1053cca9 100644 --- a/apps/common/features/src/entities/post/model/post-interface.ts +++ b/apps/common/features/src/entities/post/model/post-interface.ts @@ -79,5 +79,5 @@ export interface PostService { pstNo: string, data: PostUpdateFormData, ): Promise; - deletePost(bbsId: string, pstNo: string): Promise; + deletePost(bbsId: string, pstNo: string, pstPswd?: string): Promise; } diff --git a/apps/common/features/src/widgets/post/ui/post-action.tsx b/apps/common/features/src/widgets/post/ui/post-action.tsx index c08c75694..6cc9fc100 100644 --- a/apps/common/features/src/widgets/post/ui/post-action.tsx +++ b/apps/common/features/src/widgets/post/ui/post-action.tsx @@ -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); }, });