import { ListItem } from "@/shared/components/ui/list-item" import type { Game } from "@/shared/db/schema" import { formatPlaytime } from "../schema" import { gameStateColors } from "../schema" const apiBase = import.meta.env.BASE_URL.replace(/\/$/, "") interface GameListItemProps { game: Game onClick?: () => void } export function GameListItem({ game, onClick }: GameListItemProps) { const coverUrl = game.cover_image_id ? `${apiBase}/api/igdb/image/${game.cover_image_id}/thumb` : game.source === "steam" ? `${apiBase}/api/steam/icon/${game.source_id}` : undefined const imgClass = game.cover_image_id ? "h-10 w-10 rounded object-cover" : "h-10 w-16 rounded object-cover" return ( 0 ? formatPlaytime(game.playtime_hours) : undefined } media={ coverUrl ? ( ) : ( {game.source.toUpperCase()} ) } after={} onClick={onClick} /> ) } function GameListItemAfter({ game }: { game: Game }) { const ratingText = game.rating >= 0 ? `★ ${Math.round(game.rating / 2)}/5` : null const dotColor = game.game_state !== "not_set" ? gameStateColors[game.game_state] : null return ( {ratingText && {ratingText}} {dotColor && ( )} {game.is_favorite && } ) }