import React, {Component} from 'react'; import WiaasBox from '../../../mainComponents/box/WiaasBox.jsx'; import {API_SERVER} from '../../../config'; import FileDownloader from '../../../helpers/FileDownloader'; const fileHandler = new FileDownloader(); class OrderDocumentsGroup extends Component { constructor(props) { super(props); this.state = {}; } downloadDocument(orderId, itemId, document){ const fileUrl = `${API_SERVER}/wp-json/wiaas/order/${orderId}/item/${itemId}/document/${document.key}`; fileHandler.download(fileUrl, `${document.name}.${document.extension}`); } render() { const {documentsGroup, orderId} = this.props; return (
{ documentsGroup.documents && documentsGroup.documents.length > 0 && { documentsGroup.documents.map((document, index) => { return (
{this.downloadDocument(orderId, documentsGroup.orderItemId, document)}} className="document-link-big">
{document.name}
); }) }
}
) } } export default OrderDocumentsGroup;