From d49d3dd0e68c5c71c6ab93d55311198551ea7508 Mon Sep 17 00:00:00 2001 From: carkom Date: Mon, 22 Jan 2024 23:10:39 +0000 Subject: [PATCH] typecheck fixes --- .../src/components/reports/ReportOptions.ts | 11 +++++++++-- .../src/components/reports/SaveReportMenu.tsx | 2 +- .../src/components/reports/SaveReportName.tsx | 8 ++++---- packages/loot-core/src/server/reports/app.ts | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts index 6c6c4be3a18..d76a2dc02f0 100644 --- a/packages/desktop-client/src/components/reports/ReportOptions.ts +++ b/packages/desktop-client/src/components/reports/ReportOptions.ts @@ -6,9 +6,16 @@ import { type CategoryGroupEntity, type PayeeEntity, } from 'loot-core/src/types/models'; +import { useCategories } from '../../hooks/useCategories'; const startDate = monthUtils.subMonths(monthUtils.currentMonth(), 5); const endDate = monthUtils.currentMonth(); +const categories = useCategories(); +const selectAll: CategoryEntity[] = []; +categories.grouped.map(categoryGroup => + categoryGroup.categories && + categoryGroup.categories.map(category => selectAll.push(category)), +); export const defaultReport: CustomReportEntity = { id: undefined, @@ -23,9 +30,9 @@ export const defaultReport: CustomReportEntity = { showEmpty: false, showOffBudget: false, showUncategorized: false, - selectedCategories: null, + selectedCategories: selectAll, graphType: 'BarGraph', - conditions: null, + conditions: [], conditionsOp: 'and', }; diff --git a/packages/desktop-client/src/components/reports/SaveReportMenu.tsx b/packages/desktop-client/src/components/reports/SaveReportMenu.tsx index cc88db4af7d..01e311dd260 100644 --- a/packages/desktop-client/src/components/reports/SaveReportMenu.tsx +++ b/packages/desktop-client/src/components/reports/SaveReportMenu.tsx @@ -13,7 +13,7 @@ export function SaveReportMenu({ }: { report: CustomReportEntity; onClose: () => void; - onMenuSelect: (item) => void; + onMenuSelect: (item: string) => void; savedStatus: string; }) { return ( diff --git a/packages/desktop-client/src/components/reports/SaveReportName.tsx b/packages/desktop-client/src/components/reports/SaveReportName.tsx index c1b97c47c50..16138e5b177 100644 --- a/packages/desktop-client/src/components/reports/SaveReportName.tsx +++ b/packages/desktop-client/src/components/reports/SaveReportName.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { RefObject, useEffect } from 'react'; import { theme } from '../../style'; import { Button } from '../common/Button'; @@ -11,10 +11,10 @@ import { FormField, FormLabel } from '../forms'; type SaveReportNameProps = { onClose: () => void; menuItem: string; - onNameChange; - inputRef; + onNameChange: (name: string) => void; + inputRef: RefObject; onAddUpdate: () => void; - err; + err: string; }; export function SaveReportName({ diff --git a/packages/loot-core/src/server/reports/app.ts b/packages/loot-core/src/server/reports/app.ts index 2fa01d11942..62429d00f52 100644 --- a/packages/loot-core/src/server/reports/app.ts +++ b/packages/loot-core/src/server/reports/app.ts @@ -42,7 +42,7 @@ const reportModel = { }; async function reportNameExists( - name: string, + name: string | undefined, reportId: string | undefined, newItem: boolean, ) {