fix: change the me endpoint to useQuery api

This commit is contained in:
mengstabketemaw
2026-07-08 13:36:52 +03:00
parent 9dd4c8867f
commit c106ac68d4
13 changed files with 36 additions and 87 deletions

View File

@@ -4,6 +4,6 @@ import { baseQueryWithReauth } from './base-query-with-reauth';
export const baseApi = createApi({
reducerPath: 'baseApi',
baseQuery: baseQueryWithReauth,
tagTypes: ['Api'],
tagTypes: ['Api', 'Me'],
endpoints: () => ({}),
});

View File

@@ -22,11 +22,15 @@ const queryApi = baseApi.injectEndpoints({
headers,
}),
}),
getMe: builder.query<unknown, void>({
query: () => '/auth/me',
providesTags: ['Me'],
}),
}),
overrideExisting: false,
});
export const { useApiQueryQuery, useApiMutationMutation } = queryApi;
export const { useApiQueryQuery, useApiMutationMutation, useGetMeQuery } = queryApi;
export function useApiQuery<TData = unknown>(
args: ApiQueryArgs,

View File

@@ -5,11 +5,7 @@ export const SESSION_HEADER_KEYS = {
currentProjectId: 'x-current-project-id',
} as const;
const TOKEN_STORAGE_KEYS = [
'ema-backoffice-auth-token',
'ema-portal-auth-token',
'auth-token',
] as const;
const TOKEN_STORAGE_KEYS = ['auth-token'] as const;
export function resolveTokenFromStorage(): string | undefined {
for (const key of TOKEN_STORAGE_KEYS) {