Fix user selection
This commit is contained in:
parent
e6fd6d7d6f
commit
02fbfb033d
3 changed files with 32 additions and 5 deletions
|
|
@ -39,7 +39,6 @@ export default function UserManagementPage() {
|
|||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
//@todo API enum
|
||||
const isAdmin = currentUser?.role === UserRole.ADMIN;
|
||||
|
||||
// Load current user and user list (if admin)
|
||||
|
|
@ -47,6 +46,12 @@ export default function UserManagementPage() {
|
|||
loadData();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Load data for user management page
|
||||
*
|
||||
* An admin can see all users while a normal user can only see his own user data.
|
||||
* Initially, the current user is selected.
|
||||
*/
|
||||
const loadData = async () => {
|
||||
try {
|
||||
const me = await fetchCurrentUser();
|
||||
|
|
@ -133,7 +138,7 @@ export default function UserManagementPage() {
|
|||
setIsPasswordModalOpen(true);
|
||||
};
|
||||
|
||||
/** Handles creating a new user (admin only) */
|
||||
/** Add new empty user */
|
||||
const handleAddUser = () => {
|
||||
setSelectedUser({
|
||||
userName: "",
|
||||
|
|
@ -158,6 +163,7 @@ export default function UserManagementPage() {
|
|||
buttonType={ButtonType.PrimaryButton}
|
||||
/>
|
||||
)}
|
||||
{/* Leave user management and return to recipe list. @todo handle unsaved changes?*/}
|
||||
<ButtonLink icon={X} to={getRecipeListUrl()}/>
|
||||
</ButtonGroupLayout>
|
||||
</StickyHeader>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue