Skip to content

Commit

Permalink
Fix: 댓글 삭제시 모달창 보여주기
Browse files Browse the repository at this point in the history
  • Loading branch information
dongree committed Sep 2, 2023
1 parent 86ad00b commit 09d946b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/memo/CommentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { Comment } from '@/types/comment';
import Link from 'next/link';
import { deleteComeent, updateComment } from '@/service/comments';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { useContext, useState } from 'react';
import BlueBtn from '../shared/btn/BlueBtn';
import WhiteBtn from '../shared/btn/WhiteBtn';
import { ModalContext } from '@/context/ModalProvider';

type Props = {
commentProperty: Comment;
Expand All @@ -25,6 +26,7 @@ export default function CommentItem({ commentProperty, isMyComment }: Props) {

const [updatedText, setUpdatedText] = useState(commentText);
const [isEditMode, setIsEditMode] = useState(false);
const { open } = useContext(ModalContext);
const router = useRouter();

return (
Expand Down Expand Up @@ -73,8 +75,10 @@ export default function CommentItem({ commentProperty, isMyComment }: Props) {
</button>
<button
onClick={() => {
deleteComeent(id);
router.refresh();
open('댓글을 삭제하시겠습니까?', () => {
deleteComeent(id);
router.refresh();
});
}}
>
삭제
Expand Down

0 comments on commit 09d946b

Please sign in to comment.