Handle wiaas documents

This commit is contained in:
Almira Krdzic
2018-10-03 16:46:41 +02:00
parent 6afffc7eca
commit 3ad210f883
42 changed files with 2258 additions and 258 deletions

View File

@@ -0,0 +1,17 @@
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'
};
export const getDocumentIcon = extension => {
return iconTypes[extension] || 'file';
};

View File

@@ -7,6 +7,7 @@ class FileDownloader {
download(fileUrl, fileName){
htmlClient.fetch({
url: fileUrl,
method: 'get',
responseType: 'arraybuffer'
})
.then((response) => {

View File

@@ -45,14 +45,14 @@ class HtmlClient {
uploadFile(file, configParams = null) {
let formData = new FormData();
formData.append('file', file, file.name);
/*
if(configParams) {
Object.keys(configParams.data).forEach((paramKey) => {
formData.append(paramKey, configParams.data[paramKey]);
});
}*/
}
configParams.data = formData;
const params = Object.assign({}, uploadParams(), configParams);

View File

@@ -1,5 +1,6 @@
import moment from 'moment';
import {fromWiaasProcessStep} from './ProcessHelper';
import { getDocumentIcon } from './DocumentHelper';
function formatDate(date) {
return date ? moment(date).format("Do MMM, YYYY") : undefined;
@@ -40,6 +41,7 @@ export const fromWCOrder = (WCOrder) => {
packages: WCOrder['line_items'].map(packageLine => {
return {
id: packageLine['product_id'],
orderItemId: packageLine['id'],
name: packageLine.name,
quantity: packageLine.quantity,
price: packageLine.price,
@@ -62,6 +64,10 @@ export const fromWCOrder = (WCOrder) => {
packageName: packageOption.name,
groupName: packageOption['group_name'] || '',
})) : [],
documents: packageLine.documents.map(document => {
document['icon'] = getDocumentIcon(document.extension);
return document;
}) || []
};
}),
process: processInfo,

View File

@@ -1,3 +1,4 @@
import { getDocumentIcon } from './DocumentHelper';
const DEFAULT_PACKAGE_IMG = 'static/img/no-photo-package.jpg';
@@ -49,12 +50,10 @@ export const fromWCPackage = wcPackage => {
country: wcPackage.country,
countryCode: wcPackage['country_code'],
currency: wcPackage.currency,
documents: wcPackage.documents ? wcPackage.documents.map(document => ({
idDocument: document.id,
documentName: document.name,
extension: document.extension,
idPackage: wcPackage.id,
})) : [],
documents: wcPackage.documents ? wcPackage.documents.map(document => {
document.icon = getDocumentIcon(document.extension);
return document;
}) : [],
shortDescription: wcPackage.description,
prices: extractPrices(wcPackage.id, wcPackage.prices || []),
groups: extractGroups(wcPackage.groups || {}),