mirror of
https://github.com/get-drexa/drive.git
synced 2026-02-02 16:11:17 +00:00
15 lines
432 B
TypeScript
15 lines
432 B
TypeScript
import { queryOptions } from "@tanstack/react-query"
|
|
import { atomWithQuery } from "jotai-tanstack-query"
|
|
import { fetchApi } from "../lib/api"
|
|
import { User } from "./user"
|
|
|
|
export const currentUserQuery = queryOptions({
|
|
queryKey: ["currentUser"],
|
|
queryFn: async () =>
|
|
fetchApi("GET", "/users/me", {
|
|
returns: User,
|
|
}).then(([_, result]) => result),
|
|
})
|
|
|
|
export const currentUserAtom = atomWithQuery(() => currentUserQuery)
|