From d999f7c43f53cf2618d760d3d555655c9a6af263 Mon Sep 17 00:00:00 2001 From: sipp11 Date: Mon, 14 Dec 2015 13:09:16 +0700 Subject: [PATCH] Tx form rearrange new route --- src/app.jsx | 5 +-- src/components/Account.js | 23 +++++++++----- src/components/AccountForm.js | 1 + src/components/Tx.js | 11 ++++++- src/components/TxForm.js | 57 +++++++++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 src/components/AccountForm.js create mode 100644 src/components/TxForm.js diff --git a/src/app.jsx b/src/app.jsx index ec58419..c0a0e35 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -16,8 +16,9 @@ var routes = ( - - + + + ); diff --git a/src/components/Account.js b/src/components/Account.js index a9232d0..26c53b2 100644 --- a/src/components/Account.js +++ b/src/components/Account.js @@ -3,6 +3,7 @@ import {Link} from 'react-router'; import AuthenticatedComponent from './AuthenticatedComponent'; import AccountStore from '../stores/AccountStore.js'; import AccountService from '../services/AccountService.js'; +import Tx from './Tx'; /* List of all account related to user @@ -61,13 +62,21 @@ class Account extends React.Component { } render() { - return ( -
-
    - {this.state.accounts.map(this.renderAccounts)} -
-
- ) + if (this.props.params.accountId) { + return ( +
+ +
+ ) + } else { + return ( +
+
    + {this.state.accounts.map(this.renderAccounts)} +
+
+ ) + } } }; diff --git a/src/components/AccountForm.js b/src/components/AccountForm.js new file mode 100644 index 0000000..f7b0b4d --- /dev/null +++ b/src/components/AccountForm.js @@ -0,0 +1 @@ +AccountForm.js \ No newline at end of file diff --git a/src/components/Tx.js b/src/components/Tx.js index c9ba6eb..73ca1c7 100644 --- a/src/components/Tx.js +++ b/src/components/Tx.js @@ -1,5 +1,7 @@ import React from 'react'; import AuthenticatedComponent from './AuthenticatedComponent'; +import TxForm from './TxForm'; + import AccountStore from '../stores/AccountStore'; import AccountService from '../services/AccountService'; import TxStore from '../stores/TxStore'; @@ -59,16 +61,23 @@ class Tx extends React.Component { ) } + updateTx(tx) { + + } + render() { + return (

{this.state.account.title}

    {this.state.txs.map(this.renderTx)}
+ +
) } } -export default AuthenticatedComponent(Tx); +export default Tx; diff --git a/src/components/TxForm.js b/src/components/TxForm.js new file mode 100644 index 0000000..a1acdc4 --- /dev/null +++ b/src/components/TxForm.js @@ -0,0 +1,57 @@ +/* + Add Tx Form + +*/ + +import React from 'react'; +import AccountStore from '../stores/AccountStore'; + +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 + 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 + } + + // 3. Add the fish to the App State + this.props.addFish(fish); + this.refs.fishForm.reset(); + } + + render() { + return ( +
+ + + + + + + + +
+ ) + } +}; + +export default TxForm;