Add unit tests for backend and refactor few things on frontend

This commit is contained in:
Almira Krdzic
2018-08-14 00:44:51 +02:00
parent 47bc6bdab1
commit bb3fecd811
14 changed files with 1221 additions and 5541 deletions

View File

@@ -1,5 +1,4 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import OrderListItem from './OrderListItem.jsx';
import {WiaasTable, WiaasTableHeader, WiaasTableBody} from '../../../mainComponents/table/WiaasTable.jsx';
import {orderTexts} from '../../../constants/ordersConstants';
@@ -34,7 +33,7 @@ class OrderList extends Component {
''
];
if(this.props.isCompanyAdmin && this.props.isViewAllOrdersChecked[type]) {
if(this.props.showOrderCustomer) {
activeOrdersHeader.splice(2, 0, orderTexts.headers.PLACED_BY);
activeOrdersHeader.join();
historyOrdersHeader.splice(2, 0, orderTexts.headers.PLACED_BY);
@@ -45,7 +44,7 @@ class OrderList extends Component {
}
render() {
const {orders, type, isCompanyAdmin, isViewAllOrdersChecked} = this.props;
const {orders, type} = this.props;
return (
<div>
@@ -53,11 +52,7 @@ class OrderList extends Component {
<WiaasTableHeader headers={this.getHeadersByType(type)}/>
<WiaasTableBody>
{
orders &&
orders.map((order, index) =>
(order.isMyOrder || (isCompanyAdmin && isViewAllOrdersChecked[type])) &&
<OrderListItem key={order.id} order={order} type={type} />
)
orders.map(order => <OrderListItem key={order.id} order={order} type={type} />)
}
</WiaasTableBody>
</WiaasTable>
@@ -65,9 +60,4 @@ class OrderList extends Component {
);
}
}
const mapStateToProps = (state) => ({
isCompanyAdmin: true, //state.auth.isCompanyAdmin,
isViewAllOrdersChecked: state.ordersReducer.isViewAllOrdersChecked
});
export default connect(mapStateToProps)(OrderList);
export default OrderList;

View File

@@ -64,7 +64,7 @@ class OrderPackage extends Component {
<div className="package-name">{orderPackage.quantity} x {orderPackage.name}</div>
</WiaasTableCol>
<WiaasTableCol header="Price">
{this.calculateQuantityPrice(orderPackage.quantity, orderPackage.price).toLocaleString()} {orderPackage.packageCurrency && orderPackage.packageCurrency.currency} {' '}
{this.calculateQuantityPrice(orderPackage.quantity, orderPackage.price).toLocaleString()} {order.currency} {' '}
({orderPackage.paymentType})
</WiaasTableCol>
<WiaasTableCol header="Services and support">