diff --git a/backend/src/main/java/com/funeat/product/domain/Product.java b/backend/src/main/java/com/funeat/product/domain/Product.java index e66aa59cf..eca71a02d 100644 --- a/backend/src/main/java/com/funeat/product/domain/Product.java +++ b/backend/src/main/java/com/funeat/product/domain/Product.java @@ -3,6 +3,8 @@ import com.funeat.member.domain.bookmark.ProductBookmark; import com.funeat.review.domain.Review; import java.util.List; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicLong; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; @@ -42,6 +44,8 @@ public class Product { @OneToMany(mappedBy = "product") private List productBookmarks; + private Long reviewCount = 0L; + protected Product() { } @@ -106,4 +110,12 @@ public Double getAverageRating() { public Category getCategory() { return category; } + + public Long getReviewCount() { + return reviewCount; + } + + public void addReviewCount() { + reviewCount++; + } } diff --git a/backend/src/main/java/com/funeat/review/application/ReviewService.java b/backend/src/main/java/com/funeat/review/application/ReviewService.java index 2cf840ed1..ec7020cad 100644 --- a/backend/src/main/java/com/funeat/review/application/ReviewService.java +++ b/backend/src/main/java/com/funeat/review/application/ReviewService.java @@ -95,6 +95,7 @@ public void create(final Long productId, final Long memberId, final MultipartFil final Long countByProduct = reviewRepository.countByProduct(findProduct); findProduct.updateAverageRating(savedReview.getRating(), countByProduct); + findProduct.addReviewCount(); reviewTagRepository.saveAll(reviewTags); } diff --git a/frontend/src/components/Product/ProductList/ProductList.tsx b/frontend/src/components/Product/ProductList/ProductList.tsx index 114405aab..2bdaf30e6 100644 --- a/frontend/src/components/Product/ProductList/ProductList.tsx +++ b/frontend/src/components/Product/ProductList/ProductList.tsx @@ -40,7 +40,7 @@ const ProductList = ({ category, selectedOption }: ProductListProps) => { ))} -
+
); }; diff --git a/frontend/src/components/Product/ProductTitle/ProductTitle.tsx b/frontend/src/components/Product/ProductTitle/ProductTitle.tsx index be0e499f1..1c10cf2f0 100644 --- a/frontend/src/components/Product/ProductTitle/ProductTitle.tsx +++ b/frontend/src/components/Product/ProductTitle/ProductTitle.tsx @@ -33,6 +33,7 @@ const ProductTitleContainer = styled.div` flex-direction: row; justify-content: space-between; align-items: center; + height: 30px; `; const ProductTitleLink = styled(Link)` diff --git a/frontend/src/components/Recipe/RecipeList/RecipeList.tsx b/frontend/src/components/Recipe/RecipeList/RecipeList.tsx index 35b3d4edf..ae1bb1907 100644 --- a/frontend/src/components/Recipe/RecipeList/RecipeList.tsx +++ b/frontend/src/components/Recipe/RecipeList/RecipeList.tsx @@ -35,7 +35,7 @@ const RecipeList = ({ selectedOption }: RecipeListProps) => { ))} -
+
); }; diff --git a/frontend/src/hooks/common/useIntersectionObserver.ts b/frontend/src/hooks/common/useIntersectionObserver.ts index b07fc87bc..c02ee9901 100644 --- a/frontend/src/hooks/common/useIntersectionObserver.ts +++ b/frontend/src/hooks/common/useIntersectionObserver.ts @@ -4,7 +4,7 @@ import { useRef, useEffect } from 'react'; const defaultOptions = { root: null, rootMargin: '0px', - threshold: 1.0, + threshold: 0.3, }; const useIntersectionObserver = ( diff --git a/frontend/src/pages/RecipePage.tsx b/frontend/src/pages/RecipePage.tsx index 52a7f0928..579639542 100644 --- a/frontend/src/pages/RecipePage.tsx +++ b/frontend/src/pages/RecipePage.tsx @@ -93,6 +93,7 @@ const TitleWrapper = styled.div` display: flex; justify-content: space-between; align-items: center; + height: 30px; `; const Title = styled(Heading)` @@ -106,7 +107,7 @@ const SortButtonWrapper = styled.div` `; const RecipeListWrapper = styled.div` - height: calc(100% - 192px); + height: calc(100% - 190px); overflow-y: auto; `;