fork/replay-manager-for-slippi
git clone https://git.julia.blue/fork/replay-manager-for-slippi
e23096d
main
1import { 2Dialog , 3DialogActions , 4DialogContent , 5DialogContentText , 6DialogTitle , 7Button , 8Stack , 9Typography , 10LinearProgress , 11Box , 12} from '@mui/material' ; 13 14import { SlpDownloadStatus } from '../common/types' ; 15 16function LinearProgressWithLabel ({ value} :{ value :number }) { 17return ( 18< Box sx = {{ display :'flex' , alignItems :'center' , width :300 }}> 19< Box sx = {{ width :'100%' , mr :1 }}> 20< LinearProgress variant = "determinate" value = { value } /> 21</ Box > 22< Box sx = {{ minWidth :35 }}> 23< Typography variant = "body2" color = "text.secondary" >{ ` ${ Math . round ( 24value , 25)} %` }</ Typography > 26</ Box > 27</ Box > 28); 29} 30 31export default function SlpDownloadModal ({ 32 status, 33 onClose, 34} :{ 35status :SlpDownloadStatus ; 36onClose :() => void ; 37}) { 38if ( status . status === 'downloading' ) { 39return ( 40< Dialog open PaperProps = {{ sx :{ minWidth :400 , textAlign :'center' } }}> 41< DialogTitle > Downloading SLP files... </ DialogTitle > 42< DialogContent > 43< Stack alignItems = "center" gap = { 2 }> 44< LinearProgressWithLabel value = { status . progress } /> 45< Typography variant = "body2" color = "text.secondary" > 46{ `Current file: ${ status . currentFile } ` } 47</ Typography > 48</ Stack > 49</ DialogContent > 50</ Dialog > 51); 52} 53if ( status . status === 'error' ) { 54return ( 55< Dialog open onClose = { onClose }> 56< DialogTitle > Error Downloading SLP Files </ DialogTitle > 57< DialogContent > 58< DialogContentText > 59Failed to download the following SLP files: 60</ DialogContentText > 61{ status . failedFiles . map (( file ) => ( 62< DialogContentText key = { file }>{ file }</ DialogContentText > 63))} 64</ DialogContent > 65< DialogActions > 66< Button onClick = { onClose }> Close </ Button > 67</ DialogActions > 68</ Dialog > 69); 70} 71return null ; 72}