Spaces:
Running
Running
Review an solve errors
Browse files- components/navbar.js +18 -15
components/navbar.js
CHANGED
|
@@ -104,25 +104,28 @@ class AppNavbar extends HTMLElement {
|
|
| 104 |
<i data-feather="menu" width="18" height="18"></i>
|
| 105 |
</button>
|
| 106 |
</div>
|
| 107 |
-
<script>
|
| 108 |
-
document.getElementById('logoutBtn').addEventListener('click', async () => {
|
| 109 |
-
try {
|
| 110 |
-
const response = await fetch('/api/logout', {
|
| 111 |
-
method: 'POST',
|
| 112 |
-
credentials: 'include'
|
| 113 |
-
});
|
| 114 |
-
if (response.ok) {
|
| 115 |
-
window.location.href = '/login.html';
|
| 116 |
-
}
|
| 117 |
-
} catch (error) {
|
| 118 |
-
console.error('Logout error:', error);
|
| 119 |
-
}
|
| 120 |
-
});
|
| 121 |
-
</script>
|
| 122 |
</div>
|
| 123 |
`;
|
| 124 |
// Re-initialize feather icons inside shadow DOM
|
| 125 |
feather.replace();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
| 127 |
}
|
| 128 |
customElements.define('app-navbar', AppNavbar);
|
|
|
|
| 104 |
<i data-feather="menu" width="18" height="18"></i>
|
| 105 |
</button>
|
| 106 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
</div>
|
| 108 |
`;
|
| 109 |
// Re-initialize feather icons inside shadow DOM
|
| 110 |
feather.replace();
|
| 111 |
+
|
| 112 |
+
// Add logout functionality
|
| 113 |
+
const logoutBtn = this.shadowRoot.getElementById('logoutBtn');
|
| 114 |
+
if (logoutBtn) {
|
| 115 |
+
logoutBtn.addEventListener('click', async () => {
|
| 116 |
+
try {
|
| 117 |
+
const response = await fetch('/api/logout', {
|
| 118 |
+
method: 'POST',
|
| 119 |
+
credentials: 'include'
|
| 120 |
+
});
|
| 121 |
+
if (response.ok) {
|
| 122 |
+
window.location.href = '/login.html';
|
| 123 |
+
}
|
| 124 |
+
} catch (error) {
|
| 125 |
+
console.error('Logout error:', error);
|
| 126 |
+
}
|
| 127 |
+
});
|
| 128 |
+
}
|
| 129 |
}
|
| 130 |
}
|
| 131 |
customElements.define('app-navbar', AppNavbar);
|