diff options
Diffstat (limited to 'src/lib/home')
| -rw-r--r-- | src/lib/home/components/PromotionProgram.jsx | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/lib/home/components/PromotionProgram.jsx b/src/lib/home/components/PromotionProgram.jsx index c2779fd2..b204df8e 100644 --- a/src/lib/home/components/PromotionProgram.jsx +++ b/src/lib/home/components/PromotionProgram.jsx @@ -2,12 +2,12 @@ import Link from '@/core/components/elements/Link/Link' import Image from 'next/image' import { bannerApi } from '@/api/bannerApi'; import useDevice from '@/core/hooks/useDevice' -import { div } from 'lodash-contrib'; +import { Swiper, SwiperSlide } from 'swiper/react'; 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 '> @@ -19,7 +19,7 @@ const BannerSection = () => { // </Link> )} </div> - {promotionProgram.data && + {isDesktop && (promotionProgram.data && promotionProgram.data?.length > 0 && ( <div className='grid grid-cols-3 sm:grid-cols-3 gap-4 rounded-md'> {promotionProgram.data?.map((banner) => ( @@ -36,7 +36,28 @@ const BannerSection = () => { ))} </div> - )} + ))} + +{isMobile && ( + + <Swiper slidesPerView={1.1} spaceBetween={8} freeMode> + {promotionProgram.data?.map((banner) => ( + <SwiperSlide key={banner.id}> + <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> + </SwiperSlide> + ))} + </Swiper> + + )} </div> ) |
