Skip to content

Commit

Permalink
fix: 리뷰, 꿀조합 작성 함수 디바운스 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Leejin-Yang committed Sep 15, 2023
1 parent b17c35b commit 467764e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import RecipeNameInput from '../RecipeNameInput/RecipeNameInput';
import RecipeUsedProducts from '../RecipeUsedProducts/RecipeUsedProducts';

import { ImageUploader, SvgIcon } from '@/components/Common';
import { useImageUploader, useFormData } from '@/hooks/common';
import { useImageUploader, useFormData, useTimeout } from '@/hooks/common';
import { useRecipeFormValueContext, useRecipeFormActionContext } from '@/hooks/context';
import { useRecipeRegisterFormMutation } from '@/hooks/queries/recipe';
import type { RecipeRequest } from '@/types/recipe';
Expand Down Expand Up @@ -61,6 +61,8 @@ const RecipeRegisterForm = ({ closeRecipeDialog }: RecipeRegisterFormProps) => {
});
};

const [debouncedRecipeSubmit] = useTimeout(handleRecipeFormSubmit, 200);

return (
<RecipeRegisterFormContainer>
<RecipeHeading tabIndex={0}>나만의 꿀조합 만들기🍯</RecipeHeading>
Expand All @@ -69,7 +71,7 @@ const RecipeRegisterForm = ({ closeRecipeDialog }: RecipeRegisterFormProps) => {
</CloseButton>
<Divider />
<Spacing size={36} />
<form onSubmit={handleRecipeFormSubmit}>
<form onSubmit={debouncedRecipeSubmit}>
<RecipeNameInput recipeName={recipeFormValue.title} />
<Spacing size={40} />
<RecipeUsedProducts />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import StarRate from '../StarRate/StarRate';
import { ImageUploader, SvgIcon } from '@/components/Common';
import { ProductOverviewItem } from '@/components/Product';
import { MIN_DISPLAYED_TAGS_LENGTH } from '@/constants';
import { useFormData, useImageUploader, useScroll } from '@/hooks/common';
import { useFormData, useImageUploader, useScroll, useTimeout } from '@/hooks/common';
import { useReviewFormActionContext, useReviewFormValueContext } from '@/hooks/context';
import { useProductDetailQuery } from '@/hooks/queries/product';
import { useReviewRegisterFormMutation } from '@/hooks/queries/review';
Expand Down Expand Up @@ -77,6 +77,8 @@ const ReviewRegisterForm = ({ productId, targetRef, closeReviewDialog, initTabMe
});
};

const [debouncedReviewSubmit] = useTimeout(handleSubmit, 200);

return (
<ReviewRegisterFormContainer>
<ReviewHeading tabIndex={0}>리뷰 작성</ReviewHeading>
Expand All @@ -88,7 +90,7 @@ const ReviewRegisterForm = ({ productId, targetRef, closeReviewDialog, initTabMe
<ProductOverviewItem name={productDetail.name} image={productDetail.image} />
</ProductOverviewItemWrapper>
<Divider customHeight="4px" variant="disabled" />
<RegisterForm onSubmit={handleSubmit}>
<RegisterForm onSubmit={debouncedReviewSubmit}>
<ReviewImageUploaderContainer>
<Heading as="h2" size="xl" tabIndex={0}>
구매한 상품 사진이 있다면 올려주세요.
Expand All @@ -110,7 +112,7 @@ const ReviewRegisterForm = ({ productId, targetRef, closeReviewDialog, initTabMe
<RebuyCheckbox />
<Spacing size={16} />
<Text size="sm" color={theme.textColors.disabled}>
[작성시 유의사항] 신뢰성 확보에 저해되는 게시물은 삭제하거나 보이지 않게 할 수 있습니다.{' '}
[작성시 유의사항] 신뢰성 확보에 저해되는 게시물은 삭제하거나 보이지 않게 할 수 있습니다.
</Text>
<Spacing size={10} />
<FormButton type="submit" customWidth="100%" customHeight="60px" size="xl" weight="bold" disabled={!isValid}>
Expand Down

0 comments on commit 467764e

Please sign in to comment.