Enum for user role - somehow user page is currently unresponsive. Probably because of previous layout changes

This commit is contained in:
araemer 2025-11-30 08:42:07 +01:00
parent bd6ee25910
commit e6fd6d7d6f
5 changed files with 94 additions and 21 deletions

View file

@ -17,6 +17,7 @@ import type {UserListResponse} from "../../api/dtos/UserListResponse";
import UserList from "./UserList";
import UserEditForm from "./UserEditForm";
import ErrorPopup from "../basics/ErrorPopup";
import {UserRole} from "../../api/enums/UserRole.ts";
/**
* UserManagementPage
@ -39,8 +40,7 @@ export default function UserManagementPage() {
const [error, setError] = useState<string | null>(null);
//@todo API enum
const adminRole: string = "admin";
const isAdmin = currentUser?.role === adminRole;
const isAdmin = currentUser?.role === UserRole.ADMIN;
// Load current user and user list (if admin)
useEffect(() => {
@ -52,7 +52,7 @@ export default function UserManagementPage() {
const me = await fetchCurrentUser();
setCurrentUser(me);
if (me.role === adminRole) {
if (me.role === UserRole.ADMIN) {
const userResponse: UserListResponse = await fetchAllUsers();
// Sort users alphabetically by last name, then first name
@ -140,7 +140,7 @@ export default function UserManagementPage() {
firstName: "",
lastName: "",
email: "",
role: "user",
role: UserRole.USER,
});
};