From 2b44d32b01c0da5fc58ae0fbb4552e6e268a7f8e Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Tue, 3 May 2022 13:21:04 -0700 Subject: [PATCH] Store robot token in cookies. Add renew order after success for makers. --- api/views.py | 12 ++++---- frontend/src/components/BookPage.js | 40 +++++++++++++------------- frontend/src/components/BottomBar.js | 8 +++--- frontend/src/components/HomePage.js | 3 +- frontend/src/components/MakerPage.js | 2 +- frontend/src/components/TradeBox.js | 15 +++++++++- frontend/src/components/UserGenPage.js | 29 ++++++++++--------- frontend/src/utils/cookies.js | 4 +++ 8 files changed, 67 insertions(+), 46 deletions(-) diff --git a/api/views.py b/api/views.py index 1b8f8b31..50918732 100644 --- a/api/views.py +++ b/api/views.py @@ -384,15 +384,17 @@ class OrderView(viewsets.ViewSet): # Add invoice amount once again if invoice was expired. data["invoice_amount"] = Logics.payout_amount(order,request.user)[1]["invoice_amount"] - # 10) If status is 'Expired', add expiry reason. - elif (order.status == Order.Status.EXP): - data["expiry_reason"] = order.expiry_reason - data["expiry_message"] = Order.ExpiryReasons(order.expiry_reason).label - # other pieces of info useful to renew an identical order + # 10) If status is 'Expired', "Sending", "Finished" or "failed routing", add info for renewal: + elif order.status in [Order.Status.EXP, Order.Status.SUC, Order.Status.PAY, Order.Status.FAI]: data["public_duration"] = order.public_duration data["bond_size"] = order.bond_size data["bondless_taker"] = order.bondless_taker + # If status is 'Expired' add expiry reason + if order.status == Order.Status.EXP: + data["expiry_reason"] = order.expiry_reason + data["expiry_message"] = Order.ExpiryReasons(order.expiry_reason).label + return Response(data, status.HTTP_200_OK) def take_update_confirm_dispute_cancel(self, request, format=None): diff --git a/frontend/src/components/BookPage.js b/frontend/src/components/BookPage.js index a7987092..afec3d64 100644 --- a/frontend/src/components/BookPage.js +++ b/frontend/src/components/BookPage.js @@ -26,7 +26,7 @@ class BookPage extends Component { pageSize: 6, }; - if(this.props.orders.length == 0){ + if(this.props.bookOrders.length == 0){ this.getOrderDetails(2, 0) } } @@ -85,8 +85,8 @@ class BookPage extends Component {
order.type == this.props.type || this.props.type == 2) - .filter(order => order.currency == this.props.currency || this.props.currency == 0) + this.props.bookOrders.filter(order => order.type == this.props.bookType || this.props.bookType == 2) + .filter(order => order.currency == this.props.bookCurrency || this.props.bookCurrency == 0) .map((order) => ({id: order.id, avatar: window.location.origin +'/static/assets/avatars/' + order.maker_nick + '.png', @@ -103,7 +103,7 @@ class BookPage extends Component { premium: order.premium, }) )} - loading={this.props.loading} + loading={this.props.bookLoading} columns={[ // { field: 'id', headerName: 'ID', width: 40 }, { field: 'robot', headerName: t("Robot"), width: 240, @@ -166,7 +166,7 @@ class BookPage extends Component { ) }} - pageSize={this.props.loading ? 0 : this.state.pageSize} + pageSize={this.props.bookLoading ? 0 : this.state.pageSize} rowsPerPageOptions={[6,20,50]} onPageSizeChange={(newPageSize) => this.setState({pageSize:newPageSize})} onRowClick={(params) => this.handleRowClick(params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places. @@ -180,10 +180,10 @@ class BookPage extends Component { return (
order.type == this.props.type || this.props.type == 2) - .filter(order => order.currency == this.props.currency || this.props.currency == 0) + this.props.bookOrders.filter(order => order.type == this.props.bookType || this.props.bookType == 2) + .filter(order => order.currency == this.props.bookCurrency || this.props.bookCurrency == 0) .map((order) => ({id: order.id, avatar: window.location.origin +'/static/assets/avatars/' + order.maker_nick + '.png', @@ -267,7 +267,7 @@ class BookPage extends Component { ) }} - pageSize={this.props.loading ? 0 : this.state.pageSize} + pageSize={this.props.bookLoading ? 0 : this.state.pageSize} rowsPerPageOptions={[6,20,50]} onPageSizeChange={(newPageSize) => this.setState({pageSize:newPageSize})} onRowClick={(params) => this.handleRowClick(params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places. @@ -308,10 +308,10 @@ class BookPage extends Component { - {this.props.type == 0 ? - t("No orders found to sell BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode}) + {this.props.bookType == 0 ? + t("No orders found to sell BTC for {{currencyCode}}",{currencyCode:this.props.bookCurrencyCode}) : - t("No orders found to buy BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode}) + t("No orders found to buy BTC for {{currencyCode}}",{currencyCode:this.props.bookCurrencyCode}) } @@ -382,7 +382,7 @@ class BookPage extends Component {
- {this.props.type == 0 ? t("and receive") : (this.props.type == 1 ? t("and pay with") : t("and use") )} + {this.props.bookType == 0 ? t("and receive") : (this.props.bookType == 1 ? t("and pay with") : t("and use") )}