summaryrefslogtreecommitdiff
path: root/src/lib/home/components/BannerSection.jsx
blob: 2010503d73cd6e7be512056de9b89c027e770805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Link from '@/core/components/elements/Link/Link'
import Image from 'next/image'

const { useQuery } = require('react-query')
const { default: bannerSectionApi } = require('../api/bannerSectionApi')

const BannerSection = () => {
  const fetchBannerSection = async () => await bannerSectionApi()
  const bannerSection = useQuery('bannerSection', fetchBannerSection)

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

export default BannerSection