diff options
Diffstat (limited to 'jb-ui/src/models/authAPI.ts')
| -rw-r--r-- | jb-ui/src/models/authAPI.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/jb-ui/src/models/authAPI.ts b/jb-ui/src/models/authAPI.ts index 2964d55..a3efbcb 100644 --- a/jb-ui/src/models/authAPI.ts +++ b/jb-ui/src/models/authAPI.ts @@ -1,5 +1,13 @@ import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; import type { User } from "@/types/authApi"; +export const bpuid = import.meta.env.VITE_BPUID; + +// const DEV_USER: User = { +// blocked: false, +// display_name: null, +// email: "demo@jamesbillings67.com", +// product_user_id: import.meta.env.VITE_BPUID, +// }; export const authApi = createApi({ reducerPath: "authApi", @@ -10,7 +18,16 @@ export const authApi = createApi({ tagTypes: ["User"], endpoints: (builder) => ({ getMe: builder.query<User, void>({ - query: () => "/session/", + queryFn: async (_arg, _api, _extra, baseQuery) => { + // if (import.meta.env.DEV) { + // return { data: DEV_USER }; + // } + const result = await baseQuery("/session/"); + return result.data + ? { data: result.data as User } + : { error: result.error! }; + }, + providesTags: ["User"], }), // logout: builder.mutation({ @@ -22,3 +39,5 @@ export const authApi = createApi({ // export const { useGetMeQuery, useLogoutMutation } = authApi; export const { useGetMeQuery } = authApi; + +// |
