Files
nerandClaude Opus 5 6fc41c0901 feat: surface availability, airing progress and the director in preview
Movies get a theatre/stream/blu-ray icon in the info row, series get the
latest aired episode as S03 E07. Both reveal the relevant dates on hover or
tap through a shared Hint tooltip.

Release dates ride along on the details request via append_to_response and
the series fields are already in the tv payload, so neither indicator costs
an extra call. Theatre state is only claimed while the run can still be
current, otherwise a classic with no digital entry would read as in cinemas.

The credits carousel now opens with the director, read from the crew array
that the credits response already carries. A series has no single director,
so the one behind most episodes stands in.

Drop with_cast from the starring query: TMDB ANDs it with with_people, so
every director link would have resolved to an empty list.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 19:46:51 +03:00

36 lines
1.1 KiB
TypeScript

import movieAdvisor from '../clients/movieAdvisor';
import { mapDetailsToAiring } from '../dto/Airing';
import { mapReleaseDatesToAvailability } from '../dto/Availability';
import { mapMovieSeriesToShow } from '../dto/Show';
export type DetailsQueryProps = {
showId?: Show['id'];
showType?: Show['type'];
};
type DetailsResponse = (Movie | Series) &
Details &
TMDBSeriesDetails & {
release_dates?: { results: TMDBCountryReleaseDates[] };
};
const detailsQuery = ({ showId, showType }: DetailsQueryProps) => ({
enabled: Boolean(showId),
queryKey: ['details', showId, showType],
queryFn: () =>
movieAdvisor
.get<DetailsResponse>(
`/${showType}/${showId}`,
showType === 'movie' ? { params: { append_to_response: 'release_dates' } } : undefined
)
.then(({ release_dates, ...response }) => ({
...response,
...mapMovieSeriesToShow(response, showType),
availability: mapReleaseDatesToAvailability(release_dates?.results),
airing: showType === 'tv' ? mapDetailsToAiring(response) : undefined
}))
.catch((error) => Promise.reject(error))
});
export default detailsQuery;