import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; import { useForm, usePage } from '@inertiajs/react'; import { MessageCircle, ThumbsDown, ThumbsUp } from 'lucide-react'; import { useEffect } from 'react'; import { BlogShowProps } from '../show'; const BlogLikeDislike = () => { const { props } = usePage(); const { blog, likesCount, dislikesCount, userReaction, commentsCount, translate } = props; const { button, common } = translate; const { data, setData, post, processing } = useForm({ blog_id: blog.id, type: '', }); const handleReaction = (type: 'like' | 'dislike') => { if (processing) return; setData('type', type); }; useEffect(() => { if (data.type === 'like' || data.type === 'dislike') { post(route('blogs.like-dislike.toggle'), { preserveScroll: true, }); } }, [data]); return (

{commentsCount} {commentsCount > 1 ? common.comments : common.comment}

); }; export default BlogLikeDislike;