From cd9d1fb674320cf35ebedc9e065741c62bce95b4 Mon Sep 17 00:00:00 2001 From: Neil <55785687+carkom@users.noreply.github.com> Date: Fri, 19 Jan 2024 22:39:09 +0000 Subject: [PATCH 01/11] Clean-up some custom reports code (#2254) * work * missed * notes * change element name * update * update changes * merge fixes --- .../src/components/reports/ReportSidebar.jsx | 124 ++++++++++-------- .../src/components/reports/ReportTopbar.jsx | 41 +++--- .../reports/reports/CustomReport.jsx | 51 ++++--- upcoming-release-notes/2254.md | 6 + 4 files changed, 131 insertions(+), 91 deletions(-) create mode 100644 upcoming-release-notes/2254.md diff --git a/packages/desktop-client/src/components/reports/ReportSidebar.jsx b/packages/desktop-client/src/components/reports/ReportSidebar.jsx index 49857c63d88..dc2fdd24768 100644 --- a/packages/desktop-client/src/components/reports/ReportSidebar.jsx +++ b/packages/desktop-client/src/components/reports/ReportSidebar.jsx @@ -20,34 +20,23 @@ import { ModeButton } from './ModeButton'; import { ReportOptions } from './ReportOptions'; export function ReportSidebar({ - startDate, - endDate, - onChangeDates, - dateRange, - setDateRange, + customReportItems, + categories, dateRangeLine, allMonths, - graphType, - setGraphType, + setDateRange, typeDisabled, setTypeDisabled, - groupBy, + setGraphType, setGroupBy, - balanceType, setBalanceType, - mode, setMode, - isDateStatic, setIsDateStatic, - showEmpty, setShowEmpty, - showOffBudgetHidden, setShowOffBudgetHidden, - showUncategorized, setShowUncategorized, - categories, - selectedCategories, setSelectedCategories, + onChangeDates, onChangeViews, }) { const onSelectRange = cond => { @@ -86,26 +75,26 @@ export function ReportSidebar({ const onChangeMode = cond => { setMode(cond); if (cond === 'time') { - if (graphType === 'TableGraph') { + if (customReportItems.graphType === 'TableGraph') { setTypeDisabled([]); } else { setTypeDisabled(['Net']); - if (['Net'].includes(balanceType)) { + if (['Net'].includes(customReportItems.balanceType)) { setBalanceType('Payment'); } } - if (graphType === 'BarGraph') { + if (customReportItems.graphType === 'BarGraph') { setGraphType('StackedBarGraph'); } - if (['AreaGraph', 'DonutGraph'].includes(graphType)) { + if (['AreaGraph', 'DonutGraph'].includes(customReportItems.graphType)) { setGraphType('TableGraph'); onChangeViews('viewLegend', false); } - if (['Month', 'Year'].includes(groupBy)) { + if (['Month', 'Year'].includes(customReportItems.groupBy)) { setGroupBy('Category'); } } else { - if (graphType === 'StackedBarGraph') { + if (customReportItems.graphType === 'StackedBarGraph') { setGraphType('BarGraph'); } else { setTypeDisabled([]); @@ -115,12 +104,17 @@ export function ReportSidebar({ const onChangeSplit = cond => { setGroupBy(cond); - if (mode === 'total') { - if (graphType !== 'TableGraph') { - setTypeDisabled(!['Month', 'Year'].includes(groupBy) ? [] : ['Net']); + if (customReportItems.mode === 'total') { + if (customReportItems.graphType !== 'TableGraph') { + setTypeDisabled( + !['Month', 'Year'].includes(customReportItems.groupBy) ? [] : ['Net'], + ); } } - if (['Net'].includes(balanceType) && graphType !== 'TableGraph') { + if ( + ['Net'].includes(customReportItems.balanceType) && + customReportItems.graphType !== 'TableGraph' + ) { setBalanceType('Payment'); } }; @@ -158,13 +152,13 @@ export function ReportSidebar({ Mode: onChangeMode('total')} > Total onChangeMode('time')} > Time @@ -181,16 +175,16 @@ export function ReportSidebar({ Split: [ option.description, @@ -251,9 +245,9 @@ export function ReportSidebar({ setShowEmpty(!showEmpty)} + checked={customReportItems.showEmpty} + value={customReportItems.showEmpty} + onChange={() => setShowEmpty(!customReportItems.showEmpty)} />