Skip to content

Commit ef9374f

Browse files
authored
Update account-dashboard.html
1 parent b5fe2b4 commit ef9374f

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

account-dashboard.html

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
<html>
33
<head>
44
<title>Coding Hut Website</title>
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link href="https://fonts.googleapis.com/css?family=Comfortaa" rel="stylesheet" />
67
<style>
78
body {
89
overflow-x: hidden;
9-
font-family: Sans-Serif;
10+
font-family: "Comfortaa", Sans-Serif;
1011
margin: 0;
12+
font-size: 22px;
1113
}
12-
<link href='https://fonts.googleapis.com/css?family=Comfortaa' rel='stylesheet'>
13-
<style>
14-
body {
15-
font-family: 'Comfortaa';font-size: 22px;
16-
}
1714

1815
.menu-container {
1916
position: relative;
@@ -108,7 +105,7 @@
108105
<nav class="menu-container">
109106
<!-- Logo -->
110107
<a href="https://scratch-coding-hut.github.io" class="menu-logo">
111-
<img src="Images/Coding-Hut-Logo.png" alt="Coding Hut Logo" width="50" height="50"></img>
108+
<img src="Images/Coding-Hut-Logo.png" alt="Coding Hut Logo" width="50" height="50" />
112109
</a>
113110

114111
<!-- Menu for Mobile -->
@@ -129,31 +126,40 @@
129126
</div>
130127
</nav>
131128

132-
<h1 id="user" style="text-align:center;"><b>Coding Hut</b></h1>
133-
<h2 style="text-align:center;">Welcome to your dashboard</h2>
134-
<p id="data" style="text-align:center;">COMING SOON</p>
129+
<h1 id="user" style="text-align: center"><b>Coding Hut</b></h1>
130+
<h2 style="text-align: center">Welcome to your dashboard</h2>
131+
<p id="data" style="text-align: center">COMING SOON</p>
135132

136133
<script>
137-
const username = localStorage.getItem('username');
138-
if (username) {
139-
document.getElementById('user').textContent = username;
140-
141-
try {
142-
const res = await fetch(`https://scratch-coding-hut-data.onrender.com/${username}`);
143-
const data = await res.json();
144-
145-
if (data) {
146-
document.getElementById('data').textContent = JSON.stringify(data);
134+
// Fetch user data and update UI
135+
async function loadUserData() {
136+
const username = localStorage.getItem("username");
137+
138+
if (username) {
139+
document.getElementById("user").textContent = username;
140+
141+
try {
142+
const res = await fetch(`https://scratch-coding-hut-data.onrender.com/${username}`);
143+
const data = await res.json();
144+
145+
if (data) {
146+
document.getElementById("data").textContent = JSON.stringify(data);
147+
}
148+
} catch (error) {
149+
console.error("Error fetching data:", error);
150+
document.getElementById("data").textContent = "Failed to load data.";
151+
}
147152
}
148-
} catch (error) {
149-
console.error('Error fetching data:', error);
150-
}
151-
}
152-
153+
}
154+
155+
// Menu toggle for mobile
153156
function toggleMenu() {
154-
var menu = document.querySelector('.menu');
155-
menu.style.display = menu.style.display === 'flex' ? 'none' : 'flex';
157+
var menu = document.querySelector(".menu");
158+
menu.style.display = menu.style.display === "flex" ? "none" : "flex";
156159
}
160+
161+
// Load user data on page load
162+
document.addEventListener("DOMContentLoaded", loadUserData);
157163
</script>
158164
</body>
159165
</html>

0 commit comments

Comments
 (0)