From 1a4189901aa23e7067b8de5cf202c217ce38534f Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Mon, 17 Oct 2022 16:59:45 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=86=D0=B5=20=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D1=85=D0=BE?= =?UTF-8?q?=D0=B4=20=D0=BD=D0=B0=20=D0=BF=D1=80=D0=B5=D0=B4=D1=8B=D0=B4?= =?UTF-8?q?=D1=83=D1=89=D1=83=D1=8E=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/FileDownload.jsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pages/FileDownload.jsx b/src/pages/FileDownload.jsx index c18b51c..9995ae9 100644 --- a/src/pages/FileDownload.jsx +++ b/src/pages/FileDownload.jsx @@ -1,4 +1,4 @@ -import { Link, useNavigate, useParams } from 'react-router-dom' +import { Link, useLocation, useNavigate, useParams } from 'react-router-dom' import { memo, useCallback, useEffect, useState } from 'react' import { InfoCircleFilled, CloseCircleOutlined } from '@ant-design/icons' import { Button, Result, Typography } from 'antd' @@ -20,6 +20,8 @@ const FileDownload = memo(function FileDownload() { const [isError, setIsError] = useState(false) const navigate = useNavigate() + const location = useLocation() + const isFirstOpenApp = location.key === 'default' useEffect(() => { invokeWebApiWrapperAsync( @@ -33,10 +35,8 @@ const FileDownload = memo(function FileDownload() { useEffect(() => { invokeWebApiWrapperAsync( async () => { - const files = await FileService.getFilesInfo(idWell) - // TODO Получается только одна категория файлов. - // Поменять при появлении метода получения инфы о конкретном файле - setFile(files.items.find((file) => file.id === idFile) ?? { id: idFile, idWell, name: `File_${idWell}_${idFile}` }) + const file = await FileService.getFileInfo(idFile) + setFile(file) }, null, () => { @@ -48,7 +48,7 @@ const FileDownload = memo(function FileDownload() { }, [idWell, idFile]) const download = useCallback(async () => { - if (!await downloadFile(file)) + if (!file || !await downloadFile(file)) setIsError(true) }, [file]) @@ -60,13 +60,16 @@ const FileDownload = memo(function FileDownload() { <> Вы перешли к странице загрузки файла!
- Файл "{file.name ?? ('№' + idFile)}", скважина "{well.caption ?? ('№' + idWell)}". + Файл "{file?.name ?? ('№' + idFile)}", скважина "{well.caption ?? ('№' + idWell)}". )} // subTitle={} extra={( <> - + {isFirstOpenApp + ? + : + } )}