Add loading UserList for admin user
This commit is contained in:
parent
ba054ef2b9
commit
ac3450239e
4 changed files with 22 additions and 10 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import {useEffect, useState} from "react";
|
||||
import {createUser, fetchCurrentUser, updateUser} from "../../api/points/UserPoint";
|
||||
import {createUser, fetchAllUsers, fetchCurrentUser, updateUser} from "../../api/points/UserPoint";
|
||||
import type {UserDto} from "../../api/dtos/UserDto.ts";
|
||||
import ContentBackground from "../basics/ContentBackground";
|
||||
import ContentBody from "../basics/ContentBody";
|
||||
|
|
@ -17,6 +17,7 @@ import {getRecipeListUrl} from "../../routes.ts";
|
|||
import TextLinkButton from "../basics/TextLinkButton.tsx";
|
||||
import SelectField from "../basics/SelectField.tsx";
|
||||
import type {CreateUserResponse} from "../../api/dtos/CreateUserResponse.ts";
|
||||
import type {UserListResponse} from "../../api/dtos/UserListResponse.ts";
|
||||
|
||||
/**
|
||||
* UserManagementPage
|
||||
|
|
@ -50,13 +51,14 @@ export default function UserManagementPage() {
|
|||
const me = await fetchCurrentUser();
|
||||
setCurrentUser(me);
|
||||
|
||||
//if (me.role === "admin") {
|
||||
// const allUsers = await fetchAllUsers();
|
||||
// setUsers(allUsers);
|
||||
//} else {
|
||||
setUsers([me]);
|
||||
setSelectedUser(me);
|
||||
//}
|
||||
if (me.role === "admin") {
|
||||
const userResponse: UserListResponse = await fetchAllUsers();
|
||||
setUsers(userResponse.valueList);
|
||||
console.log(users)
|
||||
} else {
|
||||
setUsers([me]);
|
||||
setSelectedUser(me);
|
||||
}
|
||||
};
|
||||
|
||||
/** Handles selecting a user from the list */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue