@@ -3,7 +3,7 @@ import BackButton from '@components/BackButton'
33import { ReactComponent as ReplyCheckButton } from '@assets/settings_icon/reply_check.svg'
44import { ReactComponent as CheckBoxButton } from '@assets/settings_icon/check_box.svg'
55import { QueryClient , useQuery } from '@tanstack/react-query'
6- import React , { useState } from 'react'
6+ import React , { useEffect , useState } from 'react'
77import { useNavigate } from 'react-router-dom'
88import { DeleteReplyType , MyCommentType , MyRepliesType } from 'types/replyData'
99import CommentSection from './CommentSection'
@@ -17,17 +17,18 @@ import Loading from '@components/Loading'
1717function ManageComment ( ) {
1818 const navigate = useNavigate ( )
1919
20- const { data, isLoading, isSuccess } = useQuery (
21- [ 'getMyReply' ] ,
20+ const [ isDeletedMode , setIsDeleteMode ] = useState ( false )
21+ const [ toDeleteReply , setToDeleteReply ] = useState < DeleteReplyType [ ] > ( [ ] )
22+ const [ isToast , setIsToast ] = useState ( false )
23+ const [ deletedReply , setDeletedReply ] = useState ( 0 )
24+
25+ const { data, isLoading, isSuccess, refetch } = useQuery (
26+ [ 'getMyReply' , isToast === true ] ,
2227 ( ) => getMyReply ( 0 , 10 ) ,
2328 {
2429 refetchOnMount : true ,
2530 }
2631 )
27- const [ isDeletedMode , setIsDeleteMode ] = useState ( false )
28- const [ toDeleteReply , setToDeleteReply ] = useState < DeleteReplyType [ ] > ( [ ] )
29- const [ isToast , setIsToast ] = useState ( false )
30- const [ deletedReply , setDeletedReply ] = useState ( 0 )
3132
3233 const handleClickCancel = ( ) => {
3334 setIsDeleteMode ( false )
@@ -54,10 +55,11 @@ function ManageComment() {
5455 toDeleteReply : DeleteReplyType [ ] ,
5556 reply : MyRepliesType
5657 ) : React . ReactNode => {
57- for ( let tdr = 0 ; tdr < toDeleteReply . length ; tdr ++ ) {
58- if ( currentReplyCommentId === toDeleteReply [ tdr ] . commentId ) {
58+ for ( let replyIndex = 0 ; replyIndex < toDeleteReply . length ; replyIndex ++ ) {
59+ if ( currentReplyCommentId === toDeleteReply [ replyIndex ] . commentId ) {
5960 return (
6061 < ReplyCheckButton
62+ className = "w-[18px]"
6163 onClick = { ( ) => handleClickDetailDeleteCancel ( currentReplyCommentId ) }
6264 />
6365 )
@@ -79,16 +81,21 @@ function ManageComment() {
7981 toDeleteReply . forEach ( ( reply , index ) => {
8082 deleteReply ( reply . commentId , String ( reply . recordId ) )
8183 if ( index === toDeleteReply . length - 1 ) {
82- queryClient . invalidateQueries ( [ 'getMyReply' ] )
8384 setIsDeleteMode ( false )
8485 setDeletedReply ( toDeleteReply . length )
8586 setToDeleteReply ( [ ] )
8687 setIsToast ( true )
88+ refetch ( )
8789 }
8890 } )
8991 }
9092 DeleteReplies ( )
9193 }
94+ useEffect ( ( ) => {
95+ if ( isToast ) {
96+ queryClient . invalidateQueries ( [ 'getMyReply' ] )
97+ }
98+ } , [ isToast ] )
9299
93100 const getWidth = ( ) => {
94101 if ( window . innerWidth >= 420 ) {
@@ -148,7 +155,7 @@ function ManageComment() {
148155 recordId = { reply . recordId }
149156 colorName = { `bg-${ reply . colorName } ` }
150157 title = { reply . title }
151- writer = { 'λͺ¨μ‘' }
158+ writer = { reply . recordWriterNickname }
152159 numOfComment = { reply . commentsCount }
153160 iconName = { reply . iconName }
154161 />
0 commit comments