mirror of
https://github.com/get-drexa/drive.git
synced 2026-02-02 20:31:16 +00:00
refactor: initial frontend wiring for new api
This commit is contained in:
14
apps/drive-web/src/account/account.ts
Normal file
14
apps/drive-web/src/account/account.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { type } from "arktype"
|
||||
import { atom } from "jotai"
|
||||
|
||||
export const Account = type({
|
||||
id: "string",
|
||||
userId: "string",
|
||||
createdAt: "string.date.iso.parse",
|
||||
updatedAt: "string.date.iso.parse",
|
||||
storageUsageBytes: "number",
|
||||
storageQuotaBytes: "number",
|
||||
})
|
||||
export type Account = typeof Account.infer
|
||||
|
||||
export const currentAccountAtom = atom<Account | null>(null)
|
||||
11
apps/drive-web/src/account/api.ts
Normal file
11
apps/drive-web/src/account/api.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { queryOptions } from "@tanstack/react-query"
|
||||
import { fetchApi } from "@/lib/api"
|
||||
import { Account } from "./account"
|
||||
|
||||
export const accountsQuery = queryOptions({
|
||||
queryKey: ["accounts"],
|
||||
queryFn: async () =>
|
||||
fetchApi("GET", "/accounts", {
|
||||
returns: Account.array(),
|
||||
}).then(([_, result]) => result),
|
||||
})
|
||||
Reference in New Issue
Block a user