import { Flex, Text } from "@mantine/core"; import React, { useEffect, useRef, useState } from "react"; import { CrownIcon } from "@phosphor-icons/react"; import { SeedBadge } from "./seed-badge"; import { TeamInfo } from "@/features/teams/types"; import AnimatedScore from "@/features/matches/components/animated-score"; import classes from "./match-slot.module.css"; interface MatchSlotProps { from?: number; from_loser?: boolean; team?: TeamInfo; seed?: number; cups?: number; isWinner?: boolean; groupLabel?: string; } export const MatchSlot: React.FC = ({ from, from_loser, team, seed, cups, isWinner, groupLabel }) => { const teamId = team?.id; const previousTeamIdRef = useRef(teamId); const [entranceKey, setEntranceKey] = useState(0); useEffect(() => { const previousTeamId = previousTeamIdRef.current; previousTeamIdRef.current = teamId; if (teamId && previousTeamId !== teamId) { setEntranceKey((key) => key + 1); } }, [teamId]); return ( {(seed && seed > 0) ? : undefined} 0 ? classes.slotEnter : undefined} align="center" gap={4} flex={1} > {team ? ( <> 12 ? (team.name.length > 18 ? '10px' : '11px') : 'xs'} truncate style={{ minWidth: 0, flex: 1, lineHeight: "12px" }} > {team.name} {isWinner && ( )} ) : groupLabel ? ( {groupLabel} ) : from ? ( {from_loser ? "Loser" : "Winner"} of Match {from} ) : ( TBD )} { cups !== undefined ? ( ) : undefined } ); };