diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts index d8eda05e91e..b62b6c367b3 100644 --- a/packages/desktop-client/src/components/reports/ReportOptions.ts +++ b/packages/desktop-client/src/components/reports/ReportOptions.ts @@ -64,7 +64,7 @@ const intervalOptions = [ ]; export const ReportOptions = { - groupBy: groupByOptions, + groupBy: groupByOptions.map(item => item.description), balanceType: balanceTypeOptions, balanceTypeMap: new Map( balanceTypeOptions.map(item => [item.description, item.format]), diff --git a/packages/desktop-client/src/components/reports/ReportSidebar.jsx b/packages/desktop-client/src/components/reports/ReportSidebar.jsx index 1c0125d39bd..2b42b4af260 100644 --- a/packages/desktop-client/src/components/reports/ReportSidebar.jsx +++ b/packages/desktop-client/src/components/reports/ReportSidebar.jsx @@ -27,8 +27,6 @@ export function ReportSidebar({ dateRangeLine, allMonths, setDateRange, - typeDisabled, - setTypeDisabled, setGraphType, setGroupBy, setInterval, @@ -41,8 +39,10 @@ export function ReportSidebar({ setShowUncategorized, setSelectedCategories, onChangeDates, - onChangeViews, onReportChange, + disabledItems, + defaultItems, + defaultModeItems, }) { const [menuOpen, setMenuOpen] = useState(false); const onSelectRange = cond => { @@ -87,50 +87,25 @@ export function ReportSidebar({ const onChangeMode = cond => { onReportChange({ type: 'modify' }); setMode(cond); + let graph; if (cond === 'time') { - if (customReportItems.graphType === 'TableGraph') { - setTypeDisabled([]); - } else { - setTypeDisabled(['Net']); - if (['Net'].includes(customReportItems.balanceType)) { - setBalanceType('Payment'); - } - } if (customReportItems.graphType === 'BarGraph') { setGraphType('StackedBarGraph'); - } - if (['AreaGraph', 'DonutGraph'].includes(customReportItems.graphType)) { - setGraphType('TableGraph'); - onChangeViews('viewLegend', false); - } - if (customReportItems.groupBy === 'Interval') { - setGroupBy('Category'); + graph = 'StackedBarGraph'; } } else { if (customReportItems.graphType === 'StackedBarGraph') { setGraphType('BarGraph'); - } else { - setTypeDisabled([]); + graph = 'BarGraph'; } } + defaultModeItems(graph, cond); }; const onChangeSplit = cond => { onReportChange({ type: 'modify' }); setGroupBy(cond); - if (customReportItems.mode === 'total') { - if (customReportItems.graphType !== 'TableGraph') { - setTypeDisabled( - customReportItems.groupBy !== 'Interval' ? [] : ['Net'], - ); - } - } - if ( - ['Net'].includes(customReportItems.balanceType) && - customReportItems.graphType !== 'TableGraph' - ) { - setBalanceType('Payment'); - } + defaultItems(cond); }; const onChangeBalanceType = cond => { @@ -196,17 +171,8 @@ export function ReportSidebar({