Commit a27bee5d authored by Samuel Dudík's avatar Samuel Dudík
Browse files

Order: Minor features

parent ef752cef
Pipeline #141089 passed with stages
in 2 minutes and 47 seconds
......@@ -48,6 +48,8 @@ public class CartController extends ControllerBase {
var viewModel = new CartListingViewModel();
initializeViewModel(viewModel);
viewModel.setTitle("Cart");
var cart = cartService.loadFromCookie();
var cartItems = cart.getCartItems().entrySet().stream()
.map(x -> CartItemViewModel.builder()
......
......@@ -25,6 +25,8 @@ public class MyOrderController extends ControllerBase {
var viewModel = new OrderListingViewModel();
initializeViewModel(viewModel);
viewModel.setTitle("My orders");
viewModel.setOrders(orders);
return view(viewModel);
......
......@@ -51,6 +51,7 @@ public class OrderController extends ControllerBase {
var viewModel = new OrdersListingViewModel();
initializeViewModel(viewModel);
viewModel.setTitle("Orders");
viewModel.setOrders(orders);
viewModel.setUserLookup(users);
......
......@@ -27,10 +27,8 @@ function checkout() {
{method: 'POST'}).then((res) => {
if (res.status == 410) {
document.getElementById("failure-alert").style.display = "block";
document.getElementById("success-alert").style.display = "none";
} else {
document.getElementById("success-alert").style.display = "block";
document.getElementById("failure-alert").style.display = "none";
window.location.replace(`${getUrlPrefix()}myorder`);
}
});
}
......
......@@ -9,13 +9,7 @@
<div class="container px-4 px-lg-5">
<main role="main" class="pb-3">
<h4>Cart contents:</h4>
<div style="display: none;" id="success-alert">
<div class="alert alert-success mt-2" role="alert">
The order was sent successfully!
</div>
</div>
<h2>Shopping cart</h2>
<div style="display: none;" id="failure-alert">
<div class="alert alert-danger mt-2" role="alert">
......@@ -38,7 +32,9 @@
</tbody>
</table>
<a class="btn btn-primary" href="#" onclick="checkout()">Checkout</a>
<h5 style="text-align: center" th:if="${model.cart.empty}">Empty</h5>
<a th:unless="${model.cart.empty}" class="btn btn-primary" href="#" onclick="checkout()">Checkout</a>
</main>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment