diff --git a/frontend/client/components/auth/AdminGuard.tsx b/frontend/client/components/auth/AdminGuard.tsx index 2bb4130..c49994c 100644 --- a/frontend/client/components/auth/AdminGuard.tsx +++ b/frontend/client/components/auth/AdminGuard.tsx @@ -3,6 +3,7 @@ import { useEffect, useRef, useSyncExternalStore } from "react"; import { useRouter } from "next/navigation"; import { useAuthStore } from "@/stores/authStore"; +import { normalizeRole } from "@/lib/auth/role"; import { isAdminHost } from "@/lib/host"; type Props = { @@ -14,7 +15,9 @@ function subscribe() { } function isAdmin(role: unknown): boolean { - return role === "admin" || role === 2; + // The API returns the role as PascalCase ("Admin"); normalize so the check is + // case/format-insensitive (string or numeric enum). + return normalizeRole(role) === "admin"; } export function AdminGuard({ children }: Props) { diff --git a/frontend/client/hooks/useGettingStartedChecklist.ts b/frontend/client/hooks/useGettingStartedChecklist.ts index 91dd3bf..fbc8600 100644 --- a/frontend/client/hooks/useGettingStartedChecklist.ts +++ b/frontend/client/hooks/useGettingStartedChecklist.ts @@ -3,6 +3,7 @@ import { useMemo, useState, useEffect, useCallback } from "react"; import { useQuery, useQueryClient, type InfiniteData } from "@tanstack/react-query"; import { useAuthStore } from "@/stores/authStore"; +import { normalizeRole } from "@/lib/auth/role"; import { useMyInvitations } from "@/hooks/useProjects"; import { useProfileCompleteness } from "@/hooks/useProfileCompleteness"; import { fetchProjects } from "@/lib/api/projects"; @@ -82,7 +83,7 @@ export function useGettingStartedChecklist() { }, [qc]); const items: ChecklistItem[] = useMemo(() => { - const isEnterprise = role === "enterprise" || role === 1; + const isEnterprise = normalizeRole(role) === "enterprise"; if (isEnterprise) { return [