diff --git a/apps/web/src/app/(authenticated)/settings/users/page.tsx b/apps/web/src/app/(authenticated)/settings/users/page.tsx index 45397bb..35b0f35 100644 --- a/apps/web/src/app/(authenticated)/settings/users/page.tsx +++ b/apps/web/src/app/(authenticated)/settings/users/page.tsx @@ -9,7 +9,7 @@ import { type SyntheticEvent, } from "react"; import Link from "next/link"; -import { UserPlus, UserX } from "lucide-react"; +import { Pencil, UserPlus, UserX } from "lucide-react"; import { WorkspaceMemberRole } from "@mosaic/shared"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; @@ -46,9 +46,11 @@ import { deactivateUser, fetchAdminUsers, inviteUser, + updateUser, type AdminUser, type AdminUsersResponse, type InviteUserDto, + type UpdateUserDto, } from "@/lib/api/admin"; const ROLE_PRIORITY: Record = { @@ -98,6 +100,11 @@ export default function UsersSettingsPage(): ReactElement { const [deactivateTarget, setDeactivateTarget] = useState(null); const [isDeactivating, setIsDeactivating] = useState(false); + const [editTarget, setEditTarget] = useState(null); + const [editName, setEditName] = useState(""); + const [editError, setEditError] = useState(null); + const [isEditing, setIsEditing] = useState(false); + const loadUsers = useCallback(async (showLoadingState: boolean): Promise => { try { if (showLoadingState) { @@ -188,6 +195,23 @@ export default function UsersSettingsPage(): ReactElement { } } + async function handleEditSubmit(): Promise { + if (editTarget === null) return; + setIsEditing(true); + setEditError(null); + try { + const dto: UpdateUserDto = {}; + if (editName.trim()) dto.name = editName.trim(); + await updateUser(editTarget.id, dto); + setEditTarget(null); + await loadUsers(false); + } catch (err: unknown) { + setEditError(err instanceof Error ? err.message : "Failed to update user"); + } finally { + setIsEditing(false); + } + } + return (
@@ -381,6 +405,18 @@ export default function UsersSettingsPage(): ReactElement { {isActive ? "Active" : "Inactive"} + {isActive ? (
); + + { + if (!open && !isEditing) { + setEditTarget(null); + setEditError(null); + } + }} + > + + + Edit User Role + Change role for {editTarget?.email ?? "user"}. + +
+ {editError !== null ?

{editError}

: null} +
+ + ) => { + setEditName(e.target.value); + }} + placeholder="Full name" + disabled={isEditing} + /> +
+
+ + + + +
+
; }