fork/replay-manager-for-slippi

git clone https://git.julia.blue/fork/replay-manager-for-slippi

NicoletMerge pull request #161 from sticks-stuff/feat/url-protocole23096d

2.3.4
1.9 KiB72 linesraw
1import {
2  Dialog,
3  DialogActions,
4  DialogContent,
5  DialogContentText,
6  DialogTitle,
7  Button,
8  Stack,
9  Typography,
10  LinearProgress,
11  Box,
12} from '@mui/material';
13
14import { SlpDownloadStatus } from '../common/types';
15
16function LinearProgressWithLabel({ value }: { value: number }) {
17  return (
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(
24          value,
25        )}%`}</Typography>
26      </Box>
27    </Box>
28  );
29}
30
31export default function SlpDownloadModal({
32  status,
33  onClose,
34}: {
35  status: SlpDownloadStatus;
36  onClose: () => void;
37}) {
38  if (status.status === 'downloading') {
39    return (
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  }
53  if (status.status === 'error') {
54    return (
55      <Dialog open onClose={onClose}>
56        <DialogTitle>Error Downloading SLP Files</DialogTitle>
57        <DialogContent>
58          <DialogContentText>
59            Failed 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  }
71  return null;
72}