mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-30 10:14:53 -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 { useFormat } from '@desktop-client/hooks/useFormat';
|
||||||
import { useNavigate } from '@desktop-client/hooks/useNavigate';
|
import { useNavigate } from '@desktop-client/hooks/useNavigate';
|
||||||
import { usePayees } from '@desktop-client/hooks/usePayees';
|
import { usePayees } from '@desktop-client/hooks/usePayees';
|
||||||
import {
|
import { useSchedules } from '@desktop-client/hooks/useSchedules';
|
||||||
useSchedules,
|
import { useScheduleStatus } from '@desktop-client/hooks/useScheduleStatus';
|
||||||
useScheduleStatus,
|
|
||||||
} from '@desktop-client/hooks/useSchedules';
|
|
||||||
import { useUndo } from '@desktop-client/hooks/useUndo';
|
import { useUndo } from '@desktop-client/hooks/useUndo';
|
||||||
import { addNotification } from '@desktop-client/notifications/notificationsSlice';
|
import { addNotification } from '@desktop-client/notifications/notificationsSlice';
|
||||||
import { useDispatch } from '@desktop-client/redux';
|
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 { useDateFormat } from '@desktop-client/hooks/useDateFormat';
|
||||||
import { useFeatureFlag } from '@desktop-client/hooks/useFeatureFlag';
|
import { useFeatureFlag } from '@desktop-client/hooks/useFeatureFlag';
|
||||||
import { useFormat } from '@desktop-client/hooks/useFormat';
|
import { useFormat } from '@desktop-client/hooks/useFormat';
|
||||||
import {
|
import { useSchedules } from '@desktop-client/hooks/useSchedules';
|
||||||
useSchedules,
|
import { useScheduleStatus } from '@desktop-client/hooks/useScheduleStatus';
|
||||||
useScheduleStatus,
|
|
||||||
} from '@desktop-client/hooks/useSchedules';
|
|
||||||
import {
|
import {
|
||||||
SelectedProvider,
|
SelectedProvider,
|
||||||
useSelected,
|
useSelected,
|
||||||
|
|||||||
@@ -20,10 +20,8 @@ import {
|
|||||||
ModalHeader,
|
ModalHeader,
|
||||||
} from '@desktop-client/components/common/Modal';
|
} from '@desktop-client/components/common/Modal';
|
||||||
import { Search } from '@desktop-client/components/common/Search';
|
import { Search } from '@desktop-client/components/common/Search';
|
||||||
import {
|
import { useSchedules } from '@desktop-client/hooks/useSchedules';
|
||||||
useSchedules,
|
import { useScheduleStatus } from '@desktop-client/hooks/useScheduleStatus';
|
||||||
useScheduleStatus,
|
|
||||||
} from '@desktop-client/hooks/useSchedules';
|
|
||||||
import { pushModal } from '@desktop-client/modals/modalsSlice';
|
import { pushModal } from '@desktop-client/modals/modalsSlice';
|
||||||
import type { Modal as ModalType } from '@desktop-client/modals/modalsSlice';
|
import type { Modal as ModalType } from '@desktop-client/modals/modalsSlice';
|
||||||
import { useDispatch } from '@desktop-client/redux';
|
import { useDispatch } from '@desktop-client/redux';
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ import type { ScheduleItemAction } from './SchedulesTable';
|
|||||||
|
|
||||||
import { Search } from '@desktop-client/components/common/Search';
|
import { Search } from '@desktop-client/components/common/Search';
|
||||||
import { Page } from '@desktop-client/components/Page';
|
import { Page } from '@desktop-client/components/Page';
|
||||||
import {
|
import { useSchedules } from '@desktop-client/hooks/useSchedules';
|
||||||
useSchedules,
|
import { useScheduleStatus } from '@desktop-client/hooks/useScheduleStatus';
|
||||||
useScheduleStatus,
|
|
||||||
} from '@desktop-client/hooks/useSchedules';
|
|
||||||
import { pushModal } from '@desktop-client/modals/modalsSlice';
|
import { pushModal } from '@desktop-client/modals/modalsSlice';
|
||||||
import { useDispatch } from '@desktop-client/redux';
|
import { useDispatch } from '@desktop-client/redux';
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { CategoryEntity, ScheduleEntity } from 'loot-core/types/models';
|
|||||||
|
|
||||||
import { useCachedSchedules } from './useCachedSchedules';
|
import { useCachedSchedules } from './useCachedSchedules';
|
||||||
import { useFeatureFlag } from './useFeatureFlag';
|
import { useFeatureFlag } from './useFeatureFlag';
|
||||||
import { useScheduleStatus } from './useSchedules';
|
import { useScheduleStatus } from './useScheduleStatus';
|
||||||
|
|
||||||
import type { ScheduleStatusData } from '@desktop-client/schedules';
|
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 type { ScheduleEntity, TransactionEntity } from 'loot-core/types/models';
|
||||||
|
|
||||||
import { useCachedSchedules } from './useCachedSchedules';
|
import { useCachedSchedules } from './useCachedSchedules';
|
||||||
import { useScheduleStatus } from './useSchedules';
|
import { useScheduleStatus } from './useScheduleStatus';
|
||||||
import { useSyncedPref } from './useSyncedPref';
|
import { useSyncedPref } from './useSyncedPref';
|
||||||
import { calculateRunningBalancesBottomUp } from './useTransactions';
|
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 { Query } from 'loot-core/shared/query';
|
||||||
import type { ScheduleEntity } from 'loot-core/types/models';
|
import type { ScheduleEntity } from 'loot-core/types/models';
|
||||||
|
|
||||||
import { useSyncedPref } from './useSyncedPref';
|
|
||||||
|
|
||||||
import { scheduleQueries } from '@desktop-client/schedules';
|
import { scheduleQueries } from '@desktop-client/schedules';
|
||||||
import type { ScheduleStatusData } from '@desktop-client/schedules';
|
|
||||||
|
|
||||||
export type UseSchedulesProps = {
|
export type UseSchedulesProps = {
|
||||||
query?: Query;
|
query?: Query;
|
||||||
@@ -19,21 +16,3 @@ export function useSchedules({
|
|||||||
}: UseSchedulesProps = {}): UseSchedulesResult {
|
}: UseSchedulesProps = {}): UseSchedulesResult {
|
||||||
return useQuery(scheduleQueries.aql({ query }));
|
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