feat(frontend): add useLibraryShows and useLibrarySeasons hooks

This commit is contained in:
2026-03-20 01:29:55 +01:00
parent 6cf8a6d5e3
commit 8101734c63
2 changed files with 34 additions and 0 deletions

View 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,
});
}

View File

@@ -0,0 +1,20 @@
import { useQuery } from "@tanstack/react-query";
import { api } from "@/lib/api";
import { useAuthContext } from "@/context/auth-context";
import type { ShowSummary } from "@/lib/types";
export interface ShowsFilter {
q?: string;
provider?: string;
genres?: string[];
}
export function useLibraryShows(filter: ShowsFilter = {}) {
const { token } = useAuthContext();
return useQuery<ShowSummary[]>({
queryKey: ["library", "shows", filter],
queryFn: () => api.library.shows(token!, filter),
enabled: !!token,
staleTime: 30_000,
});
}