final touches for beta skymoney (at least i think)
This commit is contained in:
16
web/src/hooks/useAuthSession.ts
Normal file
16
web/src/hooks/useAuthSession.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useQuery, type UseQueryOptions } from "@tanstack/react-query";
|
||||
import { http } from "../api/http";
|
||||
|
||||
type SessionResponse = { ok: true; userId: string; email: string | null; displayName: string | null };
|
||||
|
||||
type Options = Omit<UseQueryOptions<SessionResponse, Error>, "queryKey" | "queryFn">;
|
||||
|
||||
export function useAuthSession(options?: Options) {
|
||||
return useQuery<SessionResponse, Error>({
|
||||
queryKey: ["auth", "session"],
|
||||
queryFn: async () =>
|
||||
http<SessionResponse>("/auth/session", { skipAuthRedirect: true }),
|
||||
retry: false,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user