import React from "react"; import { SpinnerCircular } from 'spinners-react'; import { getFile } from "../../../actions"; export default class DownloadFileById extends React.Component { constructor(props) { super(props); this.state = { downloading: false, }; } _handle_onDownloadFile = () => { const { id, filename } = this.props; const { downloading } = this.state; if(!downloading) { this.setState({ downloading: true }, () => { getFile({ id, filename }) .then(() => { this.setState({ downloading: false }); }) .catch(() => { this.setState({ downloading: false }); }); }); } } render() { const { id, filename, url, bitrix, title } = this.props; const { downloading } = this.state; return ( { downloading ? ( ) : ( this.props.children ) } ) } }