import React from "react";
import {useNavigate} from "react-router-dom";

const Breadcrumb = ({ data }) => {
  const navigate = useNavigate()
  return (
    <nav aria-label="breadcrumb">
      <ol className="breadcrumb breadcrumb-style1">
        {data.map((item,index) =>
          item.link ? (
            <li className="breadcrumb-item cursor-pointer" key={index}>
              <a
                aria-label="pagination link link-underline-primary "
               onClick={()=>navigate(item.link)} 
              >
                {item.label}
              </a>
            </li>
          ) : (
            <li className="breadcrumb-item active "> {item.label}</li>
          )
        )}
      </ol>
    </nav>
  );
};

export default Breadcrumb;
