21 lines
563 B
TypeScript
21 lines
563 B
TypeScript
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,
|
|
});
|
|
}
|