Refactor queries to use non-null assert

This commit is contained in:
viown
2025-02-25 17:18:50 +03:00
parent 3df39d659c
commit 2ce9e9f1e0
28 changed files with 47 additions and 127 deletions
@@ -4,13 +4,8 @@ import { useQuery } from '@tanstack/react-query';
import { useApi } from 'hooks/useApi';
import type { AxiosRequestConfig } from 'axios';
const fetchServerLogs = async (api?: Api, options?: AxiosRequestConfig) => {
if (!api) {
console.error('[useServerLogs] No API instance available');
return;
}
const response = await getSystemApi(api).getServerLogs(options);
const fetchServerLogs = async (api: Api, options?: AxiosRequestConfig) => {
const response = await getSystemApi(api!).getServerLogs(options);
return response.data;
};
@@ -20,7 +15,7 @@ export const useServerLogs = () => {
return useQuery({
queryKey: [ 'ServerLogs' ],
queryFn: ({ signal }) => fetchServerLogs(api, { signal }),
queryFn: ({ signal }) => fetchServerLogs(api!, { signal }),
enabled: !!api
});
};