summaryrefslogtreecommitdiff
path: root/src/lib/home/components/PromotionProgram.jsx
blob: 98bc7c7f57bd60ef2dd8833a26a4f3506b01eb78 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
import Link from '@/core/components/elements/Link/Link'
import Image from 'next/image'
import { bannerApi } from '@/api/bannerApi';
import useDevice from '@/core/hooks/useDevice'
const { useQuery } = require('react-query')
const BannerSection = () => {
  const promotionProgram = useQuery('promotionProgram', bannerApi({ type: 'banner-promotion' }));
  const { isMobile, isDesktop } = useDevice()

  return (
    <div className='px-4 sm:px-0'>
      <div className='flex justify-between items-center mb-4 '>
        <div className='font-semibold sm:text-h-lg'>Promo Tersedia</div>
        {isDesktop && (
          <Link href='/shop/promo'
          className="rounded-md bg-[#FAD147]  px-3.5 py-2.5 text-sm font-semibold text-neutral-950 shadow-sm hover:bg-yellow-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-yellow-600"
        >
          Lihat Semua
        </Link>
        )}
      </div>
      {promotionProgram.data &&
    promotionProgram.data?.length > 0 && (
      <div className='grid grid-cols-3 sm:grid-cols-3 gap-4   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 hover:scale-105 transition duration-500 ease-in-out'
            />
          </Link>
        ))}
      </div>
      
    )}
    </div>
    
  )
}

export default BannerSection