Skip to content

Commit

Permalink
[FE] feat: 꿀조합 댓글이 없는 경우 예외처리 (#772)
Browse files Browse the repository at this point in the history
* feat: 댓글이 없는 경우 ui 처리

* feat: 댓글이 없는 경우 id를 읽어올 수 없는 문제 해결
  • Loading branch information
xodms0309 authored Oct 16, 2023
1 parent ff62d0e commit be83c6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/Recipe/CommentList/CommentList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Heading, Spacing } from '@fun-eat/design-system';
import { Heading, Spacing, Text, theme } from '@fun-eat/design-system';
import { useRef } from 'react';

import CommentItem from '../CommentItem/CommentItem';
Expand All @@ -24,6 +24,7 @@ const CommentList = ({ recipeId }: CommentListProps) => {
댓글 ({comments.length}개)
</Heading>
<Spacing size={12} />
{comments.length === 0 && <Text color={theme.textColors.info}>꿀조합의 첫번째 댓글을 달아보세요!</Text>}
{comments.map((comment) => (
<CommentItem key={comment.id} recipeComment={comment} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useInfiniteRecipeCommentQuery = (recipeId: number) => {
({ pageParam = { lastId: 0, totalElements: null } }) => fetchRecipeComments(pageParam, recipeId),
{
getNextPageParam: (prevResponse: CommentResponse) => {
const lastId = prevResponse.comments[prevResponse.comments.length - 1].id;
const lastId = prevResponse.comments.length ? prevResponse.comments[prevResponse.comments.length - 1].id : 0;
const totalElements = prevResponse.totalElements;
const lastCursor = { lastId: lastId, totalElements: totalElements };
return prevResponse.hasNext ? lastCursor : undefined;
Expand Down

0 comments on commit be83c6b

Please sign in to comment.