From 3c1c4bddeaa602f390afaf11c8c83ec92cabefa4 Mon Sep 17 00:00:00 2001 From: ww8007 Date: Mon, 16 Oct 2023 20:10:30 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20upload=20=EC=A4=91=EC=9D=BC=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=9E=AC=EC=9A=94=EC=B2=AD=20=EB=B3=B4=EB=82=B4?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/bookmark/CommentUploadInput.tsx | 15 ++++++++----- src/pages/BookmarkAddPage.tsx | 22 ++++++++++--------- src/pages/CategoryManagePage.tsx | 17 ++++++++------ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/comment/ui/bookmark/CommentUploadInput.tsx b/src/comment/ui/bookmark/CommentUploadInput.tsx index 60675a9b..52acc601 100644 --- a/src/comment/ui/bookmark/CommentUploadInput.tsx +++ b/src/comment/ui/bookmark/CommentUploadInput.tsx @@ -24,11 +24,13 @@ const CommentUploadInput = () => { initComment(); }; - const { mutate: postComment } = usePOSTCommentQuery({ - bookmarkId: bookmarkId ?? '', - initComment, - }); - const { mutate: editComment } = usePUTCommentQuery({ + const { mutate: postComment, isLoading: isPostLoading } = usePOSTCommentQuery( + { + bookmarkId: bookmarkId ?? '', + initComment, + }, + ); + const { mutate: editComment, isLoading: isEditLoading } = usePUTCommentQuery({ bookmarkId: bookmarkId ?? '', initComment, }); @@ -37,6 +39,9 @@ const CommentUploadInput = () => { event: React.FormEvent | MouseEvent, ) => { event.preventDefault(); + if (isPostLoading || isEditLoading) return; + if (!comment.content) return; + if (mode === 'CREATE') { postComment({ bookmarkId: Number(id), diff --git a/src/pages/BookmarkAddPage.tsx b/src/pages/BookmarkAddPage.tsx index d630d19a..0502b147 100644 --- a/src/pages/BookmarkAddPage.tsx +++ b/src/pages/BookmarkAddPage.tsx @@ -59,21 +59,23 @@ const BookmarkAddPage = () => { ); const { memberId } = useAuthStore(); - const { mutate: postBookmark } = usePOSTBookmarkMutation({ - resetAll: { - resetAllInputs, - resetCategory: () => { - setSelectedCategoryId(0); - setCategoryList(toggleCategory(0)); + const { mutate: postBookmark, isLoading: isPostLoading } = + usePOSTBookmarkMutation({ + resetAll: { + resetAllInputs, + resetCategory: () => { + setSelectedCategoryId(0); + setCategoryList(toggleCategory(0)); + }, + resetVisibility: () => onClickPublishScoped('SCOPE_PUBLIC'), }, - resetVisibility: () => onClickPublishScoped('SCOPE_PUBLIC'), - }, - memberId, - }); + memberId, + }); const { fireToast } = useToast(); const onClickSubmitButton = () => { + if (isPostLoading) return; if (isBookmarkError) { fireToast({ mode: 'ERROR', diff --git a/src/pages/CategoryManagePage.tsx b/src/pages/CategoryManagePage.tsx index 8fb8547b..76805a22 100644 --- a/src/pages/CategoryManagePage.tsx +++ b/src/pages/CategoryManagePage.tsx @@ -58,14 +58,17 @@ const CategoryManagePage = ({ mode }: CategoryManagePageProps) => { }; // 2. 저장 버튼 > 저장 - const { mutate: postCategory } = usePOSTCategoryMutation({ - memberId, - }); - const { mutate: putCategory } = usePUTCategoryMutation({ - memberId, - categoryId: categoryId ?? '', - }); + const { mutate: postCategory, isLoading: isPostLoading } = + usePOSTCategoryMutation({ + memberId, + }); + const { mutate: putCategory, isLoading: isPutLoading } = + usePUTCategoryMutation({ + memberId, + categoryId: categoryId ?? '', + }); const onClickSave = () => { + if (isPostLoading || isPutLoading) return; if (!categoryName.length) { fireToast({ message: '앗! 카테고리 이름이 비어있어요', mode: 'ERROR' }); return;