import { RiThumbUpLine } from "react-icons/ri" import { RiThumbUpFill } from "react-icons/ri" import { RiThumbDownLine } from "react-icons/ri" import { RiThumbDownFill } from "react-icons/ri" import { cn } from "@/lib/utils" import { formatLargeNumber } from "@/lib/formatLargeNumber" export const likeButtonClassName = cn( `flex flex-row`, `items-center justify-center text-center`, `h-8 lg:h-9`, `rounded-2xl`, `text-xs lg:text-sm font-medium`, `bg-neutral-700/50 text-zinc-100`, ) export function GenericLikeButton({ className, onLike, onDislike, isLikedByUser = false, isDislikedByUser = false, numberOfLikes = 0, numberOfDislikes = 0, }: { className?: string onLike?: () => void onDislike?: () => void isLikedByUser?: boolean isDislikedByUser?: boolean numberOfLikes?: number numberOfDislikes?: number }) { const classNames = cn( likeButtonClassName, className, ) const nbLikes = Math.max(0, numberOfLikes) const nbDislikes = Math.max(0, numberOfDislikes) return (
{ try { if (!isLikedByUser) onLike?.() } catch (err) { }}} >
{ isLikedByUser ? : }
{nbLikes > 0 ? formatLargeNumber(nbLikes) : ""}
{ try { if (!isDislikedByUser) onDislike?.() } catch (err) { }}} >
 
{ isDislikedByUser ? : }
{nbDislikes > 0 ? formatLargeNumber(numberOfDislikes) : ""}
) }