File tree 4 files changed +41
-3
lines changed
BoardCardPackage/BoardCardModalPackage
4 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -52,14 +52,14 @@ export default function BoardCardModalComments({
52
52
>
53
53
< li className = "w-full rounded-[10px] hover:bg-primary-50 active:bg-primary-100" >
54
54
< button className = "w-full p-3 body1" type = "button" >
55
- 차단하기
55
+ 삭제하기
56
56
</ button >
57
57
</ li >
58
- < li className = "w-full rounded-[10px] hover:bg-primary-50 active:bg-primary-100" >
58
+ { /* <li className="w-full rounded-[10px] hover:bg-primary-50 active:bg-primary-100">
59
59
<button className="w-full p-3 body1" type="button">
60
60
신고하기
61
61
</button>
62
- </ li >
62
+ </li> */ }
63
63
< li className = "w-full rounded-[10px] hover:bg-primary-50 active:bg-primary-100" >
64
64
< button
65
65
className = "w-full p-3 body1"
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export default function ModalBoardCard({ board }: { board: Board }) {
11
11
userName = { board . writer }
12
12
userImage = { board . userImageUrl }
13
13
createdDate = { board . createdDate }
14
+ boardId = { board . id }
14
15
/>
15
16
< BoardCardModal . Content
16
17
type = "modal"
Original file line number Diff line number Diff line change
1
+ import { deleteComment } from '@/service/board' ;
2
+ import Toast from '@/utils/notification' ;
3
+ import { useMutation } from '@tanstack/react-query' ;
4
+
5
+ export default function useDeleteComment ( ) {
6
+ const { mutate, isLoading } = useMutation ( {
7
+ mutationFn : ( { boardId, replyId } : { boardId : number ; replyId : number } ) =>
8
+ deleteComment ( boardId , replyId ) ,
9
+ onSuccess : ( ) => {
10
+ Toast . success ( '댓글이 성공적으로 삭제 되었습니다.' ) ;
11
+ } ,
12
+ onError : ( ) => {
13
+ Toast . error ( '댓글을 삭제하지 못했습니다. 잠시후 다시 시도해주세요.🥲' ) ;
14
+ } ,
15
+ } ) ;
16
+ return { mutate, isLoading } ;
17
+ }
Original file line number Diff line number Diff line change @@ -74,6 +74,26 @@ export async function getCommentList(
74
74
}
75
75
}
76
76
77
+ export async function deleteComment ( boardId : number , replyId : number ) {
78
+ const url = `/endpoint/api/reply/remove/${ boardId } /${ replyId } ` ;
79
+ try {
80
+ const response = await fetch ( url ) ;
81
+ if ( response . status === 401 ) {
82
+ throw new AuthError ( '로그인이 필요한 서비스입니다.' ) ;
83
+ }
84
+ if ( ! response . ok ) {
85
+ throw new Error ( `서버오류:${ response . status } ` ) ;
86
+ }
87
+ return await response . json ( ) ;
88
+ } catch ( error ) {
89
+ if ( error instanceof AuthError ) {
90
+ window . location . replace ( '/auth/login' ) ;
91
+ alert ( error . message ) ;
92
+ }
93
+ throw error ;
94
+ }
95
+ }
96
+
77
97
export async function addBookmarkBoard ( boardId : number ) {
78
98
const url = `endpoint/api/bookmark/add?boardId=${ boardId } ` ;
79
99
try {
You can’t perform that action at this time.
0 commit comments