import NextImage from 'next/image';
import Link from '@/core/components/elements/Link/Link';
import useDevice from '@/core/hooks/useDevice';
import { createSlug } from '@/core/utils/slug';

const MediaCard = ({ media }) => {
  const { isMobile } = useDevice();    

//   console.log("Media logo:", media);

  return (
    <Link
      href={createSlug(media.url || '#')}
      className={`
        py-1 px-2 border-gray_r-6 flex justify-center items-center
        hover:scale-110 transition duration-500 ease-in-out
        ${isMobile ? 'h-16' : 'h-24'}
      `}
      aria-label={media.name}
    >
      {media.image ? (
        <NextImage
          src={media.image}
          alt={media.name}
          width={500}
          height={500}
          quality={85}
          className="h-full w-[122px] object-contain object-center"
        />
      ) : (
        <span
          className="text-center"
          style={{ fontSize: `${16 - media.name.length * 0.5}px` }}
        >
          {media.name}
        </span>
      )}
    </Link>
  );
};

export default MediaCard;
