From 1c83854b4a12959e7e519d92f06bcdfc7a35549c Mon Sep 17 00:00:00 2001 From: carkom Date: Mon, 16 Oct 2023 14:51:33 +0100 Subject: [PATCH] Functionality additions and Privacy Filters --- .../src/components/reports/Custom.js | 143 ++++++++++++------ .../src/components/reports/Header.js | 3 - .../src/components/reports/ReportSummary.js | 124 +++++++++++++++ .../components/reports/graphs/AreaGraph.tsx | 17 ++- .../components/reports/graphs/BarGraph.tsx | 15 +- .../reports/graphs/BarLineGraph.tsx | 15 +- .../components/reports/graphs/DonutGraph.tsx | 15 +- .../components/reports/graphs/LineGraph.tsx | 15 +- .../reports/graphs/StackedBarGraph.tsx | 15 +- 9 files changed, 278 insertions(+), 84 deletions(-) create mode 100644 packages/desktop-client/src/components/reports/ReportSummary.js diff --git a/packages/desktop-client/src/components/reports/Custom.js b/packages/desktop-client/src/components/reports/Custom.js index 1aae229950d..125abc568d4 100644 --- a/packages/desktop-client/src/components/reports/Custom.js +++ b/packages/desktop-client/src/components/reports/Custom.js @@ -32,13 +32,13 @@ import LineGraph from './graphs/LineGraph'; import StackedBarGraph from './graphs/StackedBarGraph'; import Header from './Header'; import ReportsTable from './ReportsTable'; +import { ReportSplit, ReportSummary } from './ReportSummary'; import { SavedGraphMenuButton } from './SavedGraphs'; import defaultSpreadsheet from './spreadsheets/default-spreadsheet'; import useReport from './useReport'; import { fromDateRepr } from './util'; export default function Custom() { - const [graphType, setGraphType] = useState('AreaGraph'); const categories = useCategories(); const [selectedCategories, setSelectedCategories] = useState(null); useEffect(() => { @@ -68,6 +68,9 @@ export default function Custom() { const [type, setType] = useState(1); const [dateRange, setDateRange] = useState(6); const [mode, setMode] = useState('time'); + const [graphType, setGraphType] = useState('AreaGraph'); + const [viewSplit, setViewSplit] = useState(false); + const [viewSummary, setViewSummary] = useState(false); const getGraphData = useMemo(() => { return defaultSpreadsheet( @@ -126,10 +129,6 @@ export default function Custom() { run(); }, []); - function selectGraph(graph) { - setGraphType(graph); - } - function GraphType() { if (graphType === 'AreaGraph') { return ( @@ -210,6 +209,28 @@ export default function Custom() { setMode(cond); } + function onChangeGraph(cond) { + setGraphType(cond); + } + + function GraphButton({ selected, children, style, onSelect, title }) { + return ( + + ); + } + function ModeButton({ selected, children, style, onSelect }) { return ( - - - + - - + - - + + + + + {(viewSplit || viewSummary) && ( + + + {viewSummary && ( + + )} + {viewSplit && } + + + )} + diff --git a/packages/desktop-client/src/components/reports/Header.js b/packages/desktop-client/src/components/reports/Header.js index 5f61e448bd8..c3a0d6b0eca 100644 --- a/packages/desktop-client/src/components/reports/Header.js +++ b/packages/desktop-client/src/components/reports/Header.js @@ -158,9 +158,6 @@ function Header({ All Time - {path === '/reports/custom' && ( - - )} )} {filters && filters.length > 0 && ( diff --git a/packages/desktop-client/src/components/reports/ReportSummary.js b/packages/desktop-client/src/components/reports/ReportSummary.js new file mode 100644 index 00000000000..74e09305193 --- /dev/null +++ b/packages/desktop-client/src/components/reports/ReportSummary.js @@ -0,0 +1,124 @@ +import React from 'react'; + +import * as monthUtils from 'loot-core/src/shared/months'; +import { integerToCurrency } from 'loot-core/src/shared/util'; + +import { theme, styles } from '../../style'; +import Text from '../common/Text'; +import View from '../common/View'; +import PrivacyFilter from '../PrivacyFilter'; + +export function ReportSummary({ + start, + end, + totalExpenses, + totalIncome, + onSelectSummary, + selectType, +}) { + let amt = + selectType === 'Expense' + ? totalExpenses + : selectType === 'Income' + ? totalIncome + : totalExpenses + totalIncome; + let net = totalExpenses > totalIncome ? 'EXPENSE' : 'INCOME'; + return ( + + + + {monthUtils.format(start, 'MMM yyyy')} -{' '} + {monthUtils.format(end, 'MMM yyyy')} + + + + + {selectType === 'Expense' + ? 'TOTAL SPENDING' + : selectType === 'Income' + ? 'TOTAL INCOME' + : 'NET ' + net} + + + + {integerToCurrency(amt)} + + + For this time period + + + ); +} + +export function ReportSplit({ onSelectSplit }) { + return ( + + + Categories + + + ); +} diff --git a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx index e9197ff0d9a..d4783479481 100644 --- a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx @@ -14,6 +14,7 @@ import { import { theme } from '../../../style'; import { type CSSProperties } from '../../../style'; import AlignedText from '../../common/AlignedText'; +import PrivacyFilter from '../../PrivacyFilter'; import Container from '../Container'; type AreaGraphProps = { @@ -92,13 +93,15 @@ function AreaGraph({ style, graphData, compact }: AreaGraphProps) { {payload[0].payload.date}
- - - {payload[0].payload.networth}} - /> - + + + + {payload[0].payload.networth}} + /> + +
diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx index d8ff9c59ee1..95c3c5b5ffb 100644 --- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx @@ -14,6 +14,7 @@ import { import { theme } from '../../../style'; import { type CSSProperties } from '../../../style'; import AlignedText from '../../common/AlignedText'; +import PrivacyFilter from '../../PrivacyFilter'; import Container from '../Container'; type BarGraphProps = { @@ -76,12 +77,14 @@ function BarGraph({ style, graphData, compact, domain }: BarGraphProps) { {payload[0].payload.date}
- - - {payload[0].payload.change}} - /> + + + + {payload[0].payload.change}} + /> +
diff --git a/packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsx index 3905efe5902..a27c5ee4044 100644 --- a/packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsx @@ -15,6 +15,7 @@ import { import { theme } from '../../../style'; import { type CSSProperties } from '../../../style'; import AlignedText from '../../common/AlignedText'; +import PrivacyFilter from '../../PrivacyFilter'; import Container from '../Container'; type BarLineGraphProps = { @@ -82,12 +83,14 @@ function BarLineGraph({ {payload[0].payload.date}
- - - {payload[0].payload.change}} - /> + + + + {payload[0].payload.change}} + /> +
diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx index f8934ac75f5..938cf892f1d 100644 --- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx @@ -6,6 +6,7 @@ import { PieChart, Pie, Tooltip, ResponsiveContainer } from 'recharts'; import { theme } from '../../../style'; import { type CSSProperties } from '../../../style'; import AlignedText from '../../common/AlignedText'; +import PrivacyFilter from '../../PrivacyFilter'; import Container from '../Container'; type DonutGraphProps = { @@ -64,12 +65,14 @@ function DonutGraph({ style, graphData, compact, domain }: DonutGraphProps) { {payload[0].payload.date}
- - - {payload[0].payload.change}} - /> + + + + {payload[0].payload.change}} + /> +
diff --git a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx index fcb750e2673..9841c618580 100644 --- a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx @@ -14,6 +14,7 @@ import { import { theme } from '../../../style'; import { type CSSProperties } from '../../../style'; import AlignedText from '../../common/AlignedText'; +import PrivacyFilter from '../../PrivacyFilter'; import Container from '../Container'; type LineGraphProps = { @@ -76,12 +77,14 @@ function LineGraph({ style, graphData, compact, domain }: LineGraphProps) { {payload[0].payload.date}
- - - {payload[0].payload.change}} - /> + + + + {payload[0].payload.change}} + /> +
diff --git a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx index 6627cebe429..f547a6cc0bb 100644 --- a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx @@ -14,6 +14,7 @@ import { import { theme } from '../../../style'; import { type CSSProperties } from '../../../style'; import AlignedText from '../../common/AlignedText'; +import PrivacyFilter from '../../PrivacyFilter'; import Container from '../Container'; type StackedBarGraphProps = { @@ -81,12 +82,14 @@ function StackedBarGraph({ {payload[0].payload.date}
- - - {payload[0].payload.change}} - /> + + + + {payload[0].payload.change}} + /> +