mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 02:21:35 +00:00
Implement last order always shown on robot profile
This commit is contained in:
parent
60944ea716
commit
1b4d42cfdf
@ -1,6 +1,6 @@
|
||||
import os
|
||||
from re import T
|
||||
from django.db.models import Sum
|
||||
from django.db.models import Sum, Q
|
||||
from rest_framework import status, viewsets
|
||||
from rest_framework.generics import CreateAPIView, ListAPIView
|
||||
from rest_framework.views import APIView
|
||||
@ -768,6 +768,10 @@ class InfoView(ListAPIView):
|
||||
request.user)
|
||||
if not has_no_active_order:
|
||||
context["active_order_id"] = order.id
|
||||
else:
|
||||
last_order = Order.objects.filter(Q(maker=request.user) | Q(taker=request.user)).last()
|
||||
if last_order:
|
||||
context["last_order_id"] = last_order.id
|
||||
|
||||
return Response(context, status.HTTP_200_OK)
|
||||
|
||||
|
@ -69,7 +69,9 @@ class BottomBar extends Component {
|
||||
this.setState(null)
|
||||
fetch('/api/info/')
|
||||
.then((response) => response.json())
|
||||
.then((data) => this.setState(data) & this.setState({active_order_id: data.active_order_id ? data.active_order_id : null})
|
||||
.then((data) => this.setState(data)
|
||||
& this.setState({active_order_id: data.active_order_id ? data.active_order_id : null,
|
||||
last_order_id: data.last_order_id ? data.last_order_id : null})
|
||||
& this.props.setAppState({nickname:data.nickname, loading:false}));
|
||||
}
|
||||
|
||||
@ -305,6 +307,7 @@ class BottomBar extends Component {
|
||||
</ListItem>
|
||||
|
||||
<Divider/>
|
||||
|
||||
{this.state.active_order_id ?
|
||||
<ListItemButton onClick={this.handleClickCloseProfile} to={'/order/'+this.state.active_order_id} component={LinkRouter}>
|
||||
<ListItemIcon>
|
||||
@ -315,10 +318,20 @@ class BottomBar extends Component {
|
||||
<ListItemText primary={t("One active order #{{orderID}}",{orderID: this.state.active_order_id})} secondary={t("Your current order")}/>
|
||||
</ListItemButton>
|
||||
:
|
||||
<ListItem>
|
||||
<ListItemIcon><NumbersIcon/></ListItemIcon>
|
||||
<ListItemText primary={t("No active orders")} secondary={t("Your current order")}/>
|
||||
</ListItem>
|
||||
|
||||
this.state.last_order_id ?
|
||||
<ListItemButton onClick={this.handleClickCloseProfile} to={'/order/'+this.state.last_order_id} component={LinkRouter}>
|
||||
<ListItemIcon>
|
||||
<NumbersIcon color="primary"/>
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={t("Your last order #{{orderID}}",{orderID: this.state.last_order_id})} secondary={t("Inactive order")}/>
|
||||
</ListItemButton>
|
||||
:
|
||||
<ListItem>
|
||||
<ListItemIcon><NumbersIcon/></ListItemIcon>
|
||||
<ListItemText primary={t("No active orders")} secondary={t("You do not have previous orders")}/>
|
||||
</ListItem>
|
||||
|
||||
}
|
||||
|
||||
<ListItem>
|
||||
|
@ -172,7 +172,9 @@
|
||||
"Taker fee":"Comisión del tomador",
|
||||
"Number of public BUY orders": "Nº de órdenes públicas de COMPRA",
|
||||
"Number of public SELL orders": "Nº de órdenes públicas de VENTA",
|
||||
|
||||
"Your last order #{{orderID}}":"Tu última orden #{{orderID}}",
|
||||
"Inactive order":"Orden inactiva",
|
||||
"You do not have previous orders":"No tienes órdenes previas",
|
||||
|
||||
"ORDER PAGE - OrderPage.js": "Order details page",
|
||||
"Order Box": "Orden",
|
||||
|
Loading…
Reference in New Issue
Block a user