diff --git a/src/components/AuthenticatedApp.js b/src/components/AuthenticatedApp.js index cf53aca..e7cf2c5 100644 --- a/src/components/AuthenticatedApp.js +++ b/src/components/AuthenticatedApp.js @@ -37,14 +37,14 @@ export default class AuthenticatedApp extends React.Component { -
+ {/*
-
+
*/} ); } diff --git a/src/components/Tx.js b/src/components/Tx.js index a2b1c73..85a5124 100644 --- a/src/components/Tx.js +++ b/src/components/Tx.js @@ -51,13 +51,21 @@ class Tx extends React.Component { getTxState() { return { account: AccountStore.account, - txs: TxStore.txs + txs: TxStore.txs, + tx: {} } } + changeTx(selTx) { + this.setState({tx: selTx}); + } + renderTx(tx) { return ( -
  • {tx.date} {tx.amount} {tx.currency}
  • +
  • + Edit + {tx.date} {tx.amount} {tx.currency} +
  • ) } @@ -77,7 +85,6 @@ class Tx extends React.Component { } render() { - return (
    @@ -85,12 +92,12 @@ class Tx extends React.Component {

    -
      {this.state.txs.map(this.renderTx)}
    +
      {this.state.txs.map(this.renderTx)}
    -
    - +
    ) diff --git a/src/components/TxForm.js b/src/components/TxForm.js index 0d00faf..413695a 100644 --- a/src/components/TxForm.js +++ b/src/components/TxForm.js @@ -26,20 +26,45 @@ class TxForm extends React.Component { this.refs.txForm.reset(); } + handleChange(evt) { + var currTx = this.state.tx; + console.log(evt.target.name); + console.log(evt.target.value); + currTx[evt.target.name] = evt.target.value; + console.log(currTx); + this.setState({updated: currTx}); + } + render() { + this.state = this.state || {}; + if (this.state.updated) { + this.state.tx = this.state.updated; + delete this.state["updated"]; + } else { + this.state.tx = this.props.tx; + } + if (Object.keys(this.state.tx).length == 0) { + this.state.tx = { + id: '', amount: '', currency: '', + date: '2015-12-16', note: '' + }; + } return (
    - +
    - +
    - +
    +
    - +
    @@ -70,7 +96,8 @@ class TxForm extends React.Component { TxForm.propTypes = { txFormHandler : React.PropTypes.func.isRequired, - accounts : React.PropTypes.array.isRequired + accounts : React.PropTypes.array.isRequired, + tx : React.PropTypes.object, } export default TxForm;