|
|
|
@ -2,33 +2,35 @@
|
|
|
|
|
Add Tx Form |
|
|
|
|
<AddTxForm /> |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
<input type="text" ref="currency" placeholder="Currency" /> |
|
|
|
|
<input type="text" ref="date" placeholder="Date" /> |
|
|
|
|
<select ref="account"> |
|
|
|
|
{this.state.accounts.map((account) => { |
|
|
|
|
{this.props.accounts.map((account) => { |
|
|
|
|
var opts = { value: account.id }; |
|
|
|
|
return ( |
|
|
|
|
<option value="{account.id}"> |
|
|
|
|
{account.title} ({account.currency})</option> |
|
|
|
|
<option {...opts}>{account.title} ({account.currency})</option> |
|
|
|
|
) |
|
|
|
|
})} |
|
|
|
|
</select> |
|
|
|
|
<textarea type="text" ref="note" placeholder="Note"></textarea> |
|
|
|
|
<input type="text" ref="image" placeholder="URL to Image" /> |
|
|
|
|
<button type="submit">+ Add Tx </button> |
|
|
|
|
<button type="submit">+ Add Tx</button> |
|
|
|
|
</form> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|