Files
old-new-wiaas/frontend/src/containers/orders/components/OrderPackage.jsx

93 lines
5.2 KiB
React
Raw Normal View History

2018-06-14 16:49:28 +02:00
import React, {Component} from 'react';
import {Col} from 'reactstrap';
import WiaasBox from '../../../mainComponents/box/WiaasBox.jsx';
import {WiaasTable, WiaasTableHeader, WiaasTableBody, WiaasTableRow, WiaasTableCol} from '../../../mainComponents/table/WiaasTable.jsx';
import {orderTexts} from '../../../constants/ordersConstants';
import '../style/Orders.css';
class OrderPackage extends Component {
calculateRecuringPrice(packageDetails) {
return packageDetails.quantity * (parseFloat(packageDetails.recurringPrice) + parseFloat(packageDetails.servicePrice));
2018-06-14 16:49:28 +02:00
}
calculateQuantityPrice(quantity, price, recurringPrice = 0) {
return quantity * parseFloat(price + recurringPrice);
}
getHeadersByType(type) {
if(type === 'active') {
return ['Package', 'Price', 'Services and support', 'Delivery active step'];
}
return ['Package', 'Price', 'Services and support', 'End of Life'];
}
render() {
const {order, type} = this.props;
return (
<WiaasTableRow className={"order-border-" + order.status}>
<Col lg="3" sm="12" xs="12">
<WiaasBox mainTitle="Order Details">
<div className="order-details-container">
<WiaasTableRow id={'delivery-address-' + order.id}>
<Col lg="4" sm="4" xs="4">{orderTexts.labels.DELIVERY_ADDRESS}:</Col>
<Col lg="8" sm="8" xs="8">{order.deliveryAddress}</Col>
</WiaasTableRow>
<WiaasTableRow id={'phone-' + order.id}>
<Col lg="4" sm="4" xs="4">{orderTexts.labels.PHONE_NUMBER}:</Col>
2018-08-08 12:21:26 +02:00
<Col lg="8" sm="8" xs="8">{order.customer.phone}</Col>
2018-06-14 16:49:28 +02:00
</WiaasTableRow>
<WiaasTableRow id={'mail-' + order.id}>
<Col lg="4" sm="4" xs="4">{orderTexts.labels.MAIL}:</Col>
2018-08-08 12:21:26 +02:00
<Col lg="8" sm="8" xs="8">{order.customer.email}</Col>
2018-06-14 16:49:28 +02:00
</WiaasTableRow>
<WiaasTableRow id={'commercial-lead-phone-' + order.id}>
<Col lg="4" sm="4" xs="4">{order.commercialLead ? order.commercialLead.name : ''} {orderTexts.labels.PHONE_NUMBER}:</Col>
<Col lg="8" sm="8" xs="8">{order.commercialLead ? order.commercialLead.phone : ''}</Col>
2018-06-14 16:49:28 +02:00
</WiaasTableRow>
<WiaasTableRow id={'mail-' + order.id}>
<Col lg="4" sm="4" xs="4">{order.commercialLead ? order.commercialLead.name : ''} {orderTexts.labels.MAIL}:</Col>
<Col lg="8" sm="8" xs="8">{order.commercialLead ? order.commercialLead.email : ''}</Col>
2018-06-14 16:49:28 +02:00
</WiaasTableRow>
</div>
</WiaasBox>
</Col>
<Col lg="9" sm="12" xs="12">
<WiaasBox mainTitle="Items">
<WiaasTable>
<WiaasTableHeader headers={this.getHeadersByType(type)}/>
<WiaasTableBody>
{order.packages.map((orderPackage, index) =>
<WiaasTableRow className="order-central-row" key={orderPackage.id}>
2018-06-14 16:49:28 +02:00
<WiaasTableCol header="Package" className="package-info-col">
2018-08-08 12:21:26 +02:00
<div className="package-name">{orderPackage.quantity} x {orderPackage.name}</div>
2018-06-14 16:49:28 +02:00
</WiaasTableCol>
<WiaasTableCol header="Price">
{this.calculateQuantityPrice(orderPackage.quantity, orderPackage.price).toLocaleString()} {order.currency} {' '}
2018-06-14 16:49:28 +02:00
({orderPackage.paymentType})
</WiaasTableCol>
<WiaasTableCol header="Services and support">
{this.calculateRecuringPrice(orderPackage).toLocaleString() + ' / ' + orderPackage.periodUnit + ' '}
{orderTexts.labels.EXTEND} {orderPackage.periodUnit} (Max {orderPackage.maxContractPeriod})
2018-06-14 16:49:28 +02:00
</WiaasTableCol>
<WiaasTableCol>
{
type === 'active'
? orderPackage.shortDesc || '-'
: orderPackage.dateCompleted || '-'
2018-06-14 16:49:28 +02:00
}
</WiaasTableCol>
</WiaasTableRow>
)}
</WiaasTableBody>
</WiaasTable>
</WiaasBox>
</Col>
</WiaasTableRow>
);
}
}
export default OrderPackage;