1 | <!DOCTYPE html>
|
---|
2 | <html lang="en" xmlns:th="http://www.thymeleaf.org">
|
---|
3 | <head>
|
---|
4 | <meta charset="UTF-8">
|
---|
5 | <title>Shopping Cart</title>
|
---|
6 | <script src="https://cdn.tailwindcss.com"></script>
|
---|
7 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
---|
8 | <link href="./output.css" rel="stylesheet">
|
---|
9 | </head>
|
---|
10 |
|
---|
11 | <body class="font-sans antialiased bg-gray-100 flex flex-col min-h-screen">
|
---|
12 |
|
---|
13 | <!-- Navbar -->
|
---|
14 | <nav class="bg-gray-800 text-white p-4 text-lg sm:text-xl"> <!-- Responsive font size -->
|
---|
15 | <div class="container mx-auto flex justify-between items-center">
|
---|
16 | <div class="flex items-center">
|
---|
17 | <img src="/images/logoWhite.png" alt="Logo" class="object-cover h-32 w-32 rounded-lg">
|
---|
18 | <h1 class="text-2xl font-semibold ml-4 sm:text-3xl">Tech Harbor</h1> <!-- Responsive font size -->
|
---|
19 | </div>
|
---|
20 | <ul class="flex space-x-8">
|
---|
21 | <li><a href="/" class="hover:text-emerald-500">Home</a></li>
|
---|
22 | <li><a th:href="@{'/aboutUs'}" class="hover:text-emerald-500">About Us</a></li>
|
---|
23 | <li th:if="${user != null}">
|
---|
24 | <a th:href="@{'/orders/{id}' (id=${user.userId})}" class="hover:text-emerald-500">My Orders</a>
|
---|
25 | </li>
|
---|
26 | <li th:if="${user != null}">
|
---|
27 | <a th:href="@{'/reviews/{id}' (id=${user.userId})}" class="hover:text-emerald-500">My Reviews</a>
|
---|
28 | </li>
|
---|
29 | </ul>
|
---|
30 | <ul class="flex space-x-4">
|
---|
31 | <li th:if="${user != null}">
|
---|
32 | <span>Welcome <span th:text="${user.nameUser}"></span></span>
|
---|
33 | </li>
|
---|
34 | <li th:if="${user != null}">
|
---|
35 | <a th:href="@{'/shoppingCart'}"><i class="fa-solid fa-cart-shopping"></i></a>
|
---|
36 | </li>
|
---|
37 | <li th:if="${user != null}">
|
---|
38 | <a class="hover:text-emerald-500" th:href="@{/logout}">Log out</a>
|
---|
39 | </li>
|
---|
40 | <li th:if="${user == null}">
|
---|
41 | <a th:href="@{/login}" class="hover:text-emerald-500">Sign In</a>
|
---|
42 | </li>
|
---|
43 | <li th:if="${user == null}">
|
---|
44 | <a th:href="@{/register}" class="hover:text-emerald-500">Register</a>
|
---|
45 | </li>
|
---|
46 | </ul>
|
---|
47 |
|
---|
48 | </div>
|
---|
49 | </nav>
|
---|
50 |
|
---|
51 | <main class="container mx-auto mt-8 flex-grow">
|
---|
52 | <h2 class="text-2xl font-bold mb-4">Shopping Cart</h2>
|
---|
53 |
|
---|
54 | <div th:if="${cartItems.isEmpty()}" class="text-center p-4">
|
---|
55 | <p>Your cart is empty.</p>
|
---|
56 | <a href="/" class="underline hover:text-emerald-500">Continue Shopping</a>
|
---|
57 | </div>
|
---|
58 |
|
---|
59 | <div th:unless="${cartItems.isEmpty()}" class="my-8">
|
---|
60 | <table class="w-full rounded-md border shadow">
|
---|
61 | <thead>
|
---|
62 | <tr class="text-center">
|
---|
63 | <th class="px-4 py-2">Image</th>
|
---|
64 | <th class="px-4 py-2">Product</th>
|
---|
65 | <th class="px-4 py-2">Warranty</th>
|
---|
66 | <th class="px-4 py-2">Price</th>
|
---|
67 | </tr>
|
---|
68 | </thead>
|
---|
69 | <tbody>
|
---|
70 | <tr th:each="cartItem : ${cartItems}" class="text-center bg-white hover:bg-gray-100">
|
---|
71 | <td class="px-4 py-2">
|
---|
72 | <img th:src="${cartItem.productImage}" alt="Product Image"
|
---|
73 | class="m-auto w-32 h-32 rounded-lg object-cover">
|
---|
74 | </td>
|
---|
75 | <td class="px-4 py-2">
|
---|
76 | <a th:href="@{'/product/{id}' (id=${cartItem.productId})}" class="font-bold hover:text-emerald-500">
|
---|
77 | <span th:text="${cartItem.productName}"></span>
|
---|
78 | </a>
|
---|
79 | </td>
|
---|
80 | <td class="px-4 py-2">
|
---|
81 | <span th:text="${cartItem.productWarranty} + ' years'"></span>
|
---|
82 | </td>
|
---|
83 | <td class="px-4 py-2">
|
---|
84 | <span th:text="${cartItem.productPrice} + ' ден.'"></span>
|
---|
85 | </td>
|
---|
86 | <td class="px-4 py-2">
|
---|
87 | <a th:with="orderId=${cartItem.getProductId()}" th:href="@{'/removeFromShoppingCart/' + ${orderId}}"
|
---|
88 | class="px-4 py-2 bg-red-500 text-white rounded-md hover:bg-red-600">Remove</a>
|
---|
89 | </td>
|
---|
90 | </tr>
|
---|
91 | </tbody>
|
---|
92 |
|
---|
93 | </table>
|
---|
94 | <div class="flex items-center justify-end mt-4">
|
---|
95 | <span class="font-bold text-lg mr-8" th:text="'Total: ' + ${grandTotal} + ' ден.'"></span>
|
---|
96 | <a th:href="@{'/checkout'}" class="px-4 py-2 bg-emerald-500 text-white rounded-md hover:bg-emerald-600">Checkout</a>
|
---|
97 | </div>
|
---|
98 | </div>
|
---|
99 | </main>
|
---|
100 |
|
---|
101 | <!-- Footer -->
|
---|
102 | <footer class="bg-white rounded-lg shadow m-4 dark:bg-gray-800">
|
---|
103 | <div class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-between">
|
---|
104 | <span class="text-sm text-gray-500 sm:text-center dark:text-gray-400">© 2024 Tech Harbor. All rights reserved.™
|
---|
105 | </span>
|
---|
106 | <ul class="flex flex-wrap items-center mt-3 text-sm font-medium text-gray-500 dark:text-gray-400 sm:mt-0">
|
---|
107 | <li>
|
---|
108 | <a th:href="@{'/aboutUs'}" class="hover:underline me-4 md:me-6">About</a>
|
---|
109 | </li>
|
---|
110 | <li>
|
---|
111 | <a href="#" class="hover:underline me-4 md:me-6">Privacy Policy</a>
|
---|
112 | </li>
|
---|
113 | <li>
|
---|
114 | <a href="#" class="hover:underline">Contact</a>
|
---|
115 | </li>
|
---|
116 | </ul>
|
---|
117 | </div>
|
---|
118 | </footer>
|
---|
119 | </body>
|
---|
120 | </html> |
---|