diff --git a/src/pages/Report.jsx b/src/pages/Report.jsx
index dd5d287..c97151e 100644
--- a/src/pages/Report.jsx
+++ b/src/pages/Report.jsx
@@ -37,6 +37,11 @@ const imgPaths = {
'.las': '/images/las.png'
}
+const contentTypes = {
+ '.pdf': 'application/pdf',
+ '.las': 'application/octet-stream'
+}
+
// Экспорт рендера
export default function Report(props) {
@@ -80,8 +85,8 @@ export default function Report(props) {
{ progressData.operation }
- {getReportFile(event, progressData.reportName)}}
- download={progressData.reportName}>
+ getReportFile(event, progressData.reportName)}
+ download>
{ progressData.reportName }
>
@@ -91,8 +96,9 @@ export default function Report(props) {
const getReportFile = async (event, reportFileName) => {
try {
const element = event.target
- let reportFile = await ReportService.getReport(wellId, reportFileName)
- let reportUrl = URL.createObjectURL(reportFile)
+ let bytesArray = await ReportService.getReport(wellId, reportFileName)
+ const contentType = contentTypes[reportFileName.slice(-4)]
+ let reportUrl = URL.createObjectURL(new File(bytesArray, {type: contentType}))
element.href = reportUrl
} catch (error) {
notify(`Не удалось скачать отчет по скважине (${wellId}) c
@@ -120,7 +126,7 @@ export default function Report(props) {
duration: 0
});
- if (progressData.reportName.length)
+ if (progressData.reportName?.length)
unSubscribeReportHub()
}
}