diff --git a/api/views.py b/api/views.py index 61532ff5..ac2103df 100644 --- a/api/views.py +++ b/api/views.py @@ -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) diff --git a/frontend/src/components/BottomBar.js b/frontend/src/components/BottomBar.js index a007d4a3..a64d5d82 100644 --- a/frontend/src/components/BottomBar.js +++ b/frontend/src/components/BottomBar.js @@ -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> diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json index b3f729fb..36e37bcb 100644 --- a/frontend/src/locales/es.json +++ b/frontend/src/locales/es.json @@ -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",