import Image from '@/core/components/elements/Image/Image'
import Link from '@/core/components/elements/Link/Link'
import useDevice from '@/core/hooks/useDevice'
import { createSlug } from '@/core/utils/slug'

const BrandCard = ({ brand }) => {
  const { isMobile } = useDevice()
  return (
    <Link
      href={createSlug('/shop/brands/', brand.name, brand.id)}
      className={`py-1 px-2 rounded border border-gray_r-6 flex justify-center items-center ${isMobile ? 'h-16' : 'h-24'}`}
    >
      {brand.logo && (
        <Image
          src={brand.logo}
          alt={brand.name}
          className='h-full w-full object-contain object-center'
        />
      )}
      {!brand.logo && (
        <span
          className='text-center'
          style={{ fontSize: `${14 - brand.name.length * 0.5}px` }}
        >
          {brand.name}
        </span>
      )}
    </Link>
  )
}

export default BrandCard
