import React, { useEffect } from "react";
import Order_Details_Card from "../order_details_card/Order_Details_Card";
import { useDispatch, useSelector } from "react-redux";
import { getAllCancelOrder, getAllOrder } from "../../../../features/order/orderSlice";
import { encodeId } from "../../../../utils/common";

const Cancelled = () => {
  const data = [
    {
      order_id: 75843,
      item_no: 1,
      price: 1200,
      date: "13th May | 03:28 pm",
    },
    {
      order_id: 989,
      item_no: 3,
      price: 1500,
      date: "15th May | 03:00 pm",
    },
    {
      order_id: 75843,
      item_no: 1,
      price: 1200,
      date: "13th May | 03:28 pm",
    },
  ];

  const dispatch = useDispatch();
  const order = useSelector((state) => state.order.allCancelOrders);

  useEffect(() => {
    const statusIds = [11];
    dispatch(getAllCancelOrder({ order_status_id: statusIds }));
  }, [dispatch]);

  return (
    <section className="Cancelled Ordered">
      {order?.data?.map((item,index) => {
        return (
          <Order_Details_Card data={item} baseLike={`/cancel-order-details/${encodeId(item?.id)}?type=Cancel`} key={index}/>
        );
      })}

      <div className="no_data_main_div">
        <p className="no_data_text">No more orders to show</p>
      </div>
    </section>
  );
};

export default Cancelled;
