import "./Common_Product_Swiper.css";
import Common_Heading_Holder from "../common_heading_holder/Common_Heading_Holder";
import { Swiper, SwiperSlide } from "swiper/react";
import { Pagination } from "swiper/modules";
import "swiper/css";
import "swiper/css/pagination";
import Common_Product_Card from "../common_product_card/Common_Product_Card";

const Common_Product_Swiper = (props) => {
  return (
    <section className="Common_Product_Swiper ">
      <div className="card_heading_div">
        <Common_Heading_Holder
          headingText={props?.headingText}
          viewShowAllButton={true}
          goto={`/shop?category_id=${props?.data?.id}`}
        />
      </div>

      <div className="products_main_div">
        <Swiper
          spaceBetween={10}         
          modules={[Pagination]}
          autoplay={{ delay: 300 }}
          className="common_swiper"
          breakpoints={{
            0: {
              slidesPerView: 2.3,
            },
            480: {
              slidesPerView: 3,
            },
            575: {
              slidesPerView: 3.5,
            },
            768: {
              slidesPerView: 4,
            },
            992: {
              slidesPerView: 4.5,
            },
            1200: {
              slidesPerView: 5.3,
            },
            1400: {
              slidesPerView: 6,
            },
          }}
        >
          {" "}
          {props?.data?.p_sub_categories?.length > 0 &&
            props?.data?.p_sub_categories?.map((item) => {
              return (
                <SwiperSlide>
                  <Common_Product_Card
                    prodImg={process.env.NEXT_PUBLIC_IMG_URL + item?.image}
                    prodName={item?.name}
                    theme_colour={props?.theme_colour}
                    goto={`/shop-subcategory?category_id=${props?.data?.id}&sub_category_id=${item?.id}&category_image=${props?.data?.image}`}
                  />
                </SwiperSlide>
              );
            })}
        </Swiper>
      </div>
    </section>
  );
};

export default Common_Product_Swiper;
