|
|
@ -2,33 +2,35 @@ |
|
|
|
Add Tx Form |
|
|
|
Add Tx Form |
|
|
|
<AddTxForm /> |
|
|
|
<AddTxForm /> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
import React from 'react'; |
|
|
|
import React from 'react'; |
|
|
|
import AccountStore from '../stores/AccountStore'; |
|
|
|
import autobind from 'autobind-decorator'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@autobind |
|
|
|
class TxForm extends React.Component { |
|
|
|
class TxForm extends React.Component { |
|
|
|
|
|
|
|
|
|
|
|
constructor(props) { |
|
|
|
|
|
|
|
super(props); |
|
|
|
|
|
|
|
console.log(AccountStore.accounts) |
|
|
|
|
|
|
|
this.state = {accounts: []}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateTx(event) { |
|
|
|
updateTx(event) { |
|
|
|
// 1. Stop the form from submitting
|
|
|
|
// 1. Stop the form from submitting
|
|
|
|
event.preventDefault(); |
|
|
|
event.preventDefault(); |
|
|
|
// 2. Take the data from the form and create an object
|
|
|
|
// 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 = { |
|
|
|
var tx = { |
|
|
|
id : this.refs.id.value, |
|
|
|
id : React.findDOMNode(this.refs.id).value, |
|
|
|
price : this.refs.price.value, |
|
|
|
amount : React.findDOMNode(this.refs.amount).value, |
|
|
|
status : this.refs.status.value, |
|
|
|
currency : React.findDOMNode(this.refs.currency).value, |
|
|
|
desc : this.refs.desc.value, |
|
|
|
date : React.findDOMNode(this.refs.date).value, |
|
|
|
image : this.refs.image.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
|
|
|
|
React.findDOMNode(this.refs.txForm).reset(); |
|
|
|
this.props.addFish(fish); |
|
|
|
// this.props.addFish(fish);
|
|
|
|
this.refs.fishForm.reset(); |
|
|
|
// this.refs.fishForm.reset();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
@ -39,16 +41,16 @@ class TxForm extends React.Component { |
|
|
|
<input type="text" ref="currency" placeholder="Currency" /> |
|
|
|
<input type="text" ref="currency" placeholder="Currency" /> |
|
|
|
<input type="text" ref="date" placeholder="Date" /> |
|
|
|
<input type="text" ref="date" placeholder="Date" /> |
|
|
|
<select ref="account"> |
|
|
|
<select ref="account"> |
|
|
|
{this.state.accounts.map((account) => { |
|
|
|
{this.props.accounts.map((account) => { |
|
|
|
|
|
|
|
var opts = { value: account.id }; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<option value="{account.id}"> |
|
|
|
<option {...opts}>{account.title} ({account.currency})</option> |
|
|
|
{account.title} ({account.currency})</option> |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
})} |
|
|
|
})} |
|
|
|
</select> |
|
|
|
</select> |
|
|
|
<textarea type="text" ref="note" placeholder="Note"></textarea> |
|
|
|
<textarea type="text" ref="note" placeholder="Note"></textarea> |
|
|
|
<input type="text" ref="image" placeholder="URL to Image" /> |
|
|
|
<input type="text" ref="image" placeholder="URL to Image" /> |
|
|
|
<button type="submit">+ Add Tx </button> |
|
|
|
<button type="submit">+ Add Tx</button> |
|
|
|
</form> |
|
|
|
</form> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|