-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReportViewMUI.js
91 lines (87 loc) · 1.89 KB
/
ReportViewMUI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import React from "react";
import { Download, PlayArrow } from "@mui/icons-material";
import { Alert, Box, Button, Typography, Paper, Stack } from "@mui/material";
import {
STATUS_PREVIEW,
STATUS_GENERATING,
STATUS_ERROR,
STATUS_READY,
} from "./ReportStatus";
const ReportViewMUI = ({
title,
filename,
generate,
contentRef,
downloadURL,
status,
statusMessage,
children,
}) => (
<Box>
<Typography variant="h3" component="h1">
{title}
</Typography>
<Alert
sx={{ my: 3 }}
severity={
{
[STATUS_PREVIEW]: "info",
[STATUS_GENERATING]: "warning",
[STATUS_ERROR]: "error",
[STATUS_READY]: "success",
}[status]
}
>
{statusMessage}
</Alert>
<Stack spacing={2} direction="row" sx={{ my: 3 }}>
<Button
variant="contained"
onClick={generate}
disabled={status !== STATUS_PREVIEW}
startIcon={<PlayArrow />}
>
Generate
</Button>
<Button
variant="contained"
href={downloadURL}
download={filename}
disabled={status !== STATUS_READY}
startIcon={<Download />}
>
Download
</Button>
</Stack>
<Typography variant="h4" component="h2">
Preview
</Typography>
<Box
sx={{
my: 2,
overflow: "scroll",
maxHeight: "400px",
border: "1px solid #aaa",
backgroundColor: "#ddd",
userSelect: "none",
cursor: "default",
}}
>
<Paper
sx={{
display: "inline-block",
p: "1in",
width: "8.5in",
minHeight: "11in",
borderRadius: "10px",
m: 4,
boxShadow: (theme) => theme.shadows[7],
}}
// elevation={5}
>
<div ref={contentRef}>{children}</div>
</Paper>
</Box>
</Box>
);
export default ReportViewMUI;