import UserContext from '@/contexts/userContext'; import useBeerPostComments from '@/hooks/useBeerPostComments'; import useTimeDistance from '@/hooks/useTimeDistance'; import BeerCommentQueryResult from '@/services/BeerComment/schema/BeerCommentQueryResult'; import format from 'date-fns/format'; import Link from 'next/link'; import { FC, useContext } from 'react'; import { Rating } from 'react-daisyui'; import { FaEllipsisH } from 'react-icons/fa'; import { useInView } from 'react-intersection-observer'; import { z } from 'zod'; interface CommentCardProps { comment: z.infer; mutate: ReturnType['mutate']; ref?: ReturnType['ref']; } const CommentCardDropdown: FC = ({ comment, mutate }) => { const { user } = useContext(UserContext); const isCommentOwner = user?.id === comment.postedBy.id; const handleDelete = async () => { const response = await fetch(`/api/beer-comments/${comment.id}`, { method: 'DELETE', }); if (!response.ok) { throw new Error('Failed to delete comment'); } await mutate(); }; return (
  • {isCommentOwner ? ( <> ) : ( )}
); }; const CommentCardBody: FC = ({ comment, mutate, ref }) => { const { user } = useContext(UserContext); const timeDistance = useTimeDistance(new Date(comment.createdAt)); return (

{comment.postedBy.username}

posted{' '} {' '} ago

{user && }
{Array.from({ length: 5 }).map((val, index) => ( ))}

{comment.content}

); }; export default CommentCardBody;