"use client";

import React, { useEffect, useState } from "react";
import "./Cart_Products.css";
import Breadcrumb_comp from "../common-components/breadcrumb-comp/Breadcrumb_comp";
import Cart_Products_card from "./cart_Products_card/Cart_Products_card";
import May_you_like_also from "./may_you_like_also/May_you_like_also";
import Back_text_holder from "../common-components/back_text_holder/Back_text_holder";
import { useDispatch, useSelector } from "react-redux";
import { getAllCart } from "../../features/cart/cartSlice";


function Cart_Products() {


  const breadcrumbs = [
    { label: "Home", link: "/", isActive: false },
    { label: "Cart Products", link: "", isActive: true },
  ];

  const isSignin = useSelector((state) => state.auth.is_signin);
  const dispatch = useDispatch();
  const allcartData = useSelector((state) => state.cart.allCarts);
  useEffect(() => {
    dispatch(getAllCart(isSignin));
  }, [dispatch]);

  const [instock, setInstock] = useState(false);
  return (
    <>
      <section className="Cart_Products">
        <Breadcrumb_comp breadcrumbs={breadcrumbs} />
        <Cart_Products_card
          instock={instock}
          setInstock={setInstock}
          data={allcartData}
        />
        <May_you_like_also instock={instock} data={allcartData} />
        <Back_text_holder baseLink="/shops" backText="Product" />
   
      </section>
    </>
  );
}

export default Cart_Products;
