import Link from 'next/link' import Image from 'next/image' import { Swiper, SwiperSlide } from 'swiper/react' import 'swiper/css' import { DiscountProduct, ProductPrice, ResponsiveImage, Skeleton } from 'components' import { useGetProductsQuery } from '@/store/services' const DiscountSlider = props => { //? Props const { currentCategory } = props const { products, isLoading } = useGetProductsQuery( { sort: 6, category: currentCategory?.slug, page_size: 15, discount: true, }, { selectFromResult: ({ data, isLoading }) => ({ products: data?.data?.products, isLoading, }), } ) //? Render(s) if (currentCategory) { return (
{isLoading ? Array(10) .fill('_') .map((_, index) => ( )) : products?.map((product, index) => (
))} {currentCategory.name}
查看全部
) } } export default DiscountSlider