Skip to content

Commit 41d08a7

Browse files
authored
fix(website): open preview as blob on mobile
2 parents 93ef919 + 2aaea5f commit 41d08a7

1 file changed

Lines changed: 49 additions & 29 deletions

File tree

website/src/routes/archive/[id]/page.tsx

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import {
2222
ListItemText,
2323
ListItemButton,
2424
Divider,
25-
Skeleton
25+
Skeleton,
26+
useMediaQuery,
27+
useTheme
2628
} from "@mui/material";
2729
import { useLocation, useSearchParams, useNavigate, useParams } from "react-router-dom";
2830
import {
@@ -31,7 +33,8 @@ import {
3133
EditRounded as EditRoundedIcon,
3234
SaveRounded as SaveRoundedIcon,
3335
DeleteRounded as DeleteRoundedIcon,
34-
CancelRounded as CancelRoundedIcon
36+
CancelRounded as CancelRoundedIcon,
37+
PictureAsPdfRounded as PictureAsPdfIcon
3538
} from "@mui/icons-material";
3639

3740
import { Sidebar } from "@components/layout";
@@ -40,6 +43,8 @@ import { getArchive, getArchiveFile, getPrograms, getProgramModules, getArchiveV
4043
import type { DtoArchiveEntryResponse as ExamListEntry, DtoProgramResponse as Program, DtoModuleResponse as Module } from "@lib/api";
4144

4245
export default function ExamDetailsPage() {
46+
const theme = useTheme();
47+
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
4348
const { user } = useAuth();
4449
const location = useLocation();
4550
const navigate = useNavigate();
@@ -361,7 +366,7 @@ export default function ExamDetailsPage() {
361366
onClose={handleCloseDialog}
362367
fullWidth
363368
maxWidth="sm"
364-
PaperProps={{ sx: { borderRadius: 3, height: '90vh' } }}
369+
PaperProps={{ sx: { borderRadius: 3, height: isMobile ? 'auto' : '90vh' } }}
365370
>
366371
{selectedExam && (
367372
<>
@@ -532,32 +537,47 @@ export default function ExamDetailsPage() {
532537
</Stack>
533538
</Stack>
534539

535-
<Box sx={{
536-
width: '100%',
537-
flexGrow: 1,
538-
bgcolor: 'grey.100',
539-
borderRadius: 2,
540-
overflow: 'hidden',
541-
border: '1px solid',
542-
borderColor: 'divider',
543-
position: 'relative',
544-
}}>
545-
{previewUrl ? (
546-
<iframe
547-
src={previewUrl}
548-
width="100%"
549-
height="100%"
550-
style={{ border: 'none' }}
551-
title="Vorschau"
552-
/>
553-
) : (
554-
<Box display="flex" flexDirection="column" alignItems="center" justifyContent="center" height="100%" sx={{ p: 4 }}>
555-
<Skeleton variant="rectangular" width="100%" height="100%" sx={{ position: 'absolute', inset: 0, borderRadius: 0 }} />
556-
<CircularProgress size={30} sx={{ zIndex: 1 }} />
557-
<Typography variant="body2" color="text.secondary" sx={{ ml: 2, mt: 1, zIndex: 1, fontWeight: 500 }}>Lade Vorschau...</Typography>
558-
</Box>
559-
)}
560-
</Box>
540+
{isMobile ? (
541+
previewUrl && (
542+
<Button
543+
fullWidth
544+
variant="outlined"
545+
startIcon={<PictureAsPdfIcon />}
546+
onClick={() => window.open(previewUrl, '_blank')}
547+
sx={{ borderRadius: 2, py: 1.5 }}
548+
>
549+
PDF öffnen
550+
</Button>
551+
)
552+
) : (
553+
<Box sx={{
554+
width: '100%',
555+
flexGrow: 1,
556+
bgcolor: 'grey.100',
557+
borderRadius: 2,
558+
overflow: 'hidden',
559+
border: '1px solid',
560+
borderColor: 'divider',
561+
position: 'relative',
562+
minHeight: 400
563+
}}>
564+
{previewUrl ? (
565+
<iframe
566+
src={previewUrl}
567+
width="100%"
568+
height="100%"
569+
style={{ border: 'none' }}
570+
title="Vorschau"
571+
/>
572+
) : (
573+
<Box display="flex" flexDirection="column" alignItems="center" justifyContent="center" height="100%" sx={{ p: 4 }}>
574+
<Skeleton variant="rectangular" width="100%" height="100%" sx={{ position: 'absolute', inset: 0, borderRadius: 0 }} />
575+
<CircularProgress size={30} sx={{ zIndex: 1 }} />
576+
<Typography variant="body2" color="text.secondary" sx={{ ml: 2, mt: 1, zIndex: 1, fontWeight: 500 }}>Lade Vorschau...</Typography>
577+
</Box>
578+
)}
579+
</Box>
580+
)}
561581

562582
<TextField
563583
id="edit-exam-comment"

0 commit comments

Comments
 (0)