From 85950d86818c69d3d493900216fe8e186f6bf157 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Wed, 21 Feb 2024 14:56:35 +0900 Subject: [PATCH 1/3] Fix: Add emtpy comment warning --- src/components/board/CommentForm.tsx | 8 +++++++- src/components/board/CommentList.tsx | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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..feb13a264 100644 --- a/src/components/board/CommentList.tsx +++ b/src/components/board/CommentList.tsx @@ -28,6 +28,11 @@ 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, From 21a99336d91da3704126aeeb3aab2b670b08e598 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Wed, 21 Feb 2024 15:09:03 +0900 Subject: [PATCH 2/3] Chore: Remove duplicated code --- src/components/board/CommentList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/board/CommentList.tsx b/src/components/board/CommentList.tsx index feb13a264..a7c8d2fcb 100644 --- a/src/components/board/CommentList.tsx +++ b/src/components/board/CommentList.tsx @@ -35,7 +35,7 @@ const Comment = ({ comment, postId }: ICommentProps) => { } axiosWithAuth .put(`/api/v1/team/post/comment/${comment.answerId}`, { - content: formData.get('content') as string, + content, }) .then(() => { openToast({ severity: 'success', message: '댓글을 수정했습니다.' }) From eb9f4fa314bf9f38188bdda3f7d84da05f4fcbe0 Mon Sep 17 00:00:00 2001 From: yoouyeon Date: Wed, 21 Feb 2024 15:20:51 +0900 Subject: [PATCH 3/3] Style: Add word-break property --- src/components/board/CommentPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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')}