feat(frontend): add useLibrarySearch, useLibrarySyncStatus, useTriggerSync, useAdminSettings hooks

This commit is contained in:
2026-03-20 00:30:44 +01:00
parent 978ad1cdb0
commit 49c7f7abd7
3 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
"use client";
import { useQuery } from "@tanstack/react-query";
import { api } from "@/lib/api";
import { useAuthContext } from "@/context/auth-context";
export interface LibrarySearchParams {
q?: string;
type?: string;
series?: string[];
collection?: string;
provider?: string;
decade?: number;
min_duration?: number;
max_duration?: number;
genres?: string[];
offset?: number;
limit?: number;
}
/**
* Paginated library search — always enabled, DB-backed (fast).
* Separate from useLibraryItems in use-library.ts which is snapshot-based
* and used only for block editor filter preview.
*/
export function useLibrarySearch(params: LibrarySearchParams) {
const { token } = useAuthContext();
return useQuery({
queryKey: ["library", "search", params],
queryFn: () => api.library.itemsPage(token!, params),
enabled: !!token,
staleTime: 2 * 60 * 1000,
});
}