import { queryOptions } from "@tanstack/react-query"; import { $api, fetchClient } from "@/client/lib/api"; import type { operations } from "@/client/lib/openapi-types"; export type MeProfile = operations["getApiV1Me"]["responses"][200]["content"]["application/json"]; export const meQueryKey = ["get", "/api/v1/me"] as const; export const meQueryOptions = queryOptions({ queryKey: meQueryKey, queryFn: async ({ signal }) => { const { data, error, response } = await fetchClient.GET("/api/v1/me", { signal }); if (response.status === 401) return null; if (error) throw error; return (data ?? null) as MeProfile | null; }, staleTime: 30_000, retry: false, }); export function useMe() { return $api.useQuery( "get", "/api/v1/me", {}, { staleTime: 30_000, retry: false, }, ); }