sipp11 9 years ago
parent
commit
534078a7bb
  1. 24
      src/components/Account.js
  2. 2
      src/components/AuthenticatedApp.js
  3. 14
      src/components/Tx.js

24
src/components/Account.js

@ -23,11 +23,11 @@ class Account extends React.Component {
} }
componentDidMount() { componentDidMount() {
if (this.state.accounts.length < 1) { AccountStore.addChangeListener(this._onChange);
if (this.state.accounts == null || this.state.accounts.length < 1) {
this.fetchAllAccounts(); this.fetchAllAccounts();
} }
AccountStore.addChangeListener(this._onChange);
} }
componentWillUnmount() { componentWillUnmount() {
@ -40,19 +40,10 @@ class Account extends React.Component {
getAccountState() { getAccountState() {
return { return {
accounts: this.getAllAccountsState(), accounts: AccountStore.accounts
account: this.getOneAccountsState()
} }
} }
getAllAccountsState() {
return AccountStore.accounts
}
getOneAccountsState() {
return AccountStore.account
}
renderAccounts(act, index) { renderAccounts(act, index) {
return ( return (
<li key={act.id}><a onClick={this.handleAccountView.bind(this, act)}> <li key={act.id}><a onClick={this.handleAccountView.bind(this, act)}>
@ -89,6 +80,11 @@ class Account extends React.Component {
accountView = this.renderAccountView(); accountView = this.renderAccountView();
} }
var accountList = <li>No account yet</li>
if (this.state.accounts != null) {
accountList = this.state.accounts.map(this.renderAccounts)
}
if (this.props.params.accountId) { if (this.props.params.accountId) {
return ( return (
<div className="grid-block"> <div className="grid-block">
@ -104,7 +100,7 @@ class Account extends React.Component {
<div className="grid-block"> <div className="grid-block">
<div className="large-4 medium-4 small-12"> <div className="large-4 medium-4 small-12">
<ul> <ul>
{this.state.accounts.map(this.renderAccounts)} {accountList}
</ul> </ul>
</div> </div>
<div className="large-6 medium-6 small-12"> <div className="large-6 medium-6 small-12">

2
src/components/AuthenticatedApp.js

@ -58,7 +58,7 @@ export default class AuthenticatedApp extends React.Component {
if (!this.state.userLoggedIn) { if (!this.state.userLoggedIn) {
return ( return (
<div className="title-bar"> <div className="title-bar">
<div className="center title"><a>getExpensy</a></div> <div className="center title"><Link to={`/`}>getExpensy</Link></div>
<span className="left hide-for-medium"><a zf-toggle="sub-nav">Menu</a></span> <span className="left hide-for-medium"><a zf-toggle="sub-nav">Menu</a></span>
<span className="right"><Link to={`signup`}>Sign Up</Link></span> <span className="right"><Link to={`signup`}>Sign Up</Link></span>
</div> </div>

14
src/components/Tx.js

@ -108,16 +108,18 @@ class Tx extends React.Component {
} }
render() { render() {
var txsList = ( var txsList = <li>No transaction yet</li>
<li>No transaction yet</li> if (this.state.txs.length)
);
if (this.state.txs.length) {
txsList = this.state.txs.map(this.renderTx); txsList = this.state.txs.map(this.renderTx);
}
var act_title = '';
if (this._account)
act_title = this._account.title;
return ( return (
<div className="grid-block"> <div className="grid-block">
<div className="large-2 medium-2 small-12"> <div className="large-2 medium-2 small-12">
<h1>{this.props.account.title}</h1> <h1>{act_title}</h1>
</div> </div>
<div className="large-5 medium-5 small-12"> <div className="large-5 medium-5 small-12">
<hr/> <hr/>

Loading…
Cancel
Save