diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts index 7cc13b86e27..a7c0332d1de 100644 --- a/packages/desktop-client/src/components/reports/ReportOptions.ts +++ b/packages/desktop-client/src/components/reports/ReportOptions.ts @@ -10,7 +10,7 @@ import { const startDate = monthUtils.subMonths(monthUtils.currentMonth(), 5); const endDate = monthUtils.currentMonth(); -export const defaultState: CustomReportEntity = { +export const defaultReport: CustomReportEntity = { id: undefined, mode: 'total', groupBy: 'Category', diff --git a/packages/desktop-client/src/components/reports/ReportTopbar.jsx b/packages/desktop-client/src/components/reports/ReportTopbar.jsx index fa66bcbcff0..f6017541656 100644 --- a/packages/desktop-client/src/components/reports/ReportTopbar.jsx +++ b/packages/desktop-client/src/components/reports/ReportTopbar.jsx @@ -14,7 +14,7 @@ import { View } from '../common/View'; import { FilterButton } from '../filters/FiltersMenu'; import { GraphButton } from './GraphButton'; -import { SaveReport, SaveReportMenuButton } from './SaveReport'; +import { SaveReport } from './SaveReport'; export function ReportTopbar({ customReportItems, @@ -30,6 +30,8 @@ export function ReportTopbar({ viewLabels, onApplyFilter, onChangeViews, + onReportChange, + onResetReports, }) { return ( diff --git a/packages/desktop-client/src/components/reports/SaveReportName.tsx b/packages/desktop-client/src/components/reports/SaveReportName.tsx index d8e36cca771..c68f71a3149 100644 --- a/packages/desktop-client/src/components/reports/SaveReportName.tsx +++ b/packages/desktop-client/src/components/reports/SaveReportName.tsx @@ -1,4 +1,3 @@ -// @ts-strict-ignore import React, { useEffect } from 'react'; import { theme } from '../../style'; diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.jsx b/packages/desktop-client/src/components/reports/reports/CustomReport.jsx index 5ab099fe4e2..6b3f2cad03c 100644 --- a/packages/desktop-client/src/components/reports/reports/CustomReport.jsx +++ b/packages/desktop-client/src/components/reports/reports/CustomReport.jsx @@ -24,7 +24,7 @@ import { ChooseGraph } from '../ChooseGraph'; import { Header } from '../Header'; import { LoadingIndicator } from '../LoadingIndicator'; import { ReportLegend } from '../ReportLegend'; -import { ReportOptions, defaultState } from '../ReportOptions'; +import { ReportOptions, defaultReport } from '../ReportOptions'; import { ReportSidebar } from '../ReportSidebar'; import { ReportSummary } from '../ReportSummary'; import { ReportTopbar } from '../ReportTopbar'; @@ -32,7 +32,6 @@ import { createCustomSpreadsheet } from '../spreadsheets/custom-spreadsheet'; import { createGroupedSpreadsheet } from '../spreadsheets/grouped-spreadsheet'; import { useReport } from '../useReport'; import { fromDateRepr } from '../util'; -import { useLocation } from 'react-router-dom'; export function CustomReport() { const categories = useCategories(); @@ -55,7 +54,7 @@ export function CustomReport() { } = useFilters(); const location = useLocation(); - const loadReport = location.state.report ?? defaultState; + const loadReport = location.state.report ?? defaultReport; const [allMonths, setAllMonths] = useState(null); const [typeDisabled, setTypeDisabled] = useState(['Net']); @@ -83,7 +82,9 @@ export function CustomReport() { const dateRangeLine = ReportOptions.dateRange.length - 3; const [report, setReport] = useState(location.state.report ?? []); - const [savedStatus, setSavedStatus] = useState(location.state.report ? 'saved' : 'new'); + const [savedStatus, setSavedStatus] = useState( + location.state.report ? 'saved' : 'new', + ); const months = monthUtils.rangeInclusive(startDate, endDate); useEffect(() => { @@ -237,26 +238,27 @@ export function CustomReport() { }; const onResetReports = () => { - setMode(stateDefault.mode); - setGroupBy(stateDefault.groupBy); - setBalanceType(stateDefault.balanceType); - setShowEmpty(stateDefault.empty); - setShowOffBudgetHidden(stateDefault.hidden); - setShowUncategorized(stateDefault.uncat); - setGraphType(stateDefault.graphType); + setMode(defaultReport.mode); + setGroupBy(defaultReport.groupBy); + setBalanceType(defaultReport.balanceType); + setShowEmpty(defaultReport.empty); + setShowOffBudgetHidden(defaultReport.hidden); + setShowUncategorized(defaultReport.uncat); + setGraphType(defaultReport.graphType); onApplyFilter(null); - onCondOpChange(stateDefault.conditionsOp); + onCondOpChange(defaultReport.conditionsOp); setReport([]); - setStartDate(stateDefault.start); - setEndDate(stateDefault.end); + setStartDate(defaultReport.start); + setEndDate(defaultReport.end); setSavedStatus('new'); }; const onReportChange = (savedReport, type) => { - if (type === 'add-update') { //status = saved + if (type === 'add-update') { + //status = saved setReport(savedReport); } - + if (type === 'reload') { setMode(report.mode); setGroupBy(report.groupBy);