diff --git a/packages/desktop-client/src/components/schedules/SchedulesTable.tsx b/packages/desktop-client/src/components/schedules/SchedulesTable.tsx index 4cce1a00bc7..be6a1b2feda 100644 --- a/packages/desktop-client/src/components/schedules/SchedulesTable.tsx +++ b/packages/desktop-client/src/components/schedules/SchedulesTable.tsx @@ -225,12 +225,12 @@ export function SchedulesTable({ return [...unCompletedSchedules, { id: 'show-completed' }]; }, [filteredSchedules, showCompleted, allowCompleted]); - function renderSchedule({ item }: { item: ScheduleEntity }) { + function renderSchedule({ schedule }: { schedule: ScheduleEntity }) { return ( onSelect(item.id)} + onClick={() => onSelect(schedule.id)} style={{ cursor: 'pointer', backgroundColor: 'white', @@ -239,28 +239,30 @@ export function SchedulesTable({ > - {item.name ? item.name : 'None'} + {schedule.name ? schedule.name : 'None'} - + - + - {item.next_date ? monthUtilFormat(item.next_date, dateFormat) : null} + {schedule.next_date + ? monthUtilFormat(schedule.next_date, dateFormat) + : null} - + - + {!minimal && ( - {item._date && (item._date as any).frequency && ( + {schedule._date && (schedule._date as any).frequency && ( )} @@ -268,8 +270,8 @@ export function SchedulesTable({ {!minimal && ( @@ -304,7 +306,7 @@ export function SchedulesTable({ ); } - return renderSchedule({ item: item as ScheduleEntity }); + return renderSchedule({ schedule: item as ScheduleEntity }); } return ( diff --git a/packages/desktop-client/src/components/table.tsx b/packages/desktop-client/src/components/table.tsx index 91594cb4a25..5dc1bc077d1 100644 --- a/packages/desktop-client/src/components/table.tsx +++ b/packages/desktop-client/src/components/table.tsx @@ -12,6 +12,7 @@ import React, { type KeyboardEvent, type UIEvent, type ReactElement, + type Ref, } from 'react'; import { useStore } from 'react-redux'; import AutoSizer from 'react-virtualized-auto-sizer'; @@ -885,7 +886,7 @@ type TableProps = { }; export const Table: ( - props: TableProps, + props: TableProps & { ref?: Ref }, ) => ReactElement = forwardRef( ( { diff --git a/packages/loot-core/src/client/data-hooks/schedules.tsx b/packages/loot-core/src/client/data-hooks/schedules.tsx index d994d1b3842..a11bb1c7f0e 100644 --- a/packages/loot-core/src/client/data-hooks/schedules.tsx +++ b/packages/loot-core/src/client/data-hooks/schedules.tsx @@ -6,7 +6,8 @@ import { type ScheduleEntity } from '../../types/models'; import q, { liveQuery } from '../query-helpers'; export type ScheduleStatusType = ReturnType; -export type ScheduleStatuses = Map; +export type ScheduleStatuses = Map; + function loadStatuses(schedules: ScheduleEntity[], onData) { return liveQuery(getHasTransactionsQuery(schedules), onData, { mapper: data => { @@ -27,7 +28,9 @@ type UseSchedulesReturnType = { schedules: ScheduleEntity[]; statuses: ScheduleStatuses; } | null; -export function useSchedules({ transform }: UseSchedulesArgs = {}) { +export function useSchedules({ + transform, +}: UseSchedulesArgs = {}): UseSchedulesReturnType { const [data, setData] = useState(null); useEffect(() => { @@ -65,7 +68,7 @@ export function useSchedules({ transform }: UseSchedulesArgs = {}) { let SchedulesContext = createContext(null); export function SchedulesProvider({ transform, children }) { - let data = useSchedules({ transform }); + const data = useSchedules({ transform }); return ; } diff --git a/packages/loot-core/src/types/models/schedule.d.ts b/packages/loot-core/src/types/models/schedule.d.ts index 57bad1bd52c..bf74638c41d 100644 --- a/packages/loot-core/src/types/models/schedule.d.ts +++ b/packages/loot-core/src/types/models/schedule.d.ts @@ -5,7 +5,7 @@ import type { RuleEntity } from './rule'; export interface ScheduleEntity { id: string; name?: string; - rule: RuleEntity; + rule: RuleEntity['id']; next_date: string; completed: boolean; posts_transaction: boolean;