diff --git a/package.json b/package.json
index 33af65e..fe911aa 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,7 @@
},
"homepage": "https://github.com/mgonto/react-browserify-spa-seed",
"dependencies": {
+ "autobind-decorator": "^1.3.2",
"flux": "^2.0.1",
"foundation-apps": "^1.1.0",
"foundation-sites": "^6.0.0",
diff --git a/src/components/Account.js b/src/components/Account.js
index 26c53b2..e48bf72 100644
--- a/src/components/Account.js
+++ b/src/components/Account.js
@@ -65,7 +65,7 @@ class Account extends React.Component {
if (this.props.params.accountId) {
return (
-
+
)
} else {
diff --git a/src/components/AuthenticatedApp.js b/src/components/AuthenticatedApp.js
index 8f36905..e442333 100644
--- a/src/components/AuthenticatedApp.js
+++ b/src/components/AuthenticatedApp.js
@@ -41,7 +41,7 @@ export default class AuthenticatedApp extends React.Component {
diff --git a/src/components/Tx.js b/src/components/Tx.js
index 73ca1c7..9e976e2 100644
--- a/src/components/Tx.js
+++ b/src/components/Tx.js
@@ -1,4 +1,5 @@
import React from 'react';
+import autobind from 'autobind-decorator';
import AuthenticatedComponent from './AuthenticatedComponent';
import TxForm from './TxForm';
@@ -11,6 +12,7 @@ import TxService from '../services/TxService';
List of all Tx related to user
*/
+@autobind
class Tx extends React.Component {
constructor(props) {
@@ -24,10 +26,8 @@ class Tx extends React.Component {
}
componentDidMount() {
- if (!this.state.account) {
- this.fetchAccount(this.props.params.accountId);
- this.fetchTxs(this.props.params.accountId);
- } else if ( this.state.account.id !== +this.props.params.accountId ) {
+ if ( ( !this.state.account ) ||
+ ( this.state.account.id !== +this.props.params.accountId ) ) {
this.fetchAccount(this.props.params.accountId);
this.fetchTxs(this.props.params.accountId);
}
@@ -62,7 +62,7 @@ class Tx extends React.Component {
}
updateTx(tx) {
-
+ console.log("updateTx: " + tx);
}
render() {
diff --git a/src/components/TxForm.js b/src/components/TxForm.js
index a1acdc4..8724220 100644
--- a/src/components/TxForm.js
+++ b/src/components/TxForm.js
@@ -2,33 +2,35 @@
Add Tx Form
*/
-
import React from 'react';
-import AccountStore from '../stores/AccountStore';
+import autobind from 'autobind-decorator';
+@autobind
class TxForm extends React.Component {
- constructor(props) {
- super(props);
- console.log(AccountStore.accounts)
- this.state = {accounts: []};
- }
-
updateTx(event) {
// 1. Stop the form from submitting
event.preventDefault();
// 2. Take the data from the form and create an object
+ console.log(this.refs);
+ console.log(this.refs.txForm);
+ alert(React.findDOMNode(this.refs.account).value);
+ alert(React.findDOMNode(this.refs.account).value);
var tx = {
- id : this.refs.id.value,
- price : this.refs.price.value,
- status : this.refs.status.value,
- desc : this.refs.desc.value,
- image : this.refs.image.value
+ id : React.findDOMNode(this.refs.id).value,
+ amount : React.findDOMNode(this.refs.amount).value,
+ currency : React.findDOMNode(this.refs.currency).value,
+ date : React.findDOMNode(this.refs.date).value,
+ account : React.findDOMNode(this.refs.account).value,
+ note : React.findDOMNode(this.refs.note).value,
+ image : React.findDOMNode(this.refs.image).value
}
+ // 3. Add the tx to the App State
+ console.log(tx);
- // 3. Add the fish to the App State
- this.props.addFish(fish);
- this.refs.fishForm.reset();
+ React.findDOMNode(this.refs.txForm).reset();
+ // this.props.addFish(fish);
+ // this.refs.fishForm.reset();
}
render() {
@@ -39,16 +41,16 @@ class TxForm extends React.Component {
-
+
)
}