import Button from "@/components/Forms/Button";
import { baixarAws } from "@/requests/common/Aws/baixarAws";
import { useState } from "react";
import { FaDownload } from "react-icons/fa";

const ButtonDownloadAnexoComplemento = ({ anexo }: any) => {
  const [isLoading, setIsLoading] = useState(false);
  return (
    <Button
      type="button"
      loading={isLoading}
      onClick={() => {
        setIsLoading(true);
        baixarAws(anexo.caminho_anexo_complemento_card).then((res) => {
          window.open(res);
          setIsLoading(false);
        });
      }}
    >
      <FaDownload />
      {anexo.caminho_anexo_complemento_card?.split("/")?.pop()}
    </Button>
  );
};

export default ButtonDownloadAnexoComplemento;
