summaryrefslogtreecommitdiff
path: root/src/lib/home/components/PromotionProgram.jsx
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-09-25 01:53:07 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-09-25 01:53:07 +0000
commitad952b397b1cebcf85b66877da8e949e7e7a891f (patch)
treec174d9dabd75a97544884f47b513f5b4b58443a0 /src/lib/home/components/PromotionProgram.jsx
parent1e834e45f9a11911036496151b71f99de480862e (diff)
parenta66b690ad0445452816f3ac8f8e98dba2e53ca31 (diff)
Merged in perapihan-tag (pull request #331)
Perapihan tag Approved-by: trisusilo
Diffstat (limited to 'src/lib/home/components/PromotionProgram.jsx')
-rw-r--r--src/lib/home/components/PromotionProgram.jsx118
1 files changed, 63 insertions, 55 deletions
diff --git a/src/lib/home/components/PromotionProgram.jsx b/src/lib/home/components/PromotionProgram.jsx
index ae8d5d6f..ae06bd4d 100644
--- a/src/lib/home/components/PromotionProgram.jsx
+++ b/src/lib/home/components/PromotionProgram.jsx
@@ -1,13 +1,16 @@
-import Link from '@/core/components/elements/Link/Link'
-import Image from 'next/image'
+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 useDevice from '@/core/hooks/useDevice';
import { Swiper, SwiperSlide } from 'swiper/react';
-import BannerPromoSkeleton from '../components/Skeleton/BannerPromoSkeleton';
-const { useQuery } = require('react-query')
+import BannerPromoSkeleton from '../components/Skeleton/BannerPromoSkeleton';
+const { useQuery } = require('react-query');
const BannerSection = () => {
- const promotionProgram = useQuery('promotionProgram', bannerApi({ type: 'banner-promotion' }));
- const { isMobile, isDesktop } = useDevice()
+ const promotionProgram = useQuery(
+ 'promotionProgram',
+ bannerApi({ type: 'banner-promotion' })
+ );
+ const { isMobile, isDesktop } = useDevice();
if (promotionProgram.isLoading) {
return <BannerPromoSkeleton />;
@@ -16,60 +19,65 @@ const BannerSection = () => {
return (
<div className='px-4 sm:px-0'>
<div className='flex justify-between items-center mb-4 '>
- <h1 className='font-semibold text-[14px] sm:text-h-lg'> <Link href='/shop/promo' className='!text-black font-semibold' >Promo Tersedia</Link></h1>
+ <h1 className='font-semibold text-[14px] sm:text-h-lg'>
+ {' '}
+ <Link href='/shop/promo' className='!text-black font-semibold'>
+ Promo Tersedia
+ </Link>
+ </h1>
{isDesktop && (
<Link href='/shop/promo' className='!text-red-500 font-semibold'>
- Lihat Semua
- </Link>
+ Lihat Semua
+ </Link>
)}
{isMobile && (
- <Link href='/shop/promo' className='!text-red-500 font-semibold sm:text-h-sm'>
- Lihat Semua
- </Link>
- )}
- </div>
- {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) => (
- <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
+ href='/shop/promo'
+ className='!text-red-500 font-semibold sm:text-h-sm'
+ >
+ Lihat Semua
</Link>
- ))}
+ )}
</div>
-
- ))}
+ {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) => (
+ <Link key={banner.id} href={banner.url}>
+ <Image
+ width={439}
+ height={150}
+ quality={85}
+ src={banner.image}
+ alt={banner.name}
+ className='h-auto w-full rounded hover:scale-105 transition duration-500 ease-in-out'
+ />
+ </Link>
+ ))}
+ </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>
-
- )}
+ {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={85}
+ src={banner.image}
+ alt={banner.name}
+ className='h-auto w-full rounded '
+ />
+ </Link>
+ </SwiperSlide>
+ ))}
+ </Swiper>
+ )}
</div>
-
- )
-}
+ );
+};
-export default BannerSection
+export default BannerSection;