Sfoglia il codice sorgente

Update transactions display

Lee Morgan 6 anni fa
parent
commit
51e85781b4

+ 1 - 0
views/dashboardPage/dashboard.ejs

@@ -279,6 +279,7 @@
                     <div class="itemDisplay">
                         <p></p>
                         <p></p>
+                        <p></p>
                     </div>
                 </template>
             </div>

+ 0 - 8
views/dashboardPage/sidebars/transactionDetails.ejs

@@ -8,14 +8,6 @@
         </button>
 
         <% if(merchant.pos === "none"){ %>
-            <button class="iconButton" onclick="transactionDetailsComp.edit()">
-                <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                    <path d="M12 20h9"></path>
-                    <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
-                </svg>
-            </button>
-
-        
             <button class="iconButton" onclick="transactionDetailsComp.remove()">
                 <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                     <polyline points="3 6 5 6 21 6"></polyline>

+ 10 - 1
views/dashboardPage/transactions.js

@@ -15,8 +15,17 @@ window.transactionsStrandObj = {
                 transaction.onclick = ()=>{transactionDetailsComp.display(merchant.transactions[i])};
                 transactionsList.appendChild(transaction);
 
+                let totalRecipes = 0;
+                let totalPrice = 0;
+
+                for(let j = 0; j < merchant.transactions[i].recipes.length; j++){
+                    totalRecipes += merchant.transactions[i].recipes[j].quantity;
+                    totalPrice += merchant.transactions[i].recipes[j].recipe.price * merchant.transactions[i].recipes[j].quantity;
+                }
+
                 transaction.children[0].innerText = `${merchant.transactions[i].date.toLocaleDateString()} ${merchant.transactions[i].date.toLocaleTimeString()}`;
-                transaction.children[1].innerText = `${merchant.transactions[i].recipes.length} recipes sold`;
+                transaction.children[1].innerText = `${totalRecipes} recipes sold`;
+                transaction.children[2].innerText = `$${(totalPrice / 100).toFixed(2)}`;
             }
 
             this.isPopulated = true;