import React from "react"; import { SpinnerCircular } from "spinners-react"; import { getFile } from "../../../../actions"; export default class RequestFile extends React.Component { constructor(props) { super(props); this.state = { downloading: false } } _handle_onDownloadFile = () => { const { file } = this.props; const { downloading } = this.state; if(!downloading) { this.setState({ downloading: true }, () => { getFile({ id: file.doc_url, filename: `${ file.doc_name }.${ file.doc_extension }` }) .then(() => { this.setState({ downloading: false }); }) .catch(() => { this.setState({ downloading: false }); }); }); } } render() { const { file } = this.props; const { downloading } = this.state; return (
{ file !== undefined && file !== null && (

{ file.doc_name } Скачать документ { downloading ? () : null }

) }
) } }