Skip to content

Commit

Permalink
code improvemnts: to please master teawaterwire
Browse files Browse the repository at this point in the history
  • Loading branch information
mehl321 committed Sep 1, 2015
1 parent 116134c commit 99673d6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 33 deletions.
14 changes: 5 additions & 9 deletions components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,12 @@ let App = React.createClass({

// return recalculated balance
getNewBalance(transactions, currency) {
let balance = 0;

transactions.forEach((t) => {
balance += fx.convert(
t.amount,
{from: t.currency, to: currency}
return transactions.reduce((previous, current) => {
return previous + fx.convert(
current.amount,
{from: current.currency, to: currency}
);
});

return balance;
}, 0);
},

render() {
Expand Down
4 changes: 1 addition & 3 deletions components/CurrencySelection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ let React = require('react');

let classNames = require('classnames');

let ReactBootstrap = require('react-bootstrap');
let ButtonGroup = ReactBootstrap.ButtonGroup;
let Button = ReactBootstrap.Button;
let {ButtonGroup, Button} = require('react-bootstrap');

// currency selection component
let CurrencySelection = React.createClass({
Expand Down
5 changes: 1 addition & 4 deletions components/MainMenu.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
let React = require('react');

let ReactBootstrap = require('react-bootstrap');
let Nav = ReactBootstrap.Nav;
let NavItem = ReactBootstrap.NavItem;
let Navbar = ReactBootstrap.Navbar;
let {Navbar, Nav, NavItem} = require('react-bootstrap');

// top menu
let MainMenu = React.createClass({
Expand Down
9 changes: 2 additions & 7 deletions components/TransactionAction.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
let React = require('react');

let {Grid, Row, Col, Input, Button} = require('react-bootstrap');

let classNames = require('classnames');
let accounting = require('accounting');

let ReactBootstrap = require('react-bootstrap');
let Grid = ReactBootstrap.Grid;
let Row = ReactBootstrap.Row;
let Col = ReactBootstrap.Col;
let Input = ReactBootstrap.Input;
let Button = ReactBootstrap.Button;

const DEPOSIT = 'deposit';
const WITHDRAWAL = 'withdrawal';

Expand Down
5 changes: 2 additions & 3 deletions components/TransactionHistory.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
let React = require('react');

let ReactBootstrap = require('react-bootstrap');
let Table = ReactBootstrap.Table;
let {Table} = require('react-bootstrap');

let TransactionItem = require('./TransactionItem');

Expand All @@ -12,7 +11,7 @@ let TransactionHistory = React.createClass({
let transactions = this.props.transactions.map((t, i) => {
return (
<TransactionItem
key={this.props.transactions.size - i - 1}
key={i}
number={this.props.transactions.size - i}
amount={t.amount}
currency={t.currency}
Expand Down
8 changes: 1 addition & 7 deletions components/TransactionItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@ let TransactionItem = React.createClass({
let faCurrency = 'fa-' + this.props.currency.toLowerCase();
let classesCurrency = classNames('fa', faCurrency);

if (this.props.amount > 0) {
typeClass = "success";
} else {
typeClass = "danger";
}

return (
<tr className={typeClass}>
<tr className={this.props.amount > 0 ? 'success' : 'danger'}>
<td>{this.props.number}</td>
<td>
<i className={classesCurrency}></i> {accounting.formatMoney(this.props.amount, '')}
Expand Down

0 comments on commit 99673d6

Please sign in to comment.