Files
the-biergarten-app/src/components/BeerById/CommentCardBody.tsx
Aaron William Po b3b1d5b6d1 Feat: Implement infinite scrolling brewery comment section
Refactor beer comment schemas to work on brewery comments as well. Add robots.txt to block crawling for now.
2023-04-30 14:00:38 -04:00

31 lines
975 B
TypeScript

import useBeerPostComments from '@/hooks/useBeerPostComments';
import CommentQueryResult from '@/services/types/CommentSchema/CommentQueryResult';
import { FC, useState } from 'react';
import { useInView } from 'react-intersection-observer';
import { z } from 'zod';
import CommentContentBody from './CommentContentBody';
import EditCommentBody from './EditCommentBody';
interface CommentCardProps {
comment: z.infer<typeof CommentQueryResult>;
mutate: ReturnType<typeof useBeerPostComments>['mutate'];
ref?: ReturnType<typeof useInView>['ref'];
}
const CommentCardBody: FC<CommentCardProps> = ({ comment, mutate, ref }) => {
const [inEditMode, setInEditMode] = useState(false);
return !inEditMode ? (
<CommentContentBody comment={comment} ref={ref} setInEditMode={setInEditMode} />
) : (
<EditCommentBody
comment={comment}
mutate={mutate}
setInEditMode={setInEditMode}
ref={ref}
/>
);
};
export default CommentCardBody;