import ViewTransitionLink from "@/components/ViewTransitionLink"; import { Play, Star } from "lucide-react"; import type { EpisodeListItem } from "@/api/types"; interface EpisodeRowProps { episode: EpisodeListItem; rating?: number; watched?: boolean; progress?: number; } export default function EpisodeRow({ episode, rating, watched, progress }: EpisodeRowProps) { const watchedState = watched ?? episode.user_data?.played ?? false; const derivedProgress = progress ?? (() => { const position = episode.user_data?.position_seconds ?? 0; const duration = episode.user_data?.duration_seconds ?? 0; if (duration <= 0 || position <= 0 || watchedState) { return undefined; } return Math.max(0, Math.min(100, (position / duration) * 100)); })(); const hasProgress = derivedProgress != null && derivedProgress > 0 && derivedProgress < 100; return ( {/* Episode number */}
{episode.episode_number}
{/* Thumbnail */}
{episode.still_url ? ( {episode.title ) : (
)} {hasProgress && (
)}
{/* Info */}
{episode.title || `Episode ${episode.episode_number}`} {watchedState && ( )}
{episode.air_date && {episode.air_date}} {episode.air_date && episode.runtime > 0 && ·} {episode.runtime > 0 && {episode.runtime}m}
{/* Rating */} {rating != null && (
{rating.toFixed(1)}
)} ); }