From 172467c0a6a1e100b0346cc8adfc61695373bcdd Mon Sep 17 00:00:00 2001 From: gorkem-bwl Date: Fri, 6 Mar 2026 15:19:01 -0500 Subject: [PATCH] fix: address PR review feedback - Use useIsAdmin and useIsSuperAdmin hooks instead of manual role checks - Close delete dialog on failure, not just on success --- client/src/Pages/Account/EditUser/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/Pages/Account/EditUser/index.tsx b/client/src/Pages/Account/EditUser/index.tsx index d31722dcf..728f9f0e6 100644 --- a/client/src/Pages/Account/EditUser/index.tsx +++ b/client/src/Pages/Account/EditUser/index.tsx @@ -20,6 +20,7 @@ import { useEffect, useState } from "react"; import { DialogInput } from "@/Components/inputs/Dialog"; import { useSelector } from "react-redux"; import type { RootState } from "@/Types/state"; +import { useIsAdmin, useIsSuperAdmin } from "@/Hooks/useIsAdmin"; interface RoleOption { id: UserRole; @@ -36,8 +37,8 @@ const EditUserPage = () => { const navigate = useNavigate(); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const currentUser = useSelector((state: RootState) => state.auth.user); - const isSuperAdmin = currentUser?.role?.includes("superadmin") ?? false; - const isAdmin = isSuperAdmin || (currentUser?.role?.includes("admin") ?? false); + const isSuperAdmin = useIsSuperAdmin(); + const isAdmin = useIsAdmin(); const { data: user, isLoading } = useGet(`/auth/users/${userId}`); @@ -77,8 +78,8 @@ const EditUserPage = () => { const handleDeleteUser = async () => { const result = await deleteFn(`/auth/users/${userId}`); + setShowDeleteDialog(false); if (result) { - setShowDeleteDialog(false); navigate("/account", { state: { tab: "team" } }); } };