Skip to content

Commit 57915eb

Browse files
committed
[FE-263]fix: 레코드 삭제시 화면 업데이트 되도록
- 레코드 작성자를 실제 레코드 작성자로 변경
1 parent ba29dc4 commit 57915eb

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/pages/Setting/ManageComment/ManageComment.tsx

Lines changed: 16 additions & 9 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)
@@ -58,6 +59,7 @@ function ManageComment() {
5859
if (currentReplyCommentId === toDeleteReply[tdr].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)