Show error message for report details
This commit is contained in:
parent
403e6cbea8
commit
c0ddb950ce
@ -33,6 +33,7 @@ const HeaderContainer = styled(Space)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const ReportDetail = () => {
|
const ReportDetail = () => {
|
||||||
|
const [error, setError] = useState(null);
|
||||||
const [fileObject, setFileObject] = useState(null);
|
const [fileObject, setFileObject] = useState(null);
|
||||||
const [pagination, setPagination] = useState({
|
const [pagination, setPagination] = useState({
|
||||||
page: 1,
|
page: 1,
|
||||||
@ -60,14 +61,22 @@ const ReportDetail = () => {
|
|||||||
|
|
||||||
// Download and show report
|
// Download and show report
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
downloadReport(id, (fileDetails) => {
|
try {
|
||||||
var blob = new Blob(
|
downloadReport(id, (fileDetails) => {
|
||||||
[fileDetails.file],
|
if (!fileDetails?.file) {
|
||||||
{type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,"}
|
setError("The report has not been ready to preview.");
|
||||||
);
|
}
|
||||||
let blobUrl = URL.createObjectURL(blob);
|
var blob = new Blob(
|
||||||
setFileObject(blobUrl);
|
[fileDetails.file],
|
||||||
});
|
{type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,"}
|
||||||
|
);
|
||||||
|
let blobUrl = URL.createObjectURL(blob);
|
||||||
|
setFileObject(blobUrl);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
setError("The report has not been ready to preview.");
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
@ -129,7 +138,9 @@ const ReportDetail = () => {
|
|||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
</HeaderContainer>
|
</HeaderContainer>
|
||||||
<ReportContainer>
|
<ReportContainer>
|
||||||
{fileObject && <SheetViewer file={fileObject} />}
|
{(fileObject && !error) && <SheetViewer file={fileObject} />}
|
||||||
|
{(!fileObject && !error) && <Typography.Title level={5}>Loading...</Typography.Title>}
|
||||||
|
{error && <Typography.Title level={5}>{error}</Typography.Title>}
|
||||||
</ReportContainer>
|
</ReportContainer>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -113,6 +113,10 @@ export async function downloadReport(report_id: string, downloadFinishedCallback
|
|||||||
filename: filename,
|
filename: filename,
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
downloadFinishedCallback && downloadFinishedCallback({
|
||||||
|
file: null,
|
||||||
|
filename: null,
|
||||||
|
});
|
||||||
notification.error({
|
notification.error({
|
||||||
message: `${error?.message}`,
|
message: `${error?.message}`,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user