diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-06-29 06:35:57 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-06-29 06:35:57 +0000 |
| commit | 24bf0ef6152ea8a62284280d3b2c966ff01b4e8d (patch) | |
| tree | 6d7fcdf6aaecddb4ad38fff64090125ce999e623 /src/lib/home/components | |
| parent | 6df1a73f3ccfc6c222bc797b48db774125833040 (diff) | |
| parent | ca0faeb73b521a40a2e96b2e7b724b839db6aa57 (diff) | |
Merged in promotion-program (pull request #146)
<iman> update mobile view
Diffstat (limited to 'src/lib/home/components')
| -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> ) |
