fork/replay-manager-for-slippi
git clone https://git.julia.blue/fork/replay-manager-for-slippi
e87008e
2.3.7
1import { 2Dialog , 3DialogContent , 4DialogTitle , 5ListItemButton , 6ListItemText , 7Typography , 8} from '@mui/material' ; 9import { useState } from 'react' ; 10import { Entrant , Set , State } from '../common/types' ; 11 12export default function TiebreakerDialog ({ 13 entrants, 14 selectSet, 15} :{ 16entrants :Entrant []; 17selectSet :( set :Set ) => Promise < void >; 18}) { 19const [ open , setOpen ] = useState ( false ); 20const [ selectedEntrant , setSelectedEntrant ] = useState < Entrant >({ 21id :0 , 22participants :[], 23}); 24return ( 25<> 26< ListItemButton 27dense 28onClick = { async () => { 29setOpen ( true ); 30}} 31> 32< Typography 33alignItems = "center" 34display = "flex" 35justifyContent = "right" 36variant = "subtitle2" 37width = "100%" 38> 39tiebreaker... 40</ Typography > 41</ ListItemButton > 42< Dialog 43open = { open } 44onClose = {() => { 45setSelectedEntrant ({ id :0 , participants :[] }); 46setOpen ( false ); 47}} 48> 49< DialogTitle > Generate Tiebreaker Set... </ DialogTitle > 50< DialogContent > 51{ entrants . map (( entrant ) => ( 52< ListItemButton 53dense 54key = { entrant . id } 55style = {{ 56backgroundColor : 57selectedEntrant . id === entrant . id ?'#5BCEFA' :undefined , 58}} 59onClick = {() => { 60if ( selectedEntrant . id ) { 61if ( selectedEntrant . id === entrant . id ) { 62setSelectedEntrant ({ id :0 , participants :[] }); 63} else { 64selectSet ({ 65id :- 1 , 66sggId :null , 67state :State . PENDING , 68round :Number . MAX_SAFE_INTEGER , 69fullRoundText :'Tie-Breaker' , 70entrant1Id :selectedEntrant . id , 71entrant1Participants :selectedEntrant . participants , 72entrant2Id :entrant . id , 73entrant2Participants :entrant . participants , 74wasReported :false , 75entrant1Score :null , 76entrant2Score :null , 77gameScores :[], 78ordinal :null , 79stream :null , 80station :null , 81winnerId :null , 82updatedAtMs :0 , 83completedAtMs :0 , 84}); 85setSelectedEntrant ({ id :0 , participants :[] }); 86setOpen ( false ); 87} 88} else { 89setSelectedEntrant ({ 90id :entrant . id , 91participants :entrant . participants , 92}); 93} 94}} 95> 96< ListItemText > 97< span >{ entrant . participants [ 0 ]. displayName }</ span > 98{ entrant . participants . length > 1 && ( 99< span >{ entrant . participants [ 1 ]. displayName }</ span > 100)} 101</ ListItemText > 102</ ListItemButton > 103))} 104</ DialogContent > 105</ Dialog > 106</> 107); 108}