From b831d15eab54350293f95c59351c7bf23a38442e Mon Sep 17 00:00:00 2001 From: Matt Fiddaman Date: Thu, 16 Jan 2025 15:13:45 +0000 Subject: [PATCH] upcoming schedule setting: move setting to modal (#4164) * upcoming schedule setting: move setting to modal * note * change nomenclature * remove strict override --- .../desktop-client/src/components/Modals.tsx | 4 + .../components/schedules/UpcomingLength.tsx | 80 ++++++++++++++ .../src/components/schedules/index.tsx | 36 +++--- .../src/components/settings/Upcoming.tsx | 103 ------------------ .../src/client/state-types/modals.d.ts | 2 + upcoming-release-notes/4164.md | 6 + 6 files changed, 115 insertions(+), 116 deletions(-) create mode 100644 packages/desktop-client/src/components/schedules/UpcomingLength.tsx delete mode 100644 packages/desktop-client/src/components/settings/Upcoming.tsx create mode 100644 upcoming-release-notes/4164.md diff --git a/packages/desktop-client/src/components/Modals.tsx b/packages/desktop-client/src/components/Modals.tsx index 4b4919cfbf..4c1ac33c48 100644 --- a/packages/desktop-client/src/components/Modals.tsx +++ b/packages/desktop-client/src/components/Modals.tsx @@ -74,6 +74,7 @@ import { DiscoverSchedules } from './schedules/DiscoverSchedules'; import { PostsOfflineNotification } from './schedules/PostsOfflineNotification'; import { ScheduleDetails } from './schedules/ScheduleDetails'; import { ScheduleLink } from './schedules/ScheduleLink'; +import { UpcomingLength } from './schedules/UpcomingLength'; import { NamespaceContext } from './spreadsheet/NamespaceContext'; export function Modals() { @@ -373,6 +374,9 @@ export function Modals() { case 'schedules-discover': return ; + case 'schedules-upcoming-length': + return ; + case 'schedule-posts-offline-notification': return ; diff --git a/packages/desktop-client/src/components/schedules/UpcomingLength.tsx b/packages/desktop-client/src/components/schedules/UpcomingLength.tsx new file mode 100644 index 0000000000..c6b86552ee --- /dev/null +++ b/packages/desktop-client/src/components/schedules/UpcomingLength.tsx @@ -0,0 +1,80 @@ +import React from 'react'; +import { Trans, useTranslation } from 'react-i18next'; + +import { type SyncedPrefs } from 'loot-core/types/prefs'; + +import { useSyncedPref } from '../../hooks/useSyncedPref'; +import { Modal, ModalCloseButton, ModalHeader } from '../common/Modal'; +import { Paragraph } from '../common/Paragraph'; +import { Select } from '../common/Select'; +import { View } from '../common/View'; + +function useUpcomingLengthOptions() { + const { t } = useTranslation(); + + const upcomingLengthOptions: { + value: SyncedPrefs['upcomingScheduledTransactionLength']; + label: string; + }[] = [ + { value: '1', label: t('1 day') }, + { value: '7', label: t('1 week') }, + { value: '14', label: t('2 weeks') }, + { value: '30', label: t('1 month') }, + ]; + + return { upcomingLengthOptions }; +} + +export function UpcomingLength() { + const { t } = useTranslation(); + const [_upcomingLength, setUpcomingLength] = useSyncedPref( + 'upcomingScheduledTransactionLength', + ); + + const { upcomingLengthOptions } = useUpcomingLengthOptions(); + + const upcomingLength = _upcomingLength || '7'; + + return ( + + {({ state: { close } }) => ( + <> + } + /> + + + Change how many days in advance of the scheduled date a scheduled + transaction appears in the account ledger as upcoming. + + + + + This only affects how schedules are displayed and not how budget + data is stored. It can be changed at any time. + + + + + Only the first instance of a recurring transaction will be shown. + + + + [ - x.value || '7', - x.label, - ])} - value={upcomingLength} - onChange={newValue => setUpcomingLength(newValue)} - /> - - - - - } - > - - - - Upcoming Length does not affect how budget data is - stored, and can be changed at any time. - - - - - - ) : ( - - - - ); -} diff --git a/packages/loot-core/src/client/state-types/modals.d.ts b/packages/loot-core/src/client/state-types/modals.d.ts index 8e09e5ba3e..19ff499522 100644 --- a/packages/loot-core/src/client/state-types/modals.d.ts +++ b/packages/loot-core/src/client/state-types/modals.d.ts @@ -181,6 +181,8 @@ type FinanceModals = { 'schedules-discover': null; + 'schedules-upcoming-length': null; + 'schedule-posts-offline-notification': null; 'account-menu': { accountId: string; diff --git a/upcoming-release-notes/4164.md b/upcoming-release-notes/4164.md new file mode 100644 index 0000000000..a7437aa64e --- /dev/null +++ b/upcoming-release-notes/4164.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [matt-fidd] +--- + +Move upcoming schedule length setting