From 1b6b921adcae07b5a7612fe9e02d43dd26d216a6 Mon Sep 17 00:00:00 2001 From: sparrowscout Date: Tue, 2 Aug 2022 01:35:51 +0900 Subject: [PATCH] =?UTF-8?q?[Update]=20Modal=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ReplyComment.js | 80 +++++++++++++++------------------- 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/src/components/ReplyComment.js b/src/components/ReplyComment.js index 890c9d9..2a86648 100644 --- a/src/components/ReplyComment.js +++ b/src/components/ReplyComment.js @@ -1,16 +1,16 @@ -import React, { useRef, useState } from "react"; -import { useQueryClient } from "react-query"; -import { useRecoilValue } from "recoil"; -import { UserInfoAtom } from "../atom/atom"; -import person from "../styles/images/person.png"; -import styled from "styled-components"; -import arrow from "../styles/icon/detail/replyarrow.svg"; -import { useEditReply, useRemoveReply } from "../hook/useCommentData"; -import { postApis } from "../api/post"; -import { CommentDate, DeleteBtn, ModiBtn, UpdateBtn } from "./Comment"; -import AlertModal from "./AlertModal"; -import { Btn, GrayLineBtn } from "../styles/style"; -import { Content } from "./ApplyBtn"; +import React, { useRef, useState } from 'react'; +import { useQueryClient } from 'react-query'; +import { useRecoilValue } from 'recoil'; +import { UserInfoAtom } from '../atom/atom'; +import person from '../styles/images/person.png'; +import styled from 'styled-components'; +import arrow from '../styles/icon/detail/replyarrow.svg'; +import { useEditReply, useRemoveReply } from '../hook/useCommentData'; +import { postApis } from '../api/post'; +import { CommentDate, DeleteBtn, ModiBtn, UpdateBtn } from './Comment'; +import AlertModal from './AlertModal'; +import { Btn, GrayLineBtn } from '../styles/style'; +import { Content } from './ApplyBtn'; const ReplyComment = (props) => { const [isEdit, setIsEdit] = useState(false); @@ -22,32 +22,33 @@ const ReplyComment = (props) => { const writeUser = props.data.nickname; const id = props.commentId; - - const replyRef = useRef(""); + const replyId = props.data.commentReplyId; + console.log(replyId); + const replyRef = useRef(''); const queryClient = useQueryClient(); // 대 댓글 수정 const { mutateAsync: editReply } = useEditReply(); - const modifyReplyClick = async (replyId) => { - if (replyRef.current.value === "") { + const modifyReplyClick = async () => { + if (replyRef.current.value === '') { openModiModal(); return; } const replyData = { content: replyRef.current.value, replyId, id }; setIsEdit(false); await editReply(replyData); - queryClient.invalidateQueries("commentList"); + queryClient.invalidateQueries('commentList'); }; // 대 댓글 삭제 const { mutateAsync: removeReply } = useRemoveReply(); - const deleteReplyClick = async (replyId) => { + const deleteReplyClick = async () => { const replyData = { replyId, id }; await removeReply(replyData); - queryClient.invalidateQueries("commentList"); + queryClient.invalidateQueries('commentList'); }; const openModal = () => { @@ -67,7 +68,7 @@ const ReplyComment = (props) => { return ( -
+
사진

{props.data.nickname}

@@ -109,30 +110,19 @@ const ReplyComment = (props) => {
- - -

대 댓글을 삭제하시겠습니까?

-
- 취소 - { - deleteReplyClick(props.data.id); - }} - > - 삭제 - -
-
-
- - - -

내용을 입력해주세요!

-
- 확인 -
-
-
+ + + ); };