From f8ec87c7f2b71040965c1cdc49ae9b6f92be6df2 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 17 Dec 2025 21:01:44 +0000 Subject: [PATCH] chore: delete unused useUserAccess hook from use-rbac.ts --- surfsense_web/hooks/use-rbac.ts | 69 --------------------------------- 1 file changed, 69 deletions(-) diff --git a/surfsense_web/hooks/use-rbac.ts b/surfsense_web/hooks/use-rbac.ts index b4b3693d5..2d8e4a22d 100644 --- a/surfsense_web/hooks/use-rbac.ts +++ b/surfsense_web/hooks/use-rbac.ts @@ -96,75 +96,6 @@ export interface InviteInfo { // ============ Members Hook ============ -export function useUserAccess(searchSpaceId: number) { - const [access, setAccess] = useState(null); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - - const fetchAccess = useCallback(async () => { - if (!searchSpaceId) return; - - try { - setLoading(true); - const response = await authenticatedFetch( - `${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/searchspaces/${searchSpaceId}/my-access`, - { method: "GET" } - ); - - if (!response.ok) { - const errorData = await response.json().catch(() => ({})); - throw new Error(errorData.detail || "Failed to fetch access info"); - } - - const data = await response.json(); - setAccess(data); - setError(null); - return data; - } catch (err: any) { - setError(err.message || "Failed to fetch access info"); - console.error("Error fetching access:", err); - } finally { - setLoading(false); - } - }, [searchSpaceId]); - - useEffect(() => { - fetchAccess(); - }, [fetchAccess]); - - // Helper function to check if user has a specific permission - const hasPermission = useCallback( - (permission: string) => { - if (!access) return false; - // Owner/full access check - if (access.permissions.includes("*")) return true; - return access.permissions.includes(permission); - }, - [access] - ); - - // Helper function to check if user has any of the given permissions - const hasAnyPermission = useCallback( - (permissions: string[]) => { - if (!access) return false; - if (access.permissions.includes("*")) return true; - return permissions.some((p) => access.permissions.includes(p)); - }, - [access] - ); - - return { - access, - loading, - error, - fetchAccess, - hasPermission, - hasAnyPermission, - }; -} - -// ============ Invite Info Hook (Public) ============ - export function useInviteInfo(inviteCode: string | null) { const [inviteInfo, setInviteInfo] = useState(null); const [loading, setLoading] = useState(true);