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').then((r) => r.data), getById: (id: number) => api.get(`/people/${id}`).then((r) => r.data), getCredits: (id: number) => api.get(`/people/${id}/credits`).then((r) => r.data), getTmdbFilmography: (id: number) => api.get(`/people/${id}/tmdb-filmography`).then((r) => r.data), fetchByTmdbId: (tmdb_id: number, pinned = false) => api.post('/people/fetch', { tmdb_id, pinned }).then((r) => r.data), update: (id: number, data: Partial) => api.put(`/people/${id}`, data).then((r) => r.data), search: (query: string) => api.get('/people/search', { params: { query } }).then((r) => r.data), };