feat(frontend): add useLibraryShows and useLibrarySeasons hooks
This commit is contained in:
14
k-tv-frontend/hooks/use-library-seasons.ts
Normal file
14
k-tv-frontend/hooks/use-library-seasons.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { api } from "@/lib/api";
|
||||
import { useAuthContext } from "@/context/auth-context";
|
||||
import type { SeasonSummary } from "@/lib/types";
|
||||
|
||||
export function useLibrarySeasons(seriesName: string | null, provider?: string) {
|
||||
const { token } = useAuthContext();
|
||||
return useQuery<SeasonSummary[]>({
|
||||
queryKey: ["library", "seasons", seriesName, provider],
|
||||
queryFn: () => api.library.seasons(token!, seriesName!, provider),
|
||||
enabled: !!token && !!seriesName,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user