Checkout logic

This commit is contained in:
Almira Krdzic
2018-10-04 03:15:51 +02:00
18 changed files with 285 additions and 147 deletions

View File

@@ -5,20 +5,6 @@ import FileDownloader from '../../../helpers/FileDownloader';
const fileHandler = new FileDownloader();
const iconTypes = {
doc: 'file-word-o',
docx: 'file-word-o',
odt: 'file-word-o',
ods: 'file-excel-o',
pdf: 'file-pdf-o',
png: 'file-image-o',
jpg: 'file-image-o',
xls: 'file-excel-o',
xlsx: 'file-excel-o',
ppt: 'file-powerpoint-o',
pptx: 'file-powerpoint-o'
};
class OrderDocumentsGroup extends Component {
constructor(props) {
super(props);
@@ -26,13 +12,9 @@ class OrderDocumentsGroup extends Component {
this.state = {};
}
getDocumentIcon(documentType) {
return iconTypes[documentType] || 'file';
}
downloadDocument(orderId, itemId, document){
const fileUrl = `${API_SERVER}/wp-json/wiaas/documents/order/${orderId}/${document.type}?item_id=${itemId}&document_key=${document.key}`;
fileHandler.download(fileUrl, document.name);
fileHandler.download(fileUrl, `${document.name}.${document.extension}`);
}
render() {
@@ -47,7 +29,7 @@ class OrderDocumentsGroup extends Component {
{
documentsGroup.documents.map(document => <a id={'document-' + document.key} key={'order-document-' + document.key}>
<div onClick={() => {this.downloadDocument(orderId, documentsGroup.orderItemId, document)}} className="document-link-big">
<i className={'fa fa-4x fa-' + this.getDocumentIcon(document.extension)} aria-hidden="true"></i>
<i className={`fa fa-4x fa-${document.icon}`} aria-hidden="true"></i>
<div>
{document.name}
</div>