Skip to content

A local-first personal finance app

add compact to custom reports (#2258)

Neil83f13cbdc85c
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
index 4d380951f1..9aa4e7a923 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
@@ -50,7 +50,7 @@ export function ReportTable({
});
const renderItem = useCallback(
- ({ item, groupByItem, mode, style, monthsCount }) => {
+ ({ item, groupByItem, mode, style, monthsCount, compact }) => {
return (
<ReportTableRow
item={item}
@@ -59,6 +59,7 @@ export function ReportTable({
mode={mode}
style={style}
monthsCount={monthsCount}
+ compact={compact}
/>
);
},
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableHeader.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableHeader.tsx
index 7db0209fde..ea81dc5343 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableHeader.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableHeader.tsx
@@ -64,7 +64,7 @@ export function ReportTableHeader({
return (
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
key={index}
@@ -77,7 +77,7 @@ export function ReportTableHeader({
<>
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value="Deposits"
@@ -85,7 +85,7 @@ export function ReportTableHeader({
/>
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value="Payments"
@@ -95,7 +95,7 @@ export function ReportTableHeader({
)}
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value="Totals"
@@ -103,7 +103,7 @@ export function ReportTableHeader({
/>
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value="Average"
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx
index ca8c7621db..d961144b65 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableList.tsx
@@ -30,8 +30,9 @@ export function ReportTableList({
index: number;
parent_index?: number;
style?: CSSProperties;
+ compact: boolean;
};
- function RenderRow({ index, parent_index, style }: RenderRowProps) {
+ function RenderRow({ index, parent_index, style, compact }: RenderRowProps) {
const item =
parent_index === undefined
? data[index]
@@ -43,6 +44,7 @@ export function ReportTableList({
mode,
style,
monthsCount,
+ compact,
});
}
@@ -55,6 +57,7 @@ export function ReportTableList({
<>
<RenderRow
index={index}
+ compact={compact}
style={
item.categories && {
color: theme.tableRowHeaderText,
@@ -71,6 +74,7 @@ export function ReportTableList({
<RenderRow
key={category.id}
index={i}
+ compact={compact}
parent_index={index}
/>
);
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
index b0adffaa2d..4779f22dff 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
@@ -17,6 +17,7 @@ type ReportTableRowProps = {
mode: string;
style?: CSSProperties;
monthsCount: number;
+ compact: boolean;
};
export const ReportTableRow = memo(
@@ -27,6 +28,7 @@ export const ReportTableRow = memo(
mode,
style,
monthsCount,
+ compact,
}: ReportTableRowProps) => {
const average = amountToInteger(item[balanceTypeOp]) / monthsCount;
return (
@@ -54,7 +56,7 @@ export const ReportTableRow = memo(
<Cell
key={amountToCurrency(month[balanceTypeOp])}
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={amountToCurrency(month[balanceTypeOp])}
@@ -80,7 +82,7 @@ export const ReportTableRow = memo(
width="flex"
privacyFilter
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
/>
@@ -94,7 +96,7 @@ export const ReportTableRow = memo(
width="flex"
privacyFilter
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
/>
@@ -109,7 +111,7 @@ export const ReportTableRow = memo(
}
style={{
fontWeight: 600,
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
width="flex"
@@ -124,7 +126,7 @@ export const ReportTableRow = memo(
}
style={{
fontWeight: 600,
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
width="flex"
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableTotals.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableTotals.tsx
index c149e5d6cc..784f6054e2 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableTotals.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableTotals.tsx
@@ -85,7 +85,7 @@ export function ReportTableTotals({
return (
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
key={amountToCurrency(item[balanceTypeOp])}
@@ -104,7 +104,7 @@ export function ReportTableTotals({
<>
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={amountToCurrency(data.totalAssets)}
@@ -118,7 +118,7 @@ export function ReportTableTotals({
/>
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={amountToCurrency(data.totalDebts)}
@@ -134,7 +134,7 @@ export function ReportTableTotals({
)}
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={amountToCurrency(data[balanceTypeOp])}
@@ -148,7 +148,7 @@ export function ReportTableTotals({
/>
<Cell
style={{
- minWidth: 85,
+ minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={integerToCurrency(Math.round(average))}
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.jsx b/packages/desktop-client/src/components/reports/reports/CustomReport.jsx
index 009a66e882..c182ec3847 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReport.jsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.jsx
@@ -54,7 +54,7 @@ export function CustomReport() {
} = useFilters();
const location = useLocation();
- const loadReport = location.state.report ?? defaultState;
+ const loadReport = location.state && (location.state.report ?? defaultState);
const [allMonths, setAllMonths] = useState(null);
const [typeDisabled, setTypeDisabled] = useState(['Net']);
diff --git a/upcoming-release-notes/2258.md b/upcoming-release-notes/2258.md
new file mode 100644
index 0000000000..372cadd501
--- /dev/null
+++ b/upcoming-release-notes/2258.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [carkom]
+---
+
+Adding compact elements to custom reports.