From 34c9b81e775b09cc7280fbea629664f0010980ea Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 3 Oct 2022 20:40:13 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D1=81=D1=83=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=20=D1=80=D0=B0=D0=BF=D0=BE=D1=80=D1=82=D0=B0=20=D0=B8=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D1=91=D0=BD=20=D1=84=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D0=B0=D1=82=20=D0=B4=D0=B0=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Reports/DailyReport/index.jsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pages/Reports/DailyReport/index.jsx b/src/pages/Reports/DailyReport/index.jsx index 665c36b..15f7869 100644 --- a/src/pages/Reports/DailyReport/index.jsx +++ b/src/pages/Reports/DailyReport/index.jsx @@ -6,7 +6,7 @@ import moment from 'moment' import { useWell } from '@asb/context' import LoaderPortal from '@components/LoaderPortal' import { DateRangeWrapper, Table, makeDateColumn, makeColumn } from '@components/Table' -import { download, invokeWebApiWrapperAsync } from '@components/factory' +import { download, invokeWebApiWrapperAsync, notify } from '@components/factory' import { arrayOrDefault, wrapPrivateComponent } from '@utils' import { DailyReportService } from '@api' @@ -37,6 +37,16 @@ const DailyReport = memo(() => { const checkIsDateBusy = useCallback((current) => current.isAfter(moment(), 'day') || data.some((row) => moment(row.reportDate).isSame(current, 'day')), [data]) + const makeOnDownloadClick = useCallback((report) => async () => { + const date = moment(report.reportDate) + + try { + await download(`/api/well/${well.id}/DailyReport/${date.format('YYYY-MM-DD')}/excel`) + } catch { + notify(`Не удалось скачать суточный рапорт от ${date.format('DD.MM.YYYY')}`, 'error', well) + } + }, [well]) + const columns = useMemo(() => [ makeDateColumn('Дата', 'reportDate', undefined, 'DD.MM.YYYY', { width: 300 }), makeColumn('', '', { width: 200, render: (_, report) => ( @@ -44,7 +54,7 @@ const DailyReport = memo(() => {