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

@@ -37,13 +37,13 @@ class CartUploadDocument extends Component {
downloadDocument(document){
fileHandler.download(
`${API_SERVER}/wp-json/wiaas/cart/items/${this.props.cartItem.key}/documents/${this.props.idDocumentType}?document_key=${document.key}`,
document.name);
`${document.name}.${document.extension}`);
}
downloadTemplate(document) {
fileHandler.download(
`${API_SERVER}/wp-json/wiaas/documents?document_id=${document.id}`,
document.name);
`${document.name}.${document.extension}`);
}
render() {

View File

@@ -10,7 +10,7 @@ class PackageInfo extends Component {
downloadDocument(document){
fileHandler.download(
`${API_SERVER}/wp-json/wiaas/documents?document_id=${document.id}`,
document.name);
`${document.name}.${document.extension}`);
}
render() {

View File

@@ -140,9 +140,6 @@ class ProcessContainer extends Component {
}
onViewChange(activeView){
if(activeView === 'documents'){
this.props.dispatch(fetchOrderInfo(this.props.idOrder));
}
this.setState({activeView});
}
@@ -232,7 +229,7 @@ class ProcessContainer extends Component {
{
this.state.activeView === 'documents' &&
<OrderDocuments idOrder={orderInfo.id} />
<OrderDocuments orderDocumentsBundle={orderInfo.documents} />
}
</div>
}

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>

View File

@@ -22,12 +22,6 @@ class PackageInfo extends Component {
});
}
downloadDocument(document){
const fileUrl = `${API_SERVER}/utils/api/downloadFile?idDocument=${document.idDocument}&fileName=${document.documentName}.${document.extension}&fileType=${document.documentTypeName}`
const fileName = document.documentName + '.' + document.extension;
fileHandler.download(fileUrl, fileName);
}
render() {
const {orderPackage, currency, onViewChange} = this.props;
const shouldShowPriceInfo = orderPackage.recurringPrice > 0 || orderPackage.servicePrice > 0;
@@ -122,17 +116,6 @@ class PackageInfo extends Component {
}
</Col>
}
{
orderPackage.documents &&
<Col xl="2">
<div className="subtitle"><h6>{orderTexts.labels.DOCUMENTS}:</h6></div>
{
orderPackage.documents.length > 0 ?
<div className="link-to-docs" onClick={()=>onViewChange('documents')}>{orderTexts.buttons.SEE_DOCUMENTS}</div>:
<span>{orderTexts.labels.NO_DOCUMENTS}</span>
}
</Col>
}
</Row>
</Container>
);