import { IconButton } from "@mui/material";
import PictureAsPdfIcon from "@mui/icons-material/PictureAsPdf";
import axios from "axios";
import { useSelector } from "react-redux";
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";

function PdfKillRequest({ pdf_key }) {
  const selectedSubUser = useSelector(
    (state) => state.userSlice.selectedSubUser
  );
  return (
    <a
      rel="noreferrer"
      href={`${axios.defaults.baseURL}kill_request_pdf/?key=${pdf_key}${
        checkPathStartsWith("slaughter")
          ? `&role_key=${selectedSubUser?.key || ""}`
          : ""
      }`}
      target="_blank"
    >
      <IconButton>
        <PictureAsPdfIcon sx={{ color: "green" }} />
      </IconButton>
    </a>
  );
}

export default PdfKillRequest;
