2022-12-22 01:21:51 +01:00
|
|
|
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
2022-12-28 23:41:36 +01:00
|
|
|
import apiInstance from '@utils/api/instance'
|
|
|
|
import { AxiosError } from 'axios'
|
2022-12-22 01:21:51 +01:00
|
|
|
|
|
|
|
export type QueryKeyRules = ['Rules']
|
|
|
|
|
|
|
|
const queryFunction = () =>
|
|
|
|
apiInstance<Mastodon.Rule[]>({
|
|
|
|
method: 'get',
|
|
|
|
url: 'instance/rules'
|
|
|
|
}).then(res => res.body)
|
|
|
|
|
|
|
|
const useRulesQuery = (params?: { options?: UseQueryOptions<Mastodon.Rule[], AxiosError> }) => {
|
|
|
|
const queryKey: QueryKeyRules = ['Rules']
|
|
|
|
return useQuery(queryKey, queryFunction, params?.options)
|
|
|
|
}
|
|
|
|
|
|
|
|
export { useRulesQuery }
|