Gitlab@Informatics

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

8.3

parent 43f47383
Branches
No related tags found
No related merge requests found
Pipeline #604 passed with warnings
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<a href="cart.html">Cart (<span id="cart-item-count">0</span>)</a> <a href="cart.html">Cart (<span id="cart-item-count">0</span>)</a>
</div> </div>
<div class="user-info"> <div class="user-info">
<span id="welcome-message">Welcome, User</span> <!-- Display User's Name here --> <span id="welcome-message">Welcome, User</span> <!-- Display User's Email here -->
<a href="edit-order.html" class="edit-order-btn">Edit Order</a> <!-- ปุ่ม Edit Order --> <a href="edit-order.html" class="edit-order-btn">Edit Order</a> <!-- ปุ่ม Edit Order -->
</div> </div>
<div class="logout"> <div class="logout">
...@@ -102,9 +102,9 @@ ...@@ -102,9 +102,9 @@
async function displayUsername() { async function displayUsername() {
try { try {
const response = await fetch('/api/getUser'); // Endpoint to get the username const response = await fetch('/api/getUser'); // Endpoint to get the user's email
const user = await response.json(); const user = await response.json();
document.getElementById('welcome-message').innerText = `Welcome, ${user.email} `; document.getElementById('welcome-message').innerText = `Welcome, ${user.email}`; // Display email here
} catch (error) { } catch (error) {
console.log('Error fetching user info:', error); console.log('Error fetching user info:', error);
} }
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
// Initially load products and cart item count // Initially load products and cart item count
fetchProducts(); // Fetch all products initially fetchProducts(); // Fetch all products initially
updateCart(); // Update cart count when page loads updateCart(); // Update cart count when page loads
displayUsername(); // Display user info when page loads displayUsername(); // Display user's email when page loads
</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