mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
Move useScheduleStatus to a separate file
This commit is contained in:
@@ -23,10 +23,8 @@ import { useDateFormat } from '@desktop-client/hooks/useDateFormat';
|
||||
import { useFormat } from '@desktop-client/hooks/useFormat';
|
||||
import { useNavigate } from '@desktop-client/hooks/useNavigate';
|
||||
import { usePayees } from '@desktop-client/hooks/usePayees';
|
||||
import {
|
||||
useSchedules,
|
||||
useScheduleStatus,
|
||||
} from '@desktop-client/hooks/useSchedules';
|
||||
import { useSchedules } from '@desktop-client/hooks/useSchedules';
|
||||
import { useScheduleStatus } from '@desktop-client/hooks/useScheduleStatus';
|
||||
import { useUndo } from '@desktop-client/hooks/useUndo';
|
||||
import { addNotification } from '@desktop-client/notifications/notificationsSlice';
|
||||
import { useDispatch } from '@desktop-client/redux';
|
||||
|
||||
@@ -58,10 +58,8 @@ import { GenericInput } from '@desktop-client/components/util/GenericInput';
|
||||
import { useDateFormat } from '@desktop-client/hooks/useDateFormat';
|
||||
import { useFeatureFlag } from '@desktop-client/hooks/useFeatureFlag';
|
||||
import { useFormat } from '@desktop-client/hooks/useFormat';
|
||||
import {
|
||||
useSchedules,
|
||||
useScheduleStatus,
|
||||
} from '@desktop-client/hooks/useSchedules';
|
||||
import { useSchedules } from '@desktop-client/hooks/useSchedules';
|
||||
import { useScheduleStatus } from '@desktop-client/hooks/useScheduleStatus';
|
||||
import {
|
||||
SelectedProvider,
|
||||
useSelected,
|
||||
|
||||
@@ -20,10 +20,8 @@ import {
|
||||
ModalHeader,
|
||||
} from '@desktop-client/components/common/Modal';
|
||||
import { Search } from '@desktop-client/components/common/Search';
|
||||
import {
|
||||
useSchedules,
|
||||
useScheduleStatus,
|
||||
} from '@desktop-client/hooks/useSchedules';
|
||||
import { useSchedules } from '@desktop-client/hooks/useSchedules';
|
||||
import { useScheduleStatus } from '@desktop-client/hooks/useScheduleStatus';
|
||||
import { pushModal } from '@desktop-client/modals/modalsSlice';
|
||||
import type { Modal as ModalType } from '@desktop-client/modals/modalsSlice';
|
||||
import { useDispatch } from '@desktop-client/redux';
|
||||
|
||||
@@ -14,10 +14,8 @@ import type { ScheduleItemAction } from './SchedulesTable';
|
||||
|
||||
import { Search } from '@desktop-client/components/common/Search';
|
||||
import { Page } from '@desktop-client/components/Page';
|
||||
import {
|
||||
useSchedules,
|
||||
useScheduleStatus,
|
||||
} from '@desktop-client/hooks/useSchedules';
|
||||
import { useSchedules } from '@desktop-client/hooks/useSchedules';
|
||||
import { useScheduleStatus } from '@desktop-client/hooks/useScheduleStatus';
|
||||
import { pushModal } from '@desktop-client/modals/modalsSlice';
|
||||
import { useDispatch } from '@desktop-client/redux';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { CategoryEntity, ScheduleEntity } from 'loot-core/types/models';
|
||||
|
||||
import { useCachedSchedules } from './useCachedSchedules';
|
||||
import { useFeatureFlag } from './useFeatureFlag';
|
||||
import { useScheduleStatus } from './useSchedules';
|
||||
import { useScheduleStatus } from './useScheduleStatus';
|
||||
|
||||
import type { ScheduleStatusData } from '@desktop-client/schedules';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { IntegerAmount } from 'loot-core/shared/util';
|
||||
import type { ScheduleEntity, TransactionEntity } from 'loot-core/types/models';
|
||||
|
||||
import { useCachedSchedules } from './useCachedSchedules';
|
||||
import { useScheduleStatus } from './useSchedules';
|
||||
import { useScheduleStatus } from './useScheduleStatus';
|
||||
import { useSyncedPref } from './useSyncedPref';
|
||||
import { calculateRunningBalancesBottomUp } from './useTransactions';
|
||||
|
||||
|
||||
29
packages/desktop-client/src/hooks/useScheduleStatus.ts
Normal file
29
packages/desktop-client/src/hooks/useScheduleStatus.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { UseQueryResult } from '@tanstack/react-query';
|
||||
|
||||
import type { ScheduleEntity } from 'loot-core/types/models';
|
||||
|
||||
import { useSyncedPref } from './useSyncedPref';
|
||||
|
||||
import { scheduleQueries } from '@desktop-client/schedules';
|
||||
import type { ScheduleStatusData } from '@desktop-client/schedules';
|
||||
|
||||
type UseScheduleStatusProps = {
|
||||
schedules: ScheduleEntity[];
|
||||
};
|
||||
|
||||
type UseScheduleStatusResult = UseQueryResult<ScheduleStatusData>;
|
||||
|
||||
export function useScheduleStatus({
|
||||
schedules,
|
||||
}: UseScheduleStatusProps): UseScheduleStatusResult {
|
||||
const [upcomingLength = '7'] = useSyncedPref(
|
||||
'upcomingScheduledTransactionLength',
|
||||
);
|
||||
return useQuery(
|
||||
scheduleQueries.statuses({
|
||||
schedules,
|
||||
upcomingLength,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -4,10 +4,7 @@ import type { UseQueryResult } from '@tanstack/react-query';
|
||||
import type { Query } from 'loot-core/shared/query';
|
||||
import type { ScheduleEntity } from 'loot-core/types/models';
|
||||
|
||||
import { useSyncedPref } from './useSyncedPref';
|
||||
|
||||
import { scheduleQueries } from '@desktop-client/schedules';
|
||||
import type { ScheduleStatusData } from '@desktop-client/schedules';
|
||||
|
||||
export type UseSchedulesProps = {
|
||||
query?: Query;
|
||||
@@ -19,21 +16,3 @@ export function useSchedules({
|
||||
}: UseSchedulesProps = {}): UseSchedulesResult {
|
||||
return useQuery(scheduleQueries.aql({ query }));
|
||||
}
|
||||
|
||||
type UseScheduleStatusProps = {
|
||||
schedules: ScheduleEntity[];
|
||||
};
|
||||
|
||||
type UseScheduleStatusResult = UseQueryResult<ScheduleStatusData>;
|
||||
|
||||
export function useScheduleStatus({
|
||||
schedules,
|
||||
}: UseScheduleStatusProps): UseScheduleStatusResult {
|
||||
const [upcomingLength = '7'] = useSyncedPref('upcomingScheduledTransactionLength');
|
||||
return useQuery(
|
||||
scheduleQueries.statuses({
|
||||
schedules,
|
||||
upcomingLength,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user