Handle wiaas documents
This commit is contained in:
17
frontend/src/helpers/DocumentHelper.js
Normal file
17
frontend/src/helpers/DocumentHelper.js
Normal 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';
|
||||
};
|
||||
@@ -7,6 +7,7 @@ class FileDownloader {
|
||||
download(fileUrl, fileName){
|
||||
htmlClient.fetch({
|
||||
url: fileUrl,
|
||||
method: 'get',
|
||||
responseType: 'arraybuffer'
|
||||
})
|
||||
.then((response) => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 || {}),
|
||||
|
||||
Reference in New Issue
Block a user