Unified · Split
| @@ -1,5 +1,5 @@ | |||
| 1 | import React, { createContext, useContext } from "react"; | 1 | import React, { createContext, useContext } from "react"; |
| 2 | import { Atom, useAtomValue, Result } from "@effect-atom/atom-react"; | 2 | import { useAtomValue, Result } from "@effect-atom/atom-react"; |
| 3 | 3 | ||
| 4 | import { CloudApiClient } from "./client"; | 4 | import { CloudApiClient } from "./client"; |
| 5 | 5 | ||
| @@ -19,16 +19,11 @@ type AuthTeam = { · 13 unmodified lines | |||
| 19 | name: string; | 19 | name: string; |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | type MeResponse = { | ||
| 23 | user: AuthUser; | ||
| 24 | team: AuthTeam | null; | ||
| 25 | }; | ||
| 26 | |||
| 27 | // --------------------------------------------------------------------------- | 22 | // --------------------------------------------------------------------------- |
| 28 | // Auth atom — typed query against CloudAuthApi | 23 | // Auth atom — typed query against CloudAuthApi |
| 29 | // --------------------------------------------------------------------------- | 24 | // --------------------------------------------------------------------------- |
| 30 | 25 | ||
| 31 | export const authAtom: Atom.Atom<Result.Result<MeResponse, unknown>> = | 26 | export const authAtom: ReturnType<typeof CloudApiClient.query<"cloudAuth", "me">> = |
| 32 | CloudApiClient.query("cloudAuth", "me", { | 27 | CloudApiClient.query("cloudAuth", "me", { |
| 33 | timeToLive: "5 minutes", | 28 | timeToLive: "5 minutes", |
| 34 | }); | 29 | }); |