import React from "react"; import { SpinnerCircular } from 'spinners-react'; import { getPrintFile } from "../../../actions"; import LogFileDownload from "../../../components/LogFileDownload"; export default class DownloadPrintFormPdfButton extends LogFileDownload { constructor(props) { super(props); this.state = { downloading: false, }; } _handle_onDownloadFile = () => { const { downloading } = this.state; const { contract, num, date, type, filename } = this.props; if(!downloading) { this.setState({ downloading: true }, () => { getPrintFile({ contract, num, date, type, filename }) .then(() => { if(this._log !== undefined) { this._log(); } this.setState({ downloading: false }); }) .catch(() => { this.setState({ downloading: false }); }); }); } } render() { const { downloading } = this.state; return ( { this._handle_onDownloadFile() }}> { downloading ? ( ) : "Скачать" } ) } }