refactor(templates): complete admin header extraction
- Add theme.js to admin_users page for proper theme support - Pass currentUser to Header instead of hardcoded Admin user - Fix currentUserID reference bug (use currentUser.ID) - Remove duplicate theme loading script (now in Header) - Complete header refactoring for admin_users page
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package templates
|
||||
|
||||
templ AdminUsers(users []User, adminCount int, currentUserID string) {
|
||||
templ AdminUsers(currentUser User, users []User, adminCount int) {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -9,10 +9,11 @@ templ AdminUsers(users []User, adminCount int, currentUserID string) {
|
||||
<script src="/static/htmx.min.js"></script>
|
||||
<script src="/static/toast.js"></script>
|
||||
<script src="/static/header.js"></script>
|
||||
<script src="/static/theme.js"></script>
|
||||
<link href="/static/style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="theme-tokyo-night">
|
||||
@Header(User{Username: "Admin", Role: "admin"}, "/admin/users")
|
||||
@Header(currentUser, "/admin/users")
|
||||
|
||||
<!-- Modal Container (populated by HTMX) -->
|
||||
<div id="modal-container"></div>
|
||||
@@ -43,7 +44,7 @@ templ AdminUsers(users []User, adminCount int, currentUserID string) {
|
||||
<div class="flex items-center">
|
||||
<div>
|
||||
<div class="text-sm font-medium" style="color: var(--text-primary)">{user.Username}</div>
|
||||
if user.ID == currentUserID {
|
||||
if user.ID == currentUser.ID {
|
||||
<span class="text-xs px-2 py-1 rounded" style="background-color: var(--accent); color: white;">You</span>
|
||||
}
|
||||
</div>
|
||||
@@ -135,12 +136,6 @@ templ AdminUsers(users []User, adminCount int, currentUserID string) {
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadTheme();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user