Skip to content

Commit 434456a

Browse files
authored
Merge pull request #275 from ItRecode/FE-263
[FE-263]fix: λ ˆμ½”λ“œ μ‚­μ œμ‹œ ν™”λ©΄ μ—…λ°μ΄νŠΈ λ˜λ„λ‘
2 parents c4a8510 + a327701 commit 434456a

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

β€Žsrc/pages/Setting/ManageComment/ManageComment.tsxβ€Ž

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import BackButton from '@components/BackButton'
33
import { ReactComponent as ReplyCheckButton } from '@assets/settings_icon/reply_check.svg'
44
import { ReactComponent as CheckBoxButton } from '@assets/settings_icon/check_box.svg'
55
import { QueryClient, useQuery } from '@tanstack/react-query'
6-
import React, { useState } from 'react'
6+
import React, { useEffect, useState } from 'react'
77
import { useNavigate } from 'react-router-dom'
88
import { DeleteReplyType, MyCommentType, MyRepliesType } from 'types/replyData'
99
import CommentSection from './CommentSection'
@@ -17,17 +17,18 @@ import Loading from '@components/Loading'
1717
function 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
/>

β€Žsrc/types/replyData.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface MyRepliesType {
3333
recordCreatedAt: string
3434
recordId: number
3535
title: string
36+
recordWriterNickname: string
3637
}
3738

3839
export interface DeleteReplyType {

0 commit comments

Comments
Β (0)