import Link from 'next/link'; import { FC, useContext } from 'react'; import BeerPostQueryResult from '@/services/posts/BeerPost/schema/BeerPostQueryResult'; import { z } from 'zod'; import UserContext from '@/contexts/UserContext'; import useGetBeerPostLikeCount from '@/hooks/data-fetching/beer-likes/useBeerPostLikeCount'; import { CldImage } from 'next-cloudinary'; import BeerPostLikeButton from '../BeerById/BeerPostLikeButton'; const BeerCard: FC<{ post: z.infer }> = ({ post }) => { const { user } = useContext(UserContext); const { mutate, likeCount, isLoading } = useGetBeerPostLikeCount(post.id); return (
{post.beerImages.length > 0 && ( )}

{post.name}

{post.brewery.name}

{post.style.name}
{post.abv.toFixed(1)}% ABV {post.ibu.toFixed(1)} IBU
{!isLoading && ( liked by {likeCount} user{likeCount === 1 ? '' : 's'} )}
{!!user && !isLoading && ( )}
); }; export default BeerCard;