Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit b66e2620 authored by 65160381's avatar 65160381
Browse files

10.2

parent 2a4c494a
Branches
No related tags found
No related merge requests found
Pipeline #632 passed with warnings
...@@ -57,7 +57,10 @@ ...@@ -57,7 +57,10 @@
<label for="order-products">Products:</label> <label for="order-products">Products:</label>
<ul id="order-products"> <ul id="order-products">
${order.products.map(product => ` ${order.products.map(product => `
<li>${product.name} - $${product.price} x ${product.quantity}</li> <li>
${product.name} - $${product.price} x ${product.quantity}
<input type="number" value="${product.quantity}" min="1" id="product-quantity-${product.id}" />
</li>
`).join('')} `).join('')}
</ul> </ul>
</div> </div>
...@@ -81,6 +84,15 @@ ...@@ -81,6 +84,15 @@
const status = document.getElementById('order-status').value; const status = document.getElementById('order-status').value;
const shippingAddress = document.getElementById('order-shipping-address').value; const shippingAddress = document.getElementById('order-shipping-address').value;
// Get updated quantities of each product
const updatedProducts = [];
const productsList = document.querySelectorAll('#order-products li');
productsList.forEach(productItem => {
const productId = productItem.dataset.productId;
const quantity = document.getElementById(`product-quantity-${productId}`).value;
updatedProducts.push({ productId, quantity });
});
try { try {
const response = await fetch(`/api/orders/${orderId}`, { const response = await fetch(`/api/orders/${orderId}`, {
method: 'PUT', method: 'PUT',
...@@ -89,7 +101,8 @@ ...@@ -89,7 +101,8 @@
}, },
body: JSON.stringify({ body: JSON.stringify({
status: status, status: status,
shipping_address: shippingAddress shipping_address: shippingAddress,
products: updatedProducts
}) })
}); });
...@@ -109,5 +122,6 @@ ...@@ -109,5 +122,6 @@
// Load order details when page loads // Load order details when page loads
window.onload = loadOrderDetails; window.onload = loadOrderDetails;
</script> </script>
</body> </body>
</html> </html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment