import type React from "react"; import { ListItem, ListItemText, Typography, Box, useTheme, IconButton, Tooltip, } from "@mui/material"; import { Icon } from "@iconify/react"; import { DateChip, GameResult, MovesChip, TimeControlChip, } from "./game-item-utils"; type ChessComPlayer = { username: string; rating: number; title?: string; }; type ChessComGameProps = { id: string; white: ChessComPlayer; black: ChessComPlayer; result: string; timeControl: string; date: string; opening?: string; moves?: number; url: string; onClick?: () => void; perspectiveUserColor: "white" | "black"; }; export const ChessComGameItem: React.FC = ({ white, black, result, timeControl, date, moves, url, onClick, perspectiveUserColor, }) => { const theme = useTheme(); const formatPlayerName = (player: ChessComPlayer) => { return player.title ? `${player.title} ${player.username}` : player.username; }; const whiteWon = result === "1-0"; const blackWon = result === "0-1"; return ( {formatPlayerName(white)} ({white.rating}) vs {formatPlayerName(black)} ({black.rating}) } secondary={ {moves && moves > 0 && } } sx={{ mr: 2 }} /> { e.stopPropagation(); window.open(url, "_blank"); }} size="small" sx={{ color: theme.palette.primary.main, "&:hover": { backgroundColor: theme.palette.action.hover, transform: "scale(1.1)", }, transition: "all 0.2s ease-in-out", }} > ); };