1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/apps/dashboard/features/logs/api/useLogOptions.ts

27 lines
787 B
TypeScript
Raw Normal View History

2024-12-17 21:35:45 +03:00
import { Api } from '@jellyfin/sdk';
import { getConfigurationApi } from '@jellyfin/sdk/lib/utils/api/configuration-api';
import { useQuery } from '@tanstack/react-query';
import { useApi } from 'hooks/useApi';
2024-12-20 23:52:05 +03:00
import type { AxiosRequestConfig } from 'axios';
2024-12-17 21:35:45 +03:00
2024-12-20 23:52:05 +03:00
export const fetchLogOptions = async (api?: Api, options?: AxiosRequestConfig) => {
2024-12-17 21:35:45 +03:00
if (!api) {
console.error('[useLogOptions] No API instance available');
return;
}
2024-12-20 23:52:05 +03:00
const response = await getConfigurationApi(api).getConfiguration(options);
2024-12-17 21:35:45 +03:00
return response.data;
};
export const useLogOptions = () => {
const { api } = useApi();
return useQuery({
queryKey: ['LogOptions'],
2024-12-20 23:52:05 +03:00
queryFn: ({ signal }) => fetchLogOptions(api, { signal }),
2024-12-17 21:35:45 +03:00
enabled: !!api
});
};