Files
movie-advisor/components/Preview/components/Availability/index.tsx
T
nerandClaude Opus 5 3dc2ebfe53 feat: replace the starring page with a person page
A credit now opens /person/{id}: portrait, name, department, life dates and
birthplace, the biography, and the full filmography ranked by vote count.
One request carries all of it — combined_credits rides along on the person
call — so the discover based starring query and its with_people filter go.

The biography fills whatever height the portrait leaves and fades where it
is cut, with the whole text in a tooltip on hover; a phone has no height to
respect there, so it simply runs on.

Route level and query level skeletons stand in while it loads, built from
the shadcn primitive.

Development server side fetches go over the loopback rather than SITE_URL,
which is a LAN address meant for other devices: once that address moves the
fetch hangs until undici times out, ten seconds per navigation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 22:09:33 +03:00

49 lines
1.4 KiB
TypeScript

'use client';
import { FC } from 'react';
import { Disc, MonitorPlay, Popcorn } from 'lucide-react';
import Hint from '@/components/ui/hint';
import { getAvailabilityState, isUpcoming } from '@/data/dto/Availability';
import { formatDate } from '@/lib/utils';
interface Props {
availability: Availability;
className?: string;
}
const ICONS = {
theatre: Popcorn,
stream: MonitorPlay,
bluray: Disc
};
const getLabels = ({ theatre, stream, bluray }: Availability, state: AvailabilityState) => {
if (state === 'bluray') return [bluray ? `On Blu-ray since ${formatDate(bluray)}` : 'On Blu-ray'];
if (state === 'stream') return [stream ? `Streaming since ${formatDate(stream)}` : 'Streaming'];
if (theatre && isUpcoming(theatre)) return [`In theatres from ${formatDate(theatre)}`];
const announced = [
stream && isUpcoming(stream) && `Streaming from ${formatDate(stream)}`,
bluray && isUpcoming(bluray) && `Blu-ray from ${formatDate(bluray)}`
].filter(Boolean) as string[];
return ['In theatres only', ...(announced.length ? announced : ['Streaming date to be announced'])];
};
const Availability: FC<Props> = ({ availability, className }) => {
const state = getAvailabilityState(availability);
if (!state) return null;
const Icon = ICONS[state];
return (
<Hint lines={getLabels(availability, state)} className={className}>
<Icon size={16} />
</Hint>
);
};
export default Availability;