diff --git a/package.json b/package.json
index de0cb03..21e0d83 100644
--- a/package.json
+++ b/package.json
@@ -39,6 +39,7 @@
"foundation-apps": "^1.1.0",
"foundation-sites": "^6.0.0",
"jwt-decode": "^1.1.0",
+ "moment": "^2.10.6",
"react": "^0.14",
"react-catalyst": "^0.3.0",
"react-dom": "^0.14.3",
diff --git a/src/actions/TxActions.js b/src/actions/TxActions.js
index a2323f3..84fe59b 100644
--- a/src/actions/TxActions.js
+++ b/src/actions/TxActions.js
@@ -1,5 +1,5 @@
import AppDispatcher from '../dispatchers/AppDispatcher.js';
-import {TX_GET, TX_NEW} from '../constants/TxConstants.js';
+import {TX_GET, TX_NEW, TX_UPDATE} from '../constants/TxConstants.js';
export default {
@@ -15,6 +15,13 @@ export default {
actionType: TX_NEW,
tx: tx
})
+ },
+
+ updateTx: (tx) => {
+ AppDispatcher.dispatch({
+ actionType: TX_UPDATE,
+ tx: tx
+ })
}
}
diff --git a/src/components/Tx.js b/src/components/Tx.js
index 85a5124..e620214 100644
--- a/src/components/Tx.js
+++ b/src/components/Tx.js
@@ -70,18 +70,28 @@ class Tx extends React.Component {
}
newTx(tx) {
- /*
- creating tx via REST; if ok, push to this.state.txs too.
- */
delete tx['id'];
- TxService.newTx(tx);
+
+ TxService
+ .newTx(tx)
+ .catch(function(err) {
+ alert("Error creating tx");
+ console.log("Error updating tx ", err);
+ });
}
updateTx(tx) {
tx.user = this.props.user.user_id;
if (!tx.id) {
- this.newTx(tx);
+ delete tx['id'];
+ TxService.newTx(tx);
}
+ TxService
+ .updateTx(tx)
+ .catch(function(err) {
+ alert("Error updating");
+ console.log("Error updating tx ", err);
+ });
}
render() {
diff --git a/src/components/TxForm.js b/src/components/TxForm.js
index 413695a..e70f737 100644
--- a/src/components/TxForm.js
+++ b/src/components/TxForm.js
@@ -3,6 +3,8 @@