import { Modal } from '../Modal'; import { Icon } from '../Icon'; import { GameCover } from '../grid/GameCover'; import { StateChip } from '../StateChip'; import { ActionButton } from '../ActionButton'; import { Game, InstallStatus } from '../../lib/types'; import { deriveState, isInProgress } from '../../lib/gameState'; import { formatBytes, formatEtiVersion, formatPlayers } from '../../lib/format'; interface Props { game: Game; thumbnailUrl: string | null; onClose: () => void; onPrimary: (game: Game) => void; onUninstall: (game: Game) => void; onRemoveDownload: (game: Game) => void; onCancelDownload: (game: Game) => void; onViewFiles: (game: Game) => void; } const tagsFromGame = (game: Game): string[] => { const tags: string[] = []; if (game.genre) tags.push(game.genre); if (game.publisher) tags.push(game.publisher); if (game.release_year) tags.push(game.release_year); return tags; }; const statusLabelFor = (game: Game): string => { switch (deriveState(game)) { case 'installed': return 'Installed'; case 'local': return 'Downloaded'; case 'downloading': return 'Downloading'; case 'busy': return 'Working…'; case 'none': return 'Not downloaded'; } }; export const GameDetailModal = ({ game, thumbnailUrl, onClose, onPrimary, onUninstall, onRemoveDownload, onCancelDownload, onViewFiles, }: Props) => { const tags = tagsFromGame(game); const canRemoveDownload = game.downloaded && !game.installed && !isInProgress(game.install_status); const canViewFiles = game.downloaded || game.installed || game.install_status === InstallStatus.Downloading; return (
{tags.length > 0 && (
{tags.map(t => {t})}
)}

{game.name}

Size
{formatBytes(game.size)}
Players
{formatPlayers(game.max_players)}
Version
{formatEtiVersion(game.local_version ?? game.eti_game_version)}
Status
{statusLabelFor(game)}
{game.description && (

{game.description}

)} {game.status_message && (

{game.status_message}

)}
onPrimary(game)} onCancelDownload={onCancelDownload} /> {game.installed && ( )} {canRemoveDownload && ( )} {canViewFiles && ( <>
)}
); };