mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 03:55:38 -04:00
Integrate TMDB credits data into the app: cast carousels on title detail pages, person detail pages with biography and filmography, and person search results in the command palette. Includes new persons/titleCast DB tables, profile image caching, and a nightly credits refresh cron job. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34 lines
772 B
TypeScript
34 lines
772 B
TypeScript
import useSWR from "swr";
|
|
import { fetcher } from "@/lib/swr/fetcher";
|
|
|
|
interface SearchResponse {
|
|
results: {
|
|
tmdbId: number;
|
|
type: "movie" | "tv" | "person";
|
|
title: string;
|
|
posterPath: string | null;
|
|
profilePath?: string | null;
|
|
releaseDate: string | null;
|
|
voteAverage: number;
|
|
knownFor?: string[];
|
|
knownForDepartment?: string;
|
|
}[];
|
|
}
|
|
|
|
export function useSearch(debouncedQuery: string) {
|
|
const trimmed = debouncedQuery.trim();
|
|
const { data, isLoading } = useSWR<SearchResponse>(
|
|
trimmed ? `/api/search?query=${encodeURIComponent(trimmed)}` : null,
|
|
fetcher,
|
|
{
|
|
revalidateOnFocus: false,
|
|
dedupingInterval: 2_000,
|
|
},
|
|
);
|
|
|
|
return {
|
|
results: data?.results?.slice(0, 8) ?? [],
|
|
isLoading,
|
|
};
|
|
}
|