import { useState } from "react"; import ViewTransitionLink from "@/components/ViewTransitionLink"; import { decodeThumbhash } from "@/lib/thumbhash"; import { formatUpcomingSubtitle, formatUpcomingTime, upcomingBadgeClass, upcomingBadgeLabel, } from "@/lib/upcomingEventPresentation"; import type { CalendarEvent } from "@/hooks/queries/calendar"; export default function CalendarEventCard({ event }: { event: CalendarEvent }) { const [loaded, setLoaded] = useState(false); const thumbhashUrl = event.poster_thumbhash ? decodeThumbhash(event.poster_thumbhash) : ""; const watched = event.watched === true; const href = event.type === "movie" ? `/item/${event.content_id}` : `/item/${event.series_id ?? event.content_id}`; const subtitle = formatUpcomingSubtitle(event); const airTime = formatUpcomingTime(event.air_time, event.air_at); return (
{event.poster_url ? ( {event.title} setLoaded(true)} /> ) : (
{event.title || "No Poster"}
)}
{event.badges.length > 0 && (
{event.badges.map((badge) => ( {upcomingBadgeLabel(badge)} ))}
)} {watched && (
✓
)}
{event.title}
{subtitle && (
{subtitle}
)} {airTime && (
{airTime}
)}
); }