Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] fix: 리뷰, 꿀조합 작성 함수 디바운스 적용 #644

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading