2025-12-23 08:58:55 +00:00
|
|
|
import type { QueryKey } from '@tanstack/react-query'
|
2024-11-19 09:16:06 +00:00
|
|
|
import {
|
2025-12-23 08:58:55 +00:00
|
|
|
|
2024-11-19 09:16:06 +00:00
|
|
|
useQueryClient,
|
|
|
|
|
} from '@tanstack/react-query'
|
|
|
|
|
|
2025-11-12 09:59:37 +00:00
|
|
|
export const useInvalid = (key?: QueryKey) => {
|
2024-11-19 09:16:06 +00:00
|
|
|
const queryClient = useQueryClient()
|
|
|
|
|
return () => {
|
2025-11-12 09:59:37 +00:00
|
|
|
if (!key)
|
|
|
|
|
return
|
2024-11-19 09:16:06 +00:00
|
|
|
queryClient.invalidateQueries(
|
|
|
|
|
{
|
|
|
|
|
queryKey: key,
|
2025-01-06 10:22:16 +00:00
|
|
|
},
|
|
|
|
|
)
|
2024-11-19 09:16:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-03-07 10:10:40 +00:00
|
|
|
|
2025-11-12 09:59:37 +00:00
|
|
|
export const useReset = (key?: QueryKey) => {
|
2025-03-07 10:10:40 +00:00
|
|
|
const queryClient = useQueryClient()
|
|
|
|
|
return () => {
|
2025-11-12 09:59:37 +00:00
|
|
|
if (!key)
|
|
|
|
|
return
|
2025-03-07 10:10:40 +00:00
|
|
|
queryClient.resetQueries(
|
|
|
|
|
{
|
|
|
|
|
queryKey: key,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|