mirror of
https://github.com/acid-info/logos-ordinals-dashboard.git
synced 2025-01-29 22:55:11 +00:00
33 lines
720 B
TypeScript
33 lines
720 B
TypeScript
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
|
import operators from '../../data/operators.json'
|
|
|
|
const useQueryOptions = {
|
|
refetchOnWindowFocus: false,
|
|
staleTime: 60 * 1000,
|
|
retry: 1,
|
|
}
|
|
|
|
export const fetchData = async () => {
|
|
return operators
|
|
// return await api.get('/operators').then((res) => res.data)
|
|
}
|
|
|
|
const useGetOperators = () => {
|
|
const queryKey = ['getOperators']
|
|
const queryClient = useQueryClient()
|
|
|
|
const updateCache = (newData: any) => {
|
|
queryClient.setQueryData(queryKey, newData)
|
|
}
|
|
|
|
const response = useQuery({
|
|
queryKey: queryKey,
|
|
queryFn: fetchData,
|
|
...useQueryOptions,
|
|
})
|
|
|
|
return { ...response, updateCache }
|
|
}
|
|
|
|
export default useGetOperators
|