import { Box, CircularProgress, Collapse, IconButton, ListItemButton, Tooltip, Typography, } from '@mui/material'; import { KeyboardArrowDown, KeyboardArrowRight, KeyboardArrowUp, PlayArrow, Refresh, } from '@mui/icons-material'; import { useState } from 'react'; import { ChallongeTournament, Set, SetWithNames, State } from '../common/types'; import SetViewInner from './SetView'; import filterSets from './filterSets'; import TiebreakerDialog from './TiebreakerDialog'; function SetView({ setWithNames, selectSet, }: { setWithNames: SetWithNames; selectSet: (set: Set) => void; }) { return ( { selectSet(setWithNames.set); }} > ); } export default function ChallongeView({ searchSubstr, tournament, getChallongeTournament, selectSet, }: { searchSubstr: string; tournament: ChallongeTournament; getChallongeTournament: () => Promise; selectSet: (set: Set) => void; }) { const [open, setOpen] = useState(true); const [completedOpen, setCompletedOpen] = useState(false); const [getting, setGetting] = useState(false); const get = async () => { setGetting(true); await getChallongeTournament(); setGetting(false); }; const pendingSetsToShow = filterSets( tournament.sets.pendingSets, searchSubstr, ); const completedSetsToShow = filterSets( tournament.sets.completedSets, searchSubstr, ); return ( (!searchSubstr || pendingSetsToShow.length > 0 || completedSetsToShow.length > 0) && ( { setOpen(!open); }} sx={{ typography: 'caption' }} > {open ? : }
{tournament.name}
{ ev.stopPropagation(); get(); }} size="small" > {getting ? : } {tournament.state === State.PENDING && ( { ev.stopPropagation(); window.open(`//challonge.com/${tournament.slug}`); }} size="small" > )}
{pendingSetsToShow.map((setWithNames) => ( ))} {completedSetsToShow.length > 0 && ( <> setCompletedOpen(!completedOpen)} > completed {completedOpen ? ( ) : ( )} {completedSetsToShow.map((setWithNames) => ( ))} )} {(tournament.tournamentType === 'swiss' || tournament.tournamentType === 'round robin') && tournament.sets.completedSets.length > 0 && tournament.sets.pendingSets.length === 0 && ( { selectSet(set); }} /> )}
) ); }