From 2ae6d8cc72ca51717dab31f423297de3937dbae1 Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Thu, 4 Apr 2024 13:31:34 -0700 Subject: [PATCH] Updated based on review --- .../autocomplete/AccountAutocomplete.tsx | 3 +- .../autocomplete/CategoryAutocomplete.tsx | 3 +- .../autocomplete/PayeeAutocomplete.tsx | 3 +- .../components/modals/AccountMenuModal.tsx | 44 ++++++++++++++++--- .../src/components/modals/CoverModal.tsx | 2 +- packages/loot-core/src/server/main.ts | 3 +- upcoming-release-notes/2472.md | 2 +- 7 files changed, 43 insertions(+), 17 deletions(-) diff --git a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx index 01a230b0379..bc053ed99b2 100644 --- a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx +++ b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx @@ -166,8 +166,7 @@ type AccountItemProps = { embedded?: boolean; }; -// eslint-disable-next-line import/no-unused-modules -export function AccountItem({ +function AccountItem({ item, className, highlighted, diff --git a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx index a979c53be77..8ff9d228ff1 100644 --- a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx +++ b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx @@ -297,8 +297,7 @@ type CategoryItemProps = { embedded?: boolean; }; -// eslint-disable-next-line import/no-unused-modules -export function CategoryItem({ +function CategoryItem({ item, className, style, diff --git a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx index 52d6f576c86..a65ed413d7d 100644 --- a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx +++ b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx @@ -472,8 +472,7 @@ type PayeeItemProps = { embedded?: boolean; }; -// eslint-disable-next-line import/no-unused-modules -export function PayeeItem({ +function PayeeItem({ item, className, highlighted, diff --git a/packages/desktop-client/src/components/modals/AccountMenuModal.tsx b/packages/desktop-client/src/components/modals/AccountMenuModal.tsx index d224719f550..c6759989192 100644 --- a/packages/desktop-client/src/components/modals/AccountMenuModal.tsx +++ b/packages/desktop-client/src/components/modals/AccountMenuModal.tsx @@ -1,4 +1,3 @@ -// @ts-strict-ignore import React, { useState } from 'react'; import { useLiveQuery } from 'loot-core/src/client/query-hooks'; @@ -17,6 +16,11 @@ import { type CommonModalProps } from '../Modals'; import { Notes } from '../Notes'; import { Tooltip } from '../tooltips'; +type NoteEntity = { + id: string; + note: string; +}; + type AccountMenuModalProps = { modalProps: CommonModalProps; accountId: string; @@ -39,9 +43,9 @@ export function AccountMenuModal({ const accounts = useAccounts(); const account = accounts.find(c => c.id === accountId); const data = useLiveQuery( - () => q('notes').filter({ id: account.id }).select('*'), - [account.id], - ); + () => q('notes').filter({ id: account?.id }).select('*'), + [account?.id], + ) as NoteEntity[] | null; const originalNotes = data && data.length > 0 ? data[0].note : null; const _onClose = () => { @@ -49,7 +53,11 @@ export function AccountMenuModal({ onClose?.(); }; - const onRename = newName => { + const onRename = (newName: string) => { + if (!account) { + return; + } + if (newName !== account.name) { onSave?.({ ...account, @@ -59,6 +67,10 @@ export function AccountMenuModal({ }; const _onEditNotes = () => { + if (!account) { + return; + } + onEditNotes?.(account.id); }; @@ -70,6 +82,10 @@ export function AccountMenuModal({ flexBasis: '100%', }; + if (!account) { + return null; + } + return ( 0 ? originalNotes : 'No notes'} + notes={ + originalNotes && originalNotes.length > 0 + ? originalNotes + : 'No notes' + } editable={false} focused={false} getStyle={() => ({ @@ -152,7 +172,17 @@ export function AccountMenuModal({ ); } -function AdditionalAccountMenu({ account, onClose, onReopen }) { +type AdditionalAccountMenuProps = { + account: AccountEntity; + onClose?: (accountId: string) => void; + onReopen?: (accountId: string) => void; +}; + +function AdditionalAccountMenu({ + account, + onClose, + onReopen, +}: AdditionalAccountMenuProps) { const [menuOpen, setMenuOpen] = useState(false); const itemStyle: CSSProperties = { ...styles.mediumText, diff --git a/packages/desktop-client/src/components/modals/CoverModal.tsx b/packages/desktop-client/src/components/modals/CoverModal.tsx index 875bbefbf4c..90f4369da98 100644 --- a/packages/desktop-client/src/components/modals/CoverModal.tsx +++ b/packages/desktop-client/src/components/modals/CoverModal.tsx @@ -61,7 +61,7 @@ export function CoverModal({ const category = categories.find(c => c.id === categoryId); - if (category == null) { + if (!category) { return null; } diff --git a/packages/loot-core/src/server/main.ts b/packages/loot-core/src/server/main.ts index 8c072d062cb..0cc70892db3 100644 --- a/packages/loot-core/src/server/main.ts +++ b/packages/loot-core/src/server/main.ts @@ -441,8 +441,7 @@ handlers['must-category-transfer'] = async function ({ id }) { handlers['payee-create'] = mutator(async function ({ name }) { return withUndo(async () => { - const id = await db.insertPayee({ name }); - return id; + return db.insertPayee({ name }); }); }); diff --git a/upcoming-release-notes/2472.md b/upcoming-release-notes/2472.md index d49653d0ef3..dcbd90e59d6 100644 --- a/upcoming-release-notes/2472.md +++ b/upcoming-release-notes/2472.md @@ -3,4 +3,4 @@ category: Enhancements authors: [joel-jeremy] --- -Mobile menu modals. +Add more modals in mobile for account, scheduled transactions, budget summary, and balance actions.