import Link from '@/core/components/elements/Link/Link'
import Image from 'next/image'
import { bannerApi } from '@/api/bannerApi';

const { useQuery } = require('react-query')

const BannerSection = () => {
  const promotionProgram = useQuery('promotionProgram', bannerApi({ type: 'banner-promotion' }));

  return (
    promotionProgram.data &&
    promotionProgram.data?.length > 0 && (
      <div className='grid grid-cols-3 sm:grid-cols-3 gap-4  rounded rounded-md'>
        {promotionProgram.data?.map((banner) => (
          <Link key={banner.id} href={banner.url}>
            <Image
              width={439}
              height={150}
              quality={100}
              src={banner.image}
              alt={banner.name}
              className='h-auto  w-full rounded'
            />
          </Link>
        ))}
      </div>
    )
  )
}

export default BannerSection
