Skip to content

Commit

Permalink
fix: upload 중일 경우 재요청 보내지 않도록 처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ww8007 committed Oct 16, 2023
1 parent 2ed17a8 commit 99a72d8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
15 changes: 10 additions & 5 deletions src/comment/ui/bookmark/CommentUploadInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand All @@ -37,6 +39,9 @@ const CommentUploadInput = () => {
event: React.FormEvent<HTMLFormElement> | MouseEvent<HTMLButtonElement>,
) => {
event.preventDefault();
if (isPostLoading || isEditLoading) return;
if (!comment.content) return;

if (mode === 'CREATE') {
postComment({
bookmarkId: Number(id),
Expand Down
22 changes: 12 additions & 10 deletions src/pages/BookmarkAddPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
17 changes: 10 additions & 7 deletions src/pages/CategoryManagePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 99a72d8

Please sign in to comment.