From 7bba1b512ce4c80e77e644dcb343207e11aaa415 Mon Sep 17 00:00:00 2001 From: Chaeyeon1 <66813821+Chaeyeon1@users.noreply.github.com> Date: Thu, 30 Nov 2023 19:51:51 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[categoryId]/[postId]/postId.style.tsx | 76 ++++++++++++------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx b/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx index 8a8c34c..6823087 100644 --- a/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx +++ b/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx @@ -17,6 +17,7 @@ import CheckIcon from '@mui/icons-material/Check'; import CloseIcon from '@mui/icons-material/Close'; import { DeleteReplyApi, PatchReplyLikeApi, putReplyApi } from '@/api/reply-api'; import { Dialog } from '@/components/Dialog/Dialog'; +import { enqueueSnackbar } from 'notistack'; export const ThumbnailArea = styled(Stack)({ width: '100%', @@ -123,13 +124,23 @@ function RepliesComponent({ const deleteReplyQuery = useMutation(DeleteReplyApi, { onSuccess() { - queryClient.invalidateQueries(['reply']); + queryClient.invalidateQueries(['replies']); }, }); - const deleteClick = () => { - deleteReplyQuery.mutate({ replyId: replyId}); + deleteReplyQuery.mutate( + { replyId: replyId }, + { + onSuccess: () => { + queryClient.invalidateQueries(['replies']); + enqueueSnackbar({ message: '댓글이 성공적으로 삭제되었습니다.', variant: 'success' }); + }, + onError: () => { + enqueueSnackbar({ message: '에러입니다.', variant: 'error' }); + }, + }, + ); }; const [isAccept, setIsAccept] = useState(Number); @@ -190,9 +201,15 @@ function RepliesComponent({ }, [introduceData]); return ( - + - + - {nickname} + {nickname} - - {likesCount} - - {isLiked ? ( - - - + {likesCount} + {isLiked ? ( + + + + ) : ( + + + + )} + + {who === 'me(author)' || who === 'me' ? ( + ) : ( - - - + <> )} - - {who === 'me(author)' || who === 'me' ? : <>} - - - {who === 'me(author)' || who === 'me' ? : <>} - - + + + {who === 'me(author)' || who === 'me' ? ( + + ) : ( + <> + )} + + - - - - + {message} - setPutReplyOpen(false)}> 수정하기 @@ -265,7 +284,6 @@ function RepliesComponent({ }} /> - {/* 댓글 상대방 introduction */} setIntroduceOpen(false)}>