Files
Showy/react_frontend/src/api/people.ts
T
Mohammed AbadandCopilot 02cdcf733d feat(frontend): navigate non-library entries to TMDB preview page
- Add TmdbPreviewPage showing TMDB details without adding to library
- Display backdrop, poster, title, tagline, genres, rating, storyline
- Show season/episode count for TV series
- Add "Add to Library" button that creates entry then redirects to details page
- Show "Already in Library — View" if entry exists in DB
- Add /entry/tmdb/:type/:tmdbId route in router.tsx
- Add TmdbPreview type, entriesApi.previewTmdb(), and useTmdbPreview() hook
- Update EntryCard to navigate to preview page instead of auto-adding

Co-authored-by: Copilot <copilot@github.com>
2026-04-27 04:03:21 +01:00

45 lines
1.2 KiB
TypeScript

import { api } from '@/lib/api';
import type { People, Credit } from '@/types';
export interface TmdbFilmographyItem {
id: number;
title?: string;
name?: string;
poster_path: string | null;
release_date?: string;
first_air_date?: string;
media_type: 'movie' | 'tv';
character?: string;
job?: string;
department?: string;
credit_id?: string;
popularity?: number;
}
export interface TmdbFilmographyResponse {
cast: TmdbFilmographyItem[];
crew: TmdbFilmographyItem[];
}
export const peopleApi = {
getAll: () => api.get<People[]>('/people').then((r) => r.data),
getById: (id: number) =>
api.get<People>(`/people/${id}`).then((r) => r.data),
getCredits: (id: number) =>
api.get<Credit[]>(`/people/${id}/credits`).then((r) => r.data),
getTmdbFilmography: (id: number) =>
api.get<TmdbFilmographyResponse>(`/people/${id}/tmdb-filmography`).then((r) => r.data),
fetchByTmdbId: (tmdb_id: number, pinned = false) =>
api.post<People>('/people/fetch', { tmdb_id, pinned }).then((r) => r.data),
update: (id: number, data: Partial<People>) =>
api.put<People>(`/people/${id}`, data).then((r) => r.data),
search: (query: string) =>
api.get<People[]>('/people/search', { params: { query } }).then((r) => r.data),
};