import { Dialog, DialogContent, DialogTitle, ListItemButton, ListItemText, Typography, } from '@mui/material'; import { useState } from 'react'; import { Entrant, Set, State } from '../common/types'; export default function TiebreakerDialog({ entrants, selectSet, }: { entrants: Entrant[]; selectSet: (set: Set) => Promise; }) { const [open, setOpen] = useState(false); const [selectedEntrant, setSelectedEntrant] = useState({ id: 0, participants: [], }); return ( <> { setOpen(true); }} > tiebreaker... { setSelectedEntrant({ id: 0, participants: [] }); setOpen(false); }} > Generate Tiebreaker Set... {entrants.map((entrant) => ( { if (selectedEntrant.id) { if (selectedEntrant.id === entrant.id) { setSelectedEntrant({ id: 0, participants: [] }); } else { selectSet({ id: -1, sggId: null, state: State.PENDING, round: Number.MAX_SAFE_INTEGER, fullRoundText: 'Tie-Breaker', entrant1Id: selectedEntrant.id, entrant1Participants: selectedEntrant.participants, entrant2Id: entrant.id, entrant2Participants: entrant.participants, wasReported: false, entrant1Score: null, entrant2Score: null, gameScores: [], ordinal: null, stream: null, station: null, winnerId: null, updatedAtMs: 0, completedAtMs: 0, }); setSelectedEntrant({ id: 0, participants: [] }); setOpen(false); } } else { setSelectedEntrant({ id: entrant.id, participants: entrant.participants, }); } }} > {entrant.participants[0].displayName} {entrant.participants.length > 1 && ( {entrant.participants[1].displayName} )} ))} ); }