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(() => {