Procházet zdrojové kódy

Update the display order of transactions on the frontend

Lee Morgan před 5 roky
rodič
revize
289f68c0c9

+ 1 - 1
controllers/renderer.js

@@ -93,7 +93,7 @@ module.exports = {
                         merchant: new ObjectId(req.session.user),
                         date: {$gte: firstDay},
                     }},
-                    {$sort: {date: 1}},
+                    {$sort: {date: -1}},
                     {$project: {
                         date: 1,
                         recipes: 1

+ 1 - 2
views/dashboardPage/bundle.js

@@ -224,7 +224,7 @@ class Merchant{
 
         if(isNew){
             this.transactions.push(transaction);
-            this.transactions.sort((a, b) => a.date > b.date ? 1 : -1);
+            this.transactions.sort((a, b) => a.date > b.date ? -1 : 1);
         }
 
         let keys = Object.keys(ingredients);
@@ -2239,7 +2239,6 @@ let orderDetails = {
             let price = order.ingredients[i].pricePerUnit * order.ingredients[i].quantity;
             grandTotal += price;
 
-            console.log(order.ingredients[i])
             const ingredient = order.ingredients[i].ingredient;
             const convertedQuantity = ingredient.convert(order.ingredients[i].quantity);
             const convertedPrice = controller.reconvertPrice(order.ingredients[i].ingredient.unitType, order.ingredients[i].ingredient.unit, order.ingredients[i].pricePerUnit);

+ 1 - 1
views/dashboardPage/js/Merchant.js

@@ -177,7 +177,7 @@ class Merchant{
 
         if(isNew){
             this.transactions.push(transaction);
-            this.transactions.sort((a, b) => a.date > b.date ? 1 : -1);
+            this.transactions.sort((a, b) => a.date > b.date ? -1 : 1);
         }
 
         let keys = Object.keys(ingredients);

+ 0 - 1
views/dashboardPage/js/orderDetails.js

@@ -18,7 +18,6 @@ let orderDetails = {
             let price = order.ingredients[i].pricePerUnit * order.ingredients[i].quantity;
             grandTotal += price;
 
-            console.log(order.ingredients[i])
             const ingredient = order.ingredients[i].ingredient;
             const convertedQuantity = ingredient.convert(order.ingredients[i].quantity);
             const convertedPrice = controller.reconvertPrice(order.ingredients[i].ingredient.unitType, order.ingredients[i].ingredient.unit, order.ingredients[i].pricePerUnit);