diff --git a/src/components/board/CommentForm.tsx b/src/components/board/CommentForm.tsx index c92b132fa..ac4ea2214 100644 --- a/src/components/board/CommentForm.tsx +++ b/src/components/board/CommentForm.tsx @@ -20,11 +20,17 @@ export const CommentForm = ({ postId, teamId }: ICommentFormProps) => { e.preventDefault() setIsLoading(true) const formData = new FormData(e.currentTarget) + const content = formData.get('new-content') as string + if (!content) { + setIsLoading(false) + openToast({ severity: 'error', message: '댓글을 입력해주세요.' }) + return + } axiosWithAuth .post('/api/v1/team/post/comment/', { teamId: teamId, postId: postId, - content: formData.get('new-content') as string, + content, }) .then(() => { setIsLoading(false) diff --git a/src/components/board/CommentList.tsx b/src/components/board/CommentList.tsx index 71758fc24..a7c8d2fcb 100644 --- a/src/components/board/CommentList.tsx +++ b/src/components/board/CommentList.tsx @@ -28,9 +28,14 @@ const Comment = ({ comment, postId }: ICommentProps) => { const handleEdit = (e: FormEvent) => { e.preventDefault() const formData = new FormData(e.currentTarget) + const content = formData.get('content') as string + if (!content) { + openToast({ severity: 'error', message: '댓글을 입력해주세요.' }) + return + } axiosWithAuth .put(`/api/v1/team/post/comment/${comment.answerId}`, { - content: formData.get('content') as string, + content, }) .then(() => { openToast({ severity: 'success', message: '댓글을 수정했습니다.' }) diff --git a/src/components/board/CommentPanel.tsx b/src/components/board/CommentPanel.tsx index b5ef5dd4a..7e6d2005c 100644 --- a/src/components/board/CommentPanel.tsx +++ b/src/components/board/CommentPanel.tsx @@ -219,7 +219,7 @@ export const CommentItem = ({ ) : ( - + {comment.content} {dayjs(comment.createdAt).format('YYYY년 M월 D일 h:m A')}