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] feat: 꿀조합 댓글이 없는 경우 예외처리 #772

Merged
merged 2 commits into from
Oct 16, 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
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
Loading