/**
* Feed item component for PodTUI
* Displays a single feed/podcast in the list
*/
import type { Feed, FeedVisibility } from "../types/feed"
import { format } from "date-fns"
interface FeedItemProps {
feed: Feed
isSelected: boolean
showEpisodeCount?: boolean
showLastUpdated?: boolean
compact?: boolean
}
export function FeedItem(props: FeedItemProps) {
const formatDate = (date: Date): string => {
return format(date, "MMM d")
}
const episodeCount = () => props.feed.episodes.length
const unplayedCount = () => {
// This would be calculated based on episode status
return props.feed.episodes.length
}
const visibilityIcon = () => {
return props.feed.visibility === "public" ? "[P]" : "[*]"
}
const visibilityColor = () => {
return props.feed.visibility === "public" ? "green" : "yellow"
}
const pinnedIndicator = () => {
return props.feed.isPinned ? "*" : " "
}
if (props.compact) {
// Compact single-line view
return (
{props.isSelected ? ">" : " "}
{visibilityIcon()}
{props.feed.customName || props.feed.podcast.title}
{props.showEpisodeCount && (
({episodeCount()})
)}
)
}
// Full view with details
return (
{/* Title row */}
{props.isSelected ? ">" : " "}
{visibilityIcon()}
{pinnedIndicator()}
{props.feed.customName || props.feed.podcast.title}
{/* Details row */}
{props.showEpisodeCount && (
{episodeCount()} episodes ({unplayedCount()} new)
)}
{props.showLastUpdated && (
Updated: {formatDate(props.feed.lastUpdated)}
)}
{/* Description (truncated) */}
{props.feed.podcast.description && (
{props.feed.podcast.description.slice(0, 60)}
{props.feed.podcast.description.length > 60 ? "..." : ""}
)}
)
}