"use client" import { useQuery } from "@tanstack/react-query" import { apiClient } from "@/lib/api/client" import type { AdminUserRole } from "@/lib/api/admin-types" import { useAuthReady } from "@/lib/api/use-auth-ready" export type CurrentUser = { sub: string email: string name: string status: string platform_admin: boolean role: AdminUserRole groups?: string[] } export function useCurrentUser() { const { ready, authenticated } = useAuthReady() return useQuery({ queryKey: ["current-user"], queryFn: () => apiClient.get("/users/me"), staleTime: 60_000, enabled: ready && authenticated, retry: 1, }) }