mirror of
https://github.com/get-drexa/drive.git
synced 2026-02-02 18:41:17 +00:00
refactor: initial frontend wiring for new api
This commit is contained in:
14
apps/drive-web/src/user/api.ts
Normal file
14
apps/drive-web/src/user/api.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
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)
|
||||
9
apps/drive-web/src/user/user.ts
Normal file
9
apps/drive-web/src/user/user.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { type } from "arktype"
|
||||
|
||||
export const User = type({
|
||||
id: "string",
|
||||
displayName: "string",
|
||||
email: "string",
|
||||
})
|
||||
|
||||
export type User = typeof User.infer
|
||||
Reference in New Issue
Block a user