fixed bug with amount not updating / solved double dispatch problem with cartAction.load / removed all console.log calls - it became too chatty / add them as needed

This commit is contained in:
Senad Uka
2015-05-14 06:21:49 +02:00
parent 49dd10acbc
commit 6453b1b241
22 changed files with 73 additions and 104 deletions

View File

@@ -8,42 +8,25 @@ var Router = require('react-router');
var CartTotal = React.createClass({
render: function() {
render: function() {
var counts = this.props.itemCounts;
var total = 0;
this.props.items.map(function (i) {
var count = counts[i.get('id')].get('count');
var price = i.get('list_price');
var items = this.props.items.models;
for (var i = 0; i < items.length; i++) {
var item = items[i];
var count = counts[item.get('id')].get('count');
var price = item.get('list_price');
total += (price * count)
return total;
};
});
var deliveryCosts = this.props.deliveryCosts.get('delivery_price');
if (!this.props.justMerchandise) {
return (
<div className="col-md-3 cart-total">
<div>
Roba: {Globals.FormatCurrency(total)}
</div>
<div>
Dostava: {Globals.FormatCurrency(deliveryCosts)}
</div>
<div>
Ukupno: {Globals.FormatCurrency(total + (+deliveryCosts))}
</div>
</div>
);
}
else {
return ( <span>{Globals.FormatCurrency(total)}</span>);
}
return ( <span>{Globals.FormatCurrency(total)}</span>);
}