refactor: initial frontend wiring for new api

This commit is contained in:
2025-12-15 00:13:10 +00:00
parent 528aa943fa
commit 05edf69ca7
63 changed files with 1876 additions and 1991 deletions

View 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)

View 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),
})