diff --git a/server.js b/server.js index 021bd55..8f2db38 100644 --- a/server.js +++ b/server.js @@ -10,6 +10,7 @@ const env = { 'API_KEY': 0, 'ALCHEMY': process.env.ALCHEMY || 0, } + console.log('ENV',env.NETWORK_ID) app.enable('trust proxy'); app.use(function(req, res, next) { diff --git a/src/actions/orderActions.js b/src/actions/orderActions.js index dfd8960..c763568 100644 --- a/src/actions/orderActions.js +++ b/src/actions/orderActions.js @@ -131,12 +131,9 @@ export const sendListOrder = (formValues, account) => async dispatch => { dispatch(setProcessing(true)); let { token, tokenAmount, price } = formValues; - console.log('token') - console.log(token) try { var staticAddresses = FactoryProvider.getStaticAddresses(); const exchange = await Exchange.at(staticAddresses.exchange); - const response = await exchange.list(token, tokenAmount, price * 1e18, { from: account, gas: 400000 diff --git a/src/components/ApprovalFormComponent.js b/src/components/ApprovalFormComponent.js index 85b99e0..66a16b4 100644 --- a/src/components/ApprovalFormComponent.js +++ b/src/components/ApprovalFormComponent.js @@ -2,7 +2,6 @@ import React from 'react'; import { Field } from 'redux-form'; import { InputGroup } from 'reactstrap'; import InputNumber from './InputNumber'; -import Select from './Select.js'; export const ApprovalFormComponent = ({ handleSubmit, diff --git a/src/components/ApprovalFormContainer.js b/src/components/ApprovalFormContainer.js index 47df4aa..ed3aa6c 100644 --- a/src/components/ApprovalFormContainer.js +++ b/src/components/ApprovalFormContainer.js @@ -22,7 +22,6 @@ export let ApprovalFormContainer = props => { ); @@ -31,12 +30,10 @@ export let ApprovalFormContainer = props => { ApprovalFormContainer.propTypes = { sendApproveOrder: PropTypes.func.isRequired, userAccount: PropTypes.string, - userTokens: PropTypes.array, positionInfo: PropTypes.object, }; const mapStateToProps = state => ({ - userTokens: state.user.userTokens, userAccount: state.user.userAccount }); diff --git a/src/components/List.js b/src/components/List.js index 033f218..3ed052e 100644 --- a/src/components/List.js +++ b/src/components/List.js @@ -1,95 +1,26 @@ import React, { Component } from 'react'; -import { connect } from 'react-redux'; import PropTypes from 'prop-types'; -import ListFormContainer from './ListFormContainer'; -import ApprovalFormContainer from './ApprovalFormContainer'; -export class List extends Component { - constructor() { - super(); - this.state = { - formOpen: false, - resultsMessage: '' - }; - - this.toggleFormVisibility = this.toggleFormVisibility.bind(this); +export default class List extends Component { + constructor(props){ + super(props); + this.toggleForm = this.toggleForm.bind(this); } - componentWillReceiveProps(nextProps) { - if (nextProps.listOrderError !== null) { - this.setState({ - resultsMessage: `Error: ${nextProps.listOrderError}`, - formOpen: false - }); - } else if (nextProps.listOrderId) { - this.setState({ resultsMessage: '', formOpen: false }); - this.props.refreshPage(true); - } else if (nextProps.listOrderApproveError) { - this.setState({ - resultsMessage: `Error: ${nextProps.listOrderApproveError}`, - formOpen: true - }); - } else if (nextProps.listOrderApproved) { - this.setState({ - resultsMessage: `Order approval confirmed`, - formOpen: true - }); - } + toggleForm(positionInfo){ + this.props.toggleFormVisibility(positionInfo); } - toggleFormVisibility() { - this.setState({ - formOpen: !this.state.formOpen - }); - } - renderOrderModal = () => ( - this.state.formOpen || this.state.resultsMessage ? ( -
-
-
-
-

- { this.props.listOrderApproved ? List Order : Approve Order } -

- { this.props.listOrderApproved ? : } - {this.state.resultsMessage && ( -
- {this.state.resultsMessage} -
- )} -
-
-
- ) : ( - null - ) - ); - closeOrderModal = () => this.setState({ formOpen: false, resultsMessage: "" }); render() { return (
- -
- {this.renderOrderModal()} -
+
); } } + List.propTypes = { - listOrderId: PropTypes.string, - listOrderError: PropTypes.string, - listOrderApproved: PropTypes.bool, - listOrderApproveError: PropTypes.string, - refreshPage: PropTypes.func, positionInfo: PropTypes.object, + toggleFormVisibility: PropTypes.func, }; - -const mapStateToProps = state => ({ - listOrderId: state.order.list.id, - listOrderError: state.order.listOrderError, - listOrderApproved: state.order.list.approved, - listOrderApproveError: state.order.listOrderFundsError -}); - -export default connect(mapStateToProps, { })(List); diff --git a/src/components/MyPositionsBulletin.js b/src/components/MyPositionsBulletin.js index e204984..f787ed5 100644 --- a/src/components/MyPositionsBulletin.js +++ b/src/components/MyPositionsBulletin.js @@ -5,8 +5,24 @@ import Loading from './Loading'; import { SET_USER_POSITIONS } from '../actions/types'; import { formatter } from '../formatter' import List from './List' +import ListFormContainer from './ListFormContainer'; +import ApprovalFormContainer from './ApprovalFormContainer'; export class MyPositionsBulletin extends Component { + constructor() { + super(); + + this.state = { + cashoutOpen: false, + detailsOpen: false, + formOpen: false, + resultsMessage: false, + approvedPosition: null, + chosenPositionInfo: null, + }; + + this.toggleFormVisibility = this.toggleFormVisibility.bind(this); + } formatPercent (val, empty) { if (!val) { return {empty || '$0'} } var cls = val < 0 ? 'warning' : 'success' @@ -38,7 +54,7 @@ export class MyPositionsBulletin extends Component { {balance} {date} - + ); @@ -46,6 +62,35 @@ export class MyPositionsBulletin extends Component { return rows; }; + toggleFormVisibility(chosenPositionInfo) { + this.setState({ + formOpen: !this.state.formOpen, + chosenPositionInfo: chosenPositionInfo, + }); + } + renderOrderModal = () => ( + this.state.formOpen || this.state.resultsMessage ? ( +
+
+
+
+

+ { this.props.listOrderApproved ? List Order : Approve Order } +

+ { this.props.listOrderApproved ? : } + {this.state.resultsMessage && ( +
+ {this.state.resultsMessage} +
+ )} +
+
+
+ ) : ( + null + ) + ); + closeOrderModal = () => this.setState({ formOpen: false, resultsMessage: "" }); render() { return (
@@ -61,6 +106,9 @@ export class MyPositionsBulletin extends Component { {this.renderRows()} +
+ {this.renderOrderModal()} +
); } @@ -69,12 +117,20 @@ export class MyPositionsBulletin extends Component { MyPositionsBulletin.propTypes = { handleList: PropTypes.func.isRequired, loading: PropTypes.bool.isRequired, - userPositions: PropTypes.array + userPositions: PropTypes.array, + listOrderId: PropTypes.string, + listOrderError: PropTypes.string, + listOrderApproved: PropTypes.bool, + listOrderApproveError: PropTypes.string, }; const mapStateToProps = state => ({ loading: state.status.fetchInProgress.includes(SET_USER_POSITIONS), - userPositions: state.user.userPositions + userPositions: state.user.userPositions, + listOrderId: state.order.list.id, + listOrderError: state.order.listOrderError, + listOrderApproved: state.order.list.approved, + listOrderApproveError: state.order.listOrderFundsError }); export default connect(mapStateToProps,{ })(MyPositionsBulletin);