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
46
47
48
49
50
51
52
53
54
55
56
57
|
import { Swiper, SwiperProps, SwiperSlide } from 'swiper/react';
import { Navigation, Pagination, Autoplay } from 'swiper';
import usePreferredBrand from '../hooks/usePreferredBrand'
import PreferredBrandSkeleton from './Skeleton/PreferredBrandSkeleton'
import BrandCard from '@/lib/brand/components/BrandCard'
import useDevice from '@/core/hooks/useDevice'
import Link from '@/core/components/elements/Link/Link'
const PreferredBrand = () => {
let query = 'level_s'
let params = 'prioritas'
const { preferredBrands } = usePreferredBrand(query)
const { isMobile, isDesktop } = useDevice()
const swiperBanner = {
modules:[Navigation, Pagination, Autoplay],
autoplay: {
delay: 4000,
disableOnInteraction: false
},
loop: true,
className: 'h-[70px] md:h-[100px] w-full',
slidesPerView: isMobile ? 4 : 8,
spaceBetween: isMobile ? 12 : 0,
pagination: {
dynamicBullets: true,
dynamicMainBullets: isMobile ? 6 : 8,
clickable: true,
}
}
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'>Brand Pilihan</div>
{isDesktop && (
<Link href='/shop/brands' className='!text-red-500 font-semibold'>
Lihat Semua
</Link>
)}
</div>
<div className='border rounded border-gray_r-6'>
{preferredBrands.isLoading && <PreferredBrandSkeleton />}
{!preferredBrands.isLoading && (
<Swiper {...swiperBanner}>
{preferredBrands.data?.data.map((brand) => (
<SwiperSlide key={brand.id}>
<BrandCard brand={brand} />
</SwiperSlide>
))}
</Swiper>
)}
</div>
</div>
)
}
export default PreferredBrand
|