Skip to content

Commit

Permalink
Merge branch 'master' into cleanReports
Browse files Browse the repository at this point in the history
  • Loading branch information
carkom authored Jan 19, 2024
2 parents 85d2f1d + fbb1a96 commit 2c4cb97
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 32 deletions.
30 changes: 17 additions & 13 deletions packages/desktop-client/src/components/manager/DeleteFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ export function DeleteFile({ modalProps, actions, file }: DeleteFileProps) {
null,
);

async function onDelete() {
setLoadingState(isCloudFile ? 'cloud' : 'local');
await actions.deleteBudget(
'id' in file ? file.id : undefined,
isCloudFile ? file.cloudFileId : undefined,
);
setLoadingState(null);

modalProps.onBack();
}

return (
<Modal
{...modalProps}
Expand Down Expand Up @@ -75,7 +64,16 @@ export function DeleteFile({ modalProps, actions, file }: DeleteFileProps) {
padding: '10px 30px',
fontSize: 14,
}}
onClick={onDelete}
onClick={async () => {
setLoadingState('cloud');
await actions.deleteBudget(
'id' in file ? file.id : undefined,
file.cloudFileId,
);
setLoadingState(null);

modalProps.onBack();
}}
>
Delete file from all devices
</ButtonWithLoading>
Expand Down Expand Up @@ -125,7 +123,13 @@ export function DeleteFile({ modalProps, actions, file }: DeleteFileProps) {
backgroundColor: theme.errorText,
}),
}}
onClick={onDelete}
onClick={async () => {
setLoadingState('local');
await actions.deleteBudget(file.id);
setLoadingState(null);

modalProps.onBack();
}}
>
Delete file locally
</ButtonWithLoading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ export function ReportTable({
});

const renderItem = useCallback(
({ item, groupByItem, mode, style, key, monthsCount }) => {
({ item, groupByItem, mode, style, monthsCount }) => {
return (
<ReportTableRow
key={key}
item={item}
balanceTypeOp={balanceTypeOp}
groupByItem={groupByItem}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@ export function ReportTableList({
const groupByItem = ['Month', 'Year'].includes(groupBy) ? 'date' : 'name';

type RenderRowProps = {
key: string;
index: number;
parent_index?: number;
style?: CSSProperties;
};
function RenderRow({ index, parent_index, style, key }: RenderRowProps) {
const item = parent_index
? data[parent_index].categories[index]
: data[index];
function RenderRow({ index, parent_index, style }: RenderRowProps) {
const item =
parent_index === undefined
? data[index]
: data[parent_index].categories[index];

return renderItem({
item,
groupByItem,
mode,
style,
key,
monthsCount,
});
}
Expand All @@ -55,7 +54,6 @@ export function ReportTableList({
{data ? (
<>
<RenderRow
key={item.id}
index={index}
style={
item.categories && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const ReportTableRow = memo(
const average = amountToInteger(item[balanceTypeOp]) / monthsCount;
return (
<Row
key={item.id}
collapsed={true}
style={{
color: theme.tableText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ export function ReportTableTotals({
key={amountToCurrency(item[balanceTypeOp])}
value={amountToCurrency(item[balanceTypeOp])}
title={
Math.abs(item[balanceTypeOp]) > 100000 &&
amountToCurrency(item[balanceTypeOp])
Math.abs(item[balanceTypeOp]) > 100000
? amountToCurrency(item[balanceTypeOp])
: undefined
}
width="flex"
privacyFilter
Expand All @@ -108,8 +109,9 @@ export function ReportTableTotals({
}}
value={amountToCurrency(data.totalAssets)}
title={
Math.abs(data.totalAssets) > 100000 &&
amountToCurrency(data.totalAssets)
Math.abs(data.totalAssets) > 100000
? amountToCurrency(data.totalAssets)
: undefined
}
width="flex"
privacyFilter
Expand All @@ -121,8 +123,9 @@ export function ReportTableTotals({
}}
value={amountToCurrency(data.totalDebts)}
title={
Math.abs(data.totalDebts) > 100000 &&
amountToCurrency(data.totalDebts)
Math.abs(data.totalDebts) > 100000
? amountToCurrency(data.totalDebts)
: undefined
}
width="flex"
privacyFilter
Expand All @@ -136,8 +139,9 @@ export function ReportTableTotals({
}}
value={amountToCurrency(data[balanceTypeOp])}
title={
Math.abs(data[balanceTypeOp]) > 100000 &&
amountToCurrency(data[balanceTypeOp])
Math.abs(data[balanceTypeOp]) > 100000
? amountToCurrency(data[balanceTypeOp])
: undefined
}
width="flex"
privacyFilter
Expand All @@ -149,8 +153,9 @@ export function ReportTableTotals({
}}
value={integerToCurrency(Math.round(average))}
title={
Math.abs(Math.round(average / 100)) > 100000 &&
integerToCurrency(Math.round(average))
Math.abs(Math.round(average / 100)) > 100000
? integerToCurrency(Math.round(average))
: undefined
}
width="flex"
privacyFilter
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2249.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [carkom]
---

Fixing a bug where custom reports table graph crashes due to a type mismatch error.
6 changes: 6 additions & 0 deletions upcoming-release-notes/2251.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---

Fix 'delete file' button always deleting the cloud file.

0 comments on commit 2c4cb97

Please sign in to comment.